72{
73
74 ISvcLocator* svcLocator = Gaudi::svcLocator();
76 StatusCode sc = svcLocator->service(
"TofCaliSvc",
tofCaliSvc);
77 if (sc != StatusCode::SUCCESS) {
78 cout << "TofEnergyRec Get Calibration Service Failed !! " << endl;
79 }
80
82 sc = svcLocator->service(
"TofQCorrSvc",
tofQCorrSvc);
83 if (sc != StatusCode::SUCCESS) {
84 cout << "TofEnergyRec Get QCorr Service Failed !! " << endl;
85 }
86
88 sc = svcLocator->service(
"TofQElecSvc",
tofQElecSvc);
89 if (sc != StatusCode::SUCCESS) {
90 cout << "TofEnergyRec Get QElec Service Failed !! " << endl;
91 }
92
93 vector<TofData*>::iterator it;
94 for(it=tofDataVec.begin();
95 it!=tofDataVec.end();
96 it++) {
97
104
105
106 if(m_output) {
107 m_part = barrel_ec;
108 m_layer = layer;
109 m_im = im;
110 m_end = end;
111 }
112
113 if((*it)->barrel()) {
117 if(bTofData->
tdc1()<=0||bTofData->
tdc1()>8000||bTofData->
tdc2()<=0||bTofData->
tdc2()>8000)
continue;
118
119 double adc1,adc2,tdc1,tdc2;
120 tdc1 = bTofData->
tdc1();
121 tdc2 = bTofData->
tdc2();
122 adc1 = bTofData->
adc1();
123 adc2 = bTofData->
adc2();
124
125
127 if(fabs(zpos)>115) continue;
129 if(tofq<100||tofq>10000) continue;
130
131 double energy = tofq*m_calibConst;
132
133 zpos /= 100.;
134
137
138 if(m_output) {
139 m_part = barrel_ec;
140 m_layer = layer;
141 m_im = im;
142 m_end = end;
143 m_adc1 = bTofData->
adc1();
144 m_adc2 = bTofData->
adc2();
145 m_tdc1 = bTofData->
tdc1();
146 m_tdc2 = bTofData->
tdc2();
147 m_zpos = zpos;
149 m_tuple->write();
150 }
151
152 } else {
153
154 if(!is_mrpc)
155 {
156
157
158
159
160
161 }
162 else if(is_mrpc)
163 {
164
166 double charge_ns = eTofData->
adc();
167
168
169
170
171
172
173
174 bool neutral =true;
175 bool neighborhood = false;
176
177 int partId_all = barrel_ec;
178 int module_all = im/25;
179 int strip_all = im%25;
180
181 int partId_charged =-9999;
182 int module_charged =-9999;
183 int strip_charged =-9999;
184
185
186
187
188
189
190
191
192
193
194
195
196
197 RecTofTrackCol::iterator rec_charged;
198
199
200 for( rec_charged = recTofTrackCol->begin(); rec_charged != recTofTrackCol->end();rec_charged++)
201 {
202
203
204
205
206
208 status->
setStatus((*rec_charged)->status());
210 if((*rec_charged)->tofID()<=125) continue;
211
213 {
214 if((*rec_charged)->tofID()>=600) {partId_charged=3; module_charged = ((*rec_charged)->tofID()-574)/25; strip_charged =((*rec_charged)->tofID()-574)%25; }
215 else {partId_charged=4; module_charged = ((*rec_charged)->tofID()-100)/25; strip_charged =((*rec_charged)->tofID()-100)%25; }
216 }
217 else
218 {
219 if((*rec_charged)->tofID()>=600) {partId_charged=6; module_charged = ((*rec_charged)->tofID()-574)/25; strip_charged =((*rec_charged)->tofID()-574)%25; }
220 else {partId_charged=5;module_charged = ((*rec_charged)->tofID()-100)/25; strip_charged =((*rec_charged)->tofID()-100)%25;}
221 }
222
223 delete status;
224
225
226
227
228
229
230
231
232
233 if( (partId_all==3 || partId_all==4) && (partId_charged==3 || partId_charged==4 ) )
234 {
235 if( partId_all==partId_charged && module_charged == module_all &&
abs(strip_charged-strip_all)<3) neutral =
false;
236 if( partId_all==partId_charged && module_charged == module_all)
237 {
238 if(strip_all%2==0 && strip_charged%2!=0 && strip_charged<strip_all &&
abs(strip_charged-strip_all)<4) neutral =
false;
239 if(strip_all%2!=0 && strip_charged%2==0 && strip_charged>strip_all &&
abs(strip_charged-strip_all)<4) neutral =
false;
240 }
241
242
243 if( partId_all!=partId_charged &&
abs(module_charged-module_all)<2)
244 {
245 if(strip_all%2==0 && strip_charged%2!=0 &&
abs(strip_charged-strip_all)<3 ) neutral =
false;
246 if(strip_all%2==0 && strip_charged%2!=0 && strip_charged<strip_all &&
abs(strip_charged-strip_all)<4) neutral =
false;
247
248 if(strip_all%2!=0 && strip_charged%2==0 &&
abs(strip_charged-strip_all)<3 ) neutral =
false;
249 if(strip_all%2!=0 && strip_charged%2==0 && strip_charged>strip_all &&
abs(strip_charged-strip_all)<4) neutral =
false;
250 }
251
252 }
253 else if ( (partId_all==5 || partId_all==6) && (partId_charged==5 || partId_charged==6 ) )
254 {
255 if( partId_all==partId_charged && module_charged ==module_all &&
abs(strip_charged-strip_all)<3) neutral =
false;
256
257 if( partId_all==partId_charged && module_charged == module_all)
258 {
259 if(strip_all%2==0 && strip_charged%2!=0 && strip_charged<strip_all &&
abs(strip_charged-strip_all)<4) neutral =
false;
260 if(strip_all%2!=0 && strip_charged%2==0 && strip_charged>strip_all &&
abs(strip_charged-strip_all)<4) neutral =
false;
261 }
262
263
264 if( partId_all!=partId_charged &&
abs(module_charged-module_all)<2)
265 {
266 if(strip_all%2==0 && strip_charged%2!=0 &&
abs(strip_charged-strip_all)<3 ) neutral =
false;
267 if(strip_all%2==0 && strip_charged%2!=0 && strip_charged<strip_all &&
abs(strip_charged-strip_all)<4) neutral =
false;
268
269 if(strip_all%2!=0 && strip_charged%2==0 &&
abs(strip_charged-strip_all)<3 ) neutral =
false;
270 if(strip_all%2!=0 && strip_charged%2==0 && strip_charged>strip_all &&
abs(strip_charged-strip_all)<4) neutral =
false;
271 }
272 }
273
274
275
276
277
278
279
280
281
282
283
284 }
285
286
287
288
289 vector<TofData*>::iterator it_temp;
290 for(it_temp=tofDataVec.begin();it_temp!=tofDataVec.end();it_temp++)
291 {
292
296 int module_temp = im_temp/25;
297 int strip_temp = im_temp%25;
299
300 if( partId_temp==1 ) continue;
301 if(!is_mrpc_temp) continue;
302
303 if( (partId_all==3 || partId_all==4) && (partId_temp==3 || partId_temp==4 ) )
304 {
305 if( partId_all==partId_temp && module_temp == module_all &&
abs(strip_temp-strip_all)!=0 &&
abs(strip_temp-strip_all)<3) neighborhood =
true;
306 if( partId_all==partId_temp && module_temp == module_all)
307 {
308 if(strip_all%2==0 && strip_temp%2!=0 && strip_temp<strip_all &&
abs(strip_temp-strip_all)<4 &&
abs(strip_temp-strip_all)!=0) neighborhood =
true;
309 if(strip_all%2!=0 && strip_temp%2==0 && strip_temp>strip_all &&
abs(strip_temp-strip_all)<4 &&
abs(strip_temp-strip_all)!=0) neighborhood =
true;
310 }
311
312 if( partId_all!=partId_temp &&
abs(module_temp-module_all)<2)
313 {
314 if(strip_all%2==0 && strip_temp%2!=0 &&
abs(strip_temp-strip_all)<3 ) neighborhood =
true;
315 if(strip_all%2==0 && strip_temp%2!=0 && strip_temp<strip_all &&
abs(strip_temp-strip_all)<4) neighborhood =
true;
316
317 if(strip_all%2!=0 && strip_temp%2==0 &&
abs(strip_temp-strip_all)<3 ) neighborhood =
true;
318 if(strip_all%2!=0 && strip_temp%2==0 && strip_temp>strip_all &&
abs(strip_temp-strip_all)<4) neighborhood =
true;
319 }
320
321 }
322 else if( (partId_all==5 || partId_all==6) && (partId_temp==5 || partId_temp==6 ) )
323 {
324 if( partId_all==partId_temp && module_temp == module_all &&
abs(strip_temp-strip_all)!=0 &&
abs(strip_temp-strip_all)<3) neighborhood =
true;
325 if( partId_all==partId_temp && module_temp == module_all)
326 {
327 if(strip_all%2==0 && strip_temp%2!=0 && strip_temp<strip_all &&
abs(strip_temp-strip_all)<4 &&
abs(strip_temp-strip_all)!=0) neighborhood =
true;
328 if(strip_all%2!=0 && strip_temp%2==0 && strip_temp>strip_all &&
abs(strip_temp-strip_all)<4 &&
abs(strip_temp-strip_all)!=0) neighborhood =
true;
329 }
330
331 if( partId_all!=partId_temp &&
abs(module_temp-module_all)<2)
332 {
333 if(strip_all%2==0 && strip_temp%2!=0 &&
abs(strip_temp-strip_all)<3 ) neighborhood =
true;
334 if(strip_all%2==0 && strip_temp%2!=0 && strip_temp<strip_all &&
abs(strip_temp-strip_all)<4) neighborhood =
true;
335
336 if(strip_all%2!=0 && strip_temp%2==0 &&
abs(strip_temp-strip_all)<3 ) neighborhood =
true;
337 if(strip_all%2!=0 && strip_temp%2==0 && strip_temp>strip_all &&
abs(strip_temp-strip_all)<4) neighborhood =
true;
338 }
339
340 }
341
342 }
343
344
346
347 if(neutral==true)
348 {
349
350
351 if(charge_ns<15.0716)
energy = 326.35-10.6284*15.0716-1.4169*15.0716*15.0716-0.0514292*15.0716*15.0716*15.0716+0.00645421*15.0716*15.0716*15.0716*15.0716;
352 else if(charge_ns>15.9131)
energy = -7.91205+0.814588*charge_ns;
353 else energy = 326.35-10.6284*charge_ns-1.4169*charge_ns*charge_ns-0.0514292*charge_ns*charge_ns*charge_ns+0.00645421*charge_ns*charge_ns*charge_ns*charge_ns;
354 }
355 else
356 {
357 if(neighborhood==
false)
energy = -7.91205+0.814588*charge_ns;
358 else
359 {
360 if(15.16>= charge_ns)
energy= -72550.7+14230.9*15.16-930.499*15.16*15.16+20.2818*15.16*15.16*15.16;
361 if(15.16< charge_ns &&charge_ns<15.7633)
energy= -72550.7+14230.9*charge_ns-930.499*charge_ns*charge_ns+20.2818*charge_ns*charge_ns*charge_ns;
362 else energy = -7.91205+0.814588*charge_ns;
363 }
364 }
365
366
367
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385 }
386
387 }
388 }
389}
double abs(const EvtComplex &c)
************Class m_ypar INTEGER m_KeyWgt INTEGER m_nphot INTEGER m_KeyGPS INTEGER m_IsBeamPolarized INTEGER m_EvtGenInterface DOUBLE PRECISION m_Emin DOUBLE PRECISION m_sphot DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_q2 DOUBLE PRECISION m_PolBeam2 DOUBLE PRECISION m_xErrPb *COMMON c_KK2f $ !CMS energy average $ !Spin Polarization vector first beam $ !Spin Polarization vector second beam $ !Beam energy spread[GeV] $ !minimum hadronization energy[GeV] $ !input READ never touch them !$ !debug facility $ !maximum weight $ !inverse alfaQED $ !minimum real photon energy
ITofQElecSvc * tofQElecSvc
ITofQCorrSvc * tofQCorrSvc
virtual const double BPh(double ADC1, double ADC2, double zHit, unsigned int id)=0
virtual const double ZTDC(double tleft, double tright, unsigned id)=0
void setEnergy(double energy)
void setZpos(double zpos)
void setStatus(unsigned int status)
static int end(const Identifier &id)
static int phi_module(const Identifier &id)
static int barrel_ec(const Identifier &id)
Values of different levels (failure returns 0)
static bool is_mymrpc(const Identifier &id)
static int layer(const Identifier &id)