Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DEventProcessor_truth_dirc.cc
Go to the documentation of this file.
1 // -----------------------------------------
2 // DEventProcessor_truth_dirc.cc
3 // -----------------------------------------
4 
6 
7 // Routine used to create our DEventProcessor
8 extern "C" {
9  void InitPlugin(JApplication *app) {
10  InitJANAPlugin(app);
11  app->AddProcessor(new DEventProcessor_truth_dirc());
12  }
13 }
14 
16 }
17 
19 }
20 
22  string locOutputFileName = "hd_root.root";
23  if(gPARMS->Exists("OUTPUT_FILENAME"))
24  gPARMS->GetParameter("OUTPUT_FILENAME", locOutputFileName);
25 
26  //go to file
27  TFile* locFile = (TFile*)gROOT->FindObject(locOutputFileName.c_str());
28  if(locFile != NULL)
29  locFile->cd("");
30  else
31  gDirectory->cd("/");
32 
33  TDirectory *mainDir = gDirectory;
34  TDirectory *dircDir = gDirectory->mkdir("DIRC_truth");
35  dircDir->cd();
36 
37  int nChannels = 108*64;
38  hTruthPixelHitTime = new TH2F("hTruthPixelHitTime", "; Pixel Channel # ; #Delta t (ns)", nChannels, 0, nChannels, 200, -100, 100);
39 
40  hTruthBarHitXY = new TH2F("hTruthBarHitXY", "; Bar Hit X (cm); Bar Hit Y (cm)", 200, -100, 100, 200, -100, 100);
41  hTruthBarHitBar = new TH1F("hTruthBarHitBar", "; Bar #", 48, 0.5, 47.5);
42  hTruthPmtHitZY_North = new TH2F("hTruthPmtHitZY_North", "North Box; PMT Hit Z (cm); PMT Hit Y (cm)", 100, 525, 560, 110, 0., 110.);
43  hTruthPmtHitZY_South = new TH2F("hTruthPmtHitZY_South", "South Box; PMT Hit Z (cm); PMT Hit Y (cm)", 100, 525, 560, 110, -110., 0.);
44 
45  hTruthPmtHit_North = new TH2F("hTruthPmtHit_North", "North Box; Pmt Hit Column ; Pixel Hit Row", 6, 0, 6, 18, 0, 18);
46  hTruthPmtHit_South = new TH2F("hTruthPmtHit_South", "South Box; Pmt Hit Column ; Pixel Hit Row", 6, 0, 6, 18, 0, 18);
47  hTruthPixelHit_North = new TH2F("hTruthPixelHit_North", "North Box; Pixel Hit X ; Pixel Hit Y", 144, -0.5, 143.5, 48, -0.5, 47.5);
48  hTruthPixelHit_South = new TH2F("hTruthPixelHit_South", "South Box; Pixel Hit X ; Pixel Hit Y", 144, -0.5, 143.5, 48, -0.5, 47.5);
49 
50  hPixelHit_North = new TH2F("hPixelHit_North", "North Box; Pixel Hit X ; Pixel Hit Y", 144, -0.5, 143.5, 48, -0.5, 47.5);
51  hPixelHit_South = new TH2F("hPixelHit_South", "South Box; Pixel Hit X ; Pixel Hit Y", 144, -0.5, 143.5, 48, -0.5, 47.5);
52  mainDir->cd();
53 
54  return NOERROR;
55 }
56 
57 jerror_t DEventProcessor_truth_dirc::brun(jana::JEventLoop *loop, int32_t runnumber)
58 {
59 
60 
61  return NOERROR;
62 }
63 
64 jerror_t DEventProcessor_truth_dirc::evnt(JEventLoop *loop, uint64_t eventnumber) {
65  vector<const DBeamPhoton*> beam_photons;
66  vector<const DMCThrown*> mcthrowns;
67  vector<const DMCTrackHit*> mctrackhits;
68  vector<const DDIRCTruthBarHit*> dircBarHits;
69  vector<const DDIRCTruthPmtHit*> dircPmtHits;
70  vector<const DDIRCPmtHit*> dircRecoPmtHits;
71 
72  loop->Get(beam_photons);
73  loop->Get(mcthrowns);
74  loop->Get(mctrackhits);
75  loop->Get(dircPmtHits);
76  loop->Get(dircBarHits);
77  loop->Get(dircRecoPmtHits);
78 
79  // get DIRC geometry
80  vector<const DDIRCGeometry*> locDIRCGeometryVec;
81  loop->Get(locDIRCGeometryVec);
82  auto locDIRCGeometry = locDIRCGeometryVec[0];
83 
84  for (unsigned int j = 0; j < dircBarHits.size(); j++){
85  //double px = dircBarHits[j]->px;
86  //double py = dircBarHits[j]->py;
87  //double pz = dircBarHits[j]->pz;
88 
89  double x = dircBarHits[j]->x;
90  double y = dircBarHits[j]->y;
91  int bar = dircBarHits[j]->bar;
92 
93  japp->RootWriteLock(); //ACQUIRE ROOT LOCK
94  hTruthBarHitXY->Fill(x, y);
95  hTruthBarHitBar->Fill(bar);
96  japp->RootUnLock();
97  }
98 
99  for (unsigned int h = 0; h < dircPmtHits.size(); h++){
100 
101  int ch=dircPmtHits[h]->ch;
102 
103  double x = dircPmtHits[h]->x;
104  double y = dircPmtHits[h]->y;
105  double z = dircPmtHits[h]->z;
106  double t = dircPmtHits[h]->t;
107  double t_fixed = dircPmtHits[h]->t_fixed;
108 
109  // get PMT labels
110  int pmt_column = locDIRCGeometry->GetPmtColumn(ch);
111  int pmt_row = locDIRCGeometry->GetPmtRow(ch);
112 
113  // get pixel labels
114  int pixel_row = locDIRCGeometry->GetPixelRow(ch);
115  int pixel_col = locDIRCGeometry->GetPixelColumn(ch);
116 
117  japp->RootWriteLock(); //ACQUIRE ROOT LOCK
118  hTruthPixelHitTime->Fill(ch, t-t_fixed);
119  if(x < 0.) {
120  hTruthPmtHitZY_South->Fill(z, y);
121  hTruthPmtHit_South->Fill(pmt_column, pmt_row);
122  hTruthPixelHit_South->Fill(pixel_row, pixel_col);
123  }
124  else {
125  hTruthPmtHitZY_North->Fill(z, y);
126  hTruthPmtHit_North->Fill(pmt_column, pmt_row);
127  hTruthPixelHit_North->Fill(pixel_row, pixel_col);
128  }
129  japp->RootUnLock();
130  }
131 
132  for (unsigned int h = 0; h < dircRecoPmtHits.size(); h++){
133 
134  int ch=dircRecoPmtHits[h]->ch;
135  //double t = dircRecoPmtHits[h]->t;
136 
137  // get pixel labels
138  int pixel_row = locDIRCGeometry->GetPixelRow(ch);
139  int pixel_col = locDIRCGeometry->GetPixelColumn(ch);
140 
141  // comparison of truth and reco hits
142  /*
143  vector<const DDIRCTruthPmtHit*> dircTruthPmtHits;
144  dircRecoPmtHits[h]->Get(dircTruthPmtHits);
145  if(dircTruthPmtHits.empty())
146  cout<<"didn't find associated truth hit"<<endl;
147  else if(fabs(t - dircTruthPmtHits[0]->t_fixed) > 1.0)
148  cout<<"found associated truth hit with large DeltaT = "<<t - dircTruthPmtHits[0]->t_fixed<<endl;
149  */
150 
151  japp->RootWriteLock(); //ACQUIRE ROOT LOCK
152  if(ch < 108*64) {
153  hPixelHit_South->Fill(pixel_row, pixel_col);
154  }
155  else {
156  hPixelHit_North->Fill(pixel_row, pixel_col);
157  }
158  japp->RootUnLock();
159  }
160 
161  return NOERROR;
162 }
163 
165  return NOERROR;
166 }
167 
169  return NOERROR;
170 }
Double_t x[NCHANNELS]
Definition: st_tw_resols.C:39
#define y
TDirectory * mainDir
Definition: p2k_hists.C:2
jerror_t evnt(JEventLoop *loop, uint64_t eventnumber)
JApplication * japp
InitPlugin_t InitPlugin
jerror_t brun(jana::JEventLoop *loop, int32_t runnumber)