77 MsgStream log(
msgSvc(), name());
79 log << MSG::INFO <<
"in initialize()" << endmsg;
83 if ( nt1 ) m_tuple1 = nt1;
85 m_tuple1 =
ntupleSvc()->book (
"FILE1/vxyz", CLID_ColumnWiseTuple,
"ks N-Tuple example");
87 status = m_tuple1->addItem (
"vx0", m_vx0);
88 status = m_tuple1->addItem (
"vy0", m_vy0);
89 status = m_tuple1->addItem (
"vz0", m_vz0);
90 status = m_tuple1->addItem (
"vr0", m_vr0);
91 status = m_tuple1->addItem (
"rvxy0", m_rvxy0);
92 status = m_tuple1->addItem (
"rvz0", m_rvz0);
93 status = m_tuple1->addItem (
"rvphi0", m_rvphi0);
96 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple1) << endmsg;
97 return StatusCode::FAILURE;
101 NTuplePtr nt2(
ntupleSvc(),
"FILE1/photon");
102 if ( nt2 ) m_tuple2 = nt2;
104 m_tuple2 =
ntupleSvc()->book (
"FILE1/photon", CLID_ColumnWiseTuple,
"ks N-Tuple example");
106 status = m_tuple2->addItem (
"dthe", m_dthe);
107 status = m_tuple2->addItem (
"dphi", m_dphi);
108 status = m_tuple2->addItem (
"dang", m_dang);
109 status = m_tuple2->addItem (
"eraw", m_eraw);
112 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple2) << endmsg;
113 return StatusCode::FAILURE;
118 NTuplePtr nt3(
ntupleSvc(),
"FILE1/etot");
119 if ( nt3 ) m_tuple3 = nt3;
121 m_tuple3 =
ntupleSvc()->book (
"FILE1/etot", CLID_ColumnWiseTuple,
"ks N-Tuple example");
123 status = m_tuple3->addItem (
"m2gg", m_m2gg);
124 status = m_tuple3->addItem (
"etot", m_etot);
127 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple3) << endmsg;
128 return StatusCode::FAILURE;
132 NTuplePtr nt4(
ntupleSvc(),
"FILE1/fit4c");
133 if ( nt4 ) m_tuple4 = nt4;
135 m_tuple4 =
ntupleSvc()->book (
"FILE1/fit4c", CLID_ColumnWiseTuple,
"ks N-Tuple example");
137 status = m_tuple4->addItem (
"chi2", m_chi1);
138 status = m_tuple4->addItem (
"mpi0", m_mpi0);
141 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple4) << endmsg;
142 return StatusCode::FAILURE;
149 NTuplePtr nt5(
ntupleSvc(),
"FILE1/fit5c");
150 if ( nt5 ) m_tuple5 = nt5;
152 m_tuple5 =
ntupleSvc()->book (
"FILE1/fit5c", CLID_ColumnWiseTuple,
"ks N-Tuple example");
154 status = m_tuple5->addItem (
"chi2", m_chi2);
155 status = m_tuple5->addItem (
"mrh0", m_mrh0);
156 status = m_tuple5->addItem (
"mrhp", m_mrhp);
157 status = m_tuple5->addItem (
"mrhm", m_mrhm);
160 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple5) << endmsg;
161 return StatusCode::FAILURE;
165 NTuplePtr nt6(
ntupleSvc(),
"FILE1/geff");
166 if ( nt6 ) m_tuple6 = nt6;
168 m_tuple6 =
ntupleSvc()->book (
"FILE1/geff", CLID_ColumnWiseTuple,
"ks N-Tuple example");
170 status = m_tuple6->addItem (
"fcos", m_fcos);
171 status = m_tuple6->addItem (
"elow", m_elow);
174 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple6) << endmsg;
175 return StatusCode::FAILURE;
180 if(m_checkDedx == 1) {
181 NTuplePtr nt7(
ntupleSvc(),
"FILE1/dedx");
182 if ( nt7 ) m_tuple7 = nt7;
184 m_tuple7 =
ntupleSvc()->book (
"FILE1/dedx", CLID_ColumnWiseTuple,
"ks N-Tuple example");
186 status = m_tuple7->addItem (
"ptrk", m_ptrk);
187 status = m_tuple7->addItem (
"chie", m_chie);
188 status = m_tuple7->addItem (
"chimu", m_chimu);
189 status = m_tuple7->addItem (
"chipi", m_chipi);
190 status = m_tuple7->addItem (
"chik", m_chik);
191 status = m_tuple7->addItem (
"chip", m_chip);
192 status = m_tuple7->addItem (
"probPH", m_probPH);
193 status = m_tuple7->addItem (
"normPH", m_normPH);
194 status = m_tuple7->addItem (
"ghit", m_ghit);
195 status = m_tuple7->addItem (
"thit", m_thit);
198 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple7) << endmsg;
199 return StatusCode::FAILURE;
204 if(m_checkTof == 1) {
205 NTuplePtr nt8(
ntupleSvc(),
"FILE1/tofe");
206 if ( nt8 ) m_tuple8 = nt8;
208 m_tuple8 =
ntupleSvc()->book (
"FILE1/tofe",CLID_ColumnWiseTuple,
"ks N-Tuple example");
210 status = m_tuple8->addItem (
"ptrk", m_ptot_etof);
211 status = m_tuple8->addItem (
"cntr", m_cntr_etof);
212 status = m_tuple8->addItem (
"ph", m_ph_etof);
213 status = m_tuple8->addItem (
"rhit", m_rhit_etof);
214 status = m_tuple8->addItem (
"qual", m_qual_etof);
215 status = m_tuple8->addItem (
"te", m_te_etof);
216 status = m_tuple8->addItem (
"tmu", m_tmu_etof);
217 status = m_tuple8->addItem (
"tpi", m_tpi_etof);
218 status = m_tuple8->addItem (
"tk", m_tk_etof);
219 status = m_tuple8->addItem (
"tp", m_tp_etof);
222 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple8) << endmsg;
223 return StatusCode::FAILURE;
230 if(m_checkTof == 1) {
231 NTuplePtr nt9(
ntupleSvc(),
"FILE1/tof1");
232 if ( nt9 ) m_tuple9 = nt9;
234 m_tuple9 =
ntupleSvc()->book (
"FILE1/tof1", CLID_ColumnWiseTuple,
"ks N-Tuple example");
236 status = m_tuple9->addItem (
"ptrk", m_ptot_btof1);
237 status = m_tuple9->addItem (
"cntr", m_cntr_btof1);
238 status = m_tuple9->addItem (
"ph", m_ph_btof1);
239 status = m_tuple9->addItem (
"zhit", m_zhit_btof1);
240 status = m_tuple9->addItem (
"qual", m_qual_btof1);
241 status = m_tuple9->addItem (
"te", m_te_btof1);
242 status = m_tuple9->addItem (
"tmu", m_tmu_btof1);
243 status = m_tuple9->addItem (
"tpi", m_tpi_btof1);
244 status = m_tuple9->addItem (
"tk", m_tk_btof1);
245 status = m_tuple9->addItem (
"tp", m_tp_btof1);
248 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple9) << endmsg;
249 return StatusCode::FAILURE;
255 if(m_checkTof == 1) {
256 NTuplePtr nt10(
ntupleSvc(),
"FILE1/tof2");
257 if ( nt10 ) m_tuple10 = nt10;
259 m_tuple10 =
ntupleSvc()->book (
"FILE1/tof2", CLID_ColumnWiseTuple,
"ks N-Tuple example");
261 status = m_tuple10->addItem (
"ptrk", m_ptot_btof2);
262 status = m_tuple10->addItem (
"cntr", m_cntr_btof2);
263 status = m_tuple10->addItem (
"ph", m_ph_btof2);
264 status = m_tuple10->addItem (
"zhit", m_zhit_btof2);
265 status = m_tuple10->addItem (
"qual", m_qual_btof2);
266 status = m_tuple10->addItem (
"te", m_te_btof2);
267 status = m_tuple10->addItem (
"tmu", m_tmu_btof2);
268 status = m_tuple10->addItem (
"tpi", m_tpi_btof2);
269 status = m_tuple10->addItem (
"tk", m_tk_btof2);
270 status = m_tuple10->addItem (
"tp", m_tp_btof2);
273 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple10) << endmsg;
274 return StatusCode::FAILURE;
280 NTuplePtr nt11(
ntupleSvc(),
"FILE1/pid");
281 if ( nt11 ) m_tuple11 = nt11;
283 m_tuple11 =
ntupleSvc()->book (
"FILE1/pid", CLID_ColumnWiseTuple,
"ks N-Tuple example");
285 status = m_tuple11->addItem (
"ptrk", m_ptrk_pid);
286 status = m_tuple11->addItem (
"cost", m_cost_pid);
287 status = m_tuple11->addItem (
"dedx", m_dedx_pid);
288 status = m_tuple11->addItem (
"tof1", m_tof1_pid);
289 status = m_tuple11->addItem (
"tof2", m_tof2_pid);
290 status = m_tuple11->addItem (
"prob", m_prob_pid);
293 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple11) << endmsg;
294 return StatusCode::FAILURE;
303 log << MSG::INFO <<
"successfully return from initialize()" <<endmsg;
304 return StatusCode::SUCCESS;
313 MsgStream log(
msgSvc(), name());
314 log << MSG::INFO <<
"in execute()" << endreq;
316 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
317 int runNo=eventHeader->runNumber();
318 int event=eventHeader->eventNumber();
319 log << MSG::DEBUG <<
"run, evtnum = "
322 cout<<
"event "<<
event<<endl;
327 log << MSG::DEBUG <<
"ncharg, nneu, tottks = "
328 << evtRecEvent->totalCharged() <<
" , "
329 << evtRecEvent->totalNeutral() <<
" , "
330 << evtRecEvent->totalTracks() <<endreq;
337 Vint iGood, ipip, ipim;
347 Hep3Vector xorigin(0,0,0);
359 SmartIF<IVertexDbSvc> m_vtxSvc;
360 m_vtxSvc = serviceLocator()->service(
"VertexDbSvc");
361 if(m_vtxSvc->isVertexValid()){
363 double* dbv = m_vtxSvc->PrimaryVertex();
364 double* vv = m_vtxSvc->SigmaPrimaryVertex();
365 xorigin.setX(dbv[0]);
366 xorigin.setY(dbv[1]);
367 xorigin.setZ(dbv[2]);
370 for(
int i = 0; i < evtRecEvent->totalCharged(); i++){
372 if(!(*itTrk)->isMdcTrackValid())
continue;
374 double pch=mdcTrk->
p();
375 double x0=mdcTrk->
x();
376 double y0=mdcTrk->
y();
377 double z0=mdcTrk->
z();
378 double theta0=mdcTrk->
theta();
379 double phi0=mdcTrk->
helix(1);
380 double xv=xorigin.x();
381 double yv=xorigin.y();
382 double Rxy=(x0-xv)*
cos(phi0)+(y0-yv)*
sin(phi0);
388 HepVector a = mdcTrk->
helix();
389 HepSymMatrix Ea = mdcTrk->
err();
391 HepPoint3D IP(xorigin[0],xorigin[1],xorigin[2]);
394 HepVector vecipa = helixip.
a();
395 double Rvxy0=fabs(vecipa[0]);
396 double Rvz0=vecipa[3];
397 double Rvphi0=vecipa[1];
406 if(fabs(Rvz0) >= 10.0)
continue;
407 if(fabs(Rvxy0) >= 1.0)
continue;
408 if(fabs(
cos(theta0)) >= 0.93)
continue;
411 nCharge += mdcTrk->
charge();
417 int nGood = iGood.size();
418 log << MSG::DEBUG <<
"ngood, totcharge = " << nGood <<
" , " << nCharge << endreq;
419 if((nGood != 2)||(nCharge!=0)){
420 return StatusCode::SUCCESS;
426 for(
int i = evtRecEvent->totalCharged(); i< evtRecEvent->totalTracks(); i++) {
428 if(!(*itTrk)->isEmcShowerValid())
continue;
430 Hep3Vector emcpos(emcTrk->
x(), emcTrk->
y(), emcTrk->
z());
435 for(
int j = 0; j < evtRecEvent->totalCharged(); j++) {
437 if(!(*jtTrk)->isExtTrackValid())
continue;
442 double angd = extpos.angle(emcpos);
443 double thed = extpos.theta() - emcpos.theta();
444 double phid = extpos.deltaPhi(emcpos);
445 thed = fmod(thed+CLHEP::twopi+CLHEP::twopi+
pi, CLHEP::twopi) - CLHEP::pi;
446 phid = fmod(phid+CLHEP::twopi+CLHEP::twopi+
pi, CLHEP::twopi) - CLHEP::pi;
453 if(dang>=200)
continue;
454 double eraw = emcTrk->
energy();
457 dthe = dthe * 180 / (CLHEP::pi);
458 dphi = dphi * 180 / (CLHEP::pi);
459 dang = dang * 180 / (CLHEP::pi);
467 {
if(eraw <= (m_energyThreshold/2))
continue;}
469 {
if(eraw <= m_energyThreshold)
continue;}
474 if(fabs(dang) < m_gammaAngleCut)
continue;
487 int nGam = iGam.size();
489 log << MSG::DEBUG <<
"num Good Photon " << nGam <<
" , " <<evtRecEvent->totalNeutral()<<endreq;
491 return StatusCode::SUCCESS;
503 if(m_checkDedx == 1) {
504 for(
int i = 0; i < nGood; i++) {
506 if(!(*itTrk)->isMdcTrackValid())
continue;
507 if(!(*itTrk)->isMdcDedxValid())
continue;
510 m_ptrk = mdcTrk->
p();
512 m_chie = dedxTrk->
chiE();
513 m_chimu = dedxTrk->
chiMu();
514 m_chipi = dedxTrk->
chiPi();
515 m_chik = dedxTrk->
chiK();
516 m_chip = dedxTrk->
chiP();
519 m_probPH = dedxTrk->
probPH();
520 m_normPH = dedxTrk->
normPH();
530 if(m_checkTof == 1) {
531 for(
int i = 0; i < nGood; i++) {
533 if(!(*itTrk)->isMdcTrackValid())
continue;
534 if(!(*itTrk)->isTofTrackValid())
continue;
537 SmartRefVector<RecTofTrack> tofTrkCol = (*itTrk)->tofTrack();
539 double ptrk = mdcTrk->
p();
541 SmartRefVector<RecTofTrack>::iterator iter_tof = tofTrkCol.begin();
542 for(;iter_tof != tofTrkCol.end(); iter_tof++ ) {
544 status->
setStatus((*iter_tof)->status());
547 if( status->
layer()!=0 )
continue;
548 double path=(*iter_tof)->path();
549 double tof = (*iter_tof)->tof();
550 double ph = (*iter_tof)->ph();
551 double rhit = (*iter_tof)->zrhit();
552 double qual = 0.0 + (*iter_tof)->quality();
553 double cntr = 0.0 + (*iter_tof)->tofID();
555 for(
int j = 0; j < 5; j++) {
557 double beta = gb/sqrt(1+gb*gb);
558 texp[j] = 10 * path /beta/
velc;
565 m_te_etof = tof - texp[0];
566 m_tmu_etof = tof - texp[1];
567 m_tpi_etof = tof - texp[2];
568 m_tk_etof = tof - texp[3];
569 m_tp_etof = tof - texp[4];
574 if(status->
layer()==1){
575 double path=(*iter_tof)->path();
576 double tof = (*iter_tof)->tof();
577 double ph = (*iter_tof)->ph();
578 double rhit = (*iter_tof)->zrhit();
579 double qual = 0.0 + (*iter_tof)->quality();
580 double cntr = 0.0 + (*iter_tof)->tofID();
582 for(
int j = 0; j < 5; j++) {
584 double beta = gb/sqrt(1+gb*gb);
585 texp[j] = 10 * path /beta/
velc;
593 m_te_btof1 = tof - texp[0];
594 m_tmu_btof1 = tof - texp[1];
595 m_tpi_btof1 = tof - texp[2];
596 m_tk_btof1 = tof - texp[3];
597 m_tp_btof1 = tof - texp[4];
601 if(status->
layer()==2){
602 double path=(*iter_tof)->path();
603 double tof = (*iter_tof)->tof();
604 double ph = (*iter_tof)->ph();
605 double rhit = (*iter_tof)->zrhit();
606 double qual = 0.0 + (*iter_tof)->quality();
607 double cntr = 0.0 + (*iter_tof)->tofID();
609 for(
int j = 0; j < 5; j++) {
611 double beta = gb/sqrt(1+gb*gb);
612 texp[j] = 10 * path /beta/
velc;
620 m_te_btof2 = tof - texp[0];
621 m_tmu_btof2 = tof - texp[1];
622 m_tpi_btof2 = tof - texp[2];
623 m_tk_btof2 = tof - texp[3];
624 m_tp_btof2 = tof - texp[4];
641 for(
int i = 0; i < nGam; i++) {
644 double eraw = emcTrk->
energy();
645 double phi = emcTrk->
phi();
646 double the = emcTrk->
theta();
647 HepLorentzVector
ptrk;
655 pGam.push_back(
ptrk);
662 for(
int i = 0; i < nGood; i++) {
679 m_ptrk_pid = mdcTrk->
p();
694 if(mdcKalTrk->
charge() >0) {
695 ipip.push_back(iGood[i]);
696 HepLorentzVector
ptrk;
697 ptrk.setPx(mdcKalTrk->
px());
698 ptrk.setPy(mdcKalTrk->
py());
699 ptrk.setPz(mdcKalTrk->
pz());
705 ppip.push_back(
ptrk);
707 ipim.push_back(iGood[i]);
708 HepLorentzVector
ptrk;
709 ptrk.setPx(mdcKalTrk->
px());
710 ptrk.setPy(mdcKalTrk->
py());
711 ptrk.setPz(mdcKalTrk->
pz());
717 ppim.push_back(
ptrk);
747 int npip = ipip.size();
748 int npim = ipim.size();
749 if(npip*npim != 1)
return SUCCESS;
758 HepLorentzVector pTot;
759 for(
int i = 0; i < nGam - 1; i++){
760 for(
int j = i+1; j < nGam; j++) {
761 HepLorentzVector p2g = pGam[i] + pGam[j];
762 pTot = ppip[0] + ppim[0];
772 RecMdcKalTrack *pipTrk = (*(evtRecTrkCol->begin()+ipip[0]))->mdcKalTrack();
773 RecMdcKalTrack *pimTrk = (*(evtRecTrkCol->begin()+ipim[0]))->mdcKalTrack();
790 HepSymMatrix Evx(3, 0);
807 if(!vtxfit->
Fit(0))
return SUCCESS;
822 HepLorentzVector
ecms(0.034,0,0,3.097);
824 double chisq = 9999.;
827 for(
int i = 0; i < nGam-1; i++) {
828 RecEmcShower *g1Trk = (*(evtRecTrkCol->begin()+iGam[i]))->emcShower();
829 for(
int j = i+1; j < nGam; j++) {
830 RecEmcShower *g2Trk = (*(evtRecTrkCol->begin()+iGam[j]))->emcShower();
837 bool oksq = kmfit->
Fit();
839 double chi2 = kmfit->
chisq();
851 RecEmcShower *g1Trk = (*(evtRecTrkCol->begin()+ig1))->emcShower();
852 RecEmcShower *g2Trk = (*(evtRecTrkCol->begin()+ig2))->emcShower();
859 bool oksq = kmfit->
Fit();
861 HepLorentzVector ppi0 = kmfit->
pfit(2) + kmfit->
pfit(3);
863 m_chi1 = kmfit->
chisq();
877 HepLorentzVector
ecms(0.034,0,0,3.097);
878 double chisq = 9999.;
881 for(
int i = 0; i < nGam-1; i++) {
882 RecEmcShower *g1Trk = (*(evtRecTrkCol->begin()+iGam[i]))->emcShower();
883 for(
int j = i+1; j < nGam; j++) {
884 RecEmcShower *g2Trk = (*(evtRecTrkCol->begin()+iGam[j]))->emcShower();
892 if(!kmfit->
Fit(0))
continue;
893 if(!kmfit->
Fit(1))
continue;
894 bool oksq = kmfit->
Fit();
896 double chi2 = kmfit->
chisq();
907 log << MSG::INFO <<
" chisq = " << chisq <<endreq;
910 RecEmcShower* g1Trk = (*(evtRecTrkCol->begin()+ig1))->emcShower();
911 RecEmcShower* g2Trk = (*(evtRecTrkCol->begin()+ig2))->emcShower();
920 bool oksq = kmfit->
Fit();
922 HepLorentzVector ppi0 = kmfit->
pfit(2) + kmfit->
pfit(3);
923 HepLorentzVector prho0 = kmfit->
pfit(0) + kmfit->
pfit(1);
924 HepLorentzVector prhop = ppi0 + kmfit->
pfit(0);
925 HepLorentzVector prhom = ppi0 + kmfit->
pfit(1);
927 m_chi2 = kmfit->
chisq();
931 double eg1 = (kmfit->
pfit(2)).e();
932 double eg2 = (kmfit->
pfit(3)).e();
933 double fcos =
abs(eg1-eg2)/ppi0.rho();
940 if(fabs(prho0.m()-0.770)<0.150) {
941 if(fabs(fcos)<0.99) {
942 m_fcos = (eg1-eg2)/ppi0.rho();
943 m_elow = (eg1 < eg2) ? eg1 : eg2;
951 return StatusCode::SUCCESS;