144 {
145
147 log << MSG::INFO << "TofRawDataProvider::tofDataMapFull()" << endreq;
148
149 if( !m_tofDataMap.empty() ) {
150
151 log << MSG::WARNING << "TofRawDataProvider::tofDataMapFull: m_tofDataMap is NOT empty!" << endreq;
152
154 for( ;
iter != m_tofDataMap.end();
iter++ ) {
155 delete (*iter).second;
156 }
157 m_tofDataMap.clear();
158 }
159
160 std::string evtDataSvc_name("EventDataSvc");
161 if(isGaudiThreaded(
m_name)){
162 evtDataSvc_name += getGaudiThreadIDfromName(
m_name);
163 }
164
165
166 IDataProviderSvc* eventSvc;
167 StatusCode sc =
m_svcLocator->service( evtDataSvc_name.c_str(),eventSvc,
true );
168 if( !sc.isSuccess() ) {
169 log << MSG::FATAL << "TofRawDataProvider::tofDataMapFull: ERROR Could not load EventDataSvc" << endreq;
170 return;
171 }
172
173
174 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc,"/Event/EventHeader");
175 if( !eventHeader ) {
176 log << MSG::FATAL << "TofRawDataProvider could not find Event Header!" << endreq;
177 return;
178 }
179 m_run = eventHeader->runNumber();
180 m_event = eventHeader->eventNumber();
181
182 bool mc = ( m_run < 0 ) ? true:false;
184 qCorr = qCorr && (!mc);
187 misLable = ( !mc && misLable );
188
189 int identmp = -1;
190 vector<int> deadId;
191 for( unsigned int i=0; i<5; i++ ) {
193 if( identmp != 0x2fffffff ) {
194 deadId.push_back( identmp );
195 }
197 if( identmp != 0x2fffffff ) {
198 deadId.push_back( identmp );
199 }
201 if( identmp != 0x2fffffff ) {
202 deadId.push_back( identmp );
203 }
204 }
205
206
207 SmartDataPtr<TofDigiCol> tofDigiCol(eventSvc,"/Event/Digi/TofDigiCol");
208 if( !tofDigiCol ) {
209 log << MSG::WARNING << "TofRawDataProvider::tofDataMapFull: Could not find Tof Digi Data!" << endreq;
210 return;
211 }
212
213 int qnumber = 0;
214 int tnumber = 0;
215
216 std::vector<Adc*> chargeVec;
217 std::vector<Tdc*> timeVec;
218
219 TofDigiCol::iterator
iter = tofDigiCol->begin();
220 for( ;
iter != tofDigiCol->end();
iter++ ) {
222 unsigned int iden_value = iden.
get_value();
223
224 bool sameId = false;
225 vector<int>::iterator iter_dead = deadId.begin();
226 for( ; iter_dead != deadId.end(); iter_dead++ ) {
227 if( iden_value == (*iter_dead) ) {
228 sameId = true;
229 break;
230 }
231 }
232 if( sameId ) {
233 if( mc ) { continue; }
234 else {
235 std::string bore;
240
241 log << MSG::ERROR << "TofRawDataProvider::tofDataMapFull: Dead Channel Number is not Correct, please check TOF Calibration Constants! " << bore << endreq;
242 }
243 }
244
246
247 unsigned int overflow = (*iter)->getOverflow();
248 if(
TofID::is_scin(iden) && ( ( overflow & 0xfe000000 ) == 0xfe000000 ) )
continue;
249
250
251
252
253
254
255
257
258 if( ( iden_value & 0x2fffffe0 ) == 0x2000c800 ) {
259 iden_value = 0x2000c900 + ( iden_value & 0x1f );
261 }
262
263 if( ( iden_value & 0x2fffffe0 ) == 0x2000c820 ) {
264 iden_value = 0x2000c8e0 + ( iden_value & 0x1f );
266 }
267 }
268
269
270
271
272
273 bool multiQ = ( ( overflow & 0x8 ) != 0 );
274 bool multiT = ( ( overflow & 0x4 ) != 0 );
275
276 unsigned int tdcChannel = (*iter)->getTimeChannel();
277 unsigned int adcChannel = (*iter)->getChargeChannel();
279 adcChannel = ( adcChannel | 0x80000 );
280 }
281
282 if( (adcChannel&0x7fffffff) != 0x7fffffff ) {
286
287
288
290 adcChannel += 0x18000;
291 }
292
293
295 qnumber++;
297 chargeVec.push_back( adc );
298 }
299
300 if( tdcChannel != 0x7fffffff ) {
302
303
304
306 tdcChannel += 0x18000;
307 }
308
309
311 tnumber++;
313 timeVec.push_back( tdc );
314 }
315
316 if( multiT || multiQ ) {
317 TofDigiCol::iterator iter_next =
iter + 1;
318 if( iter_next != tofDigiCol->end() ) {
319 unsigned int idenNext_value = ((*iter_next)->identify()).get_value();
320 if( iden_value == idenNext_value ) continue;
321 }
322 }
323
324 qnumber = 0;
325 tnumber = 0;
326
327 std::vector<PmtData*> pmtDataVec;
329 std::vector<Tdc*>::iterator iter_t = timeVec.begin();
330 for( ; iter_t != timeVec.end(); iter_t++ ) {
331 int tclock = (*iter_t)->clock();
335 std::vector<Adc*>::iterator iter_q = chargeVec.begin();
336 for( ; iter_q != chargeVec.end(); iter_q++ ) {
337 if( (*iter_q)->times() != -1 ) { continue; }
338 int qclock = (*iter_q)->clock();
339 if(
abs(tclock-qclock)<2 ) {
340 if( ( pmt->
quality() & 0x2 ) != 0 ) {
341 if( (*iter_q)->value() > pmt->
adc() ) {
344 }
345 }
346 else {
348 }
349 }
350 }
351 pmtDataVec.push_back( pmt );
352 }
353
354 std::vector<Adc*>::iterator iter_q = chargeVec.begin();
355 for( ; iter_q != chargeVec.end(); iter_q++ ) {
356 if( (*iter_q)->times() != -1 ) { continue; }
360 pmtDataVec.push_back( pmt );
361 }
362
363 }
364
366 std::vector<Tdc*>::iterator iter_t = timeVec.begin();
367 for( ; iter_t != timeVec.end(); iter_t++ ) {
368 std::vector<Adc*>::iterator iter_q = chargeVec.begin();
369 for( ; iter_q != chargeVec.end(); iter_q++ ) {
370 if( ( (*iter_q)->qtc() - (*iter_t)->value() ) >
totForward && ( (*iter_q)->qtc() - (*iter_t)->value() ) <
totBackward ) {
375 pmtDataVec.push_back( pmt );
376 }
377 }
378 if( (*iter_t)->times() == -1 ) {
381 pmtDataVec.push_back( pmt );
382 }
383 }
384
385 std::vector<Adc*>::iterator iter_q = chargeVec.begin();
386 for( ; iter_q != chargeVec.end(); iter_q++ ) {
387 if( (*iter_q)->times() != -1 ) { continue; }
391 pmtDataVec.push_back( pmt );
392 }
393
394 }
395
396 chargeVec.clear();
397 timeVec.clear();
398
399 unsigned int iden_value_key = (iden_value & 0xfffffffe );
402
405 if( ( barrel_ec == 0 ) || ( barrel_ec == 2 ) ) {
406 std::vector<PmtData*>::iterator iter_pmt = pmtDataVec.begin();
407 for( ; iter_pmt != pmtDataVec.end(); iter_pmt++ ) {
409 if( misLable ) {
411 if( barrel_ec==2 && tofid==42 ) {
413 iden_value_key = iden91;
415 }
416 if( barrel_ec==2 && tofid==43 ) {
418 iden_value_key = iden90;
420 }
421 }
425 m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
426 }
427 }
428 else if( barrel_ec == 1 ) {
429 unsigned int count = m_tofDataMap.count( iden_value_key );
431 std::vector<PmtData*>::iterator iter_pmt = pmtDataVec.begin();
432 for( ; iter_pmt != pmtDataVec.end(); iter_pmt++ ) {
435 if( end == 0 ) {
437 }
438 else {
440 }
442 m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
443 }
444 }
445 else {
446 pair< IterTofDataMap, IterTofDataMap > range = m_tofDataMap.equal_range( iden_value_key );
447 std::vector<PmtData*>::iterator iter_pmt = pmtDataVec.begin();
448 for( ; iter_pmt != pmtDataVec.end(); iter_pmt++ ) {
449 bool used = false;
451 for(
unsigned int tofDataNumber = 0; tofDataNumber <
count; tofDataNumber++,
iter++ ) {
452
453 bool matched = false;
454 if( end == 0 ) {
455 if( ( (*iter_pmt)->quality() & 0x1 ) != 0 ) {
456 if( ( ((*iter).second)->quality() & 0x1 ) != 0 ) {
457 double time1 = (*iter_pmt)->tdc();
458 double time2 = ((*iter).second)->tdc2();
460 }
461 else {
462 if( ( ((*iter).second)->quality() & 0x2 ) != 0 ) {
463 double time1 = (*iter_pmt)->tclock();
464 double time2 = (*iter_pmt)->qclock();
465 double time3 = ((*iter).second)->qclock2();
467 }
468 }
469 }
470 else {
471 if( ( (*iter_pmt)->quality() & 0x2 ) != 0 ) {
472 if( ( ((*iter).second)->quality() & 0x1 ) != 0 ) {
473 if( ( ( ((*iter).second)->quality() & 0x2 ) != 0 ) ) {
474 double time1 = (*iter_pmt)->qclock();
475 double time2 = ((*iter).second)->tclock2();
476 double time3 = ((*iter).second)->qclock2();
478 }
479 }
480 else {
481 if( ( ( ((*iter).second)->quality() & 0x2 ) != 0 ) ) {
482 double time1 = (*iter_pmt)->qclock();
483 double time2 = ((*iter).second)->qclock2();
485 }
486 }
487 }
488 }
489
490 if( matched ) {
491 used = true;
492 if( ( ( (*iter).second)->quality() & 0xc ) == 0 ) {
493 ((*iter).second)->setForward( (*iter_pmt) );
494 }
495 else {
501 m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
502 }
503 }
504
505 }
506 else {
507 if( ( (*iter_pmt)->quality() & 0x1 ) != 0 ) {
508 if( ( ((*iter).second)->quality() & 0x4 ) != 0 ) {
509 double time1 = (*iter_pmt)->tdc();
510 double time2 = ((*iter).second)->tdc1();
512 }
513 else {
514 if( ( ((*iter).second)->quality() & 0x8 ) != 0 ) {
515 double time1 = (*iter_pmt)->tclock();
516 double time2 = (*iter_pmt)->qclock();
517 double time3 = ((*iter).second)->qclock1();
519 }
520 }
521 }
522 else {
523 if( ( (*iter_pmt)->quality() & 0x2 ) != 0 ) {
524 if( ( ((*iter).second)->quality() & 0x4 ) != 0 ) {
525 if( ( ( ((*iter).second)->quality() & 0x8 ) != 0 ) ) {
526 double time1 = (*iter_pmt)->qclock();
527 double time2 = ((*iter).second)->tclock1();
528 double time3 = ((*iter).second)->qclock1();
530 }
531 else {
532 }
533 }
534 else {
535 if( ( ( ((*iter).second)->quality() & 0x8 ) != 0 ) ) {
536 double time1 = (*iter_pmt)->qclock();
537 double time2 = ((*iter).second)->qclock1();
539 }
540 }
541 }
542 }
543
544 if( matched ) {
545 used = true;
546 if( ( ( (*iter).second)->quality() & 0x3 ) == 0 ) {
547 ((*iter).second)->setBackward( (*iter_pmt) );
548 }
549 else {
552 tof->
setForward( ((*iter).second)->forward() );
555 m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
556 }
557 }
558 }
559 }
560
561 if( ! used ) {
564 if( end == 0 ) {
566 }
567 else {
569 }
571 m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
572 }
573 }
574 }
575 }
576 }
577
579
580
581
582
584
585 unsigned int count = m_tofDataMap.count( iden_value_key );
587 std::vector<PmtData*>::iterator iter_pmt = pmtDataVec.begin();
588 for( ; iter_pmt != pmtDataVec.end(); iter_pmt++ ) {
591 if( end == 0 ) {
593 }
594 else {
596 }
598 m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
599 }
600 }
601 else {
602 pair< IterTofDataMap, IterTofDataMap > range = m_tofDataMap.equal_range( iden_value_key );
603 std::vector<PmtData*>::iterator iter_pmt = pmtDataVec.begin();
604 for( ; iter_pmt != pmtDataVec.end(); iter_pmt++ ) {
605 bool used = false;
607 for(
unsigned int tofDataNumber = 0; tofDataNumber <
count; tofDataNumber++,
iter++ ) {
608 bool matched = false;
609 if( end == 0 ) {
610 if( ( (*iter_pmt)->quality() & 0x1 ) != 0 ) {
611 if( ( ((*iter).second)->quality() & 0x1 ) != 0 ) {
612 double time1 = (*iter_pmt)->tdc();
613 double time2 = ((*iter).second)->tdc2();
615 }
616 }
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649 if( matched ) {
650 used = true;
651 if( ( ( (*iter).second)->quality() & 0xc ) == 0 ) {
652 ((*iter).second)->setForward( (*iter_pmt) );
653 }
654 else {
660 m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
661 }
662 }
663 }
664 else {
665 if( ( (*iter_pmt)->quality() & 0x1 ) != 0 ) {
666 if( ( ((*iter).second)->quality() & 0x4 ) != 0 ) {
667 double time1 = (*iter_pmt)->tdc();
668 double time2 = ((*iter).second)->tdc1();
670 }
671 }
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704 if( matched ) {
705 used = true;
706 if( ( ( (*iter).second)->quality() & 0x3 ) == 0 ) {
707 ((*iter).second)->setBackward( (*iter_pmt) );
708 }
709 else {
712 tof->
setForward( ((*iter).second)->forward() );
715 m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
716 }
717 }
718 }
719 }
720
721 if( ! used ) {
724 if( end == 0 ) {
726 }
727 else {
729 }
731 m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
732 }
733 }
734 }
735 }
736
737 pmtDataVec.clear();
738
739 }
740
741 return;
742
743}
const double timeDiffMRPC
void setValue(Identifier identify, int value)
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
void setIdentify(unsigned int iden)
unsigned int quality() const
void setForward(PmtData *pmt)
void setTMatched(bool tmatched)
void setBackward(PmtData *pmt)
void setIdentify(Identifier identify)
static bool is_scin(const Identifier &id)
static int end(const Identifier &id)
static bool is_barrel(const Identifier &id)
Test for barrel.
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)
void setNumber(int number)