45 MsgStream log(
msgSvc(), name());
47 log << MSG::INFO <<
"in initialize()" << endmsg;
51 if(service(
"THistSvc", m_thsvc).isFailure()) {
52 log << MSG::ERROR <<
"Couldn't get THistSvc" << endreq;
53 return StatusCode::FAILURE;
62 sprintf( name,
"BrResDist_All_L%d", i );
63 sprintf( title,
"Barrel spacial resolution in L%d",i );
64 m_hBrResDist[i][0] =
new TH1F(name,title, 200, -100, 100 );
65 sprintf( name,
"/DQAHist/MUC/BrResDist_All_L%d", i );
66 if(m_thsvc->regHist(name, m_hBrResDist[i][0]).isFailure())
67 { log << MSG::ERROR <<
"Couldn't register " << name << endreq; }
69 sprintf( name,
"BrResDist_Dimu_L%d", i );
70 m_hBrResDist[i][1] =
new TH1F(name,title, 200, -100, 100 );
71 sprintf( name,
"/DQAHist/MUC/BrResDist_Dimu_L%d", i );
72 if(m_thsvc->regHist(name, m_hBrResDist[i][1]).isFailure())
73 { log << MSG::ERROR <<
"Couldn't register " << name << endreq; }
78 sprintf( name,
"EcResDist_All_L%d", i );
79 sprintf( title,
"Endcap spacial resolution in L%d",i );
80 m_hEcResDist[i][0] =
new TH1F(name,title, 200, -100, 100 );
81 sprintf( name,
"/DQAHist/MUC/EcResDist_All_L%d", i );
82 if(m_thsvc->regHist(name, m_hEcResDist[i][0]).isFailure())
83 { log << MSG::ERROR <<
"Couldn't register " << name << endreq; }
85 sprintf( name,
"EcResDist_Dimu_L%d", i );
86 m_hEcResDist[i][1] =
new TH1F(name,title, 200, -100, 100 );
87 sprintf( name,
"/DQAHist/MUC/EcResDist_Dimu_L%d", i );
88 if(m_thsvc->regHist(name, m_hEcResDist[i][1]).isFailure())
89 { log << MSG::ERROR <<
"Couldn't register " << name << endreq; }
120 for(
int i=0; i<
TAGN; i++)
122 for(
int j=0; j<2; j++)
124 for(
int k=0; k<
LVLN; k++)
127 sprintf( title,
"%s efficiency",
LNAME[k] );
130 m_hEff[k][i][j] =
new TH1F(name,title, LAYER_MAX+1, -0.5, LAYER_MAX+0.5);
131 m_hEff[k][i][j]->GetXaxis()->SetTitle(
"Layer id");
133 m_hEff[k][i][j] =
new TH1F(name,title, BOX_MAX+1, -0.5, BOX_MAX+0.5);
134 m_hEff[k][i][j]->GetXaxis()->SetTitle(
"Box id [EE:0~31, BR:32~103, WE:104~135]");
137 m_hEff[k][i][j]->GetXaxis()->SetTitle(
"Strip id");
140 m_hEff[k][i][j]->GetXaxis()->CenterTitle();
143 sprintf( name,
"/DQAHist/MUC/%sEff_%s_%s",
LNAME[k],
ENAME[i],
HTYPE[j] );
144 if(m_thsvc->regHist(name, m_hEff[k][i][j]).isFailure())
145 { log << MSG::ERROR <<
"Couldn't register " << name << endreq; }
149 sprintf( title,
"%s noise ratio",
LNAME[1] );
150 m_hNosRatio[i][j] =
new TH1F(name, title, BOX_MAX+1, -0.5, BOX_MAX+0.5);
151 m_hNosRatio[i][j]->GetXaxis()->SetTitle(
"Box id [EE:0~31, BR:32~103, WE:104~135]");
152 m_hNosRatio[i][j]->GetXaxis()->CenterTitle();
156 sprintf( name,
"/DQAHist/MUC/%sNosRatio_%s_%s",
LNAME[1],
ENAME[i],
HTYPE[j] );
157 if(m_thsvc->regHist(name, m_hNosRatio[i][j]).isFailure())
158 { log << MSG::ERROR <<
"Couldn't register " << name << endreq; }
162 sprintf( name,
"Costheta_%s",
ENAME[i]);
163 sprintf( title,
"Costheta");
164 m_hCostheta[i] =
new TH1F(name, title, 360, -1.0, 1.0);
165 m_hCostheta[i]->GetXaxis()->SetTitle(
"cos#theta");
166 m_hCostheta[i]->GetXaxis()->CenterTitle();
168 sprintf( name,
"Phi_%s",
ENAME[i]);
169 sprintf( title,
"Phi");
170 m_hPhi[i] =
new TH1F(name, title, 360, -
PI,
PI);
171 m_hPhi[i]->GetXaxis()->SetTitle(
"#phi");
172 m_hPhi[i]->GetXaxis()->CenterTitle();
174 sprintf( name,
"/DQAHist/MUC/Costheta_%s",
ENAME[i] );
175 if(m_thsvc->regHist(name, m_hCostheta[i]).isFailure())
176 { log << MSG::ERROR <<
"Couldn't register " << name << endreq; }
177 sprintf( name,
"/DQAHist/MUC/Phi_%s",
ENAME[i] );
178 if(m_thsvc->regHist(name, m_hPhi[i]).isFailure())
179 { log << MSG::ERROR <<
"Couldn't register Phi_All" << endreq; }
191 for(
int j=0; j<SEGMENT_MAX; j++ )
192 for(
int k=0; k<LAYER_MAX; k++ )
193 for(
int n=0;
n<STRIP_INBOX_MAX;
n++ )
195 m_recordAll[i][j][k][
n][0] = 0;
196 m_recordAll[i][j][k][
n][1] = 0;
197 m_recordAll[i][j][k][
n][2] = 0;
198 m_recordAll[i][j][k][
n][3] = 0;
199 m_recordAll[i][j][k][
n][4] = 0;
201 m_recordDimu[i][j][k][
n][0] = 0;
202 m_recordDimu[i][j][k][
n][1] = 0;
203 m_recordDimu[i][j][k][
n][2] = 0;
204 m_recordDimu[i][j][k][
n][3] = 0;
205 m_recordDimu[i][j][k][
n][4] = 0;
208 m_ptrMucMark =
new MucMark(0,0,0,0);
212 m_expHitCol.resize(0);
213 m_effHitCol.resize(0);
214 m_nosHitCol.resize(0);
215 m_clusterCol.resize(0);
218 for(
int j=0; j<SEGMENT_MAX; j++ ) {
219 m_segDigiCol[i][j].resize(0);
222 log << MSG::INFO <<
"Initialize done!" <<endmsg;
223 return StatusCode::SUCCESS;
229 MsgStream log(
msgSvc(), name());
230 log << MSG::INFO <<
"in execute()" << endreq;
232 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
233 m_run = eventHeader->runNumber();
234 m_event = eventHeader->eventNumber();
235 log << MSG::DEBUG <<
"Run " << m_run <<
"\tEvent " << m_event <<endreq;
237 SmartDataPtr<DQAEvent::DQAEvent> dqaevt(eventSvc(),
"/Event/DQATag");
239 log << MSG::INFO <<
"success get DQAEvent" << endreq;
241 log << MSG::ERROR <<
"Error accessing DQAEvent" << endreq;
242 return StatusCode::FAILURE;
244 log << MSG::DEBUG <<
"DQA event tag = " << dqaevt->EventTag() << endreq;
246 int part, segment, layer, strip;
249 if ( dqaevt->Dimu() ) isDimu =
true;
250 log << MSG::INFO <<
"DQADimuTag:\t" << dqaevt->Dimu() << endreq;
253 log << MSG::INFO <<
"Retrieve digis" << endreq;
254 SmartDataPtr<MucDigiCol> mucDigiCol(eventSvc(),
"/Event/Digi/MucDigiCol");
256 log << MSG::FATAL <<
"Could not find MUC digi" << endreq;
257 return( StatusCode::FAILURE);
261 MucDigiCol::iterator digiIter = mucDigiCol->begin();
263 for (
int digiId =0; digiIter != mucDigiCol->end(); digiIter++, digiId++ )
265 mucId = (*digiIter)->identify();
272 m_digiCol.push_back( aMark );
273 m_segDigiCol[part][segment].push_back( aMark );
274 m_recordAll[part][segment][layer][strip][0] ++;
275 if( isDimu ) m_recordDimu[part][segment][layer][strip][0] ++;
277 log << MSG::INFO <<
"Total digis in this event: " << eventDigi << endreq;
278 if( eventDigi > 500) cout <<
"Run:\t"<< m_run <<
"\tEvent:\t"<< m_event <<
"\tdigits inflation:\t" << eventDigi << endreq;
281 m_clusterCol = (*m_ptrMucMark).CreateClusterCol(1, m_digiCol );
282 log << MSG::INFO <<
"Total clusters in this event: " << m_clusterCol.size() << endreq;
287 SmartDataPtr<RecMucTrackCol> mucTrackCol(eventSvc(),
"/Event/Recon/RecMucTrackCol");
289 log << MSG::FATAL <<
"Could not find RecMucTrackCol" << endreq;
290 return( StatusCode::FAILURE);
294 if (aRecMucTrackCol->size() < 1) {
295 log << MSG::INFO <<
"No MUC tracks in this event" << endreq;
296 return StatusCode::SUCCESS;
298 log << MSG::INFO <<
"Total tracks of this event: " << aRecMucTrackCol->size() << endreq;
300 int trackHitNum, expectedHitNum, segNum, lastLayerBR, lastLayerEC;
301 int layerPassNum[3], passMax[TRACK_SEG_MAX][2];
302 bool firedLay[TRACK_SEG_MAX][LAYER_MAX];
303 double costheta, phi;
305 trackHitNum = expectedHitNum = segNum = lastLayerBR = lastLayerEC = 0;
306 layerPassNum[0] = layerPassNum[1] = layerPassNum[2] = 0;
307 for(
int segi=0; segi<TRACK_SEG_MAX; segi++ ) {
308 passMax[segi][0] = passMax[segi][1] = 0;
309 for(
int layi=0; layi<LAYER_MAX; layi++ ) firedLay[segi][layi] = 0;
312 vector<MucRecHit*> mucRawHitCol;
313 vector<MucRecHit*> mucExpHitCol;
314 RecMucTrackCol::iterator trackIter = mucTrackCol->begin();
315 for (
int trackId = 0; trackIter != mucTrackCol->end(); trackIter++, trackId++)
317 trackHitNum = (*trackIter)->numHits();
319 if( trackHitNum == 0 ) {
320 log << MSG::INFO <<
"Track " << trackId <<
" no hits" << endreq;
324 lastLayerBR = (*trackIter)->brLastLayer();
325 lastLayerEC = (*trackIter)->ecLastLayer();
327 CLHEP::Hep3Vector a3Vector((*trackIter)->xPos(),(*trackIter)->yPos(),(*trackIter)->zPos());
328 costheta = a3Vector.cosTheta();
329 phi = a3Vector.phi();
330 if(m_thsvc->getHist(
"/DQAHist/MUC/Costheta_All", htmp).isSuccess()) {
331 htmp->Fill( costheta );
333 log << MSG::ERROR <<
"Fail to retrieve Costheta_All" << endreq;
335 if(m_thsvc->getHist(
"/DQAHist/MUC/Phi_All", htmp).isSuccess()) {
338 log << MSG::ERROR <<
"Fail to retrieve Phi_All" << endreq;
343 if(m_thsvc->getHist(
"/DQAHist/MUC/Costheta_Dimu", htmp).isSuccess()) {
344 htmp->Fill( costheta );
346 log << MSG::ERROR <<
"Fail to retrieve Costheta_Dimu" << endreq;
348 if(m_thsvc->getHist(
"/DQAHist/MUC/Phi_Dimu", htmp).isSuccess()) {
351 log << MSG::ERROR <<
"Fail to retrieve Phi_Dimu" << endreq;
354 log << MSG::INFO <<
"Fill costheta and phi:\t" << costheta <<
"\t" << phi << endreq;
361 mucExpHitCol = (*trackIter)->GetExpectedHits();
363 expectedHitNum += mucExpHitCol.size();
364 for(
unsigned int hitId = 0; hitId < mucExpHitCol.size(); hitId++)
366 pMucRawHit = mucExpHitCol[ hitId ];
367 part = pMucRawHit->
Part(); segment = pMucRawHit->
Seg();
368 layer = pMucRawHit->
Gap(); strip = pMucRawHit->
Strip();
370 MucMark* currentMark =
new MucMark( part, segment, layer, strip );
371 m_expHitCol.push_back( currentMark );
375 bool isInEffWindow =
false;
376 isInPos = currentMark->
IsInCol( m_segDigiCol[part][segment] );
379 if( part ==
BRID && (layer-lastLayerBR>1) )
continue;
380 if( part !=
BRID && (layer-lastLayerEC>1) )
continue;
383 if( part==
BRID && layer==0 && (strip<2 || strip>45) )
387 m_recordAll[part][segment][layer][strip][2] ++;
388 m_recordAll[part][segment][layer][strip][1] ++;
389 m_effHitCol.push_back( m_segDigiCol[part][segment][isInPos] );
392 m_recordDimu[part][segment][layer][strip][2] ++;
393 m_recordDimu[part][segment][layer][strip][1] ++;
397 m_recordAll[part][segment][layer][strip][1] ++;
398 if(isDimu) m_recordDimu[part][segment][layer][strip][1] ++;
405 m_recordAll[part][segment][layer][strip][2] ++;
406 m_recordAll[part][segment][layer][strip][1] ++;
407 m_effHitCol.push_back( m_segDigiCol[part][segment][isInPos] );
410 m_recordDimu[part][segment][layer][strip][2] ++;
411 m_recordDimu[part][segment][layer][strip][1] ++;
416 else for(
int tempStrip=0, hiti=-m_effWindow; hiti<=m_effWindow; hiti++ )
418 if( hiti == 0 )
continue;
419 tempStrip = strip + hiti;
420 if( tempStrip < 0 || tempStrip > m_ptrIdTr->
GetStripMax(part,segment,layer) )
continue;
422 isInPos = m_ptrMucMark->
IsInCol( part, segment, layer, tempStrip, m_segDigiCol[part][segment] );
425 m_recordAll[part][segment][layer][tempStrip][2] ++;
426 m_recordAll[part][segment][layer][tempStrip][1] ++;
427 m_effHitCol.push_back( m_segDigiCol[part][segment][isInPos] );
430 m_recordDimu[part][segment][layer][tempStrip][2] ++;
431 m_recordDimu[part][segment][layer][tempStrip][1] ++;
434 isInEffWindow =
true;
438 if( isInEffWindow ) {
continue; }
440 m_recordAll[part][segment][layer][strip][1] ++;
441 if(isDimu) m_recordDimu[part][segment][layer][strip][1] ++;
447 log << MSG::INFO <<
"Fill residual" << endreq;
448 vector<float> m_lineResCol = (*trackIter)->getDistHits();
450 mucRawHitCol = (*trackIter)->GetHits();
453 if( trackHitNum > 4 && m_lineResCol[0] != -99)
456 bool firedFlag[
PART_MAX][LAYER_MAX][2];
457 for(
int iprt=0; iprt<
PART_MAX; iprt++)
458 for(
int jlay=0; jlay<LAYER_MAX; jlay++)
459 firedFlag[iprt][jlay][0] = firedFlag[iprt][jlay][1] =
false;
461 for(
unsigned int hitId = 0; hitId < mucExpHitCol.size(); hitId++)
463 pMucExpHit = mucExpHitCol[ hitId ];
464 part = pMucExpHit->
Part(); segment = pMucExpHit->
Seg(); layer = pMucExpHit->
Gap();
465 firedFlag[part][layer][0] =
true;
468 for(
unsigned int hitId = 0; hitId < mucRawHitCol.size(); hitId++)
470 pMucRawHit = mucRawHitCol[ hitId ];
471 part = pMucRawHit->
Part(); segment = pMucRawHit->
Seg(); layer = pMucRawHit->
Gap();
474 if( firedFlag[part][layer][0] ==
true && firedFlag[part][layer][1] ==
false )
478 sprintf( name,
"/DQAHist/MUC/BrResDist_All_L%d", layer );
479 if(m_thsvc->getHist(name, htmp).isSuccess()) {
480 htmp->Fill( m_lineResCol[hitId] );
482 log << MSG::ERROR <<
"Fail to retrieve " << name << endreq;
488 sprintf( name,
"/DQAHist/MUC/BrResDist_Dimu_L%d", layer );
489 if(m_thsvc->getHist(name, htmp).isSuccess()) {
490 htmp->Fill( m_lineResCol[hitId] );
492 log << MSG::ERROR <<
"Fail to retrieve " << name << endreq;
497 sprintf( name,
"/DQAHist/MUC/EcResDist_All_L%d", layer );
498 if(m_thsvc->getHist(name, htmp).isSuccess()) {
499 htmp->Fill( m_lineResCol[hitId] );
501 log << MSG::ERROR <<
"Fail to retrieve " << name << endreq;
507 sprintf( name,
"/DQAHist/MUC/EcResDist_Dimu_L%d", layer );
508 if(m_thsvc->getHist(name, htmp).isSuccess()) {
509 htmp->Fill( m_lineResCol[hitId] );
511 log << MSG::ERROR <<
"Fail to retrieve " << name << endreq;
518 firedFlag[part][layer][1] =
true;
522 mucRawHitCol.clear();
523 mucExpHitCol.clear();
529 log << MSG::INFO <<
"Searching inc/noise hits" << endreq;
532 for(
unsigned int i=0; i < m_digiCol.size(); i++ )
536 if( m_digiCol[i]->IsInCol( m_effHitCol )!=-1 )
continue;
539 for(
unsigned int j=0; j < m_clusterCol.size(); j++ )
542 for(
unsigned int k=0; k<m_clusterCol[j].size(); k++)
544 if( m_clusterCol[j][k]->IsInCol(m_effHitCol) != -1)
551 if ( hasEffHit && (m_digiCol[i]->IsInCol( m_clusterCol[j] ) != -1) ) {
558 part = (*m_digiCol[i]).Part(); segment = (*m_digiCol[i]).
Segment();
559 layer = (*m_digiCol[i]).Layer(); strip = (*m_digiCol[i]).Strip();
562 m_recordAll[part][segment][layer][strip][3] ++;
563 if( isDimu ) m_recordDimu[part][segment][layer][strip][3] ++;
564 m_nosHitCol.push_back(m_digiCol[i]);
570 DQA_MUC::FillHistograms( isDimu );
573 for(
unsigned int i=0; i<m_digiCol.size(); i++ ) {
574 if( m_digiCol[i] != NULL )
delete m_digiCol[i];
577 for(
unsigned int i=0; i<m_expHitCol.size(); i++ ) {
578 if( m_expHitCol[i] != NULL )
delete m_expHitCol[i];
581 if( m_effHitCol.size() != 0 ) m_effHitCol.clear();
582 if( m_expHitCol.size() != 0 ) m_expHitCol.clear();
583 if( m_nosHitCol.size() != 0 ) m_nosHitCol.clear();
584 if( m_digiCol.size() != 0 ) m_digiCol.clear();
585 if( m_clusterCol.size() != 0 ) m_clusterCol.clear();
588 for(
int j=0; j<SEGMENT_MAX; j++ ) {
589 if( m_segDigiCol[i][j].size() != 0 ) m_segDigiCol[i][j].clear();
593 return StatusCode::SUCCESS;