75{
76
77 ISvcLocator* svcLocator = Gaudi::svcLocator();
79 StatusCode sc = svcLocator->service(
"TofCaliSvc",
tofCaliSvc);
80 if (sc != StatusCode::SUCCESS) {
81 cout << "TofEnergyRec Get Calibration Service Failed !! " << endl;
82 }
83
85 sc = svcLocator->service(
"TofQCorrSvc",
tofQCorrSvc);
86 if (sc != StatusCode::SUCCESS) {
87 cout << "TofEnergyRec Get QCorr Service Failed !! " << endl;
88 }
89
91 sc = svcLocator->service(
"TofQElecSvc",
tofQElecSvc);
92 if (sc != StatusCode::SUCCESS) {
93 cout << "TofEnergyRec Get QElec Service Failed !! " << endl;
94 }
95
96 vector<TofData*>::iterator it;
97 for(it=tofDataVec.begin();
98 it!=tofDataVec.end();
99 it++) {
100
107
108
109 if(m_output) {
110 m_part = barrel_ec;
111 m_layer = layer;
112 m_im = im;
113 m_end = end;
114 }
115
116 if((*it)->barrel()) {
120 if(bTofData->
tdc1()<=0||bTofData->
tdc1()>8000||bTofData->
tdc2()<=0||bTofData->
tdc2()>8000)
continue;
121
122 double adc1,adc2,tdc1,tdc2;
123 tdc1 = bTofData->
tdc1();
124 tdc2 = bTofData->
tdc2();
125 adc1 = bTofData->
adc1();
126 adc2 = bTofData->
adc2();
127
128
130 if(fabs(zpos)>115) continue;
132 if(tofq<100||tofq>10000) continue;
133
134 double energy = tofq*m_calibConst;
135
136 zpos /= 100.;
137
140
141 if(m_output) {
142 m_part = barrel_ec;
143 m_layer = layer;
144 m_im = im;
145 m_end = end;
146 m_adc1 = bTofData->
adc1();
147 m_adc2 = bTofData->
adc2();
148 m_tdc1 = bTofData->
tdc1();
149 m_tdc2 = bTofData->
tdc2();
150 m_zpos = zpos;
152 m_tuple->write();
153 }
154
155 } else {
156
157 if(!is_mrpc)
158 {
159
160
161
162
163
164 }
165 else if(is_mrpc)
166 {
167
169 double charge_ns = eTofData->
adc();
170
171
172 bool neutral =true;
173 bool neighborhood = false;
174
175 int partId_all = barrel_ec;
176 int module_all = im/25;
177 int strip_all = im%25;
178
179 int partId_charged =-9999;
180 int module_charged =-9999;
181 int strip_charged =-9999;
182
183
184
185
186
187 RecTofTrackCol::iterator rec_charged;
188
189
190 for( rec_charged = recTofTrackCol->begin(); rec_charged != recTofTrackCol->end();rec_charged++)
191 {
192
193
194
195
196
198 status->
setStatus((*rec_charged)->status());
200 if((*rec_charged)->tofID()<=125) continue;
201
203 {
204 if((*rec_charged)->tofID()>=600) {partId_charged=3; module_charged = ((*rec_charged)->tofID()-574)/25; strip_charged =((*rec_charged)->tofID()-574)%25; }
205 else {partId_charged=4; module_charged = ((*rec_charged)->tofID()-100)/25; strip_charged =((*rec_charged)->tofID()-100)%25; }
206 }
207 else
208 {
209 if((*rec_charged)->tofID()>=600) {partId_charged=6; module_charged = ((*rec_charged)->tofID()-574)/25; strip_charged =((*rec_charged)->tofID()-574)%25; }
210 else {partId_charged=5;module_charged = ((*rec_charged)->tofID()-100)/25; strip_charged =((*rec_charged)->tofID()-100)%25;}
211 }
212
213 delete status;
214
215
216
217 if( (partId_all==3 || partId_all==4) && (partId_charged==3 || partId_charged==4 ) )
218 {
219 if( partId_all==partId_charged && module_charged == module_all &&
abs(strip_charged-strip_all)<3) neutral =
false;
220 if( partId_all==partId_charged && module_charged == module_all)
221 {
222 if(strip_all%2==0 && strip_charged%2!=0 && strip_charged<strip_all &&
abs(strip_charged-strip_all)<4) neutral =
false;
223 if(strip_all%2!=0 && strip_charged%2==0 && strip_charged>strip_all &&
abs(strip_charged-strip_all)<4) neutral =
false;
224 }
225
226
227 if( partId_all!=partId_charged &&
abs(module_charged-module_all)<2)
228 {
229 if(strip_all%2==0 && strip_charged%2!=0 &&
abs(strip_charged-strip_all)<3 ) neutral =
false;
230 if(strip_all%2==0 && strip_charged%2!=0 && strip_charged<strip_all &&
abs(strip_charged-strip_all)<4) neutral =
false;
231
232 if(strip_all%2!=0 && strip_charged%2==0 &&
abs(strip_charged-strip_all)<3 ) neutral =
false;
233 if(strip_all%2!=0 && strip_charged%2==0 && strip_charged>strip_all &&
abs(strip_charged-strip_all)<4) neutral =
false;
234 }
235
236 }
237 else if ( (partId_all==5 || partId_all==6) && (partId_charged==5 || partId_charged==6 ) )
238 {
239 if( partId_all==partId_charged && module_charged ==module_all &&
abs(strip_charged-strip_all)<3) neutral =
false;
240
241 if( partId_all==partId_charged && module_charged == module_all)
242 {
243 if(strip_all%2==0 && strip_charged%2!=0 && strip_charged<strip_all &&
abs(strip_charged-strip_all)<4) neutral =
false;
244 if(strip_all%2!=0 && strip_charged%2==0 && strip_charged>strip_all &&
abs(strip_charged-strip_all)<4) neutral =
false;
245 }
246
247
248 if( partId_all!=partId_charged &&
abs(module_charged-module_all)<2)
249 {
250 if(strip_all%2==0 && strip_charged%2!=0 &&
abs(strip_charged-strip_all)<3 ) neutral =
false;
251 if(strip_all%2==0 && strip_charged%2!=0 && strip_charged<strip_all &&
abs(strip_charged-strip_all)<4) neutral =
false;
252
253 if(strip_all%2!=0 && strip_charged%2==0 &&
abs(strip_charged-strip_all)<3 ) neutral =
false;
254 if(strip_all%2!=0 && strip_charged%2==0 && strip_charged>strip_all &&
abs(strip_charged-strip_all)<4) neutral =
false;
255 }
256 }
257
258 }
259
260
261
262
263 vector<TofData*>::iterator it_temp;
264 for(it_temp=tofDataVec.begin();it_temp!=tofDataVec.end();it_temp++)
265 {
266
270 int module_temp = im_temp/25;
271 int strip_temp = im_temp%25;
273
274 if( partId_temp==1 ) continue;
275 if(!is_mrpc_temp) continue;
276
277 if( (partId_all==3 || partId_all==4) && (partId_temp==3 || partId_temp==4 ) )
278 {
279 if( partId_all==partId_temp && module_temp == module_all &&
abs(strip_temp-strip_all)!=0 &&
abs(strip_temp-strip_all)<3) neighborhood =
true;
280 if( partId_all==partId_temp && module_temp == module_all)
281 {
282 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;
283 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;
284 }
285
286 if( partId_all!=partId_temp &&
abs(module_temp-module_all)<2)
287 {
288 if(strip_all%2==0 && strip_temp%2!=0 &&
abs(strip_temp-strip_all)<3 ) neighborhood =
true;
289 if(strip_all%2==0 && strip_temp%2!=0 && strip_temp<strip_all &&
abs(strip_temp-strip_all)<4) neighborhood =
true;
290
291 if(strip_all%2!=0 && strip_temp%2==0 &&
abs(strip_temp-strip_all)<3 ) neighborhood =
true;
292 if(strip_all%2!=0 && strip_temp%2==0 && strip_temp>strip_all &&
abs(strip_temp-strip_all)<4) neighborhood =
true;
293 }
294
295 }
296 else if( (partId_all==5 || partId_all==6) && (partId_temp==5 || partId_temp==6 ) )
297 {
298 if( partId_all==partId_temp && module_temp == module_all &&
abs(strip_temp-strip_all)!=0 &&
abs(strip_temp-strip_all)<3) neighborhood =
true;
299 if( partId_all==partId_temp && module_temp == module_all)
300 {
301 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;
302 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;
303 }
304
305 if( partId_all!=partId_temp &&
abs(module_temp-module_all)<2)
306 {
307 if(strip_all%2==0 && strip_temp%2!=0 &&
abs(strip_temp-strip_all)<3 ) neighborhood =
true;
308 if(strip_all%2==0 && strip_temp%2!=0 && strip_temp<strip_all &&
abs(strip_temp-strip_all)<4) neighborhood =
true;
309
310 if(strip_all%2!=0 && strip_temp%2==0 &&
abs(strip_temp-strip_all)<3 ) neighborhood =
true;
311 if(strip_all%2!=0 && strip_temp%2==0 && strip_temp>strip_all &&
abs(strip_temp-strip_all)<4) neighborhood =
true;
312 }
313
314 }
315
316 }
317
318
320
323
324
325
326 }
327
328 }
329 }
330}
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
double GetEnergyCalibration(double, bool, bool)
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)