IMPORTANT /// We use the same datastructure as the olf tof, /// even if we do not have PMTs and so on ///
131 {
132
134 log << MSG::INFO << "TofRawDataProvider::tofDataMapFull()" << endreq;
135
136 if( !m_tofDataMap.empty() ) {
137
138 log << MSG::WARNING << "TofRawDataProvider::tofDataMapFull: m_tofDataMap is NOT empty!" << endreq;
139
141 for( ;
iter != m_tofDataMap.end();
iter++ ) {
142 delete (*iter).second;
143 }
144 m_tofDataMap.clear();
145 }
146
147 std::string evtDataSvc_name("EventDataSvc");
148 if(isGaudiThreaded(
m_name)){
149 evtDataSvc_name += getGaudiThreadIDfromName(
m_name);
150 }
151
152
153 IDataProviderSvc* eventSvc;
154 StatusCode sc =
m_svcLocator->service( evtDataSvc_name.c_str(),eventSvc,
true );
155 if( !sc.isSuccess() ) {
156 log << MSG::FATAL << "TofRawDataProvider::tofDataMapFull: ERROR Could not load EventDataSvc" << endreq;
157 return;
158 }
159
160
161 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc,"/Event/EventHeader");
162 if( !eventHeader ) {
163 log << MSG::FATAL << "TofRawDataProvider could not find Event Header!" << endreq;
164 return;
165 }
166 int run = eventHeader->runNumber();
167
168 bool mc = ( run < 0 ) ? true:false;
170 qCorr = qCorr && (!mc);
173 misLable = ( !mc && misLable );
174 vector<int> deadId;
175
176 int identmp = -1;
177 for( unsigned int i=0; i<5; i++ ) {
179
180 if( identmp != 0x2fffffff ) {
181
182 deadId.push_back( identmp );
183 }
185
186
187 if( identmp != 0x2fffffff ) {
188
189 deadId.push_back( identmp );
190 }
192
193 if( identmp != 0x2fffffff ) {
194
195 deadId.push_back( identmp );
196 }
197 }
198
199
200 SmartDataPtr<TofDigiCol> tofDigiCol(eventSvc,"/Event/Digi/TofDigiCol");
201 if( !tofDigiCol ) {
202 log << MSG::WARNING << "TofRawDataProvider::tofDataMapFull: Could not find Tof Digi Data!" << endreq;
203 return;
204 }
205
206 int qnumber = 0;
207 int tnumber = 0;
208
209 std::vector<Adc*> chargeVec;
210 std::vector<Tdc*> timeVec;
211
212
213
214
215 TofDigiCol::iterator
iter = tofDigiCol->begin();
216
217for( ;
iter != tofDigiCol->end();
iter++ ) {
218
219
220
223
224
225 if(barrel_ec_help == 0 || barrel_ec_help ==1 || barrel_ec_help==2)
226 {
227
228 unsigned int overflow = (*iter)->getOverflow();
229
230
231
232 if( ( overflow & 0xfe000000 ) == 0xfe000000 )
233 {
234 continue;
235 }
236
237
238
239
240 bool multiQ = ( ( overflow & 0x8 ) != 0 );
241 bool multiT = ( ( overflow & 0x4 ) != 0 );
242
244
245 unsigned int iden_value = iden.
get_value();
246
247
248
249
250 bool sameId = false;
251 vector<int>::iterator iter_dead = deadId.begin();
252 for( ; iter_dead != deadId.end(); iter_dead++ ) {
253 if( iden_value == (*iter_dead) ) {
254 sameId = true;
255 break;
256 }
257 }
258 if( sameId ) {
259 if( mc ) { continue; }
260 else {
261 log << MSG::ERROR << "TofRawDataProvider::tofDataMapFull: Dead Channel Number is not Correct, please check TOF Calibration Constants!" << endreq;
262 }
263 }
264
265
269
270
271
272 if( ( barrel_ec != 1 ) && ( end == 1 ) ) continue;
273
274 if( ( barrel_ec != 1 ) && ( id == 48 ) ) continue;
275
276 unsigned int tdcChannel = (*iter)->getTimeChannel();
277 unsigned int adcChannel = (*iter)->getChargeChannel();
278
279
280
281
282 if( ( overflow & 0x2 ) != 0 )
283 {
284 adcChannel = ( adcChannel | 0x80000 );
285 }
286
287 if( (adcChannel&0x7fffffff) != 0x7fffffff ) {
288
292
294 qnumber++;
296 chargeVec.push_back( adc );
297 }
298
299
300
301 if( tdcChannel != 0x7fffffff ) {
304 tnumber++;
306 timeVec.push_back( tdc );
307 }
308
309
310
311 if( multiT || multiQ ) {
312 TofDigiCol::iterator iter_next =
iter + 1;
313 if( iter_next != tofDigiCol->end() ) {
314 unsigned int idenNext_value = ((*iter_next)->identify()).get_value();
315 if( iden_value == idenNext_value ) continue;
316 }
317 }
318
319
320
321 qnumber = 0;
322 tnumber = 0;
323
324 std::vector<PmtData*> pmtDataVec;
325 std::vector<Tdc*>::iterator iter_t = timeVec.begin();
326 for( ; iter_t != timeVec.end(); iter_t++ ) {
327 int tclock = (*iter_t)->clock();
330
331 std::vector<Adc*>::iterator iter_q = chargeVec.begin();
332 for( ; iter_q != chargeVec.end(); iter_q++ ) {
333 int qclock = (*iter_q)->clock();
334
335 if(
abs(tclock-qclock)<2 ) {
336 if( ( pmt->
quality() & 0x2 ) != 0 ) {
337 if( (*iter_q)->value() > pmt->
adc() ) {
340
341
342 }
343 }
344 else {
346 }
347 }
348 }
349 pmtDataVec.push_back( pmt );
350 }
351
352
353
354 std::vector<Adc*>::iterator iter_q = chargeVec.begin();
355 for( ; iter_q != chargeVec.end(); iter_q++ ) {
356
357 if( (*iter_q)->times() != -1 )
358 {
359 continue;
360 }
361
362
365 pmtDataVec.push_back( pmt );
366 }
367
368
369
370
371 chargeVec.clear();
372 timeVec.clear();
373
374 unsigned int iden_value_key = (iden_value & 0xfffffffe );
375 if( ( barrel_ec == 0 ) || ( barrel_ec == 2 ) ) {
376 std::vector<PmtData*>::iterator iter_pmt = pmtDataVec.begin();
377 for( ; iter_pmt != pmtDataVec.end(); iter_pmt++ ) {
379 if( misLable ) {
381
382 if( barrel_ec==2 && id==42 ) {
384
385 iden_value_key = iden91;
386 }
387
388 if( barrel_ec==2 && id==43 ) {
390 iden_value_key = iden90;
391 }
392
393 }
394
395
399 m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
400 }
401 }
402 else if( barrel_ec == 1 ) {
403 unsigned int count = m_tofDataMap.count( iden_value_key );
404 if( count == 0 ) {
405 std::vector<PmtData*>::iterator iter_pmt = pmtDataVec.begin();
406 for( ; iter_pmt != pmtDataVec.end(); iter_pmt++ ) {
409 if( end == 0 ) {
411 }
412 else {
414 }
416
417 m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
418 }
419 }
420 else {
421 pair< IterTofDataMap, IterTofDataMap > range = m_tofDataMap.equal_range( iden_value_key );
422 std::vector<PmtData*>::iterator iter_pmt = pmtDataVec.begin();
423 for( ; iter_pmt != pmtDataVec.end(); iter_pmt++ ) {
424 bool used = false;
426 for(
unsigned int tofDataNumber = 0; tofDataNumber <
count; tofDataNumber++,
iter++ ) {
427 bool matched = false;
428 if( end == 0 ) {
429 if( ( ( (*iter_pmt)->quality() & 0x1 ) != 0 ) && ( ( ((*iter).second)->quality() & 0x1 ) != 0 ) ) {
430 double time1 = (*iter_pmt)->tdc();
431 double time2 = ((*iter).second)->tdc2();
433 }
434 else if( ( ( (*iter_pmt)->quality() & 0x1 ) == 0 ) && ( ( (*iter_pmt)->quality() & 0x2 ) != 0 ) && ( ( ((*iter).second)->quality() & 0x1 ) != 0 ) ) {
435 double time1 = (*iter_pmt)->qclock();
436 double time2 = ((*iter).second)->tclock2();
437 double time3 = ((*iter).second)->qclock2();
439 }
440 else if( ( ( (*iter_pmt)->quality() & 0x1 ) != 0 ) && ( ( ((*iter).second)->quality() & 0x1 ) == 0 ) && ( ( ((*iter).second)->quality() & 0x2 ) != 0 ) ) {
441 double time1 = (*iter_pmt)->tclock();
442 double time2 = (*iter_pmt)->qclock();
443 double time3 = ((*iter).second)->qclock2();
445 }
446 else if( ( ( (*iter_pmt)->quality() & 0x1 ) == 0 ) && ( ( (*iter_pmt)->quality() & 0x2 ) != 0 ) && ( ( ((*iter).second)->quality() & 0x1 ) == 0 ) && ( ( ((*iter).second)->quality() & 0x2 ) != 0 ) ) {
447 double time1 = (*iter_pmt)->qclock();
448 double time2 = ((*iter).second)->qclock2();
450 }
451
452 if( matched ) {
453 used = true;
454 if( ( ( (*iter).second)->quality() & 0xc ) == 0 ) {
455 ((*iter).second)->setForward( (*iter_pmt) );
456 }
457 else {
462
463 m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
464 }
465 }
466
467 }
468 else {
469 if( ( ( (*iter_pmt)->quality() & 0x1 ) != 0 ) && ( ( ((*iter).second)->quality() & 0x4 ) != 0 ) ) {
470 double time1 = (*iter_pmt)->tdc();
471 double time2 = ((*iter).second)->tdc1();
473 }
474 else if( ( ( (*iter_pmt)->quality() & 0x1 ) == 0 ) && ( ( (*iter_pmt)->quality() & 0x2 ) != 0 ) && ( ( ((*iter).second)->quality() & 0x4 ) != 0 ) ) {
475 double time1 = (*iter_pmt)->qclock();
476 double time2 = ((*iter).second)->tclock1();
477 double time3 = ((*iter).second)->qclock1();
479 }
480 else if( ( ( (*iter_pmt)->quality() & 0x1 ) != 0 ) && ( ( ((*iter).second)->quality() & 0x4 ) == 0 ) && ( ( ((*iter).second)->quality() & 0x8 ) != 0 ) ) {
481 double time1 = (*iter_pmt)->tclock();
482 double time2 = (*iter_pmt)->qclock();
483 double time3 = ((*iter).second)->qclock1();
485 }
486 else if( ( ( (*iter_pmt)->quality() & 0x1 ) == 0 ) && ( ( (*iter_pmt)->quality() & 0x2 ) != 0 ) && ( ( ((*iter).second)->quality() & 0x4 ) == 0 ) && ( ( ((*iter).second)->quality() & 0x8 ) != 0 ) ) {
487 double time1 = (*iter_pmt)->qclock();
488 double time2 = ((*iter).second)->qclock1();
490 }
491
492 if( matched ) {
493 used = true;
494 if( ( ( (*iter).second)->quality() & 0x3 ) == 0 ) {
495 ((*iter).second)->setBackward( (*iter_pmt) );
496 if( ( ( ((*iter).second)->quality() & 0x5 )==0x5 ) || ( ( ( ((*iter).second)->quality() & 0x5 )==0x4 ) && ( ((*iter).second)->ttimes1()==1 ) ) || ( ( ( ((*iter).second)->quality() & 0x5 )==0x1 ) && ( ((*iter).second)->ttimes2()==1 ) ) ) {
497 ((*iter).second)->setTMatched( true );
498 }
499 else {
500 ((*iter).second)->setTMatched( false );
501 }
502 }
503 else {
506 tof->
setForward( ((*iter).second)->forward() );
508 if( ( ( tof->
quality() & 0x5 )==0x5 ) || ( ( ( tof->
quality() & 0x5 )==0x4 ) && ( tof->
ttimes1()==1 ) ) || ( ( ( tof->
quality() & 0x5 )==0x1 ) && ( tof->
ttimes2()==1 ) ) ) {
510 }
511 else {
513 }
514 m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
515 }
516 }
517 }
518 }
519 if( ! used ) {
522 if( end == 0 ) {
524 }
525 else {
527 }
529 m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
530 }
531 }
532 }
533 }
534
535 pmtDataVec.clear();
536
537 }
538
539
540 else if(barrel_ec_help==3 || barrel_ec_help==4 || barrel_ec_help==5 || barrel_ec_help==6)
541 {
542
543
544
545
546
547
548
549
550
551
552
554
555 unsigned int iden_value = iden.
get_value();
556
560
561
562 unsigned int tdcChannel = (*iter)->getTimeChannel();
563 unsigned int tdc2Channel = (*iter)->getChargeChannel();
564
565
567 unsigned int pulse_length_channel_without_correction = tdc2Channel-tdcChannel;
568
570 if(correction_ta<0) continue;
571
572 time_of_flight=time_of_flight - correction_ta/1000.;
574
575
576
580
581
582 adc->
setValue_mrpc( pulse_length_channel_without_correction,(tdcChannel & 0x07e000) );
583
584 qnumber++;
586
587
590 tnumber++;
591
593
594
595 qnumber = 0;
596 tnumber = 0;
597
598
602
603
604 chargeVec.clear();
605 timeVec.clear();
606
607
608
609
610 unsigned int iden_value_key_mrpc = (iden_value & 0xffffffff );
611
617
618
619
620 m_tofDataMap.insert( make_pair( iden_value_key_mrpc, tof ) );
621
622
623
624
625
626 }
627
628
629
630}
631
632
633
634 return;
635
636}
double abs(const EvtComplex &c)
void setValue_mrpc(int value, int clock)
virtual const int BrWest(unsigned int No)=0
virtual const int QElec()=0
virtual const int BrEast(unsigned int No)=0
virtual const int QCorr()=0
virtual const int MisLable()=0
virtual const int Endcap(unsigned int No)=0
value_type get_value() const
double Time_Amplitude_Correction(unsigned int tdcChannel, unsigned int tdc2Channel)
unsigned int quality() const
static unsigned int TofTimeChannel(double time)
static double TofTime(unsigned int timeChannel)
unsigned int quality() const
void setForward(PmtData *pmt)
void setTMatched(bool tmatched)
void setBackward(PmtData *pmt)
void setIdentify(Identifier identify)
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 value_type getIntID(int barrel_ec, int layer, int phi_module, int end)
MrpcCalibSvc * mrpcCaliSvc
void setNumber(int number)