Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DEventProcessor_lut_dirc.cc
Go to the documentation of this file.
1 // -----------------------------------------
2 // DEventProcessor_lut_dirc.cc
3 // created on: 29.11.2017
4 // initial athor: r.dzhygadlo at gsi.de
5 // -----------------------------------------
6 
8 
9 // Routine used to create our DEventProcessor
10 extern "C" {
11  void InitPlugin(JApplication *app) {
12  InitJANAPlugin(app);
13  app->AddProcessor(new DEventProcessor_lut_dirc());
14  }
15 }
16 
18  fTree = NULL;
19 }
20 
22 }
23 
25  string locOutputFileName = "hd_root.root";
26  if(gPARMS->Exists("OUTPUT_FILENAME"))
27  gPARMS->GetParameter("OUTPUT_FILENAME", locOutputFileName);
28 
29  //go to file
30  TFile* locFile = (TFile*)gROOT->FindObject(locOutputFileName.c_str());
31  if(locFile != NULL)
32  locFile->cd("");
33  else
34  gDirectory->Cd("/");
35 
36  fTree = new TTree("lut_dirc","Look-up table for the geometrical reconstruction.");
37  int Nnodes = 30000;
38  for(int l=0; l<48; l++){
39  fLut[l] = new TClonesArray("DrcLutNode");
40  fTree->Branch(Form("LUT_%d",l),&fLut[l],256000,-1);
41  TClonesArray &fLuta = *fLut[l];
42  for (Long64_t n=0; n<Nnodes; n++) {
43  new((fLuta)[n]) DrcLutNode(-1);
44  }
45  }
46 
47  return NOERROR;
48 }
49 
50 jerror_t DEventProcessor_lut_dirc::evnt(JEventLoop *loop, uint64_t eventnumber) {
51  vector<const DMCThrown*> mcthrowns;
52  vector<const DDIRCTruthPmtHit*> dircPmtHits;
53 
54  loop->Get(mcthrowns);
55  loop->Get(dircPmtHits);
56 
57  if(mcthrowns.size()<1) return NOERROR;
58  if(dircPmtHits.size()!=1) return NOERROR;
59 
60  japp->RootWriteLock(); //ACQUIRE ROOT LOCK
61 
62  // loop over PMT's hits
63  for (unsigned int h = 0; h < dircPmtHits.size(); h++){
64 
65  int ch=dircPmtHits[h]->ch;
66  int lutId = dircPmtHits[h]->key_bar;
67  TVector3 dir = TVector3(mcthrowns[0]->momentum().X(),
68  mcthrowns[0]->momentum().Y(),
69  mcthrowns[0]->momentum().Z()).Unit();
70 
71  //std::cout<<"dir.X() "<<dir.X() <<" "<<dir.Y() <<" "<<dir.Z() << " | "
72  // <<mom.X() <<" "<<mom.Y() <<" "<<mom.Z() <<std::endl;
73 
74  if(lutId>=0 && lutId<48)
75  ((DrcLutNode*)(fLut[lutId]->At(ch)))->
76  AddEntry(lutId, // lut/bar id
77  ch, // pixel id
78  dir,
79  dircPmtHits[h]->path,
80  dircPmtHits[h]->refl,
81  dircPmtHits[h]->t,
82  TVector3(dircPmtHits[h]->x,dircPmtHits[h]->y,dircPmtHits[h]->z),
83  TVector3(dircPmtHits[h]->x,dircPmtHits[h]->y,dircPmtHits[h]->z));
84  }
85  japp->RootUnLock(); //RELEASE ROOT LOCK
86 
87  return NOERROR;
88 }
89 
91  return NOERROR;
92 }
93 
95  japp->RootWriteLock();
96  fTree->Fill();
97  japp->RootUnLock();
98  return NOERROR;
99 }
leg AddEntry(hTS_LED,"LED trigger","l")
Double_t x[NCHANNELS]
Definition: st_tw_resols.C:39
#define y
#define X(str)
Definition: hddm-c.cpp:83
JApplication * japp
InitPlugin_t InitPlugin
jerror_t evnt(JEventLoop *loop, uint64_t eventnumber)
TDirectory * dir
Definition: bcal_hist_eff.C:31
cout<<"1D histograms: "<< Idx<< endl;hist[k]=(TH1F *) hist_list-> At(k)
Definition: readhist.C:13