File: | plugins/Analysis/pid_dirc/DEventProcessor_pid_dirc.cc |
Location: | line 59, column 4 |
Description: | Value stored to 'dTOFz' is never read |
1 | // ----------------------------------------- |
2 | // DEventProcessor_pid_dirc.cc |
3 | // created on: 07.04.2017 |
4 | // initial athor: r.dzhygadlo at gsi.de |
5 | // ----------------------------------------- |
6 | |
7 | #include "DEventProcessor_pid_dirc.h" |
8 | #include "TCanvas.h" |
9 | #include "TH1.h" |
10 | |
11 | |
12 | // Routine used to create our DEventProcessor |
13 | extern "C" { |
14 | void InitPlugin(JApplication *app) { |
15 | InitJANAPlugin(app); |
16 | app->AddProcessor(new DEventProcessor_pid_dirc()); |
17 | } |
18 | } |
19 | |
20 | DEventProcessor_pid_dirc::DEventProcessor_pid_dirc() { |
21 | fTree = NULL__null; |
22 | fEvent = NULL__null; |
23 | } |
24 | |
25 | DEventProcessor_pid_dirc::~DEventProcessor_pid_dirc() {} |
26 | |
27 | jerror_t DEventProcessor_pid_dirc::init(void) { |
28 | string locOutputFileName = "hd_root.root"; |
29 | if(gPARMS->Exists("OUTPUT_FILENAME")) |
30 | gPARMS->GetParameter("OUTPUT_FILENAME", locOutputFileName); |
31 | |
32 | //go to file |
33 | TFile* locFile = (TFile*)gROOT(ROOT::GetROOT())->FindObject(locOutputFileName.c_str()); |
34 | if(locFile != NULL__null) |
35 | locFile->cd(""); |
36 | else |
37 | gDirectory(ROOT::Internal::TDirectoryAtomicAdapter(TDirectory::CurrentDirectory ()))->Cd("/"); |
38 | |
39 | fTree = new TTree("dirc", "dirc tree"); |
40 | fcEvent = new TClonesArray("DrcEvent"); |
41 | fTree->Branch("DrcEvent",&fcEvent,256000,1); |
42 | return NOERROR; |
43 | } |
44 | |
45 | jerror_t DEventProcessor_pid_dirc::brun(jana::JEventLoop *loop, int32_t runnumber) |
46 | { |
47 | // Get the geometry |
48 | DApplication* dapp=dynamic_cast<DApplication*>(loop->GetJApplication()); |
49 | DGeometry *geom = dapp->GetDGeometry(runnumber); |
50 | |
51 | // Outer detector geometry parameters |
52 | vector<double>tof_face; |
53 | geom->Get("//section/composition/posXYZ[@volume='ForwardTOF']/@X_Y_Z", tof_face); |
54 | vector<double>tof_plane; |
55 | geom->Get("//composition[@name='ForwardTOF']/posXYZ[@volume='forwardTOF']/@X_Y_Z/plane[@value='0']", tof_plane); |
56 | double dTOFz=tof_face[2]+tof_plane[2]; |
57 | geom->Get("//composition[@name='ForwardTOF']/posXYZ[@volume='forwardTOF']/@X_Y_Z/plane[@value='1']", tof_plane); |
58 | dTOFz+=tof_face[2]+tof_plane[2]; |
59 | dTOFz*=0.5; // mid plane between tof Planes |
Value stored to 'dTOFz' is never read | |
60 | |
61 | double dDIRCz; |
62 | vector<double>dirc_face; |
63 | vector<double>dirc_plane; |
64 | vector<double>dirc_shift; |
65 | vector<double>bar_plane; |
66 | geom->Get("//section/composition/posXYZ[@volume='DIRC']/@X_Y_Z", dirc_face); |
67 | geom->Get("//composition[@name='DRCC']/posXYZ[@volume='DCML10']/@X_Y_Z/plane[@value='1']", dirc_plane); |
68 | geom->Get("//composition[@name='DIRC']/posXYZ[@volume='DRCC']/@X_Y_Z", dirc_shift); |
69 | |
70 | dDIRCz=dirc_face[2]+dirc_plane[2]+dirc_shift[2] + 0.8625; // last shift is the average center of quartz bar (585.862) |
71 | std::cout<<"dDIRCz "<<dDIRCz<<std::endl; |
72 | |
73 | return NOERROR; |
74 | } |
75 | |
76 | //TH1F *hfine = new TH1F("hfine","hfine",200,1600,1800); |
77 | |
78 | jerror_t DEventProcessor_pid_dirc::evnt(JEventLoop *loop, uint64_t eventnumber) { |
79 | |
80 | vector<const DMCThrown*> mcthrowns; |
81 | vector<const DMCTrackHit*> mctrackhits; |
82 | vector<const DDIRCTruthBarHit*> dircBarHits; |
83 | vector<const DDIRCTruthPmtHit*> dircPmtHits; |
84 | vector<const DDIRCTDCDigiHit*> dataDigiHits; |
85 | vector<const DDIRCPmtHit*> dataPmtHits; |
86 | vector<const DL1Trigger*> trig; |
87 | |
88 | loop->Get(mcthrowns); |
89 | loop->Get(mctrackhits); |
90 | loop->Get(dircPmtHits); |
91 | loop->Get(dircBarHits); |
92 | loop->Get(dataDigiHits); |
93 | loop->Get(dataPmtHits); |
94 | loop->Get(trig); |
95 | |
96 | |
97 | japp->RootWriteLock(); //ACQUIRE ROOT LOCK |
98 | |
99 | // check for LED triggers |
100 | int trigger = 0; |
101 | if (trig.size() > 0) { |
102 | // LED appears as "bit" 15 in L1 front panel trigger monitoring plots |
103 | if (trig[0]->fp_trig_mask & 0x4000) trigger = 1; |
104 | // Physics trigger appears as "bit" 1 in L1 trigger monitoring plots |
105 | if (trig[0]->trig_mask & 0x1) trigger = 2; |
106 | } |
107 | |
108 | |
109 | // LED specific information |
110 | double locLEDRefTime = 0; |
111 | // double locLEDRefAdcTime = 0; |
112 | // double locLEDRefTdcTime = 0; |
113 | if(trigger==1) { |
114 | vector<const DDIRCLEDRef*> dircLEDRefs; |
115 | loop->Get(dircLEDRefs); |
116 | for(uint i=0; i<dircLEDRefs.size(); i++) { |
117 | const DDIRCLEDRef* dircLEDRef = (DDIRCLEDRef*)dircLEDRefs[i]; |
118 | // locLEDRefAdcTime = dircLEDRef->t_fADC; |
119 | // locLEDRefTdcTime = dircLEDRef->t_TDC; |
120 | locLEDRefTime = dircLEDRef->t_TDC; |
121 | break; |
122 | } |
123 | } |
124 | |
125 | // loop over mc/reco tracks |
126 | TClonesArray& cevt = *fcEvent; |
127 | cevt.Clear(); |
128 | for (unsigned int m = 0; m < mcthrowns.size(); m++){ |
129 | if(dircPmtHits.size() > 0.){ |
130 | fEvent = new DrcEvent(); |
131 | fEvent->SetType(trigger); |
132 | DrcHit hit; |
133 | |
134 | // loop over PMT's hits |
135 | for (unsigned int h = 0; h < dircPmtHits.size(); h++){ |
136 | int relevant(0); |
137 | // identify bar id |
138 | for (unsigned int j = 0; j < dircBarHits.size(); j++){ |
139 | //if(j != fabs(dircPmtHits[h]->key_bar)) continue; |
140 | if(mcthrowns[m]->myid == dircBarHits[j]->track){ |
141 | // double px = mcthrowns[m]->momentum().X(); |
142 | // double py = mcthrowns[m]->momentum().Y(); |
143 | // double pz = mcthrowns[m]->momentum().Z(); |
144 | |
145 | double px = dircBarHits[j]->px; |
146 | double py = dircBarHits[j]->py; |
147 | double pz = dircBarHits[j]->pz; |
148 | |
149 | fEvent->SetMomentum(TVector3(px,py,pz)); |
150 | fEvent->SetPdg(mcthrowns[m]->pdgtype); |
151 | fEvent->SetTime(dircBarHits[j]->t); |
152 | fEvent->SetParent(mcthrowns[m]->parentid); |
153 | fEvent->SetId(dircBarHits[j]->bar);// bar id where the particle hit the detector |
154 | fEvent->SetPosition(TVector3(dircBarHits[j]->x, dircBarHits[j]->y, dircBarHits[j]->z)); // position where the charged particle hit the radiator |
155 | relevant++; |
156 | } |
157 | } |
158 | |
159 | if(relevant<1) continue; |
160 | int ch=dircPmtHits[h]->ch; |
161 | int pmt=ch/64; |
162 | int pix=ch%64; |
163 | |
164 | hit.SetChannel(dircPmtHits[h]->ch); |
165 | hit.SetPmtId(pmt); |
166 | hit.SetPixelId(pix); |
167 | hit.SetPosition(TVector3(dircPmtHits[h]->x,dircPmtHits[h]->y,dircPmtHits[h]->z)); |
168 | hit.SetEnergy(dircPmtHits[h]->E); |
169 | hit.SetLeadTime(dircPmtHits[h]->t); |
170 | hit.SetPathId(dircPmtHits[h]->path); |
171 | hit.SetNreflections(dircPmtHits[h]->refl); |
172 | fEvent->AddHit(hit); |
173 | } |
174 | |
175 | if(fEvent->GetHitSize()>0) new (cevt[ cevt.GetEntriesFast()]) DrcEvent(*fEvent); |
176 | } |
177 | } |
178 | |
179 | // calibrated hists |
180 | if(dataPmtHits.size()>0){ |
181 | fEvent = new DrcEvent(); |
182 | fEvent->SetType(trigger); |
183 | fEvent->SetTime(locLEDRefTime); |
184 | |
185 | DrcHit hit; |
186 | for (const auto dhit : dataPmtHits) { |
187 | int ch=dhit->ch; |
188 | int pmt=ch/64; |
189 | int pix=ch%64; |
190 | |
191 | hit.SetChannel(ch); |
192 | hit.SetPmtId(pmt); |
193 | hit.SetPixelId(pix); |
194 | hit.SetLeadTime(dhit->t); |
195 | hit.SetTotTime(dhit->tot); |
196 | fEvent->AddHit(hit); |
197 | } |
198 | |
199 | // for (const auto dhit : dataDigiHits) { |
200 | // int ch=dhit->channel; |
201 | // int pmt=ch/64; |
202 | // int pix=ch%64; |
203 | |
204 | // hit.SetChannel(ch); |
205 | // hit.SetPmtId(pmt); |
206 | // hit.SetPixelId(pix); |
207 | // hit.SetLeadTime(dhit->time); |
208 | // hit.SetTotTime(dhit->edge); |
209 | // fEvent->AddHit(hit); |
210 | // } |
211 | |
212 | |
213 | if(fEvent->GetHitSize()>0) new (cevt[ cevt.GetEntriesFast()]) DrcEvent(*fEvent); |
214 | } |
215 | |
216 | if(cevt.GetEntriesFast()>0) fTree->Fill(); |
217 | japp->RootUnLock(); //RELEASE ROOT LOCK |
218 | |
219 | return NOERROR; |
220 | } |
221 | |
222 | jerror_t DEventProcessor_pid_dirc::erun(void) { |
223 | return NOERROR; |
224 | } |
225 | |
226 | jerror_t DEventProcessor_pid_dirc::fini(void) { |
227 | // TCanvas *c = new TCanvas("c","c",800,500); |
228 | // hfine->Draw(); |
229 | // c->Modified(); |
230 | // c->Update(); |
231 | // c->Print("htime.png"); |
232 | return NOERROR; |
233 | } |