1010#include " WCRootDataPileUpSpill.h"
1111#include " BeamTiming.h"
1212
13+ // PMT type used for 3-inch PMTs of IWCD/WCTE
14+ #include " PMTResponse3inchR12199_02.h"
15+
1316std::string fInFileTextIDNuInt = " " ;
1417std::string fInFileTextBeamBkg = " " ;
1518std::string fOutFileNamePrefix = " " ;
@@ -19,11 +22,19 @@ int fNumOfSpillsPerFile = 1000;
1922float fIDNuIntRate = 3.5 ;
2023float fBeamBkgRate = 7.5 ;
2124int fTotalNumofSpills = 10000 ;
25+ int fUseOD = 0 ;
2226
2327void ReadConfiguration (const char *);
2428
2529int main (int argc, char **argv)
2630{
31+ if (argc==1 )
32+ {
33+ std::cout<<" ** Please specify input config file ** " <<std::endl;
34+ std::cout<<" ** Usage: appGenPileUpSpill config_file ** " <<std::endl;
35+ return 0 ;
36+ }
37+
2738 std::string ConfigFileName = argv[1 ];
2839 ReadConfiguration (argv[1 ]);
2940
@@ -39,8 +50,20 @@ int main(int argc, char **argv)
3950 const int seed_beamtiming = rndm->Integer (1000000 );
4051 delete rndm; rndm = 0 ;
4152
53+ // IWCD PMT type for ID and OD
54+ int NPMTType = !fUseOD ? 1 : 2 ;
55+ vector<string> fPMTType (NPMTType);
56+ fPMTType [0 ] = " PMT3inchR12199_02" ;
57+ if (fUseOD >0 ) fPMTType [1 ] = " PMT3inchR12199_02_OD" ;
58+
4259 // Will be manaing marging true hits and digitizing merged true hits
4360 MDTManager *MDT = new MDTManager (seed_mdt);
61+ MDT->RegisterPMTType (fPMTType [0 ], new PMTResponse3inchR12199_02 ());
62+ if (fUseOD ) MDT->RegisterPMTType (fPMTType [1 ], new PMTResponse3inchR12199_02 ());
63+
64+ vector<string> listWCRootEvt (NPMTType);
65+ listWCRootEvt[0 ] = " wcsimrootevent" ;
66+ if (fUseOD ) listWCRootEvt[1 ] = " wcsimrootevent_OD" ;
4467
4568 // Manage input files for ID interactions
4669 WCRootDataIDNuInt *daIDNuInt = new WCRootDataIDNuInt ();
@@ -56,12 +79,13 @@ int main(int argc, char **argv)
5679 daBeamBkg->SetSeed (seed_beambkg);
5780
5881 // Will be used to extract file ID number
59- daIDNuInt->SetNDigitsFileIDNumber (5 );
60- daBeamBkg->SetNDigitsFileIDNumber (6 );
82+ // KMTsui: I don't have it has real usage
83+ // daIDNuInt->SetNDigitsFileIDNumber(5);
84+ // daBeamBkg->SetNDigitsFileIDNumber(6);
6185
6286 // Load input files from text file
63- daIDNuInt->LoadFiles (fInFileTextIDNuInt .c_str ());
64- daBeamBkg->LoadFiles (fInFileTextBeamBkg .c_str ());
87+ daIDNuInt->LoadFiles (fInFileTextIDNuInt .c_str (),listWCRootEvt );
88+ daBeamBkg->LoadFiles (fInFileTextBeamBkg .c_str (),listWCRootEvt );
6589
6690 // Set number of ID interactions per spill
6791 daIDNuInt->SetInteractionRate (fIDNuIntRate );
@@ -80,7 +104,7 @@ int main(int argc, char **argv)
80104 daPileUp->SetFileNameForCopyTree (daIDNuInt->GetCurrentInputFileName ());
81105
82106 // Create output file. Its name will be something like "OutFileNamePrefix".00000.root
83- daPileUp->CreateTree (fOutFileNamePrefix .c_str ());
107+ daPileUp->CreateTree (fOutFileNamePrefix .c_str (),listWCRootEvt );
84108
85109 float nuIntTime; // interaction time
86110 int nuIntBunch; // bunch id number
@@ -107,7 +131,8 @@ int main(int argc, char **argv)
107131 bt->DrawInteractionTime (nuIntTime, nuIntBunch);
108132
109133 // Add true hits of this interaction to MDT
110- daIDNuInt->AddTrueHitsToMDT (MDT, nuIntTime);
134+ for (int k=0 ; k<NPMTType; k++)
135+ daIDNuInt->AddTrueHitsToMDT (MDT->GetHitTubeCollection (fPMTType [k]), MDT->GetPMTResponse (fPMTType [k]), nuIntTime, k);
111136
112137 // Add information about this interaction
113138 daPileUp->AddInteraction (daIDNuInt, nuIntTime, nuIntBunch);
@@ -119,18 +144,24 @@ int main(int argc, char **argv)
119144 daBeamBkg->Next ();
120145
121146 bt->DrawInteractionTime (nuIntTime, nuIntBunch);
122- daBeamBkg->AddTrueHitsToMDT (MDT, nuIntTime);
147+ for (int k=0 ; k<NPMTType; k++)
148+ daBeamBkg->AddTrueHitsToMDT (MDT->GetHitTubeCollection (fPMTType [k]), MDT->GetPMTResponse (fPMTType [k]), nuIntTime, k);
123149 daPileUp->AddInteraction (daBeamBkg, nuIntTime, nuIntBunch);
124150 }
125151
126152 // Now all the true hits have been merged into one spill
127153 // Add dark noise hits, and then make digitized hits
128- MDT->DoAddDark ();
129- MDT->DoDigitize ();
130- MDT->DoTrigger ();
154+ for (int j=0 ; j<NPMTType; j++)
155+ {
156+ MDT->DoAddDark (fPMTType [j]);
157+ MDT->DoDigitize (fPMTType [j]);
158+ MDT->DoTrigger (fPMTType [j]);
159+
160+ // Add the resultant digitized hits to the output
161+ TriggerInfo *ti = MDT->GetTriggerInfo (fPMTType [j]);
162+ daPileUp->AddDigiHits (MDT->GetHitTubeCollection (fPMTType [j]), ti, i, j);
163+ }
131164
132- // Add the resultant digitized hits to the output
133- daPileUp->AddDigiHits (MDT);
134165 daPileUp->FillTree ();
135166
136167 // Clear all the true and digitized hits of this spill for the next spill
@@ -162,5 +193,6 @@ void ReadConfiguration(const char *filename)
162193 Conf->GetValue <float >(" IDNuIntRate" , fIDNuIntRate );
163194 Conf->GetValue <float >(" BeamBkgRate" , fBeamBkgRate );
164195 Conf->GetValue <int >(" TotalNumOfSpills" , fTotalNumofSpills );
196+ Conf->GetValue <int >(" UseOD" , fUseOD );
165197 Conf->Finalize ();
166198}
0 commit comments