376 MsgStream log(
msgSvc,
"MucCalibMgr");
377 log << MSG::INFO <<
"Initialize NTuples" << endreq;
380 Gaudi::svcLocator() -> service(
"NTupleSvc",
ntupleSvc);
385 NTuplePtr nt1(
ntupleSvc,
"FILE450/EventLog");
386 if ( nt1 ) { m_eventLogTuple = nt1; }
389 m_eventLogTuple =
ntupleSvc->book (
"FILE450/EventLog", CLID_RowWiseTuple,
"MucCalibConst N-Tuple");
390 if ( m_eventLogTuple )
392 sc = m_eventLogTuple->addItem (
"event_id", m_ntEventId);
393 sc = m_eventLogTuple->addItem (
"event_tag", m_ntEventTag);
394 sc = m_eventLogTuple->addItem (
"start_time", m_ntEsTime);
395 sc = m_eventLogTuple->addItem (
"digi_num", m_ntDigiNum);
396 sc = m_eventLogTuple->addItem (
"track_num", m_ntTrackNum);
397 sc = m_eventLogTuple->addItem (
"exphit_num", m_ntExpHitNum);
398 sc = m_eventLogTuple->addItem (
"effhit_num", m_ntEffHitNum);
399 sc = m_eventLogTuple->addItem (
"noshit_num", m_ntNosHitNum);
400 sc = m_eventLogTuple->addItem (
"cluster_num", m_ntClusterNum);
401 sc = m_eventLogTuple->addItem (
"event_time", m_ntEventTime);
404 log << MSG::ERROR <<
"Cannot book N-tuple:" << long(m_eventLogTuple) << endmsg;
405 return StatusCode::FAILURE;
411 NTuplePtr nt2(
ntupleSvc,
"FILE450/MdcTrkInfo");
412 if ( nt2 ) { m_mdcTrkInfoTuple = nt2; }
415 m_mdcTrkInfoTuple =
ntupleSvc->book (
"FILE450/MdcTrkInfo", CLID_RowWiseTuple,
"MucCalibConst N-Tuple");
416 if ( m_mdcTrkInfoTuple )
418 sc = m_mdcTrkInfoTuple->addItem (
"charge", m_charge);
419 sc = m_mdcTrkInfoTuple->addItem (
"mdcpx", m_mdcpx);
420 sc = m_mdcTrkInfoTuple->addItem (
"mdcpy", m_mdcpy);
421 sc = m_mdcTrkInfoTuple->addItem (
"mdcpz", m_mdcpz);
422 sc = m_mdcTrkInfoTuple->addItem (
"mdcpt", m_mdcpt);
423 sc = m_mdcTrkInfoTuple->addItem (
"mdcpp", m_mdcpp);
424 sc = m_mdcTrkInfoTuple->addItem (
"mdcphi", m_mdcphi);
425 sc = m_mdcTrkInfoTuple->addItem (
"mdctheta", m_mdctheta);
428 log << MSG::ERROR <<
"Cannot book N-tuple:" << long(m_mdcTrkInfoTuple) << endmsg;
429 return StatusCode::FAILURE;
434 NTuplePtr nt3(
ntupleSvc,
"FILE450/TrackInfo");
435 if ( nt3 ) { m_trackInfoTuple = nt3; }
438 m_trackInfoTuple =
ntupleSvc->book (
"FILE450/TrackInfo", CLID_RowWiseTuple,
"MucCalibConst N-Tuple");
439 if ( m_trackInfoTuple )
441 sc = m_trackInfoTuple->addItem (
"track_event", m_ntTrackEvent);
442 sc = m_trackInfoTuple->addItem (
"track_tag", m_ntTrackTag);
443 sc = m_trackInfoTuple->addItem (
"track_hits", m_ntTrackHits);
444 sc = m_trackInfoTuple->addItem (
"segment_fly", m_ntTrackSegFly);
445 sc = m_trackInfoTuple->addItem (
"layer_fly_a", m_ntTrackLayFlyA);
446 sc = m_trackInfoTuple->addItem (
"layer_fly_b", m_ntTrackLayFlyB);
447 sc = m_trackInfoTuple->addItem (
"layer_fly_c", m_ntTrackLayFlyC);
448 sc = m_trackInfoTuple->addItem (
"rec_mode", m_trkRecMode);
449 sc = m_trackInfoTuple->addItem (
"chi2", m_chi2);
450 sc = m_trackInfoTuple->addItem (
"px", m_px);
451 sc = m_trackInfoTuple->addItem (
"py", m_py);
452 sc = m_trackInfoTuple->addItem (
"pz", m_pz);
453 sc = m_trackInfoTuple->addItem (
"pt", m_pt);
454 sc = m_trackInfoTuple->addItem (
"pp", m_pp);
455 sc = m_trackInfoTuple->addItem (
"r", m_r );
456 sc = m_trackInfoTuple->addItem (
"costheta", m_cosTheta);
457 sc = m_trackInfoTuple->addItem (
"theta", m_theta);
458 sc = m_trackInfoTuple->addItem (
"phi", m_phi);
459 sc = m_trackInfoTuple->addItem (
"depth", m_depth);
460 sc = m_trackInfoTuple->addItem (
"br_last_lay", m_brLastLayer);
461 sc = m_trackInfoTuple->addItem (
"ec_last_lay", m_ecLastLayer);
462 sc = m_trackInfoTuple->addItem (
"total_hits", m_totalHits);
463 sc = m_trackInfoTuple->addItem (
"fired_layers", m_totalLayers);
464 sc = m_trackInfoTuple->addItem (
"maxhits_in_layer", m_maxHitsInLayer);
467 log << MSG::ERROR <<
"Cannot book N-tuple:" << long(m_trackInfoTuple) << endmsg;
468 return StatusCode::FAILURE;
473 NTuplePtr nt4(
ntupleSvc,
"FILE450/TrackDiff");
474 if ( nt4 ) { m_trackDiffTuple = nt4; }
477 m_trackDiffTuple =
ntupleSvc->book (
"FILE450/TrackDiff", CLID_RowWiseTuple,
"MucCalibConst N-Tuple");
478 if ( m_trackDiffTuple ) {
479 sc = m_trackDiffTuple->addItem (
"dimu_tag", m_ntDimuTag);
480 sc = m_trackDiffTuple->addItem (
"pos_phi_diff", m_ntPosPhiDiff);
481 sc = m_trackDiffTuple->addItem (
"pos_theta_diff", m_ntPosThetaDiff);
482 sc = m_trackDiffTuple->addItem (
"mom_phi_diff", m_ntMomPhiDiff);
483 sc = m_trackDiffTuple->addItem (
"mom_theta_diff", m_ntMomThetaDiff);
486 log << MSG::ERROR <<
"Cannot book N-tuple:" << long(m_trackDiffTuple) << endmsg;
487 return StatusCode::FAILURE;
492 NTuplePtr nt5(
ntupleSvc,
"FILE450/ClusterSize");
493 if ( nt5 ) { m_clusterSizeTuple = nt5; }
496 m_clusterSizeTuple =
ntupleSvc->book (
"FILE450/ClusterSize", CLID_RowWiseTuple,
"MucCalibConst N-Tuple");
497 if ( m_clusterSizeTuple ) {
498 sc = m_clusterSizeTuple->addItem (
"cluster_size", m_ntClusterSize);
501 log << MSG::ERROR <<
"Cannot book N-tuple:" << long(m_clusterSizeTuple) << endmsg;
502 return StatusCode::FAILURE;
507 NTuplePtr nt6(
ntupleSvc,
"FILE450/EffWindow");
508 if ( nt6 ) { m_effWindowTuple = nt6; }
511 m_effWindowTuple =
ntupleSvc->book (
"FILE450/EffWindow", CLID_RowWiseTuple,
"MucCalibConst N-Tuple");
512 if ( m_effWindowTuple ) {
513 sc = m_effWindowTuple->addItem (
"hit_window", m_ntEffWindow);
516 log << MSG::ERROR <<
"Cannot book N-tuple:" << long(m_effWindowTuple) << endmsg;
517 return StatusCode::FAILURE;
521 NTuplePtr nt7(
ntupleSvc,
"FILE450/ResInfo");
522 if ( nt7 ) { m_resInfoTuple = nt7; }
525 m_resInfoTuple =
ntupleSvc->book (
"FILE450/ResInfo", CLID_RowWiseTuple,
"MucCalibConst N-Tuple");
526 if ( m_resInfoTuple ) {
527 sc = m_resInfoTuple->addItem (
"line_res", m_lineRes);
528 sc = m_resInfoTuple->addItem (
"quad_res", m_quadRes);
529 sc = m_resInfoTuple->addItem (
"extr_res", m_extrRes);
530 sc = m_resInfoTuple->addItem (
"res_part", m_resPart);
531 sc = m_resInfoTuple->addItem (
"res_segment", m_resSegment);
532 sc = m_resInfoTuple->addItem (
"res_layer", m_resLayer);
533 sc = m_resInfoTuple->addItem (
"res_fired", m_resFired);
534 sc = m_resInfoTuple->addItem (
"res_mode", m_resMode);
537 log << MSG::ERROR <<
"Cannot book N-tuple:" << long(m_resInfoTuple) << endmsg;
538 return StatusCode::FAILURE;
572 return StatusCode::SUCCESS;
612 if(i%2 != 0 ) { stripMax = 96*7 + 112; }
613 else { stripMax = 48*8; }
614 sprintf( name,
"HitMapBarrel_Lay_L%d", i );
615 sprintf( title,
"Hit map in barrel layer %d", i );
616 m_hHitMapBarrel_Lay[i] =
new TH1F(name,title, stripMax, 0, stripMax);
621 sprintf( name,
"HitMapEastEndcap_L%d", i );
622 sprintf( title,
"Hit map in east-endcap layer %d", i );
623 m_hHitMapEndcap_Lay[0][i] =
new TH1F(name,title, stripMax, 0, stripMax);
625 sprintf( name,
"HitMapWestEndcap_L%d", i );
626 sprintf( title,
"Hit map in west-endcap layer %d", i );
627 m_hHitMapEndcap_Lay[1][i] =
new TH1F(name,title, stripMax, 0, stripMax);
635 sprintf( name,
"HitMapBarrel_Seg_S%d", i );
636 sprintf( title,
"Hit map in barrel segment %d", i );
637 if(i==2 ) { stripMax = 48*5 + 112*4; }
638 else { stripMax = 48*5 + 96*4; }
639 m_hHitMapBarrel_Seg[i] =
new TH1F(name,title, stripMax, 0, stripMax);
643 sprintf( name,
"HitMapEastEndcap_S%d", i );
644 sprintf( title,
"Hit map in east-endcap segment %d", i );
646 m_hHitMapEndcap_Seg[0][i] =
new TH1F(name,title, stripMax, 0, stripMax);
648 sprintf( name,
"HitMapWestEndcap_S%d", i );
649 sprintf( title,
"Hit map in west-endcap segment %d", i );
650 m_hHitMapEndcap_Seg[1][i] =
new TH1F(name,title, stripMax, 0, stripMax);
656 m_hHitVsEvent =
new TH1F(
"HitVsEvent",
"Hit VS event",10000,0,10000);
657 m_hHitVsEvent->GetXaxis()->SetTitle(
"Event NO.");
658 m_hHitVsEvent->GetXaxis()->CenterTitle();
659 m_hHitVsEvent->GetYaxis()->SetTitle(
"Hits");
660 m_hHitVsEvent->GetYaxis()->CenterTitle();
662 m_hTrackDistance =
new TH1F(
"TrackDistance",
"Track distance", 1000,-500,500);
663 m_hTrackDistance->GetXaxis()->SetTitle(
"Distance of fit pos and hit pos on 1st layer [cm]");
664 m_hTrackDistance->GetXaxis()->CenterTitle();
666 m_hTrackPosPhiDiff =
new TH1F(
"TrackPosPhiDiff",
"#Delta#phi of tracks pos", 720,-2*
PI,2*
PI);
667 m_hTrackPosPhiDiff->GetXaxis()->SetTitle(
"#Delta#phi [rad]");
668 m_hTrackPosPhiDiff->GetXaxis()->CenterTitle();
670 m_hTrackPosThetaDiff =
new TH1F(
"TrackPosThetaDiff",
"#Delta#theta of tracks pos", 720,-2*
PI,2*
PI);
671 m_hTrackPosThetaDiff->GetXaxis()->SetTitle(
"#Delta#theta [rad]");
672 m_hTrackPosThetaDiff->GetXaxis()->CenterTitle();
674 m_hTrackMomPhiDiff =
new TH1F(
"TrackMomPhiDiff",
"#Delta#phi of tracks mom", 720,-2*
PI,2*
PI);
675 m_hTrackMomPhiDiff->GetXaxis()->SetTitle(
"#Delta#phi [rad]");
676 m_hTrackMomPhiDiff->GetXaxis()->CenterTitle();
678 m_hTrackMomThetaDiff =
new TH1F(
"TrackMomThetaDiff",
"#Delta#theta of tracks mom", 720,-2*
PI,2*
PI);
679 m_hTrackMomThetaDiff->GetXaxis()->SetTitle(
"#Delta#theta [rad]");
680 m_hTrackMomThetaDiff->GetXaxis()->CenterTitle();
683 m_hDimuTracksPosDiff =
new TH2F(
"DimuTracksPosDiff",
"#Delta#phi VS #Delta#theta of dimu tracks pos", 720, -
PI,
PI, 720, -
PI,
PI);
684 m_hDimuTracksPosDiff->GetXaxis()->SetTitle(
"#Delta#theta");
685 m_hDimuTracksPosDiff->GetXaxis()->CenterTitle();
686 m_hDimuTracksPosDiff->GetYaxis()->SetTitle(
"#Delta#phi");
687 m_hDimuTracksPosDiff->GetYaxis()->CenterTitle();
689 m_hDimuTracksMomDiff =
new TH2F(
"DimuTracksMomDiff",
"#Delta#phi VS #Delta#theta of dimu tracks mom", 720, -
PI,
PI, 720, -
PI,
PI);
690 m_hDimuTracksMomDiff->GetXaxis()->SetTitle(
"#Delta#theta");
691 m_hDimuTracksMomDiff->GetXaxis()->CenterTitle();
692 m_hDimuTracksMomDiff->GetYaxis()->SetTitle(
"#Delta#phi");
693 m_hDimuTracksMomDiff->GetYaxis()->CenterTitle();
695 m_hPhiCosTheta =
new TH2F(
"PhiVsCosTheta",
"#phi VS cos(#theta)", 720, -1, 1, 720, -
PI,
PI);
696 m_hPhiCosTheta->GetXaxis()->SetTitle(
"cos(#theta)");
697 m_hPhiCosTheta->GetXaxis()->CenterTitle();
698 m_hPhiCosTheta->GetYaxis()->SetTitle(
"#phi");
699 m_hPhiCosTheta->GetYaxis()->CenterTitle();
701 return StatusCode::SUCCESS;
744 int part, segment, layer, stripMax;
745 part = segment = layer = stripMax = 0;
747 for(
int i=0; i<BOX_MAX; i++ )
749 m_ptrIdTr->
SetBoxPos( i, &part, &segment, &layer );
750 stripMax = m_ptrIdTr->
GetStripMax( part, segment, layer );
752 sprintf( name,
"StripFireMap_P%d_S%d_L%d_Box%d", part, segment, layer, i );
753 sprintf( title,
"Fires per strip in P%d_S%d_L%d Box%d",part, segment, layer, i );
754 m_hStripFireMap[i] =
new TH1F(name,title, stripMax, 0, stripMax);
756 sprintf( name,
"StripExpHitMap_P%d_S%d_L%d_Box%d", part, segment, layer, i );
757 sprintf( title,
"Exp hits per strip in P%d_S%d_L%d Box%d",part, segment, layer, i );
758 m_hStripExpHitMap[i] =
new TH1F(name,title, stripMax, 0, stripMax);
760 sprintf( name,
"StripEffHitMap_P%d_S%d_L%d_Box%d", part, segment, layer, i );
761 sprintf( title,
"Eff hits per strip in P%d_S%d_L%d Box%d",part, segment, layer, i );
762 m_hStripEffHitMap[i] =
new TH1F(name,title, stripMax, 0, stripMax);
764 sprintf( name,
"StripNosHitMap_P%d_S%d_L%d_Box%d", part, segment, layer, i );
765 sprintf( title,
"Inc hits per strip in P%d_S%d_L%d Box%d",part, segment, layer, i );
766 m_hStripNosHitMap[i] =
new TH1F(name,title, stripMax, 0, stripMax);
768 sprintf( name,
"StripEffMap_P%d_S%d_L%d_Box%d", part, segment, layer, i );
769 sprintf( title,
"Strip efficiency in P%d_S%d_L%d Box%d",part, segment, layer, i );
770 m_hStripEffMap[i] =
new TH1F(name,title, stripMax, 0, stripMax);
772 sprintf( name,
"StripNosRatioMap_P%d_S%d_L%d_Box%d", part, segment, layer, i );
773 sprintf( title,
"Strip noise hit ratio in P%d_S%d_L%d Box%d",part, segment, layer, i );
774 m_hStripNosRatioMap[i] =
new TH1F(name,title, stripMax, 0, stripMax);
777 m_hStripFire =
new TH1F(
"StripFire",
"Fires per strip",
STRIP_MAX+1, -0.5,
STRIP_MAX+0.5 );
778 m_hStripExpHit =
new TH1F(
"StripExpHit",
"Exp hit per strip",
STRIP_MAX+1, -0.5,
STRIP_MAX+0.5 );
779 m_hStripEffHit =
new TH1F(
"StripEffHit",
"Eff hit per strip",
STRIP_MAX+1, -0.5,
STRIP_MAX+0.5 );
780 m_hStripNosHit =
new TH1F(
"StripNoshit",
"Nos hit per strip",
STRIP_MAX+1, -0.5,
STRIP_MAX+0.5 );
781 m_hStripEff =
new TH1F(
"StripEff",
"Strip efficiency",
STRIP_MAX+1, -0.5,
STRIP_MAX+0.5 );
782 m_hStripNosRatio=
new TH1F(
"StripNosRatio",
"Strip noise hit ratio",
STRIP_MAX+1, -0.5,
STRIP_MAX+0.5 );
783 m_hStripArea =
new TH1F(
"StripArea",
"Strip area",
STRIP_MAX+1, -0.5,
STRIP_MAX+0.5 );
787 return StatusCode::SUCCESS;
1156 MsgStream log(
msgSvc,
"MucCalibMgr");
1157 log << MSG::INFO <<
"Read event" << endreq;
1159 Gaudi::svcLocator()->service(
"EventDataSvc",
eventSvc);
1160 m_evtBegin = clock();
1163 SmartDataPtr<Event::EventHeader> eventHeader(
eventSvc,
"/Event/EventHeader");
1165 log << MSG::FATAL <<
"Could not find event header" << endreq;
1166 return( StatusCode::FAILURE );
1169 m_currentRun = eventHeader->runNumber();
1170 m_currentEvent = eventHeader->eventNumber();
1171 if( m_fStartRun == 0 ) m_fStartRun = m_currentRun;
1172 m_fEndRun = m_currentRun;
1175 log << MSG::INFO <<
"Run [ " << m_currentRun <<
" ]\tEvent [ " << m_currentEvent <<
" ]" << endreq;
1176 if( ((
long)m_fTotalEvent)%2000 == 0 ) cout << m_fTotalEvent <<
"\tdone!" << endl;
1179 if( m_dimuSelect ) {
1181 log << MSG::INFO <<
"Event tag:\t" << m_eventTag << endreq;
1182 if( m_dimuOnly && m_eventTag != 1 )
return( StatusCode::FAILURE );
1186 log << MSG::INFO <<
"Retrieve digis" << endreq;
1188 SmartDataPtr<MucDigiCol> mucDigiCol(
eventSvc,
"/Event/Digi/MucDigiCol");
1190 log << MSG::FATAL <<
"Could not find MUC digi" << endreq;
1191 return( StatusCode::FAILURE);
1194 int part, segment, layer, strip, pad;
1195 part = segment = layer = strip = pad = 0;
1196 double padX, padY, padZ;
1197 padX = padY = padZ = 0.;
1201 MucDigiCol::iterator digiIter = mucDigiCol->begin();
1203 for (
int digiId =0; digiIter != mucDigiCol->end(); digiIter++, digiId++ )
1205 mucId = (*digiIter)->identify();
1211 log << MSG::DEBUG <<
"[" << part <<
"\t" << segment <<
"\t" << layer <<
"\t" << strip <<
"]\t" ;
1212 if( (digiId+1)%8 == 0 ) log << MSG::DEBUG << endreq;
1216 if(
abs(part)>=
PART_MAX ||
abs(segment)>=SEGMENT_MAX ||
abs(layer)>=LAYER_MAX ||
abs(strip)>=STRIP_INBOX_MAX) {
1217 log << MSG::ERROR << endreq <<
"Digi IDs slop over!" << endreq;
1223 m_digiCol.push_back( aMark );
1224 m_segDigiCol[part][segment].push_back( aMark );
1226 log << MSG::DEBUG << endreq;
1227 log << MSG::INFO <<
"Total digits of this event: " << eventDigi << endreq;
1228 if( eventDigi > 200) log << MSG::ERROR <<
"Event: " << m_currentEvent <<
"\tdigits sharply rise:\t" << eventDigi << endreq;
1246 int clusterNum, bigClusterNum, clusterSize;
1247 clusterNum = bigClusterNum = clusterSize = 0;
1248 if( m_clusterMode ) {
1249 log << MSG::INFO <<
"Searching clusters" << endreq;
1250 m_clusterCol = (*m_ptrMucMark).CreateClusterCol(m_clusterMode, m_digiCol );
1253 for(
unsigned int i=0; i<m_clusterCol.size(); i++ )
1255 clusterSize = m_clusterCol[i].size();
1257 if( clusterSize > CLUSTER_ALARM )
1259 log << MSG::WARNING <<
"Big cluster:" << endreq;
1260 part = (*m_clusterCol[i][0]).Part();
1261 segment = (*m_clusterCol[i][0]).
Segment();
1262 layer = (*m_clusterCol[i][0]).Layer();
1264 if( m_clusterSave ) (*m_fdata) <<
"Event:\t" << m_currentEvent <<
"\tbig cluster " << bigClusterNum << endl;
1266 for(
int j=0; j<clusterSize; j++ )
1268 strip = (*m_clusterCol[i][j]).Strip();
1269 log << MSG::WARNING <<
"[" << part <<
"\t" << segment <<
"\t" << layer <<
"\t" << strip <<
"]\t";
1270 if( (j+1)%8 == 0 ) log << MSG::WARNING << endreq;
1271 if( m_clusterSave ) (*m_fdata) << part <<
"\t" << segment <<
"\t" << layer <<
"\t" << strip << endl;
1273 log << MSG::WARNING << endreq;
1276 else if( clusterSize > 1 )
1278 log << MSG::DEBUG <<
"cluster: " << clusterNum << endreq;
1279 clusterNum ++, m_fTotalClstNum ++;
1280 part = (*m_clusterCol[i][0]).Part();
1281 segment = (*m_clusterCol[i][0]).
Segment();
1282 layer = (*m_clusterCol[i][0]).Layer();
1283 for(
int j=0; j<clusterSize; j++ )
1285 strip = (*m_clusterCol[i][j]).Strip();
1286 log << MSG::DEBUG <<
"[" << part <<
"\t" << segment <<
"\t" << layer <<
"\t" << strip <<
"]\t";
1287 if( (j+1)%8 == 0 ) log << MSG::DEBUG << endreq;
1289 log << MSG::DEBUG << endreq;
1293 if( m_clusterMode) log << MSG::INFO <<
"Total clusters in this event: " << clusterNum << endreq;
1294 else log << MSG::INFO <<
"Clusters not built" << endreq;
1298 log << MSG::INFO <<
"Retrieve tracks" << endreq;
1300 SmartDataPtr<RecMdcTrackCol> mdcTrackCol(
eventSvc,
"/Event/Recon/RecMdcTrackCol");
1302 log << MSG::FATAL <<
"Could not find mdc tracks" << endreq;
1303 return( StatusCode::FAILURE);
1306 RecMdcTrackCol::iterator mdctrkIter = mdcTrackCol->begin();
1307 for (; mdctrkIter != mdcTrackCol->end(); mdctrkIter++)
1309 m_charge = (*mdctrkIter)->charge();
1310 m_mdcpx = (*mdctrkIter)->px();
1311 m_mdcpy = (*mdctrkIter)->py();
1312 m_mdcpz = (*mdctrkIter)->pz();
1313 m_mdcpt = (*mdctrkIter)->pxy();
1314 m_mdcpp = (*mdctrkIter)->p();
1315 m_mdcphi = (*mdctrkIter)->phi();
1316 m_mdctheta = (*mdctrkIter)->theta();
1317 m_mdcTrkInfoTuple->write();
1321 SmartDataPtr<RecMucTrackCol> mucTrackCol(
eventSvc,
"/Event/Recon/RecMucTrackCol");
1323 log << MSG::FATAL <<
"Could not find RecMucTrackCol" << endreq;
1324 return( StatusCode::FAILURE);
1328 if (aRecMucTrackCol->size() < 1) {
1329 log << MSG::INFO <<
"No MUC tracks in this event" << endreq;
1330 return StatusCode::SUCCESS;
1332 log << MSG::INFO <<
"Total tracks of this event: " << aRecMucTrackCol->size() << endreq;
1339 SmartDataPtr<RecEsTimeCol> aRecEsTimeCol(
eventSvc,
"/Event/Recon/RecEsTimeCol");
1340 if( ! aRecEsTimeCol ){
1341 log << MSG::ERROR <<
"Could not find RecEsTimeCol" << endreq;
1342 return StatusCode::FAILURE;
1344 RecEsTimeCol::iterator iter_evt = aRecEsTimeCol->begin();
1347 m_ntEsTime = (*iter_evt)->getStat();
1348 if( (*iter_evt)->getStat() != 211 ) {
1349 log << MSG::WARNING <<
"Event time not by TOF, skip!" << endreq;
1350 return StatusCode::SUCCESS;
1357 phiDiff = thetaDiff = 0.;
1358 if( aRecMucTrackCol->size()==2 && (*aRecMucTrackCol)[0]->GetTotalHits() > 4 && (*aRecMucTrackCol)[1]->GetTotalHits() > 4 )
1361 phi1 = (*aRecMucTrackCol)[0]->getMucPos().phi();
phi2 = (*aRecMucTrackCol)[1]->getMucPos().phi();
1366 theta1 = (*aRecMucTrackCol)[0]->getMucPos().theta();
theta2 = (*aRecMucTrackCol)[1]->getMucPos().theta();
1368 m_hTrackPosPhiDiff->Fill( phiDiff );
1369 m_hTrackPosThetaDiff->Fill( thetaDiff );
1370 m_hDimuTracksPosDiff->Fill( thetaDiff, phiDiff );
1371 m_ntPosPhiDiff = phiDiff;
1372 m_ntPosThetaDiff = thetaDiff;
1374 log << MSG::INFO <<
"PosPhiDiff:\t" << phiDiff <<
"\tPosThetaDiff:\t" << thetaDiff << endreq;
1377 phi1 = (*aRecMucTrackCol)[0]->getMucMomentum().phi();
phi2 = (*aRecMucTrackCol)[1]->getMucMomentum().phi();
1382 theta1 = (*aRecMucTrackCol)[0]->getMucMomentum().theta();
theta2 = (*aRecMucTrackCol)[1]->getMucMomentum().theta();
1385 m_hTrackMomPhiDiff->Fill( phiDiff );
1386 m_hTrackMomThetaDiff->Fill( thetaDiff );
1387 m_hDimuTracksMomDiff->Fill( thetaDiff, phiDiff );
1388 m_ntMomPhiDiff = phiDiff;
1389 m_ntMomThetaDiff = thetaDiff;
1391 log << MSG::INFO <<
"MomPhiDiff:\t" << phiDiff <<
"\tMomThetaDiff:\t" << thetaDiff << endreq;
1392 m_ntDimuTag = m_eventTag;
1393 m_trackDiffTuple->write();
1397 RecMucTrackCol::iterator trackIter = mucTrackCol->begin();
1398 int trackHitNum, rawHitNum, expectedHitNum, segNum, trkRecMode, lastLayerBR, lastLayerEC;
1399 int layerPassNum[3], passMax[TRACK_SEG_MAX][2];
1400 bool firedLay[TRACK_SEG_MAX][LAYER_MAX];
1401 bool seedList[
PART_MAX][LAYER_MAX];
1402 trackHitNum = rawHitNum = expectedHitNum = segNum = trkRecMode = lastLayerBR = lastLayerEC = 0;
1403 layerPassNum[0] = layerPassNum[1] = layerPassNum[2] = 0;
1404 for(
int segi=0; segi<TRACK_SEG_MAX; segi++ ) {
1405 passMax[segi][0] = passMax[segi][1] = 0;
1406 for(
int layi=0; layi<LAYER_MAX; layi++ ) firedLay[segi][layi] = 0;
1410 vector<MucRecHit*> mucRawHitCol;
1411 vector<MucRecHit*> mucExpHitCol;
1413 for (
int trackId = 0; trackIter != mucTrackCol->end(); trackIter++, trackId++)
1415 trackHitNum = (*trackIter)->GetTotalHits();
1416 log << MSG::DEBUG <<
"Track: " << trackId <<
" Hits: " << trackHitNum << endreq;
1418 if( trackHitNum == 0 ) {
1419 log << MSG::INFO <<
"Track " << trackId <<
" no hits" << endreq;
1423 m_ntTrackHits = trackHitNum;
1425 m_trkRecMode = trkRecMode = (*trackIter)->GetRecMode();
1426 m_chi2 = (*trackIter)->chi2();
1427 m_px = (*trackIter)->getMucMomentum().x();
1428 m_py = (*trackIter)->getMucMomentum().y();
1429 m_pz = (*trackIter)->getMucMomentum().z();
1430 m_pt = sqrt(m_px*m_px + m_py*m_py);
1431 m_pp = sqrt(m_px*m_px + m_py*m_py + m_pz*m_pz);
1434 m_r = (*trackIter)->getMucPos().mag();
1435 m_cosTheta = (*trackIter)->getMucPos().cosTheta();
1436 m_theta = (*trackIter)->getMucPos().theta();
1437 m_phi = (*trackIter)->getMucPos().phi();
1438 m_depth = (*trackIter)->depth();
1439 m_brLastLayer = lastLayerBR = (*trackIter)->brLastLayer();
1440 m_ecLastLayer = lastLayerEC = (*trackIter)->ecLastLayer();
1441 m_totalHits = (*trackIter)->numHits();
1442 m_totalLayers = (*trackIter)->numLayers();
1443 m_maxHitsInLayer = (*trackIter)->maxHitsInLayer();
1446 m_hPhiCosTheta->Fill(m_cosTheta, m_phi);
1447 log << MSG::INFO <<
"Fill track info" << endreq;
1451 if( m_calHitCol.size() != 0 ) m_calHitCol.clear();
1454 log << MSG::DEBUG <<
"Reconstruction hits(digis in a track): " << endreq;
1455 mucRawHitCol = (*trackIter)->GetHits();
1456 rawHitNum += mucRawHitCol.size();
1459 if( trkRecMode == 3 ) {
1460 for(
int iPart=0; iPart<
PART_MAX; iPart++)
1461 for(
int iLayer=0; iLayer<LAYER_MAX; iLayer++) seedList[iPart][iLayer] =
false;
1464 for(
unsigned int hitId = 0; hitId < mucRawHitCol.size(); hitId++)
1466 pMucRawHit = mucRawHitCol[ hitId ];
1467 part = pMucRawHit->
Part();
1468 segment = pMucRawHit->
Seg();
1469 layer = pMucRawHit->
Gap();
1470 strip = pMucRawHit->
Strip();
1472 log << MSG::DEBUG <<
"[" << part <<
"\t" << segment <<
"\t" << layer <<
"\t" << strip <<
"]\t";
1477 m_calHitCol.push_back( aMark );
1480 if( trkRecMode == 3 ) seedList[part][layer] = pMucRawHit->
HitIsSeed();
1483 if(hitId == 0) { trkSeg[segNum].push_back( aMark ); segNum ++; }
1486 log << MSG::DEBUG <<
"segNum: " << segNum << endreq;
1487 bool notInSeg =
true;
1488 for(
int segi=0; segi<segNum; segi++ )
1492 trkSeg[segi].push_back( aMark );
1498 if( notInSeg ==
true )
1500 trkSeg[segNum].push_back( aMark );
1502 if( segNum > TRACK_SEG_MAX ) {
1503 log << MSG::ERROR <<
"Track segment overflow: " << segNum << endreq;
1509 log << MSG::DEBUG << endreq;
1512 layerPassNum[0] = layerPassNum[1] = layerPassNum[2] = 0;
1513 for(
int segi=0; segi<segNum; segi++ )
1516 passMax[segi][0] = passMax[segi][1] = trkSeg[segi][0]->Layer();
1517 for(
unsigned int hiti=1; hiti<trkSeg[segi].size(); hiti++ )
1519 if( trkSeg[segi][hiti]->Layer() < passMax[segi][0] )
1520 passMax[segi][0] = trkSeg[segi][hiti]->Layer();
1521 if( trkSeg[segi][hiti]->Layer() > passMax[segi][1] )
1522 passMax[segi][1] = trkSeg[segi][hiti]->Layer();
1523 firedLay[segi][trkSeg[segi][hiti]->Layer()] = 1;
1526 for(
int layi=0; layi<LAYER_MAX; layi++ ) {
1527 if( firedLay[segi][layi] ) tmpLayNum ++;
1530 if( segi == 0 ) layerPassNum[0] += passMax[segi][1] + 1;
1531 else layerPassNum[0] += (passMax[segi][1] - passMax[segi][0] + 1);
1533 layerPassNum[1] += (passMax[segi][1] - passMax[segi][0] + 1);
1534 layerPassNum[2] += tmpLayNum;
1536 trkSeg[segi].clear();
1538 m_ntTrackEvent = m_currentEvent;
1539 m_ntTrackTag = m_eventTag;
1540 m_ntTrackSegFly = segNum;
1541 m_ntTrackLayFlyA = layerPassNum[0];
1542 m_ntTrackLayFlyB = layerPassNum[1];
1543 m_ntTrackLayFlyC = layerPassNum[2];
1544 m_trackInfoTuple->write();
1545 log << MSG::INFO <<
"Track\t" << trackId <<
"\tsegment(s):\t" << segNum
1546 <<
"\tlayer passed:\t" << layerPassNum[0] <<
"\t" << layerPassNum[1] <<
"\t" << layerPassNum[2] << endreq;
1551 log << MSG::DEBUG <<
"Fitting hits(expected hits in a track): " << endreq;
1552 mucExpHitCol = (*trackIter)->GetExpectedHits();
1553 expectedHitNum += mucExpHitCol.size();
1554 for(
unsigned int hitId = 0; hitId < mucExpHitCol.size(); hitId++)
1556 pMucRawHit = mucExpHitCol[ hitId ];
1557 part = pMucRawHit->
Part(); segment = pMucRawHit->
Seg();
1558 layer = pMucRawHit->
Gap(); strip = pMucRawHit->
Strip();
1567 if(segment == 1) { padX = -padX; }
1568 else if(segment == 2) { padX = -padX, padY = -padY; }
1569 else if(segment == 3) { padY = -padY; }
1576 MucMark* currentMark =
new MucMark( part, segment, layer, strip );
1577 m_expHitCol.push_back( currentMark );
1583 bool isInEffWindow =
false;
1584 isInPos = currentMark->
IsInCol( m_segDigiCol[part][segment] );
1587 if( part ==
BRID && (layer-lastLayerBR>1) )
continue;
1588 if( part !=
BRID && (layer-lastLayerEC>1) )
continue;
1591 if( part==
BRID && layer==0 && (strip<2 || strip>45) )
1595 m_record[part][segment][layer][strip][2] ++;
1596 m_record[part][segment][layer][strip][1] ++;
1597 m_effHitCol.push_back( m_segDigiCol[part][segment][isInPos] );
1599 if( m_usePad != 0 ) {
1600 m_h2DExpMap[part][segment][layer]->Fill(padX, padY);
1601 m_h2DHitMap[part][segment][layer]->Fill(padX, padY);
1606 m_record[part][segment][layer][strip][1] ++;
1607 if( m_usePad != 0 ) m_h2DExpMap[part][segment][layer]->Fill(padX, padY);
1615 m_record[part][segment][layer][strip][2] ++;
1616 m_record[part][segment][layer][strip][1] ++;
1617 m_effHitCol.push_back( m_segDigiCol[part][segment][isInPos] );
1619 if( m_usePad != 0 ) {
1620 m_h2DExpMap[part][segment][layer]->Fill(padX, padY);
1621 m_h2DHitMap[part][segment][layer]->Fill(padX, padY);
1626 else for(
int tempStrip=0, hiti=-m_effWindow; hiti<=m_effWindow; hiti++ )
1628 if( hiti == 0 )
continue;
1629 tempStrip = strip + hiti;
1630 if( tempStrip < 0 || tempStrip > m_ptrIdTr->
GetStripMax(part,segment,layer) )
continue;
1632 isInPos = m_ptrMucMark->
IsInCol( part, segment, layer, tempStrip, m_segDigiCol[part][segment] );
1635 m_record[part][segment][layer][tempStrip][2] ++;
1636 m_record[part][segment][layer][tempStrip][1] ++;
1637 m_effHitCol.push_back( m_segDigiCol[part][segment][isInPos] );
1639 if( m_usePad != 0 ) {
1640 m_h2DExpMap[part][segment][layer]->Fill(padX, padY);
1641 m_h2DHitMap[part][segment][layer]->Fill(padX, padY);
1644 m_ntEffWindow = hiti;
1645 m_effWindowTuple->write();
1646 isInEffWindow =
true;
1651 if( isInEffWindow ) {
continue; }
1653 m_record[part][segment][layer][strip][1] ++;
1654 if( m_usePad != 0 ) m_h2DExpMap[part][segment][layer]->Fill(padX, padY);
1660 log << MSG::INFO <<
"Fill residual" << endreq;
1661 vector<float> m_lineResCol = (*trackIter)->getDistHits();
1662 vector<float> m_quadResCol = (*trackIter)->getQuadDistHits();
1663 vector<float> m_extrResCol = (*trackIter)->getExtDistHits();
1664 int mode = (*trackIter)->GetRecMode();
1666 for(
unsigned int nres = 0; nres < m_lineResCol.size(); nres++ )
1667 if( fabs(m_lineResCol[nres])>resMax ) resMax = fabs(m_lineResCol[nres]);
1669 log << MSG::INFO <<
"Good track for res" << endreq;
1670 if( trackHitNum > 4 && m_lineResCol[0] != -99)
1673 bool firedFlag[
PART_MAX][LAYER_MAX][2];
1674 for(
int iprt=0; iprt<
PART_MAX; iprt++)
1675 for(
int jlay=0; jlay<LAYER_MAX; jlay++)
1676 firedFlag[iprt][jlay][0] = firedFlag[iprt][jlay][1] =
false;
1678 for(
unsigned int hitId = 0; hitId < mucExpHitCol.size(); hitId++)
1680 pMucExpHit = mucExpHitCol[ hitId ];
1681 part = pMucExpHit->
Part(); segment = pMucExpHit->
Seg(); layer = pMucExpHit->
Gap();
1682 firedFlag[part][layer][0] =
true;
1685 log << MSG::INFO <<
"Fit res" << endreq;
1686 for(
unsigned int hitId = 0; hitId < mucRawHitCol.size(); hitId++)
1688 pMucRawHit = mucRawHitCol[ hitId ];
1689 part = pMucRawHit->
Part(); segment = pMucRawHit->
Seg(); layer = pMucRawHit->
Gap();
1691 if( part ==
BRID ) m_hBarrelResDist[layer]->Fill( m_lineResCol[hitId] );
1692 else m_hEndcapResDist[layer]->Fill( m_lineResCol[hitId] );
1695 if( firedFlag[part][layer][0] ==
true && firedFlag[part][layer][1] ==
false )
1698 m_resSegment = segment;
1700 m_lineRes = m_lineResCol[hitId];
1701 m_quadRes = m_quadResCol[hitId];
1702 m_extrRes = m_extrResCol[hitId];
1705 m_resInfoTuple->write();
1708 firedFlag[part][layer][1] =
true;
1711 log << MSG::INFO <<
"Exp res" << endreq;
1712 for(
unsigned int hitId = 0; hitId < mucExpHitCol.size(); hitId++)
1714 pMucExpHit = mucExpHitCol[ hitId ];
1715 part = pMucExpHit->
Part(); segment = pMucExpHit->
Seg(); layer = pMucExpHit->
Gap();
1717 if(firedFlag[part][layer][0] ==
true && firedFlag[part][layer][1] ==
false)
1720 m_resSegment = segment;
1727 m_resInfoTuple->write();
1733 mucRawHitCol.clear();
1734 mucExpHitCol.clear();
1738 if( resMax > 300 ) cout <<
"Res too big!\t"<< m_fTotalEvent <<
"\t"<< m_currentRun <<
"\t"<< m_currentEvent <<
"\t"<< resMax << endl;
1740 m_ntTrackNum = mucTrackCol->size();
1742 m_fTotalEffHit += rawHitNum;
1743 log << MSG::INFO <<
"Total hits in this event, raw: " << rawHitNum <<
"\texpected: " << expectedHitNum << endreq;
1747 log << MSG::INFO <<
"Searching inc/noise hits" << endreq;
1750 for(
unsigned int i=0; i < m_digiCol.size(); i++ )
1754 if( m_digiCol[i]->IsInCol( m_effHitCol ) !=-1)
continue;
1757 for(
unsigned int j=0; j < m_clusterCol.size(); j++ )
1760 for(
unsigned int k=0; k<m_clusterCol[j].size(); k++)
1762 if( m_clusterCol[j][k]->IsInCol(m_effHitCol) != -1)
1769 if ( hasEffHit && (m_digiCol[i]->IsInCol( m_clusterCol[j] ) != -1) ) {
1776 m_nosHitCol.push_back( m_digiCol[i] );
1782 return StatusCode::SUCCESS;
1843 MsgStream log(
msgSvc,
"MucCalibMgr");
1844 log << MSG::INFO <<
"Fill event" << endreq;
1846 int part, segment, layer, strip, size;
1847 part = segment = layer = strip = size = 0;
1850 log << MSG::INFO <<
"Fill digis" << endreq;
1851 for(
unsigned int i=0; i<m_digiCol.size(); i++ )
1853 part = (*m_digiCol[i]).Part();
1854 segment = (*m_digiCol[i]).
Segment();
1855 layer = (*m_digiCol[i]).Layer();
1856 strip = (*m_digiCol[i]).Strip();
1858 FillDigi( part, segment, layer, strip );
1859 m_record[part][segment][layer][strip][0] ++;
1864 log << MSG::INFO <<
"Fill rec hits" << endreq;
1865 for(
unsigned int i=0; i<m_expHitCol.size(); i++ )
1867 part = (*m_expHitCol[i]).Part();
1868 segment = (*m_expHitCol[i]).
Segment();
1869 layer = (*m_expHitCol[i]).Layer();
1870 strip = (*m_expHitCol[i]).Strip();
1873 m_record[part][segment][layer][strip][4] ++;
1878 log << MSG::INFO <<
"Fill eff hits" << endreq;
1879 for(
unsigned int i=0; i<m_effHitCol.size(); i++ )
1881 part = (*m_effHitCol[i]).Part();
1882 segment = (*m_effHitCol[i]).
Segment();
1883 layer = (*m_effHitCol[i]).Layer();
1884 strip = (*m_effHitCol[i]).Strip();
1891 log << MSG::INFO <<
"Fill clusters" << endreq;
1892 for(
unsigned int i=0; i<m_clusterCol.size(); i++ )
1894 size = m_clusterCol[i].size();
1896 if( size > CLUSTER_CUT )
1898 part = (*m_clusterCol[i][0]).Part();
1899 segment = (*m_clusterCol[i][0]).
Segment();
1900 layer = (*m_clusterCol[i][0]).Layer();
1903 m_ntClusterSize = size;
1904 m_clusterSizeTuple->write();
1909 log << MSG::INFO <<
"Fill inc/noise hits" << endreq;
1910 for(
unsigned int i=0; i<m_nosHitCol.size(); i++ )
1912 part = (*m_nosHitCol[i]).Part();
1913 segment = (*m_nosHitCol[i]).
Segment();
1914 layer = (*m_nosHitCol[i]).Layer();
1915 strip = (*m_nosHitCol[i]).Strip();
1918 m_record[part][segment][layer][strip][3] ++;
1922 m_ntEventId = m_currentEvent;
1923 m_ntEventTag = m_eventTag;
1924 m_ntDigiNum = m_digiCol.size();
1925 m_ntExpHitNum = m_expHitCol.size();
1926 m_ntEffHitNum = m_effHitCol.size();
1927 m_ntNosHitNum = m_nosHitCol.size();
1928 m_ntClusterNum = m_clusterCol.size();
1931 for(
unsigned int i=0; i<m_digiCol.size(); i++ ) {
1932 if( m_digiCol[i] != NULL )
delete m_digiCol[i];
1935 for(
unsigned int i=0; i<m_expHitCol.size(); i++ ) {
1936 if( m_expHitCol[i] != NULL )
delete m_expHitCol[i];
1944 for(
unsigned int i=0; i<m_calHitCol.size(); i++ ) {
1945 if( m_calHitCol[i] != NULL )
delete m_calHitCol[i];
1948 if( m_digiCol.size() != 0 ) m_digiCol.clear();
1949 if( m_expHitCol.size() != 0 ) m_expHitCol.clear();
1950 if( m_calHitCol.size() != 0 ) m_calHitCol.clear();
1951 if( m_effHitCol.size() != 0 ) m_effHitCol.clear();
1952 if( m_nosHitCol.size() != 0 ) m_nosHitCol.clear();
1953 if( m_clusterCol.size() != 0 ) m_clusterCol.clear();
1957 for(
int j=0; j<SEGMENT_MAX; j++ ) {
1958 if( m_segDigiCol[i][j].size() != 0 ) m_segDigiCol[i][j].clear();
1964 m_ntEventTime = (double(m_evtEnd - m_evtBegin))/CLOCKS_PER_SEC;
1965 log << MSG::INFO <<
"Event time:\t" << m_ntEventTime <<
"s" << endreq;
1966 m_eventLogTuple->write();
1968 return StatusCode::SUCCESS;
2219 MsgStream log(
msgSvc,
"MucCalibMgr");
2220 log<< MSG::INFO <<
"Analyse box efficiency and noise" << endreq;
2222 int part, segment, layer, stripMax;
2223 part = segment = layer = stripMax = 0;
2225 double digi, effHit, trackNum, nosHit, recHit;
2226 double eff, effErr, noise, nosRatio, nosRatioErr, cnt, cluster;
2227 eff = effErr = noise = nosRatio = nosRatioErr = cnt = cluster = 0.;
2229 for(
int i=0; i<BOX_MAX; i++ )
2231 m_ptrIdTr->
SetBoxPos( i, &part, &segment, &layer );
2232 stripMax = m_ptrIdTr->
GetStripMax( part, segment, layer );
2234 digi = effHit = trackNum = nosHit = recHit = 0;
2235 for(
int j=0; j<stripMax; j++ )
2237 digi += m_record[part][segment][layer][j][0];
2238 trackNum += m_record[part][segment][layer][j][1];
2239 effHit += m_record[part][segment][layer][j][2];
2240 nosHit += m_record[part][segment][layer][j][3];
2241 recHit += m_record[part][segment][layer][j][4];
2245 if( trackNum == 0 ) {
2252 eff = ( (double)effHit )/trackNum;
2253 effErr = sqrt( eff*(1-eff)/trackNum );
2258 if( m_boxResults[3][i] < LIMIT_CUT || m_fTotalDAQTime < LIMIT_CUT )
2259 noise = DEFAULT_NOS_VALUE;
2261 if( m_recMode == 2 )
2262 noise = (double)nosHit/(m_fTotalEvent*TRIGGER_WINDOW * m_boxResults[3][i]);
2264 noise = (double)nosHit/(m_fTotalDAQTime * m_boxResults[3][i]);
2268 nosRatio = ( (double)nosHit )/digi;
2269 nosRatioErr = sqrt( nosRatio*(1-nosRatio)/digi );
2272 nosRatio = DEFAULT_INC_VALUE;
2277 if( m_recMode == 2 )
2278 cnt = (double)digi/(m_fTotalEvent*TRIGGER_WINDOW * m_boxResults[3][i]);
2280 cnt = (double)digi/(m_fTotalDAQTime * m_boxResults[3][i]);
2283 cluster = m_hBoxCluster[i]->GetMean();
2285 m_boxResults[0][ i ] = eff;
2286 m_boxResults[1][ i ] = effErr;
2287 m_boxResults[2][ i ] = noise;
2288 m_boxResults[4][ i ] = cluster;
2289 m_boxResults[5][ i ] = trackNum;
2292 m_hBoxEff->Fill( i, eff );
2293 m_hBoxEff->SetBinError( i+1, effErr );
2294 m_hBoxNosRatio->Fill( i, nosRatio );
2295 m_hBoxNosRatio->SetBinError( i+1, nosRatioErr );
2296 m_hBoxNos->Fill( i, noise );
2297 m_hBoxCnt->Fill( i, cnt );
2300 m_hBoxClusterCmp->Fill( i, cluster );
2305 m_fBoxSegment = segment;
2306 m_fBoxLayer = layer;
2308 m_fBoxEffErr = effErr;
2309 m_fBoxTrkNum = trackNum;
2310 m_fBoxExpHit = recHit;
2311 m_fBoxEffHit = effHit;
2312 m_fBoxNosRatio = nosRatio;
2314 m_fBoxNosHit = nosHit;
2317 m_tBoxConst->Fill();
2320 m_fBoxCluster = cluster;
2324 return StatusCode::SUCCESS;
2329 MsgStream log(
msgSvc,
"MucCalibMgr");
2330 log<< MSG::INFO <<
"Analyse strip efficiency and noise" << endreq;
2332 int part, segment, layer, stripMax;
2333 part = segment = layer = stripMax = 0;
2335 double digi, effHit, trackNum, nosHit, recHit;
2336 double eff, effErr, noise, nosRatio, nosRatioErr, cnt, cluster;
2337 eff = effErr = noise = nosRatio = nosRatioErr = cnt = cluster = 0.;
2339 for(
int i=0; i<BOX_MAX; i++ )
2341 m_ptrIdTr->
SetBoxPos( i, &part, &segment, &layer );
2342 stripMax = m_ptrIdTr->
GetStripMax( part, segment, layer );
2344 for(
int j=0; j<stripMax; j++ )
2346 digi = m_record[part][segment][layer][j][0];
2347 trackNum = m_record[part][segment][layer][j][1];
2348 effHit = m_record[part][segment][layer][j][2];
2349 nosHit = m_record[part][segment][layer][j][3];
2350 recHit = m_record[part][segment][layer][j][4];
2352 int stripId = m_ptrIdTr->
GetStripId( part, segment, layer, j );
2355 if( trackNum == 0 ) {
2362 eff = ( (double)effHit )/trackNum;
2363 effErr = sqrt( eff*(1-eff)/trackNum );
2364 m_fCalibStripNum ++;
2368 if( m_stripResults[3][stripId] < LIMIT_CUT || m_fTotalDAQTime < LIMIT_CUT )
2369 noise = DEFAULT_NOS_VALUE;
2371 if( m_recMode == 2 )
2372 noise = (double)nosHit/(m_fTotalEvent*TRIGGER_WINDOW * m_stripResults[3][stripId]);
2374 noise = (double)nosHit/(m_fTotalDAQTime * m_stripResults[3][stripId]);
2378 nosRatio = ( (double)nosHit )/digi;
2379 nosRatioErr = sqrt( nosRatio*(1-nosRatio)/digi );
2382 nosRatio = DEFAULT_INC_VALUE;
2387 if( m_recMode == 2 )
2388 cnt = (double)digi/(m_fTotalEvent*TRIGGER_WINDOW * m_stripResults[3][stripId]);
2390 cnt = (double)digi/(m_fTotalDAQTime * m_stripResults[3][stripId]);
2393 m_stripResults[0][ stripId ] = eff;
2394 m_stripResults[1][ stripId ] = effErr;
2395 m_stripResults[2][ stripId ] = noise;
2396 m_stripResults[5][ stripId ] = trackNum;
2399 m_hStripEffMap[i]->Fill( j, eff );
2400 m_hStripEffMap[i]->SetBinError( j+1, effErr );
2401 m_hStripEff->Fill( stripId, eff );
2402 m_hStripEff->SetBinError( stripId+1, effErr );
2403 m_hStripNosRatioMap[i]->Fill( j, nosRatio );
2404 m_hStripNosRatioMap[i]->SetBinError( j+1, nosRatioErr );
2405 m_hStripNosRatio->Fill( stripId, nosRatio );
2406 m_hStripNosRatio->SetBinError( stripId+1, nosRatioErr );
2407 m_hStripNos->Fill( stripId, noise );
2408 m_hStripCnt->Fill( stripId, cnt );
2411 m_fStripId = stripId;
2412 m_fStripPart = part;
2413 m_fStripSegment = segment;
2414 m_fStripLayer = layer;
2416 m_fStripEffErr = effErr;
2417 m_fStripNosRatio = nosRatio;
2418 m_fStripDigi = digi;
2419 m_fStripNos = noise;
2421 m_fStripEffHit = effHit;
2422 m_fStripExpHit = recHit;
2423 m_fStripNosHit = nosHit;
2424 m_fStripTrkNum = trackNum;
2425 m_tStrConst->Fill();
2430 return StatusCode::SUCCESS;
2517 MsgStream log(
msgSvc,
"MucCalibMgr");
2518 log << MSG::INFO <<
"Save calibration constants" << endreq;
2522 double layerXY[2][LAYER_MAX];
2523 double layerEXY[2][LAYER_MAX];
2524 for(
int i=0; i<LAYER_MAX; i++ )
2528 if( m_layerResults[5][i] >= 100*TRACK_THRESHOLD ) {
2529 layerXY[1][i] = m_layerResults[0][i];
2530 layerEXY[1][i] = m_layerResults[1][i];
2537 m_geLayerEff =
new TGraphErrors(LAYER_MAX, layerXY[0], layerXY[1], layerEXY[0], layerEXY[1]);
2538 m_geLayerEff->SetMarkerStyle(25);
2539 m_geLayerEff->SetMarkerSize(0.5);
2540 m_cv[0] =
new TCanvas(
"GoodLayerEff",
"Layer efficiency", 50, 50, 800, 600);
2541 m_cv[0]->SetFillColor(0);
2542 m_cv[0]->SetBorderMode(0);
2543 m_geLayerEff->Draw(
"AP");
2547 double boxXY[2][BOX_MAX];
2548 double boxEXY[2][BOX_MAX];
2549 for(
int i=0; i<BOX_MAX; i++ )
2553 if( m_boxResults[5][i] >= 10*TRACK_THRESHOLD ) {
2554 boxXY[1][i] = m_boxResults[0][i];
2555 boxEXY[1][i] = m_boxResults[1][i];
2562 m_geBoxEff =
new TGraphErrors(BOX_MAX, boxXY[0], boxXY[1], boxEXY[0], boxEXY[1]);
2563 m_geBoxEff->SetMarkerStyle(25);
2564 m_geBoxEff->SetMarkerSize(0.5);
2565 m_cv[1] =
new TCanvas(
"GoodBoxEff",
"Box efficiency", 75, 75, 800, 600);
2566 m_cv[1]->SetFillColor(0);
2567 m_cv[1]->SetBorderMode(0);
2568 m_geBoxEff->Draw(
"AP");
2578 if( m_stripResults[5][i] >= TRACK_THRESHOLD ) {
2579 stripXY[1][i] = m_stripResults[0][i];
2580 stripEXY[1][i] = m_stripResults[1][i];
2587 m_geStripEff =
new TGraphErrors(
STRIP_MAX, stripXY[0], stripXY[1], stripEXY[0], stripEXY[1]);
2588 m_geStripEff->SetMarkerStyle(25);
2589 m_geStripEff->SetMarkerSize(0.5);
2590 m_cv[2] =
new TCanvas(
"GoodStripEff",
"Strip efficiency", 100, 100, 800, 600);
2591 m_cv[2]->SetFillColor(0);
2592 m_cv[2]->SetBorderMode(0);
2593 m_geStripEff->Draw(
"AP");
2599 m_hHitMapBarrel_Lay[i]->Write();
2602 m_hHitMapEndcap_Lay[0][i]->Write();
2603 m_hHitMapEndcap_Lay[1][i]->Write();
2609 m_hHitMapBarrel_Seg[i]->Write();
2612 m_hHitMapEndcap_Seg[0][i]->Write();
2613 m_hHitMapEndcap_Seg[1][i]->Write();
2616 m_hTrackDistance->Fit(
"gaus");
2617 m_hTrackPosPhiDiff->Fit(
"gaus");
2618 m_hTrackPosThetaDiff->Fit(
"gaus");
2619 m_hTrackMomPhiDiff->Fit(
"gaus");
2620 m_hTrackMomThetaDiff->Fit(
"gaus");
2622 m_hTrackDistance->Write();
2623 m_hTrackPosPhiDiff->Write();
2624 m_hTrackPosThetaDiff->Write();
2625 m_hTrackMomPhiDiff->Write();
2626 m_hTrackMomThetaDiff->Write();
2628 for(
int i=0; i<
B_LAY_NUM; i++ ) m_hBarrelResDist[i]->Write();
2629 for(
int i=0; i<
E_LAY_NUM; i++ ) m_hEndcapResDist[i]->Write();
2631 m_hBarrelResComp[0]->Write();
2632 m_hBarrelResComp[1]->Write();
2633 m_hEndcapResComp[0]->Write();
2634 m_hEndcapResComp[1]->Write();
2636 if( m_usePad != 0 ) m_histArray->Write();
2638 for(
int i=0; i<BOX_MAX; i++ )
2640 m_hStripFireMap[ i ]->Write();
2641 m_hStripExpHitMap[ i ]->Write();
2642 m_hStripEffHitMap[ i ]->Write();
2643 m_hStripNosHitMap[ i ]->Write();
2644 m_hStripEffMap[ i ]->Write();
2645 m_hStripNosRatioMap[ i ]->Write();
2647 m_hStripFire->Write();
2648 m_hStripExpHit->Write();
2649 m_hStripEffHit->Write();
2650 m_hStripNosHit->Write();
2651 m_hStripEff->Write();
2652 m_hStripArea->Write();
2653 m_hStripNos->Write();
2654 m_hStripNosRatio->Write();
2655 log << MSG::INFO <<
"Save LV2 histograms done!" << endreq;
2657 m_hBoxFire->Write();
2658 m_hBoxExpHit->Write();
2659 m_hBoxEffHit->Write();
2660 m_hBoxNosHit->Write();
2662 m_hBoxArea->Write();
2664 m_hBoxNosRatio->Write();
2665 log << MSG::INFO <<
"Save LV1 histograms done!" << endreq;
2667 m_hBrLayerFire->Write();
2668 m_hEcLayerFire->Write();
2669 m_hLayerFire->Write();
2670 m_hLayerExpHit->Write();
2671 m_hLayerEffHit->Write();
2672 m_hLayerNosHit->Write();
2673 m_hLayerEff->Write();
2674 m_hLayerArea->Write();
2675 m_hLayerNos->Write();
2676 m_hLayerNosRatio->Write();
2678 for(
int i=0; i<LAYER_MAX; i++ ) m_hLayerCluster[i]->Write();
2679 for(
int i=0; i<BOX_MAX; i++ ) m_hBoxCluster[i]->Write();
2680 m_hLayerClusterCmp->Write();
2681 m_hBoxClusterCmp->Write();
2683 log << MSG::INFO <<
"Save histograms done!" << endreq;
2686 m_fLayerCoverage = 100*(double)m_fCalibLayerNum/LAYER_MAX;
2687 m_fBoxCoverage = 100*(double)m_fCalibBoxNum/BOX_MAX;
2688 m_fStripCoverage = 100*(double)m_fCalibStripNum/
STRIP_MAX;
2690 long digi_num, trk_num, eff_hit, nos_hit, exp_hit;
2691 m_tStatLog->Branch(
"digi_num", &digi_num,
"digi_num/I");
2692 m_tStatLog->Branch(
"trk_num", &trk_num,
"trk_num/I");
2693 m_tStatLog->Branch(
"eff_hit", &eff_hit,
"eff_hit/I");
2694 m_tStatLog->Branch(
"nos_hit", &nos_hit,
"nos_hit/I");
2695 m_tStatLog->Branch(
"exp_hit", &exp_hit,
"exp_hit/I");
2703 for(
int n=0;
n<stripMax;
n++ )
2705 digi_num = m_record[i][j][k][
n][0];
2706 trk_num = m_record[i][j][k][
n][1];
2707 eff_hit = m_record[i][j][k][
n][2];
2708 nos_hit = m_record[i][j][k][
n][3];
2709 exp_hit = m_record[i][j][k][
n][4];
2714 m_jobFinish = clock();
2715 m_fTotalJobTime = (double)(m_jobFinish - m_jobStart)/CLOCKS_PER_SEC;
2719 m_tStatLog->Write();
2720 m_tLayConst->Write();
2721 m_tBoxConst->Write();
2722 m_tStrConst->Write();
2725 if( m_fdata != NULL ) m_fdata->close();
2727 return StatusCode::SUCCESS;