44 MsgStream log(
msgSvc(), name());
46 log << MSG::INFO <<
"in initialize()" << endmsg;
50 if(service(
"THistSvc", m_thsvc).isFailure()) {
51 log << MSG::ERROR <<
"Couldn't get THistSvc" << endreq;
52 return StatusCode::FAILURE;
56 m_hresAllIncBb =
new TH1F(
"HResAllIncBb",
"", 200, -1.0, 1.0);
57 if(m_thsvc->regHist(
"/DQAHist/MDC/hresAllIncBb", m_hresAllIncBb).isFailure())
58 { log << MSG::ERROR <<
"Couldn't register HResAllIncBb" << endreq; }
60 m_hresAllExcBb =
new TH1F(
"HResAllExcBb",
"", 200, -1.0, 1.0);
61 if(m_thsvc->regHist(
"/DQAHist/MDC/hresAllExcBb", m_hresAllExcBb).isFailure())
62 { log << MSG::ERROR <<
"Couldn't register HResAllExcBb" << endreq; }
64 m_hresAllEvaBb =
new TH1F(
"HResAllEvaBb",
"", 200, -1.0, 1.0);
65 if(m_thsvc->regHist(
"/DQAHist/MDC/hresAllEvaBb", m_hresAllEvaBb).isFailure())
66 { log << MSG::ERROR <<
"Couldn't register HResAllEvaBb" << endreq; }
68 m_ppLabBb =
new TH1F(
"PpLabBb",
"", 800, 0, 3);
69 if(m_thsvc->regHist(
"/DQAHist/MDC/hppLabBb", m_ppLabBb).isFailure())
70 { log << MSG::ERROR <<
"Couldn't register PpLabBb" << endreq; }
71 m_pmLabBb =
new TH1F(
"PmLabBb",
"", 800, 0, 3);
72 if(m_thsvc->regHist(
"/DQAHist/MDC/hpmLabBb", m_pmLabBb).isFailure())
73 { log << MSG::ERROR <<
"Couldn't register PmLabBb" << endreq; }
75 m_ppCmsBb =
new TH1F(
"PpCmsBb",
"", 800, 0, 3);
76 if(m_thsvc->regHist(
"/DQAHist/MDC/hppCmsBb", m_ppCmsBb).isFailure())
77 { log << MSG::ERROR <<
"Couldn't register PpCmsBb" << endreq; }
78 m_pmCmsBb =
new TH1F(
"PmCmsBb",
"", 800, 0, 3);
79 if(m_thsvc->regHist(
"/DQAHist/MDC/hpmCmsBb", m_pmCmsBb).isFailure())
80 { log << MSG::ERROR <<
"Couldn't register PmCmsBb" << endreq; }
82 m_pTotLabBb =
new TH1F(
"PTotLabBb",
"", 800, 0, 3);
83 if(m_thsvc->regHist(
"/DQAHist/MDC/hpTotLabBb", m_pTotLabBb).isFailure())
84 { log << MSG::ERROR <<
"Couldn't register PTotLabBb" << endreq; }
85 m_pTotCmsBb =
new TH1F(
"PTotCmsBb",
"", 800, 0, 3);
86 if(m_thsvc->regHist(
"/DQAHist/MDC/hpTotCmsBb", m_pTotCmsBb).isFailure())
87 { log << MSG::ERROR <<
"Couldn't register PTotCmsBb" << endreq; }
89 m_hresAllIncDimu =
new TH1F(
"HResAllIncDimu",
"", 200, -1.0, 1.0);
90 if(m_thsvc->regHist(
"/DQAHist/MDC/hresAllIncDimu", m_hresAllIncDimu).isFailure())
91 { log << MSG::ERROR <<
"Couldn't register HResAllIncDimu" << endreq; }
93 m_hresAllExcDimu =
new TH1F(
"HResAllExcDimu",
"", 200, -1.0, 1.0);
94 if(m_thsvc->regHist(
"/DQAHist/MDC/hresAllExcDimu", m_hresAllExcDimu).isFailure())
95 { log << MSG::ERROR <<
"Couldn't register HResAllExcDimu" << endreq; }
97 m_hresAllEvaDimu =
new TH1F(
"HResAllEvaDimu",
"", 200, -1.0, 1.0);
98 if(m_thsvc->regHist(
"/DQAHist/MDC/hresAllEvaDimu", m_hresAllEvaDimu).isFailure())
99 { log << MSG::ERROR <<
"Couldn't register HResAllEvaDimu" << endreq; }
101 m_ppLabDimu =
new TH1F(
"PpLabDimu",
"", 800, 0, 3);
102 if(m_thsvc->regHist(
"/DQAHist/MDC/hppLabDimu", m_ppLabDimu).isFailure())
103 { log << MSG::ERROR <<
"Couldn't register PpLabDimu" << endreq; }
104 m_pmLabDimu =
new TH1F(
"PmLabDimu",
"", 800, 0, 3);
105 if(m_thsvc->regHist(
"/DQAHist/MDC/hpmLabDimu", m_pmLabDimu).isFailure())
106 { log << MSG::ERROR <<
"Couldn't register PmLabDimu" << endreq; }
108 m_ppCmsDimu =
new TH1F(
"PpCmsDimu",
"", 800, 0, 3);
109 if(m_thsvc->regHist(
"/DQAHist/MDC/hppCmsDimu", m_ppCmsDimu).isFailure())
110 { log << MSG::ERROR <<
"Couldn't register PpCmsDimu" << endreq; }
111 m_pmCmsDimu =
new TH1F(
"PmCmsDimu",
"", 800, 0, 3);
112 if(m_thsvc->regHist(
"/DQAHist/MDC/hpmCmsDimu", m_pmCmsDimu).isFailure())
113 { log << MSG::ERROR <<
"Couldn't register PmCmsDimu" << endreq; }
115 m_pTotLabDimu =
new TH1F(
"PTotLabDimu",
"", 800, 0, 3);
116 if(m_thsvc->regHist(
"/DQAHist/MDC/hpTotLabDimu", m_pTotLabDimu).isFailure())
117 { log << MSG::ERROR <<
"Couldn't register PTotLabDimu" << endreq; }
118 m_pTotCmsDimu =
new TH1F(
"PTotCmsDimu",
"", 800, 0, 3);
119 if(m_thsvc->regHist(
"/DQAHist/MDC/hpTotCmsDimu", m_pTotCmsDimu).isFailure())
120 { log << MSG::ERROR <<
"Couldn't register PTotCmsDimu" << endreq; }
123 log << MSG::INFO <<
"Initialize done!" <<endmsg;
124 return StatusCode::SUCCESS;
130 MsgStream log(
msgSvc(), name());
131 log << MSG::INFO <<
"in execute()" << endreq;
133 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
134 m_run = eventHeader->runNumber();
135 m_event = eventHeader->eventNumber();
136 log << MSG::DEBUG <<
"Run " << m_run <<
"\tEvent " << m_event <<endreq;
138 SmartDataPtr<DQAEvent::DQAEvent> dqaevt(eventSvc(),
"/Event/DQATag");
140 log << MSG::INFO <<
"success get DQAEvent" << endreq;
142 log << MSG::ERROR <<
"Error accessing DQAEvent" << endreq;
143 return StatusCode::FAILURE;
145 log << MSG::DEBUG <<
"DQA event tag = " << dqaevt->EventTag() << endreq;
150 if ( dqaevt->Dimu() ) isDimu =
true;
151 log << MSG::INFO <<
"DQADimuTag:\t" << dqaevt->Dimu() << endreq;
155 if ( dqaevt->Bhabha() ) isBb=
true;
156 log << MSG::INFO <<
"DQABbTag:\t" << dqaevt->Bhabha() << endreq;
159 SmartDataPtr<RecMdcKalTrackCol> kaltrkCol(eventSvc(),
"/Event/Recon/RecMdcKalTrackCol");
161 log << MSG::FATAL <<
"Could not find RecMdcKalTrackCol" << endreq;
162 return StatusCode::FAILURE;
164 RecMdcKalTrackCol::iterator iter_trk = kaltrkCol->begin();
165 for(; iter_trk != kaltrkCol->end(); iter_trk++) {
170 double dr = (*iter_trk)->dr();
171 double phi0 = (*iter_trk)->fi0();
172 double kappa = (*iter_trk)->kappa();
173 double dz = (*iter_trk)->dz();
174 double tanl = (*iter_trk)->tanl();
175 double pt = 1.0 / kappa;
177 p4.setPx(-
sin(phi0) / fabs(kappa));
178 p4.setPy(
cos(phi0) / fabs(kappa));
179 p4.setPz(tanl / fabs(kappa));
181 double p3 =
p4.mag();
183 if(isBb)
mass = 0.000511;
184 else if(isDimu)
mass = 0.105658;
189 double ecm = 3.68632;
190 HepLorentzVector psip(0.011 * ecm, 0, 0.0075, ecm);
191 Hep3Vector boostv = psip.boostVector();
196 if (m_thsvc->getHist(
"/DQAHist/MDC/hpTotLabBb", hmom).isSuccess()) {
199 log << MSG::ERROR <<
"Couldn't retrieve hpTotLabBb" << endreq;
201 if (m_thsvc->getHist(
"/DQAHist/MDC/hpTotCmsBb", hmom).isSuccess()) {
204 log << MSG::ERROR <<
"Couldn't retrieve hpTotCmsBb" << endreq;
207 if (m_thsvc->getHist(
"/DQAHist/MDC/hppLabBb", hmom).isSuccess()) {
210 log << MSG::ERROR <<
"Couldn't retrieve hppLabBb" << endreq;
212 if (m_thsvc->getHist(
"/DQAHist/MDC/hppCmsBb", hmom).isSuccess()) {
215 log << MSG::ERROR <<
"Couldn't retrieve hppCmsBb" << endreq;
218 if (m_thsvc->getHist(
"/DQAHist/MDC/hpmLabBb", hmom).isSuccess()) {
221 log << MSG::ERROR <<
"Couldn't retrieve hpmLabBb" << endreq;
223 if (m_thsvc->getHist(
"/DQAHist/MDC/hpmCmsBb", hmom).isSuccess()) {
226 log << MSG::ERROR <<
"Couldn't retrieve hpmCmsBb" << endreq;
230 if (m_thsvc->getHist(
"/DQAHist/MDC/hpTotLabDimu", hmom).isSuccess()) {
233 log << MSG::ERROR <<
"Couldn't retrieve hpTotLabDimu" << endreq;
235 if (m_thsvc->getHist(
"/DQAHist/MDC/hpTotCmsDimu", hmom).isSuccess()) {
238 log << MSG::ERROR <<
"Couldn't retrieve hpTotCmsDimu" << endreq;
241 if (m_thsvc->getHist(
"/DQAHist/MDC/hppLabDimu", hmom).isSuccess()) {
244 log << MSG::ERROR <<
"Couldn't retrieve hppLabDimu" << endreq;
246 if (m_thsvc->getHist(
"/DQAHist/MDC/hppCmsDimu", hmom).isSuccess()) {
249 log << MSG::ERROR <<
"Couldn't retrieve hppCmsDimu" << endreq;
252 if (m_thsvc->getHist(
"/DQAHist/MDC/hpmLabDimu", hmom).isSuccess()) {
255 log << MSG::ERROR <<
"Couldn't retrieve hpmLabDimu" << endreq;
257 if (m_thsvc->getHist(
"/DQAHist/MDC/hpmCmsDimu", hmom).isSuccess()) {
260 log << MSG::ERROR <<
"Couldn't retrieve hpmCmsDimu" << endreq;
267 SmartDataPtr<RecMdcTrackCol> newtrkCol(eventSvc(),
"/Event/Recon/RecMdcTrackCol");
269 log << MSG::ERROR <<
"Could not find RecMdcTrackCol" << endreq;
270 return ( StatusCode::FAILURE );
273 RecMdcTrackCol::iterator it_trk = newtrkCol->begin();
274 for(; it_trk != newtrkCol->end(); it_trk++){
275 HitRefVec gothits = (*it_trk) -> getVecHits();
276 HitRefVec::iterator it_hit = gothits.begin();
277 for(; it_hit != gothits.end(); it_hit++){
281 double lr = (*it_hit) -> getFlagLR();
286 double docaInc = (*it_hit) -> getDoca();
287 double docaExc = docaInc;
293 dmeas = (*it_hit) -> getDriftDistLeft();
295 dmeas = (*it_hit) -> getDriftDistRight();
302 double resiInc = fabs(dmeas) - fabs(docaInc);
303 if( 0 == lr ) resilrInc = -1.0 * resiInc;
304 else resilrInc = resiInc;
306 double resiExc = fabs(dmeas) - fabs(docaExc);
307 if( 0 == lr ) resilrExc = -1.0 * resiExc;
308 else resilrExc = resiExc;
310 double resilrEva = 0.5 * (resilrInc + resilrExc);
314 if (m_thsvc->getHist(
"/DQAHist/MDC/hresAllIncBb", htmp).isSuccess()) {
315 htmp->Fill(resilrInc);
317 log << MSG::ERROR <<
"Couldn't retrieve hresAllIncBb" << endreq;
319 if (m_thsvc->getHist(
"/DQAHist/MDC/hresAllExcBb", htmp).isSuccess()) {
320 htmp->Fill(resilrExc);
322 log << MSG::ERROR <<
"Couldn't retrieve hresAllExcBb" << endreq;
324 if (m_thsvc->getHist(
"/DQAHist/MDC/hresAllEvaBb", htmp).isSuccess()) {
325 htmp->Fill(resilrEva);
327 log << MSG::ERROR <<
"Couldn't retrieve hresAllEvaBb" << endreq;
331 if (m_thsvc->getHist(
"/DQAHist/MDC/hresAllIncDimu", htmp).isSuccess()) {
332 htmp->Fill(resilrInc);
334 log << MSG::ERROR <<
"Couldn't retrieve hresAllIncDimu" << endreq;
336 if (m_thsvc->getHist(
"/DQAHist/MDC/hresAllExcDimu", htmp).isSuccess()) {
337 htmp->Fill(resilrExc);
339 log << MSG::ERROR <<
"Couldn't retrieve hresAllExcDimu" << endreq;
341 if (m_thsvc->getHist(
"/DQAHist/MDC/hresAllEvaDimu", htmp).isSuccess()) {
342 htmp->Fill(resilrEva);
344 log << MSG::ERROR <<
"Couldn't retrieve hresAllEvaDimu" << endreq;
350 return StatusCode::SUCCESS;