46 MsgStream log(
msgSvc(), name());
48 log << MSG::INFO <<
"in initialize()" << endmsg;
52 if(service(
"THistSvc", m_thsvc).isFailure()) {
53 log << MSG::ERROR <<
"Couldn't get THistSvc" << endreq;
54 return StatusCode::FAILURE;
63 sprintf( name,
"BrResDist_All_L%d", i );
65 m_hBrResDist[i][0] =
new TH1F(name,
title, 200, -100, 100 );
66 sprintf( name,
"/DQAHist/MUC/BrResDist_All_L%d", i );
67 if(m_thsvc->regHist(name, m_hBrResDist[i][0]).isFailure())
68 { log << MSG::ERROR <<
"Couldn't register " << name << endreq; }
70 sprintf( name,
"BrResDist_Dimu_L%d", i );
71 m_hBrResDist[i][1] =
new TH1F(name,
title, 200, -100, 100 );
72 sprintf( name,
"/DQAHist/MUC/BrResDist_Dimu_L%d", i );
73 if(m_thsvc->regHist(name, m_hBrResDist[i][1]).isFailure())
74 { log << MSG::ERROR <<
"Couldn't register " << name << endreq; }
79 sprintf( name,
"EcResDist_All_L%d", i );
81 m_hEcResDist[i][0] =
new TH1F(name,
title, 200, -100, 100 );
82 sprintf( name,
"/DQAHist/MUC/EcResDist_All_L%d", i );
83 if(m_thsvc->regHist(name, m_hEcResDist[i][0]).isFailure())
84 { log << MSG::ERROR <<
"Couldn't register " << name << endreq; }
86 sprintf( name,
"EcResDist_Dimu_L%d", i );
87 m_hEcResDist[i][1] =
new TH1F(name,
title, 200, -100, 100 );
88 sprintf( name,
"/DQAHist/MUC/EcResDist_Dimu_L%d", i );
89 if(m_thsvc->regHist(name, m_hEcResDist[i][1]).isFailure())
90 { log << MSG::ERROR <<
"Couldn't register " << name << endreq; }
121 for(
int i=0; i<
TAGN; i++)
123 for(
int j=0; j<2; j++)
125 for(
int k=0; k<
LVLN; k++)
131 m_hEff[k][i][j] =
new TH1F(name,
title, LAYER_MAX+1, -0.5, LAYER_MAX+0.5);
132 m_hEff[k][i][j]->GetXaxis()->SetTitle(
"Layer id");
134 m_hEff[k][i][j] =
new TH1F(name,
title, BOX_MAX+1, -0.5, BOX_MAX+0.5);
135 m_hEff[k][i][j]->GetXaxis()->SetTitle(
"Box id [EE:0~31, BR:32~103, WE:104~135]");
138 m_hEff[k][i][j]->GetXaxis()->SetTitle(
"Strip id");
141 m_hEff[k][i][j]->GetXaxis()->CenterTitle();
145 if(m_thsvc->regHist(name, m_hEff[k][i][j]).isFailure())
146 { log << MSG::ERROR <<
"Couldn't register " << name << endreq; }
151 m_hNosRatio[i][j] =
new TH1F(name,
title, BOX_MAX+1, -0.5, BOX_MAX+0.5);
152 m_hNosRatio[i][j]->GetXaxis()->SetTitle(
"Box id [EE:0~31, BR:32~103, WE:104~135]");
153 m_hNosRatio[i][j]->GetXaxis()->CenterTitle();
158 if(m_thsvc->regHist(name, m_hNosRatio[i][j]).isFailure())
159 { log << MSG::ERROR <<
"Couldn't register " << name << endreq; }
165 m_hCostheta[i] =
new TH1F(name,
title, 360, -1.0, 1.0);
166 m_hCostheta[i]->GetXaxis()->SetTitle(
"cos#theta");
167 m_hCostheta[i]->GetXaxis()->CenterTitle();
171 m_hPhi[i] =
new TH1F(name,
title, 360, -
PI,
PI);
172 m_hPhi[i]->GetXaxis()->SetTitle(
"#phi");
173 m_hPhi[i]->GetXaxis()->CenterTitle();
176 if(m_thsvc->regHist(name, m_hCostheta[i]).isFailure())
177 { log << MSG::ERROR <<
"Couldn't register " << name << endreq; }
179 if(m_thsvc->regHist(name, m_hPhi[i]).isFailure())
180 { log << MSG::ERROR <<
"Couldn't register Phi_All" << endreq; }
192 for(
int j=0; j<SEGMENT_MAX; j++ )
193 for(
int k=0; k<LAYER_MAX; k++ )
194 for(
int n=0;
n<STRIP_INBOX_MAX;
n++ )
196 m_recordAll[i][j][k][
n][0] = 0;
197 m_recordAll[i][j][k][
n][1] = 0;
198 m_recordAll[i][j][k][
n][2] = 0;
199 m_recordAll[i][j][k][
n][3] = 0;
200 m_recordAll[i][j][k][
n][4] = 0;
202 m_recordDimu[i][j][k][
n][0] = 0;
203 m_recordDimu[i][j][k][
n][1] = 0;
204 m_recordDimu[i][j][k][
n][2] = 0;
205 m_recordDimu[i][j][k][
n][3] = 0;
206 m_recordDimu[i][j][k][
n][4] = 0;
209 m_ptrMucMark =
new MucMark(0,0,0,0);
213 m_expHitCol.resize(0);
214 m_effHitCol.resize(0);
215 m_nosHitCol.resize(0);
216 m_clusterCol.resize(0);
219 for(
int j=0; j<SEGMENT_MAX; j++ ) {
220 m_segDigiCol[i][j].resize(0);
223 log << MSG::INFO <<
"Initialize done!" <<endmsg;
224 return StatusCode::SUCCESS;
230 MsgStream log(
msgSvc(), name());
231 log << MSG::INFO <<
"in execute()" << endreq;
233 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
234 m_run = eventHeader->runNumber();
235 m_event = eventHeader->eventNumber();
236 log << MSG::DEBUG <<
"Run " << m_run <<
"\tEvent " << m_event <<endreq;
238 SmartDataPtr<DQAEvent::DQAEvent> dqaevt(eventSvc(),
"/Event/DQATag");
240 log << MSG::INFO <<
"success get DQAEvent" << endreq;
242 log << MSG::ERROR <<
"Error accessing DQAEvent" << endreq;
243 return StatusCode::FAILURE;
245 log << MSG::DEBUG <<
"DQA event tag = " << dqaevt->EventTag() << endreq;
247 int part, segment, layer, strip;
250 if ( dqaevt->Dimu() ) isDimu =
true;
251 log << MSG::INFO <<
"DQADimuTag:\t" << dqaevt->Dimu() << endreq;
256 log << MSG::INFO <<
"Retrieve digis" << endreq;
257 SmartDataPtr<MucDigiCol> mucDigiCol(eventSvc(),
"/Event/Digi/MucDigiCol");
259 log << MSG::FATAL <<
"Could not find MUC digi" << endreq;
260 return( StatusCode::FAILURE);
264 MucDigiCol::iterator digiIter = mucDigiCol->begin();
266 for (
int digiId =0; digiIter != mucDigiCol->end(); digiIter++, digiId++ )
268 mucId = (*digiIter)->identify();
275 m_digiCol.push_back( aMark );
276 m_segDigiCol[part][segment].push_back( aMark );
277 m_recordAll[part][segment][layer][strip][0] ++;
278 if( isDimu ) m_recordDimu[part][segment][layer][strip][0] ++;
280 log << MSG::INFO <<
"Total digis in this event: " << eventDigi << endreq;
281 if( eventDigi > 500) cout <<
"Run:\t"<< m_run <<
"\tEvent:\t"<< m_event <<
"\tdigits inflation:\t" << eventDigi << endreq;
284 m_clusterCol = (*m_ptrMucMark).CreateClusterCol(1, m_digiCol );
285 log << MSG::INFO <<
"Total clusters in this event: " << m_clusterCol.size() << endreq;
290 SmartDataPtr<RecMucTrackCol> mucTrackCol(eventSvc(),
"/Event/Recon/RecMucTrackCol");
293 log << MSG::WARNING <<
"Could not find RecMucTrackCol" << endreq;
294 return( StatusCode::SUCCESS);
298 if (aRecMucTrackCol->size() < 1) {
299 log << MSG::INFO <<
"No MUC tracks in this event" << endreq;
300 return StatusCode::SUCCESS;
302 log << MSG::INFO <<
"Total tracks of this event: " << aRecMucTrackCol->size() << endreq;
304 int trackHitNum, expectedHitNum, segNum, lastLayerBR, lastLayerEC;
305 int layerPassNum[3], passMax[TRACK_SEG_MAX][2];
306 bool firedLay[TRACK_SEG_MAX][LAYER_MAX];
309 trackHitNum = expectedHitNum = segNum = lastLayerBR = lastLayerEC = 0;
310 layerPassNum[0] = layerPassNum[1] = layerPassNum[2] = 0;
311 for(
int segi=0; segi<TRACK_SEG_MAX; segi++ ) {
312 passMax[segi][0] = passMax[segi][1] = 0;
313 for(
int layi=0; layi<LAYER_MAX; layi++ ) firedLay[segi][layi] = 0;
316 vector<MucRecHit*> mucRawHitCol;
317 vector<MucRecHit*> mucExpHitCol;
318 RecMucTrackCol::iterator trackIter = mucTrackCol->begin();
319 for (
int trackId = 0; trackIter != mucTrackCol->end(); trackIter++, trackId++)
321 trackHitNum = (*trackIter)->numHits();
323 if( trackHitNum == 0 ) {
324 log << MSG::INFO <<
"Track " << trackId <<
" no hits" << endreq;
328 lastLayerBR = (*trackIter)->brLastLayer();
329 lastLayerEC = (*trackIter)->ecLastLayer();
331 CLHEP::Hep3Vector a3Vector((*trackIter)->xPos(),(*trackIter)->yPos(),(*trackIter)->zPos());
333 phi = a3Vector.phi();
334 if(m_thsvc->getHist(
"/DQAHist/MUC/Costheta_All", htmp).isSuccess()) {
337 log << MSG::ERROR <<
"Fail to retrieve Costheta_All" << endreq;
339 if(m_thsvc->getHist(
"/DQAHist/MUC/Phi_All", htmp).isSuccess()) {
342 log << MSG::ERROR <<
"Fail to retrieve Phi_All" << endreq;
347 if(m_thsvc->getHist(
"/DQAHist/MUC/Costheta_Dimu", htmp).isSuccess()) {
350 log << MSG::ERROR <<
"Fail to retrieve Costheta_Dimu" << endreq;
352 if(m_thsvc->getHist(
"/DQAHist/MUC/Phi_Dimu", htmp).isSuccess()) {
355 log << MSG::ERROR <<
"Fail to retrieve Phi_Dimu" << endreq;
358 log << MSG::INFO <<
"Fill costheta and phi:\t" <<
costheta <<
"\t" << phi << endreq;
365 mucExpHitCol = (*trackIter)->GetExpectedHits();
367 expectedHitNum += mucExpHitCol.size();
368 for(
unsigned int hitId = 0; hitId < mucExpHitCol.size(); hitId++)
370 pMucRawHit = mucExpHitCol[ hitId ];
371 part = pMucRawHit->
Part(); segment = pMucRawHit->
Seg();
372 layer = pMucRawHit->
Gap(); strip = pMucRawHit->
Strip();
374 MucMark* currentMark =
new MucMark( part, segment, layer, strip );
375 m_expHitCol.push_back( currentMark );
379 bool isInEffWindow =
false;
380 isInPos = currentMark->
IsInCol( m_segDigiCol[part][segment] );
383 if( part ==
BRID && (layer-lastLayerBR>1) )
continue;
384 if( part !=
BRID && (layer-lastLayerEC>1) )
continue;
387 if( part==
BRID && layer==0 && (strip<2 || strip>45) )
391 m_recordAll[part][segment][layer][strip][2] ++;
392 m_recordAll[part][segment][layer][strip][1] ++;
393 m_effHitCol.push_back( m_segDigiCol[part][segment][isInPos] );
396 m_recordDimu[part][segment][layer][strip][2] ++;
397 m_recordDimu[part][segment][layer][strip][1] ++;
401 m_recordAll[part][segment][layer][strip][1] ++;
402 if(isDimu) m_recordDimu[part][segment][layer][strip][1] ++;
409 m_recordAll[part][segment][layer][strip][2] ++;
410 m_recordAll[part][segment][layer][strip][1] ++;
411 m_effHitCol.push_back( m_segDigiCol[part][segment][isInPos] );
414 m_recordDimu[part][segment][layer][strip][2] ++;
415 m_recordDimu[part][segment][layer][strip][1] ++;
420 else for(
int tempStrip=0, hiti=-m_effWindow; hiti<=m_effWindow; hiti++ )
422 if( hiti == 0 )
continue;
423 tempStrip = strip + hiti;
424 if( tempStrip < 0 || tempStrip > m_ptrIdTr->
GetStripMax(part,segment,layer) )
continue;
426 isInPos = m_ptrMucMark->
IsInCol( part, segment, layer, tempStrip, m_segDigiCol[part][segment] );
429 m_recordAll[part][segment][layer][tempStrip][2] ++;
430 m_recordAll[part][segment][layer][tempStrip][1] ++;
431 m_effHitCol.push_back( m_segDigiCol[part][segment][isInPos] );
434 m_recordDimu[part][segment][layer][tempStrip][2] ++;
435 m_recordDimu[part][segment][layer][tempStrip][1] ++;
438 isInEffWindow =
true;
442 if( isInEffWindow ) {
continue; }
444 m_recordAll[part][segment][layer][strip][1] ++;
445 if(isDimu) m_recordDimu[part][segment][layer][strip][1] ++;
451 log << MSG::INFO <<
"Fill residual" << endreq;
454 vector<float> m_lineResCol = (*trackIter)->getDistHits();
456 mucRawHitCol = (*trackIter)->GetHits();
459 if( trackHitNum > 4 && m_lineResCol[0] != -99)
462 bool firedFlag[
PART_MAX][LAYER_MAX][2];
463 for(
int iprt=0; iprt<
PART_MAX; iprt++)
464 for(
int jlay=0; jlay<LAYER_MAX; jlay++)
465 firedFlag[iprt][jlay][0] = firedFlag[iprt][jlay][1] =
false;
467 for(
unsigned int hitId = 0; hitId < mucExpHitCol.size(); hitId++)
469 pMucExpHit = mucExpHitCol[ hitId ];
470 part = pMucExpHit->
Part(); segment = pMucExpHit->
Seg(); layer = pMucExpHit->
Gap();
471 firedFlag[part][layer][0] =
true;
474 for(
unsigned int hitId = 0; hitId < mucRawHitCol.size(); hitId++)
476 pMucRawHit = mucRawHitCol[ hitId ];
477 part = pMucRawHit->
Part(); segment = pMucRawHit->
Seg(); layer = pMucRawHit->
Gap();
480 if( firedFlag[part][layer][0] ==
true && firedFlag[part][layer][1] ==
false )
484 sprintf( name,
"/DQAHist/MUC/BrResDist_All_L%d", layer );
485 if(m_thsvc->getHist(name, htmp).isSuccess()) {
486 htmp->Fill( m_lineResCol[hitId] );
488 log << MSG::ERROR <<
"Fail to retrieve " << name << endreq;
494 sprintf( name,
"/DQAHist/MUC/BrResDist_Dimu_L%d", layer );
495 if(m_thsvc->getHist(name, htmp).isSuccess()) {
496 htmp->Fill( m_lineResCol[hitId] );
498 log << MSG::ERROR <<
"Fail to retrieve " << name << endreq;
503 sprintf( name,
"/DQAHist/MUC/EcResDist_All_L%d", layer );
504 if(m_thsvc->getHist(name, htmp).isSuccess()) {
505 htmp->Fill( m_lineResCol[hitId] );
507 log << MSG::ERROR <<
"Fail to retrieve " << name << endreq;
513 sprintf( name,
"/DQAHist/MUC/EcResDist_Dimu_L%d", layer );
514 if(m_thsvc->getHist(name, htmp).isSuccess()) {
515 htmp->Fill( m_lineResCol[hitId] );
517 log << MSG::ERROR <<
"Fail to retrieve " << name << endreq;
524 firedFlag[part][layer][1] =
true;
528 mucRawHitCol.clear();
529 mucExpHitCol.clear();
535 log << MSG::INFO <<
"Searching inc/noise hits" << endreq;
538 for(
unsigned int i=0; i < m_digiCol.size(); i++ )
542 if( m_digiCol[i]->IsInCol( m_effHitCol )!=-1 )
continue;
545 for(
unsigned int j=0; j < m_clusterCol.size(); j++ )
548 for(
unsigned int k=0; k<m_clusterCol[j].size(); k++)
550 if( m_clusterCol[j][k]->IsInCol(m_effHitCol) != -1)
557 if ( hasEffHit && (m_digiCol[i]->IsInCol( m_clusterCol[j] ) != -1) ) {
564 part = (*m_digiCol[i]).Part(); segment = (*m_digiCol[i]).
Segment();
565 layer = (*m_digiCol[i]).Layer(); strip = (*m_digiCol[i]).Strip();
568 m_recordAll[part][segment][layer][strip][3] ++;
569 if( isDimu ) m_recordDimu[part][segment][layer][strip][3] ++;
570 m_nosHitCol.push_back(m_digiCol[i]);
576 DQA_MUC::FillHistograms( isDimu );
579 for(
unsigned int i=0; i<m_digiCol.size(); i++ ) {
580 if( m_digiCol[i] !=
NULL )
delete m_digiCol[i];
583 for(
unsigned int i=0; i<m_expHitCol.size(); i++ ) {
584 if( m_expHitCol[i] !=
NULL )
delete m_expHitCol[i];
587 if( m_effHitCol.size() != 0 ) m_effHitCol.clear();
588 if( m_expHitCol.size() != 0 ) m_expHitCol.clear();
589 if( m_nosHitCol.size() != 0 ) m_nosHitCol.clear();
590 if( m_digiCol.size() != 0 ) m_digiCol.clear();
591 if( m_clusterCol.size() != 0 ) m_clusterCol.clear();
594 for(
int j=0; j<SEGMENT_MAX; j++ ) {
595 if( m_segDigiCol[i][j].size() != 0 ) m_segDigiCol[i][j].clear();
599 return StatusCode::SUCCESS;