16 #include <calobase/RawTower.h>
17 #include <calobase/RawTowerContainer.h>
18 #include <calobase/RawTowerGeom.h>
19 #include <calobase/RawTowerGeomContainer.h>
20 #include <calobase/RawTowerDefs.h>
22 #include <calobase/RawCluster.h>
23 #include <calobase/RawClusterContainer.h>
60 Double_t
v1 = par[0]*
h_template->Interpolate(x[0]-par[1])+par[2];
81 , outfilename(filename)
84 , g4hitntuple(nullptr)
97 rnd =
new TRandom3(0);
104 noise_midrad->ReadFile(
"/gpfs/mnt/gpfs02/sphenix/user/trinn/sPHENIX_emcal_cosmics_sector0/noise_waveforms/medium_raddmgnoise.csv",
"a1:a2:a3:a4:a5:a6:a7:a8:a9:a10:a11:a12:a13:a14:a15:a16:a17:a18:a19:a20:a21:a22:a23:a24:a25:a26:a27:a28:a29:a30:a31");
107 noise_lowrad->ReadFile(
"/gpfs/mnt/gpfs02/sphenix/user/trinn/sPHENIX_emcal_cosmics_sector0/noise_waveforms/low_raddmgnoise.csv",
"a1:a2:a3:a4:a5:a6:a7:a8:a9:a10:a11:a12:a13:a14:a15:a16:a17:a18:a19:a20:a21:a22:a23:a24:a25:a26:a27:a28:a29:a30:a31");
111 noise_norad->ReadFile(
"/gpfs/mnt/gpfs02/sphenix/user/trinn/sPHENIX_emcal_cosmics_sector0/noise_waveforms/no_raddmgnoise.csv",
"a1:a2:a3:a4:a5:a6:a7:a8:a9:a10:a11:a12:a13:a14:a15:a16:a17:a18:a19:a20:a21:a22:a23:a24:a25:a26:a27:a28:a29:a30:a31");
113 for (
int i = 0;
i < 31;
i++)
124 g4hitntuple->Branch(
"primpt",&
m_primpt);
125 g4hitntuple->Branch(
"primeta",&
m_primeta);
126 g4hitntuple->Branch(
"primphi",&
m_primphi);
127 g4hitntuple->Branch(
"tedep_emcal",&
m_tedep,
"tedep_emcal[24576]/F");
128 g4hitntuple->Branch(
"tedep_ihcal",&
m_tedep_ihcal,
"tedep_ihcal[1536]/F");
129 g4hitntuple->Branch(
"tedep_ohcal",&
m_tedep_ohcal,
"tedep_ohcal[1536]/F");
130 g4hitntuple->Branch(
"extractedadc_emcal",&
m_extractedadc,
"extractedadc_emcal[24576]/F");
131 g4hitntuple->Branch(
"extractedtime_emcal",&
m_extractedtime,
"extractedtime_emcal[24576]/F");
136 g4hitntuple->Branch(
"toweradc_emcal",&
m_toweradc,
"toweradc_emcal[24576]/F");
137 g4hitntuple->Branch(
"toweradc_ihcal",&
m_toweradc_ihcal,
"toweradc_ihcal[1536]/F");
138 g4hitntuple->Branch(
"toweradc_ohcal",&
m_toweradc_ohcal,
"toweradc_ohcal[1536]/F");
149 std::string cemc_template_input_file =
"/gpfs/mnt/gpfs02/sphenix/user/trinn/fitting_algorithm_playing/waveform_simulation/calibrations/WaveformProcessing/templates/testbeam_cemc_template.root";
150 std::string ihcal_template_input_file =
"/gpfs/mnt/gpfs02/sphenix/user/trinn/fitting_algorithm_playing/waveform_simulation/calibrations/WaveformProcessing/templates/testbeam_ihcal_template.root";
151 std::string ohcal_template_input_file =
"/gpfs/mnt/gpfs02/sphenix/user/trinn/fitting_algorithm_playing/waveform_simulation/calibrations/WaveformProcessing/templates/testbeam_ohcal_template.root";
153 TFile* fin1 = TFile::Open(cemc_template_input_file.c_str());
156 h_template =
static_cast<TProfile*
>(fin1->Get(
"waveform_template"));
158 TFile* fin2 = TFile::Open(ihcal_template_input_file.c_str());
164 TFile* fin3 = TFile::Open(ohcal_template_input_file.c_str());
190 light_collection_model.load_data_file(
string(getenv(
"CALIBRATIONROOT")) +
string(
"/CEMC/LightCollection/Prototype3Module.xml"),
191 "data_grid_light_guide_efficiency",
"data_grid_fiber_trans");
194 std::cout <<
" hey do you happen? " << std::endl;
214 std::cout <<
"PHG4FullProjSpacalCellReco::process_event - Fatal Error - Could not locate sim geometry node "
230 float waveform[24576][16];
231 float waveform_ihcal[1536][16];
232 float waveform_ohcal[1536][16];
234 float tedep_ihcal[1536];
235 float tedep_ohcal[1536];
236 for (
int i = 0;
i < 24576;
i++)
238 for (
int j = 0;
j < 16;
j++)
241 waveform[
i][
j] = 0.0;
252 for (
int i = 0;
i < 1536;
i++)
254 tedep_ihcal[
i] = 0.0;
257 tedep_ohcal[
i] = 0.0;
262 for (
int j = 0;
j < 16;
j++)
265 waveform_ihcal[
i][
j] = 0;
267 waveform_ohcal[
i][
j] = 0;
277 f_fit->SetParameters(1,0,0);
280 f_fit_ihcal->SetParameters(1,0,0);
283 f_fit_ohcal->SetParameters(1,0,0);
290 float _shiftval = 4-f_fit->GetMaximumX();
291 f_fit->SetParameters(1,_shiftval,0);
293 float _shiftval_ihcal = 4-f_fit_ihcal->GetMaximumX();
294 f_fit_ihcal->SetParameters(1,_shiftval_ihcal,0);
296 float _shiftval_ohcal = 4-f_fit_ohcal->GetMaximumX();
297 f_fit_ohcal->SetParameters(1,_shiftval_ohcal,0);
300 ostringstream nodename;
303 PHG4HitContainer* hits = findNode::getClass<PHG4HitContainer>(topNode, nodename.str().c_str());
304 PHG4HitContainer* hits_ihcal = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_HCALIN");
305 PHG4HitContainer* hits_ohcal = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_HCALOUT");
318 float pt =TMath::Sqrt(TMath::Power(part->
get_py(),2) +TMath::Power(part->
get_px(),2));
345 int scint_id = hit_iter->second->get_scint_id();
348 const int &tower_ID_z = tower_z_phi_ID.first;
349 const int &tower_ID_phi = tower_z_phi_ID.second;
351 PHG4CylinderGeom_Spacalv3::tower_map_t::const_iterator it_tower =
356 const int sub_tower_ID_x = it_tower->second.get_sub_tower_ID_x(decoder.
fiber_ID);
357 const int sub_tower_ID_y = it_tower->second.get_sub_tower_ID_y(decoder.
fiber_ID);
358 unsigned short etabinshort = etabin_cell * layergeom->
get_n_subtower_eta() + sub_tower_ID_y;
359 unsigned short phibin_cell = tower_ID_phi * layergeom->
get_n_subtower_phi() + sub_tower_ID_x;
364 double light_yield = hit_iter->second->get_light_yield();
366 const double z = 0.5 * (hit_iter->second->get_local_z(0) + hit_iter->second->get_local_z(1));
367 assert(not std::isnan(z));
371 const double x = it_tower->second.get_position_fraction_x_in_sub_tower(decoder.
fiber_ID);
372 const double y = it_tower->second.get_position_fraction_y_in_sub_tower(decoder.
fiber_ID);
379 int phibin = phibin_cell;
380 int towernumber = etabin + 96*phibin;
385 float t0 = (hit_iter->second->get_t(0)) / 16.66667;
386 float tmax = 16.667*16;
388 f_fit->SetParameters(light_yield*26000,_shiftval+t0,0);
389 if (hit_iter->second->get_t(1) >= tmin && hit_iter->second->get_t(0) <= tmax) {
390 tedep[towernumber] += light_yield*26000;
395 if (hit_iter->second->get_edep()*26000 > 1 && hit_iter->second->get_t(1) >= tmin && hit_iter->second->get_t(0) <= tmax)
397 for (
int j = 0;
j < 16;
j++)
399 waveform[towernumber][
j] +=f_fit->Eval(
j);
426 short icolumn = hit_iter->second->get_scint_id();
429 if (introw >=
ROWDIM || introw < 0)
431 std::cout << __PRETTY_FUNCTION__ <<
" row " << introw
432 <<
" exceed array size: " <<
ROWDIM
433 <<
" adjust ROWDIM and recompile" << std::endl;
436 int towerphi = introw/4;
437 int towereta = icolumn;
442 double light_yield = hit_iter->second->get_light_yield();
448 int phibin =towerphi;
449 int towernumber = etabin + 24*phibin;
455 float t0 = (hit_iter->second->get_t(0)) / 16.66667;
456 float tmax = 16.667*16;
458 f_fit_ihcal->SetParameters(light_yield*2600,_shiftval_ihcal+t0,0);
459 if (hit_iter->second->get_t(1) >= tmin && hit_iter->second->get_t(0) <= tmax) {
460 tedep_ihcal[towernumber] += light_yield*2600;
465 if (hit_iter->second->get_edep()*2600 > 1 &&hit_iter->second->get_t(1) >= tmin && hit_iter->second->get_t(0) <= tmax )
467 for (
int j = 0;
j < 16;
j++)
469 waveform_ihcal[towernumber][
j] +=f_fit_ihcal->Eval(
j);
493 short icolumn = hit_iter->second->get_scint_id();
497 if (introw >=
ROWDIM || introw < 0)
499 std::cout << __PRETTY_FUNCTION__ <<
" row " << introw
500 <<
" exceed array size: " <<
ROWDIM
501 <<
" adjust ROWDIM and recompile" << std::endl;
506 int towerphi = introw/5;
507 int towereta = icolumn;
513 double light_yield = hit_iter->second->get_light_yield();
519 int phibin =towerphi;
520 int towernumber = etabin + 24*phibin;
526 float t0 = (hit_iter->second->get_t(0)) / 16.66667;
527 float tmax =16.667*16 ;
529 f_fit_ohcal->SetParameters(light_yield*5000,_shiftval_ohcal+t0,0);
530 if (hit_iter->second->get_t(0) < tmax && hit_iter->second->get_t(1) > tmin) {
532 tedep_ohcal[towernumber] += light_yield*5000;
539 if (hit_iter->second->get_edep()*5000 > 1 && hit_iter->second->get_t(1) >= tmin && hit_iter->second->get_t(0) <= tmax)
541 for (
int j = 0;
j < 16;
j++)
543 waveform_ohcal[towernumber][
j] +=f_fit_ohcal->Eval(
j);
558 for (
int i = 0;
i < 24576;
i++)
560 int noise_waveform = (int)
rnd->Uniform(0,1990);
563 for (
int k = 0;
k < 16;
k++)
572 for (
int i = 0;
i < 1536;
i++)
574 int noise_waveform = (int)
rnd->Uniform(0,1990);
577 for (
int k = 0;
k < 16;
k++)
586 for (
int i = 0;
i < 1536;
i++)
588 int noise_waveform = (int)
rnd->Uniform(0,1990);
592 for (
int k = 0;
k < 16;
k++)
598 std::vector<std::vector<float>> fitresults;
599 std::vector<std::vector<float>> fitresults_ihcal;
600 std::vector<std::vector<float>> fitresults_ohcal;
605 std::vector<std::vector<float>> waveforms;
606 for (
int i = 0;
i < 24576;
i++)
608 std::vector<float>
tmp;
609 for (
int j = 0;
j < 16;
j++)
613 waveforms.push_back(tmp);
617 for (
int i = 0;
i < 24576;
i++)
631 std::vector<std::vector<float>> waveforms;
632 for (
int i = 0;
i < 1536;
i++)
634 std::vector<float>
tmp;
635 for (
int j = 0;
j < 16;
j++)
639 waveforms.push_back(tmp);
657 for (
int i = 0;
i < 1536;
i++)
671 std::vector<std::vector<float>> waveforms;
672 for (
int i = 0;
i < 1536;
i++)
674 std::vector<float>
tmp;
675 for (
int j = 0;
j < 16;
j++)
679 waveforms.push_back(tmp);
700 for (
int i = 0;
i < 1536;
i++)
710 std::cout << 4 << std::endl;
714 RawTowerContainer *towers = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_RAW_CEMC");
719 int phibin = tower_iter->second->get_binphi();
720 int etabin = tower_iter->second->get_bineta();
721 float energy = tower_iter->second->get_energy();
722 int towernumber = etabin + 96*phibin;
728 RawTowerContainer *towers = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_RAW_HCALIN");
733 int phibin = tower_iter->second->get_binphi();
734 int etabin = tower_iter->second->get_bineta();
735 float energy = tower_iter->second->get_energy();
736 int towernumber = etabin + 24*phibin;
742 RawTowerContainer *towers = findNode::getClass<RawTowerContainer>(topNode,
"TOWER_RAW_HCALOUT");
746 int phibin = tower_iter->second->get_binphi();
747 int etabin = tower_iter->second->get_bineta();
748 float energy = tower_iter->second->get_energy();
749 int towernumber = etabin + 24*phibin;
762 fitresults_ihcal.clear();
763 fitresults_ohcal.clear();