46 double tpc_frame_side_gap=0.8;
47 double tpc_frame_side_width=2.6;
48 double tpc_margin=0.0;
50 double tpc_frame_r3_outer=758.4;
51 double tpc_frame_r3_inner=583.5;
53 double tpc_frame_r2_outer=574.9;
54 double tpc_frame_r2_inner=411.4;
56 double tpc_frame_r1_outer=402.6;
57 double tpc_frame_r1_inner=221.0;
62 if (r<tpc_frame_r1_inner+tpc_margin)
64 if (r>tpc_frame_r1_outer-tpc_margin && r<tpc_frame_r2_inner+tpc_margin)
66 if (r>tpc_frame_r2_outer-tpc_margin && r<tpc_frame_r3_inner+tpc_margin)
68 if (r>tpc_frame_r3_outer-tpc_margin)
76 float sectorangle=(M_PI/6);
77 float nsectors=phi/sectorangle;
78 int nsec=floor(nsectors);
79 float reduced_phi=phi-nsec*sectorangle;
80 float dist_to_previous=r*sin(reduced_phi);
81 float dist_to_next=r*sin(sectorangle-reduced_phi);
82 if (dist_to_previous<tpc_frame_side_gap+tpc_frame_side_width+tpc_margin)
84 if (dist_to_next<tpc_frame_side_gap+tpc_frame_side_width+tpc_margin)
99 std::cout <<
"readDigitalCurrents::readDigitalCurrents(const std::string &name) Calling ctor" << std::endl;
105 std::cout <<
"readDigitalCurrents::~readDigitalCurrents() Calling dtor" << std::endl;
113 std::cout <<
"readDigitalCurrents::Init(PHCompositeNode *topNode) Initializing" << std::endl;
126 const int r_bins_N = 66;
127 double r_bins[r_bins_N + 1] = {217.83,
128 223.83, 229.83, 235.83, 241.83, 247.83, 253.83, 259.83, 265.83, 271.83, 277.83, 283.83, 289.83, 295.83, 301.83, 306.83,
129 311.05, 317.92, 323.31, 329.27, 334.63, 340.59, 345.95, 351.91, 357.27, 363.23, 368.59, 374.55, 379.91, 385.87, 391.23, 397.19, 402.49,
130 411.53, 421.70, 431.90, 442.11, 452.32, 462.52, 472.73, 482.94, 493.14, 503.35, 513.56, 523.76, 533.97, 544.18, 554.39, 564.59, 574.76,
131 583.67, 594.59, 605.57, 616.54, 627.51, 638.48, 649.45, 660.42, 671.39, 682.36, 693.33, 704.30, 715.27, 726.24, 737.21, 748.18, 759.11};
132 const int nphi = 205;
133 double phi_bins[nphi + 1] = { 0., 6.3083-2 * M_PI, 6.3401-2 * M_PI, 6.372-2 * M_PI, 6.4039-2 * M_PI, 6.4358-2 * M_PI, 6.4676-2 * M_PI, 6.4995-2 * M_PI, 6.5314-2 * M_PI,
134 0.2618, 0.2937, 0.3256, 0.3574, 0.3893, 0.4212, 0.453, 0.4849, 0.5168, 0.5487, 0.5805, 0.6124, 0.6443, 0.6762, 0.7081,
135 0.7399, 0.7718, 0.7854, 0.8173, 0.8491, 0.881, 0.9129, 0.9448, 0.9767, 1.0085, 1.0404, 1.0723, 1.1041, 1.136, 1.1679,
136 1.1998, 1.2317, 1.2635, 1.2954, 1.309, 1.3409, 1.3727, 1.4046, 1.4365, 1.4684, 1.5002, 1.5321, 1.564, 1.5959, 1.6277,
137 1.6596, 1.6915, 1.7234, 1.7552, 1.7871, 1.819, 1.8326, 1.8645, 1.8963, 1.9282, 1.9601, 1.992, 2.0238, 2.0557, 2.0876,
138 2.1195, 2.1513, 2.1832, 2.2151, 2.247, 2.2788, 2.3107, 2.3426, 2.3562, 2.3881, 2.42, 2.4518, 2.4837, 2.5156, 2.5474,
139 2.5793, 2.6112, 2.6431, 2.6749, 2.7068, 2.7387, 2.7706, 2.8024, 2.8343, 2.8662, 2.8798, 2.9117, 2.9436, 2.9754, 3.0073,
140 3.0392, 3.0711, 3.1029, 3.1348, 3.1667, 3.1986, 3.2304, 3.2623, 3.2942, 3.326, 3.3579, 3.3898, 3.4034, 3.4353, 3.4671,
141 3.499, 3.5309, 3.5628, 3.5946, 3.6265, 3.6584, 3.6903, 3.7221, 3.754, 3.7859, 3.8178, 3.8496, 3.8815, 3.9134, 3.927,
142 3.9589, 3.9907, 4.0226, 4.0545, 4.0864, 4.1182, 4.1501, 4.182, 4.2139, 4.2457, 4.2776, 4.3095, 4.3414, 4.3732, 4.4051,
143 4.437, 4.4506, 4.4825, 4.5143, 4.5462, 4.5781, 4.61, 4.6418, 4.6737, 4.7056, 4.7375, 4.7693, 4.8012, 4.8331, 4.865,
144 4.8968, 4.9287, 4.9606, 4.9742, 5.0061, 5.0379, 5.0698, 5.1017, 5.1336, 5.1654, 5.1973, 5.2292, 5.2611, 5.2929, 5.3248,
145 5.3567, 5.3886, 5.4204, 5.4523, 5.4842, 5.4978, 5.5297, 5.5615, 5.5934, 5.6253, 5.6572, 5.689, 5.7209, 5.7528, 5.7847,
146 5.8165, 5.8484, 5.8803, 5.9122, 5.944, 5.9759, 6.0078, 6.0214, 6.0533, 6.0851, 6.117, 6.1489, 6.1808, 6.2127, 6.2445,
169 double z_bins[2*nz+1];
170 for (
int z=0;
z<=2*
nz;
z++){
171 z_bins[
z]=-z_rdo+z_rdo/nz*
z;
174 _h_R =
new TH1F(
"_h_R" ,
"_h_R;R, [m]" ,r_bins_N ,r_bins);
175 _h_hits =
new TH1F(
"_h_hits" ,
"_h_hits;N, [hit]" ,1e5,0-0.5,1e5-0.5);
176 _h_hit_XY =
new TH2F(
"_h_hit_XY" ,
"_h_hit_XY;X, [m];Y, [m]" ,4*nr,-1*rmax,rmax,4*nr,-1*rmax,rmax);
179 _h_DC_SC =
new TH3F(
"_h_DC_SC" ,
"_h_DC_SC;#phi, [rad];R, [mm];Z, [mm]" ,nphi,phi_bins,r_bins_N ,r_bins,2*nz,z_bins);
180 _h_DC_SC_XY =
new TH2F(
"_h_DC_SC_XY" ,
"_h_DC_SC_XY;X, [mm];Y, [mm];ADC;" ,4*nr,-1*rmax,rmax,4*nr,-1*rmax,rmax);
181 _h_DC_E =
new TH2F(
"_h_DC_E" ,
"_h_DC_E;ADC;E" ,200,-100,2e3-100,500,-100,5e3-100);
185 for (
int iz = 0; iz <
nFrames; iz++)
187 sprintf(name,
"_h_SC_ibf_%d", iz);
188 sprintf(name_ax,
"_h_SC_ibf_%d;#phi, [rad];R, [mm];Z, [mm]", iz);
189 _h_SC_ibf[iz] =
new TH3F(name, name_ax, nphi, phi_bins, r_bins_N, r_bins, 2 * nz, z_bins);
204 myCSVFile.open (
"./Files/example_1ms_120evts_AA.csv");
219 std::cout <<
"readDigitalCurrents::InitRun(PHCompositeNode *topNode) Initializing for Run XXX" << std::endl;
223 std::string txt_file =
"/sphenix/user/shulga/Work/TpcPadPlane_phi_coresoftware/coresoftware/calibrations/tpc/fillSpaceChargeMaps/data/timestamps_50kHz_1M.txt";
227 txt_file =
"/phenix/u/hpereira/sphenix/work/g4simulations/timestamps_3MHz.txt";
231 ifstream InputFile (txt_file);
232 if (InputFile.is_open()){
234 while ( getline (InputFile,line) )
237 if(n_line>start_line){
238 std::istringstream is( line );
241 while( is >> n[i] ) {
248 _keys.push_back(
int(n[0]));
254 else cout <<
"Unable to open file:"<<txt_file<<endl;
258 MapsFile =
new TFile(
"/sphenix/user/shulga/Work/IBF/DistortionMap/IBF_Map.root",
"READ");
259 if ( MapsFile->IsOpen() )
printf(
"Gain/IBF Maps File opened successfully\n");
275 int bemxingsInFile =
_keys.size();
284 ostringstream nodename;
285 set<std::string>::const_iterator iter;
287 nodename <<
"TRKR_HITSET";
297 TrkrHitSetContainer* _hitmap = findNode::getClass<TrkrHitSetContainer>(topNode, nodename.str().c_str());
300 std::cout <<
PHWHERE <<
"ERROR: Can't find node TRKR_HITSET" << std::endl;
303 ostringstream geo_nodename;
304 geo_nodename <<
"CYLINDERCELLGEOM_SVTX";
309 _geom_container_ccgc = findNode::getClass<PHG4TpcCylinderGeomContainer>(topNode, geo_nodename.str().c_str());
310 if (!_geom_container_ccgc)
312 std::cout <<
PHWHERE <<
"ERROR: Can't find node CYLINDERCELLGEOM_SVTX" << std::endl;
316 _geom_container_cgc = findNode::getClass<PHG4CylinderCellGeomContainer>(topNode, geo_nodename.str().c_str());
318 if (!_geom_container_cgc)
320 std::cout <<
PHWHERE <<
"ERROR: Can't find node CYLINDERCELLGEOM_SVTX" << std::endl;
355 int f_fill_ibf[30] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
360 double _drift_velocity = 8.0e-3;
361 double phi_center = 0;
367 if (phi_center<0) phi_center+=2*M_PI;
368 if(phi_center<M_PI/2+M_PI/12 && phi_center>M_PI/2-M_PI/12){
369 if(min_phiBin>phibin)min_phiBin=phibin;
370 if(max_phiBin<phibin)max_phiBin=phibin;
372 float x = radius*cos(phi_center);
373 float y = radius*sin(phi_center);
384 TrkrHit *hit = hit_iter->second;
390 double z_ibf[30] = {-1 * 1e10, -1 * 1e10, -1 * 1e10, -1 * 1e10, -1 * 1e10, -1 * 1e10, -1 * 1e10, -1 * 1e10, -1 * 1e10, -1 * 1e10,
391 -1 * 1e10, -1 * 1e10, -1 * 1e10, -1 * 1e10, -1 * 1e10, -1 * 1e10, -1 * 1e10, -1 * 1e10, -1 * 1e10, -1 * 1e10,
392 -1 * 1e10, -1 * 1e10, -1 * 1e10, -1 * 1e10, -1 * 1e10, -1 * 1e10, -1 * 1e10, -1 * 1e10, -1 * 1e10, -1 * 1e10};
394 int RBin=
_h_R->GetXaxis()->FindBin(radius);
395 if((RBin>33 && RBin<50) && z>0){
397 if(phibin<nRBins/12 ) {
410 for (
int iz = 0; iz <
nFrames; iz++)
415 if(z>=0 && z<1.055*
m){
417 if( z_ibf[iz]>0 && z_ibf[iz]<1.055*
m){
421 if(z<0 && z>-1.055*
m){
423 if( z_ibf[iz]<0 && z_ibf[iz]>-1.055*
m){
430 if(z>=0 && z<1.055*
m){
432 if(adc>=0)
_h_DC_E->Fill(adc,E);
435 if(z<0 && z>-1.055*
m){
437 if(adc>=0)
_h_DC_E->Fill(adc,E);
451 float w_adc = adc*w_ibf;
452 _h_DC_SC->Fill(phi_center,radius,z,w_adc);
454 if(f_fill_ibf[0]==1){
458 for (
int iz = 0; iz <
nFrames; iz++)
460 if (f_fill_ibf[iz] == 1)
_h_SC_ibf[iz] ->Fill(phi_center,radius,z_ibf[iz],w_adc);
485 std::cout <<
"readDigitalCurrents::EndRun(const int runnumber) Ending Run for Run " << runnumber << std::endl;
492 std::cout <<
"readDigitalCurrents::End(PHCompositeNode *topNode) This is the End..." << std::endl;
493 _h_R ->Sumw2(
false );
499 for (
int iz = 0; iz <
nFrames; iz++)
511 std::cout <<
"readDigitalCurrents::Reset(PHCompositeNode *topNode) being Reset" << std::endl;
518 std::cout <<
"readDigitalCurrents::Print(const std::string &what) const Printing info for " << what << std::endl;
523 cout<<
"Start event is set to: "<<newEvtStart<<endl;
528 cout<<
"Fill CSV file is set to: "<<fillCSVFile<<endl;
535 std::cout <<
"Initial BeamXing is set to: " <<
_beamxing[0] << std::endl;
540 cout<<
"Collision system is set to: "<<s_syst[
_collSyst]<<endl;
551 cout<<
"IBF is set to: "<<
_f_ccgc<<endl;