27 if(!events_tree_name.EqualTo(
"wcsimrootevent") &&
28 !events_tree_name.EqualTo(
"wcsimrootevent2") &&
29 !events_tree_name.EqualTo(
"wcsimrootevent_OD")) {
30 cerr <<
"Second argument events_tree_name MUST equal one of: wcsimrootevent wcsimrootevent2 wcsimrootevent_OD" << endl;
33 const bool true_tracks_expected = events_tree_name.EqualTo(
"wcsimrootevent");
38 cout <<
"Error, could not open input file: " <<
filename << endl;
43 TTree *tree = (TTree*)
file->Get(
"wcsimT");
46 const long nevent = tree->GetEntries();
47 if(verbose) printf(
"Number of Event Tree Entries: %ld\n",nevent);
53 TBranch *branch = tree->GetBranch(events_tree_name);
54 branch->SetAddress(&wcsimrootsuperevent);
57 tree->GetBranch(events_tree_name)->SetAutoDelete(kTRUE);
60 TTree *geotree = (TTree*)
file->Get(
"wcsimGeoT");
62 geotree->SetBranchAddress(
"wcsimrootgeom", &
geo);
63 if(verbose) std::cout <<
"Geotree has: " << geotree->GetEntries() <<
" entries (1 expected)" << std::endl;
64 if (geotree->GetEntries() == 0) {
70 TTree *opttree = (TTree*)
file->Get(
"wcsimRootOptionsT");
72 opttree->SetBranchAddress(
"wcsimrootoptions", &opt);
73 if(verbose) std::cout <<
"Options tree has: " << opttree->GetEntries() <<
" entries (1 expected)" << std::endl;
74 if (opttree->GetEntries() == 0) {
86 TH1F *h1 =
new TH1F(
"h1",
"NDigits;NDigits in Trigger 0;Entries in bin", 8000, 0, 8000);
87 TH1F *hvtxX =
new TH1F(
"hvtxX",
"Event VTX X;True vertex X (cm);Entries in bin", 200, -detR, +detR);
88 TH1F *hvtxY =
new TH1F(
"hvtxY",
"Event VTX Y;True vertex Y (cm);Entries in bin", 200, -detR, +detR);
89 TH1F *hvtxZ =
new TH1F(
"hvtxZ",
"Event VTX Z;True vertex Z (cm);Entries in bin", 200, -detZ/2, +detZ/2);
98 wcsimrootevent = wcsimrootsuperevent->
GetTrigger(0);
100 printf(
"********************************************************\n");
101 printf(
"Event Number (from loop): %ld\n",
ievent);
102 printf(
"Event Number (from WCSimRootEventHeader): %d\n", wcsimrootevent->
GetHeader()->
GetEvtNum());
106 printf(
"Interaction Nuance Code: %d\n", wcsimrootevent->
GetMode());
107 printf(
"Number of Delayed Triggers (sub events): %d\n",
110 if(true_tracks_expected) {
111 printf(
"Neutrino Vertex Geometry Volume Code: %d\n", wcsimrootevent->
GetVtxvol());
112 printf(
"Neutrino Vertex Location [cm]: %f %f %f\n", wcsimrootevent->
GetVtx(0),
114 printf(
"Index of muon in WCSimRootTracks %d\n", wcsimrootevent->
GetJmu());
115 printf(
"Number of final state particles %d\n", wcsimrootevent->
GetNpar());
118 hvtxX->Fill(wcsimrootevent->
GetVtx(0));
119 hvtxY->Fill(wcsimrootevent->
GetVtx(1));
120 hvtxZ->Fill(wcsimrootevent->
GetVtx(2));
125 const int ntrack = wcsimrootevent->
GetNtrack();
128 cout <<
"SAVED TRACKS" << endl
129 <<
"Number of Saved WCSimRootTracks: " << ntrack << endl;
130 if(!true_tracks_expected)
131 cout <<
"No saved true tracks in branch: " << events_tree_name
132 <<
". You can find them in: wcsimrootevent" << endl;
134 if(ntrack && !true_tracks_expected) {
135 cerr << ntrack <<
" true tracks found in branch: " << events_tree_name
136 <<
". There should be none here. Don't trust them. You can find them in: wcsimrootevent" << endl;
140 for (
int itrack=0; itrack<ntrack_slots; itrack++)
148 cout<<
"Track: "<<itrack<<endl <<
" ";
149 int trackflag = wcsimroottrack->
GetFlag();
150 if(trackflag==-1) cout<<
"Primary neutrino track"<<endl;
151 else if(trackflag==-2) cout<<
"Neutrino target nucleus track"<<endl;
152 else cout<<
"Final state particle track"<<endl;
153 printf(
" Track ipnu (PDG code): %d\n",wcsimroottrack->
GetIpnu());
154 printf(
" PDG code of parent particle (0 for primary, 999 for parent PDG code not found in the specific logic used): %d\n",wcsimroottrack->
GetParenttype());
155 printf(
" Track ID of parent particle (0 for primary): %d\n",wcsimroottrack->
GetParentId());
157 cout<<
" Track initial dir [unit 3-vector]: (" 158 <<wcsimroottrack->
GetDir(0)<<
", " 159 <<wcsimroottrack->
GetDir(1)<<
", " 160 <<wcsimroottrack->
GetDir(2)<<
")"<<endl;
161 printf(
" Track initial relativistic energy [MeV]: %f\n", wcsimroottrack->
GetE());
162 printf(
" Track initial momentum magnitude [MeV/c]: %f\n", wcsimroottrack->
GetP());
163 printf(
" Track mass [MeV/c2]: %f\n", wcsimroottrack->
GetM());
164 printf(
" Track ID: %d\n", wcsimroottrack->
GetId());
165 printf(
" Number of ID/OD crossings: %zu\n", wcsimroottrack->
GetBoundaryPoints().size());
167 printf(
" First crossing position [mm]: (%f %f %f), KE [MeV]: %f, time [ns]: %f, type: %d\n",
198 h1->Fill(ncherenkovdigihits);
200 cout <<
"RAW HITS:" << endl;
201 printf(
"Number of PMTs with a true hit %d\n", ncherenkovhits);
206 #ifdef WCSIM_SAVE_PHOTON_HISTORY 212 for (
int itruepmt=0; itruepmt < ncherenkovhits; itruepmt++)
218 int tubeNumber = wcsimrootcherenkovhit->
GetTubeID();
219 int timeArrayIndex = wcsimrootcherenkovhit->
GetTotalPe(0);
220 int peForTube = wcsimrootcherenkovhit->
GetTotalPe(1);
222 totalPe += peForTube;
224 if ( itruepmt < 10 ) {
225 if(verbose > 1) printf(
"photon hits on tube %d : %d, times: ( ",tubeNumber,peForTube);
226 for (
int itruehit = timeArrayIndex; itruehit < timeArrayIndex + peForTube; itruehit++) {
230 if(verbose > 1) printf(
"%6.2f ", HitTime->
GetTruetime() );
232 if(verbose > 1) cout <<
")" << endl;
236 if(verbose) cout <<
"Total p.e. on all tubes: " << totalPe << endl
237 <<
" average of " << (double)totalPe/(
double)ncherenkovhits <<
" p.e. per tube" << endl;
241 if(verbose) cout <<
"DIGITIZED HITS:" << endl;
242 for (
int itrigger = 0 ; itrigger < wcsimrootsuperevent->
GetNumberOfEvents(); itrigger++)
244 wcsimrootevent = wcsimrootsuperevent->
GetTrigger(itrigger);
245 if(verbose) cout <<
"Sub event number = " << itrigger <<
"\n";
248 if(verbose) printf(
"Number of digits in sub-event: %d\n", ncherenkovdigihits);
250 if(ncherenkovdigihits>0)
254 for (
int idigi=0;idigi<ncherenkovdigihits_slots;idigi++)
258 if(!element)
continue;
267 const int tubeId = wcsimrootcherenkovdigihit->
GetTubeId();
268 if(events_tree_name.EqualTo(
"wcsimrootevent"))
270 else if(events_tree_name.EqualTo(
"wcsimrootevent2"))
272 else if(events_tree_name.EqualTo(
"wcsimrootevent_OD"))
280 printf(
"idigi, q [p.e.], time+950 [ns], tubeid (x,y,z): %d %f %f %d (%f, %f, %f) \n",idigi,wcsimrootcherenkovdigihit->
GetQ(),
281 wcsimrootcherenkovdigihit->
GetT(), tubeId, x, y, z);
285 std::vector<int> photonids=wcsimrootcherenkovdigihit->
GetPhotonIds();
288 for(
auto thephotonsid : photonids){
291 if(thehittimeobject){
292 cout<<
" digit "<<idigi<<
" photon "<<photonid<<
": ";
293 cout<<
" HitTime index "<<thephotonsid<<
", pre-smear time "<<thehittimeobject->
GetTruetime()
294 <<
", parent TrackID: "<<thehittimeobject->
GetParentID()<<
";";
296 #ifdef WCSIM_SAVE_PHOTON_HISTORY 299 if(thehithistoryobject) {
301 cout<<
" Rayleigh Scattering: "<<thehithistoryobject->
GetNRayScatters()<<
", Mie Scattering: "<<thehithistoryobject->
GetNMieScatters()<<
", Reflection: ";
312 if(verbose || idigifound != ncherenkovdigihits)
313 cout << idigifound <<
" digits found; expected " << ncherenkovdigihits << endl;
321 float win_scale = 0.75;
324 TCanvas* c1 =
new TCanvas(
"c1",
"First canvas", 500*n_wide*win_scale, 500*n_high*win_scale);
327 c1->cd(1); hvtxX->Draw();
328 c1->cd(2); hvtxY->Draw();
329 c1->cd(3); hvtxZ->Draw();
330 c1->cd(4); h1->Draw();
332 cout <<
"********************" << endl
333 << num_trig <<
" triggers found with at least one digitised hit" << endl
334 <<
" when run over " << nevent <<
" events" << endl
335 <<
" giving average of " << (double)num_trig / (
double)nevent <<
" triggers per event" << endl;
Detector geometry information (also containing PMT information arrays)
Float_t GetWCCylLength() const
WCSimRootPMT GetPMT(Int_t i, bool hybridsecondtype=false)
std::vector< double > GetBoundaryTimes() const
void Print(Option_t *option="") const
std::vector< int > GetPhotonIds() const
Int_t GetNumberOfSubEvents() const
Class holding digitised hit (aka digit or digi) information (after PMT & electronics simulation + tri...
Float_t GetWCCylRadius() const
Double_t GetTruetime() const
WCSimRootEventHeader * GetHeader()
TClonesArray * GetTracks() const
std::vector< int > GetBoundaryTypes() const
std::vector< float > GetBoundaryKEs() const
Int_t GetNcherenkovhits() const
Float_t GetDir(Int_t i=0) const
Float_t GetVtx(Int_t i=0)
std::vector< ReflectionSurface_t > GetReflectionSurfaces() const
Int_t GetParentId() const
Int_t GetParenttype() const
PMT geometry information.
Int_t GetNtrack_slots() const
TClonesArray * GetCherenkovHits() const
TClonesArray * GetCherenkovHitHistories() const
Class holding true (Cherenkov photon + dark noise) hit information.
Int_t GetNcherenkovdigihits() const
Class storing trigger information.
Int_t GetNRayScatters() const
Int_t GetTotalPe(int i) const
WCSimRootTrigger * GetTrigger(int number)
WCSimRootPMT GetODPMT(Int_t i)
TClonesArray * GetCherenkovHitTimes() const
List of WCSim running options.
Int_t GetNumberOfEvents() const
std::vector< std::vector< float > > GetBoundaryPoints() const
Class containing event information.
int sample_readfile(const char *filename="../wcsim.root", TString events_tree_name="wcsimrootevent", const int verbose=0)
Int_t GetParentID() const
Int_t GetNcherenkovdigihits_slots() const
static std::string EnumAsString(DigitizerType_t d)
Int_t GetNMieScatters() const
Class holding true (Cherenkov photon + dark noise) hit information.
TClonesArray * GetCherenkovDigiHits() const
Class holding true track information.
TriggerType_t GetTriggerType() const
Class holding scattering and reflection history for each true hit (Cherenkov photon; dark noise are a...
Float_t GetPosition(Int_t i=0) const