1#include "GaudiKernel/MsgStream.h"
2#include "GaudiKernel/AlgFactory.h"
3#include "GaudiKernel/ISvcLocator.h"
4#include "GaudiKernel/SmartDataPtr.h"
5#include "GaudiKernel/IDataProviderSvc.h"
6#include "GaudiKernel/PropertyMgr.h"
7#include "VertexFit/IVertexDbSvc.h"
8#include "GaudiKernel/Bootstrap.h"
9#include "GaudiKernel/ISvcLocator.h"
11#include "EventModel/EventModel.h"
12#include "EventModel/Event.h"
14#include "EvtRecEvent/EvtRecEvent.h"
15#include "EvtRecEvent/EvtRecTrack.h"
16#include "DstEvent/TofHitStatus.h"
17#include "EventModel/EventHeader.h"
18#include "McTruth/McParticle.h"
22#include "GaudiKernel/INTupleSvc.h"
23#include "GaudiKernel/NTuple.h"
24#include "GaudiKernel/ITHistSvc.h"
26#include "GaudiKernel/Bootstrap.h"
27#include "GaudiKernel/IHistogramSvc.h"
28#include "CLHEP/Vector/ThreeVector.h"
29#include "CLHEP/Vector/LorentzVector.h"
30#include "CLHEP/Vector/TwoVector.h"
31using CLHEP::Hep3Vector;
32using CLHEP::Hep2Vector;
33using CLHEP::HepLorentzVector;
34#include "CLHEP/Geometry/Point3D.h"
35#ifndef ENABLE_BACKWARDS_COMPATIBILITY
38#include "DQARhopiAlg/DQARhopi.h"
40#include "VertexFit/KinematicFit.h"
41#include "VertexFit/VertexFit.h"
42#include "ParticleID/ParticleID.h"
48const double mpi = 0.13957;
49const double mk = 0.493677;
50const double xmass[5] = {0.000511, 0.105658, 0.139570,0.493677, 0.938272};
52const double velc = 299.792458;
53typedef std::vector<int>
Vint;
54typedef std::vector<HepLorentzVector>
Vp4;
56const HepLorentzVector
ecms(0.034,0,0,3.097);
59int Ncut0,
Ncut1,
Ncut2,
Ncut3,
Ncut4,
Ncut5,
Ncut6,
Ncut7,
Ncut8,
Ncut9,
Ncut10;
64 Algorithm(name, pSvcLocator) {
67 declareProperty(
"Vr0cut", m_vr0cut=1.0);
68 declareProperty(
"Vz0cut", m_vz0cut=5.0);
69 declareProperty(
"Vctcut", m_cthcut=0.93);
70 declareProperty(
"EnergyThreshold", m_energyThreshold=0.05);
71 declareProperty(
"GammaAngCut", m_gammaAngCut=25.0);
72 declareProperty(
"Test4C", m_test4C = 1);
73 declareProperty(
"Test5C", m_test5C = 1);
74 declareProperty(
"CheckDedx", m_checkDedx = 1);
75 declareProperty(
"CheckTof", m_checkTof = 1);
80 MsgStream log(
msgSvc(), name());
82 log << MSG::INFO <<
"in initialize()" << endmsg;
86 NTuplePtr nt4(
ntupleSvc(),
"DQAFILE/Rhopi");
87 if ( nt4 ) m_tuple4 = nt4;
89 m_tuple4 =
ntupleSvc()->book (
"DQAFILE/Rhopi", CLID_ColumnWiseTuple,
"ks N-Tuple example");
91 status = m_tuple4->addItem (
"run", m_run);
92 status = m_tuple4->addItem (
"rec", m_rec);
93 status = m_tuple4->addItem (
"nch", m_nch);
94 status = m_tuple4->addItem (
"nneu", m_nneu);
95 status = m_tuple4->addItem (
"chi1", m_chi1);
96 status = m_tuple4->addItem (
"mpi0", m_mpi0);
97 status = m_tuple4->addItem (
"mprho0", m_prho0);
98 status = m_tuple4->addItem (
"mprhop", m_prhop);
99 status = m_tuple4->addItem (
"mprhom", m_prhom);
100 status = m_tuple4->addItem (
"mgood", m_good);
101 status = m_tuple4->addItem (
"mgam", m_gam);
102 status = m_tuple4->addItem (
"mpip", m_pip);
103 status = m_tuple4->addItem (
"mpim", m_pim);
104 status = m_tuple4->addItem (
"m2gam", m_2gam);
105 status = m_tuple4->addItem (
"ngch", m_ngch, 0, 10);
106 status = m_tuple4->addItem (
"nggneu", m_nggneu,0, 10);
107 status = m_tuple4->addItem (
"moutpi0",m_outpi0);
108 status = m_tuple4->addItem (
"cosang", m_cosang);
109 status = m_tuple4->addItem (
"moutpip",m_outpip);
110 status = m_tuple4->addItem (
"moutpim",m_outpim);
111 status = m_tuple4->addItem (
"menpip", m_enpip);
112 status = m_tuple4->addItem (
"mdcpip", m_dcpip );
113 status = m_tuple4->addItem (
"menpim", m_enpim );
114 status = m_tuple4->addItem (
"mdcpim", m_dcpim );
115 status = m_tuple4->addItem (
"mpipf", m_pipf);
116 status = m_tuple4->addItem (
"mpimf", m_pimf);
117 status = m_tuple4->addItem (
"mpi0f", m_pi0f);
119 status = m_tuple4->addItem (
"mpmax", m_pmax);
120 status = m_tuple4->addItem (
"mppx", m_ppx);
121 status = m_tuple4->addItem (
"mppy", m_ppy);
122 status = m_tuple4->addItem (
"mppz", m_ppz);
123 status = m_tuple4->addItem (
"mcosthep",m_costhep);
124 status = m_tuple4->addItem (
"mppxkal", m_ppxkal);
125 status = m_tuple4->addItem (
"mppykal", m_ppykal);
126 status = m_tuple4->addItem (
"mppzkal", m_ppzkal);
127 status = m_tuple4->addItem (
"mmpx", m_mpx);
128 status = m_tuple4->addItem (
"mmpy", m_mpy);
129 status = m_tuple4->addItem (
"mmpz", m_mpz);
130 status = m_tuple4->addItem (
"mcosthem",m_costhem);
131 status = m_tuple4->addItem (
"mmpxkal", m_mpxkal);
132 status = m_tuple4->addItem (
"mmpykal", m_mpykal);
133 status = m_tuple4->addItem (
"mmpzkal", m_mpzkal);
135 status = m_tuple4->addItem (
"mvxpin", m_vxpin);
136 status = m_tuple4->addItem (
"mvypin", m_vypin);
137 status = m_tuple4->addItem (
"mvzpin", m_vzpin);
138 status = m_tuple4->addItem (
"mvrpin", m_vrpin);
139 status = m_tuple4->addItem (
"mcosthepin",m_costhepin);
140 status = m_tuple4->addItem (
"mvxmin", m_vxmin);
141 status = m_tuple4->addItem (
"mvymin", m_vymin);
142 status = m_tuple4->addItem (
"mvzmin", m_vzmin);
143 status = m_tuple4->addItem (
"mvrmin", m_vrmin);
144 status = m_tuple4->addItem (
"mcosthemin",m_costhemin);
145 status = m_tuple4->addItem (
"mvxp", m_vxp);
146 status = m_tuple4->addItem (
"mvyp", m_vyp);
147 status = m_tuple4->addItem (
"mvzp", m_vzp);
148 status = m_tuple4->addItem (
"mvrp", m_vrp);
149 status = m_tuple4->addItem (
"mvxm", m_vxm);
150 status = m_tuple4->addItem (
"mvym", m_vym);
151 status = m_tuple4->addItem (
"mvzm", m_vzm);
152 status = m_tuple4->addItem (
"mvrm", m_vrm);
153 status = m_tuple4->addItem (
"nangecc",m_nangecc,0,10);
154 status = m_tuple4->addIndexedItem (
"mdthec", m_nangecc, m_dthec);
155 status = m_tuple4->addIndexedItem (
"mdphic", m_nangecc, m_dphic);
156 status = m_tuple4->addIndexedItem (
"mdangc", m_nangecc, m_dangc);
157 status = m_tuple4->addIndexedItem (
"mspippim", m_nangecc, m_mspippim);
159 status = m_tuple4->addItem (
"angsg", dangsg);
160 status = m_tuple4->addItem (
"thesg", dthesg);
161 status = m_tuple4->addItem (
"phisg", dphisg);
162 status = m_tuple4->addItem (
"cosgth1", cosgth1);
163 status = m_tuple4->addItem (
"cosgth2", cosgth2);
165 status = m_tuple4->addItem (
"mchi5", m_chi5);
166 status = m_tuple4->addItem (
"mkpi0", m_kpi0);
167 status = m_tuple4->addItem (
"mkpkm", m_kpkm);
168 status = m_tuple4->addItem (
"mkpp0", m_kpp0);
169 status = m_tuple4->addItem (
"mkmp0", m_kmp0);
170 status = m_tuple4->addItem (
"mpgam2pi1",m_pgam2pi1);
171 status = m_tuple4->addItem (
"mpgam2pi2",m_pgam2pi2);
172 status = m_tuple4->addItem (
"cosva1", cosva1);
173 status = m_tuple4->addItem (
"cosva2", cosva2);
174 status = m_tuple4->addItem (
"laypi1", m_laypi1);
175 status = m_tuple4->addItem (
"hit1", m_hit1);
176 status = m_tuple4->addItem (
"laypi2", m_laypi2);
177 status = m_tuple4->addItem (
"hit2", m_hit2);
178 status = m_tuple4->addItem (
"anglepm", m_anglepm);
180 status = m_tuple4->addIndexedItem (
"mptrk", m_ngch, m_ptrk);
181 status = m_tuple4->addIndexedItem (
"chie", m_ngch, m_chie);
182 status = m_tuple4->addIndexedItem (
"chimu", m_ngch,m_chimu);
183 status = m_tuple4->addIndexedItem (
"chipi", m_ngch,m_chipi);
184 status = m_tuple4->addIndexedItem (
"chik", m_ngch,m_chik);
185 status = m_tuple4->addIndexedItem (
"chip", m_ngch,m_chip);
186 status = m_tuple4->addIndexedItem (
"probPH", m_ngch,m_probPH);
187 status = m_tuple4->addIndexedItem (
"normPH", m_ngch,m_normPH);
188 status = m_tuple4->addIndexedItem (
"ghit", m_ngch,m_ghit);
189 status = m_tuple4->addIndexedItem (
"thit", m_ngch,m_thit);
191 status = m_tuple4->addIndexedItem (
"ptot_etof", m_ngch,m_ptot_etof);
192 status = m_tuple4->addIndexedItem (
"cntr_etof", m_ngch,m_cntr_etof);
193 status = m_tuple4->addIndexedItem (
"te_etof", m_ngch,m_te_etof);
194 status = m_tuple4->addIndexedItem (
"tmu_etof", m_ngch,m_tmu_etof);
195 status = m_tuple4->addIndexedItem (
"tpi_etof", m_ngch,m_tpi_etof);
196 status = m_tuple4->addIndexedItem (
"tk_etof", m_ngch,m_tk_etof);
197 status = m_tuple4->addIndexedItem (
"tp_etof", m_ngch,m_tp_etof);
198 status = m_tuple4->addIndexedItem (
"ph_etof", m_ngch,m_ph_etof);
199 status = m_tuple4->addIndexedItem (
"rhit_etof", m_ngch,m_rhit_etof);
200 status = m_tuple4->addIndexedItem (
"qual_etof", m_ngch,m_qual_etof);
201 status = m_tuple4->addIndexedItem (
"ec_toff_e", m_ngch,m_ec_toff_e);
202 status = m_tuple4->addIndexedItem (
"ec_toff_mu",m_ngch,m_ec_toff_mu);
203 status = m_tuple4->addIndexedItem (
"ec_toff_pi",m_ngch,m_ec_toff_pi);
204 status = m_tuple4->addIndexedItem (
"ec_toff_k", m_ngch,m_ec_toff_k);
205 status = m_tuple4->addIndexedItem (
"ec_toff_p", m_ngch,m_ec_toff_p);
206 status = m_tuple4->addIndexedItem (
"ec_tsig_e", m_ngch,m_ec_tsig_e);
207 status = m_tuple4->addIndexedItem (
"ec_tsig_mu",m_ngch,m_ec_tsig_mu);
208 status = m_tuple4->addIndexedItem (
"ec_tsig_pi",m_ngch,m_ec_tsig_pi);
209 status = m_tuple4->addIndexedItem (
"ec_tsig_k", m_ngch,m_ec_tsig_k);
210 status = m_tuple4->addIndexedItem (
"ec_tsig_p", m_ngch,m_ec_tsig_p);
211 status = m_tuple4->addIndexedItem (
"ec_tof", m_ngch,m_ec_tof);
212 status = m_tuple4->addIndexedItem (
"ptot_btof1",m_ngch,m_ptot_btof1);
213 status = m_tuple4->addIndexedItem (
"cntr_btof1",m_ngch,m_cntr_btof1);
214 status = m_tuple4->addIndexedItem (
"te_btof1", m_ngch,m_te_btof1);
215 status = m_tuple4->addIndexedItem (
"tmu_btof1", m_ngch,m_tmu_btof1);
216 status = m_tuple4->addIndexedItem (
"tpi_btof1", m_ngch,m_tpi_btof1);
217 status = m_tuple4->addIndexedItem (
"tk_btof1", m_ngch,m_tk_btof1);
218 status = m_tuple4->addIndexedItem (
"tp_btof1", m_ngch,m_tp_btof1);
219 status = m_tuple4->addIndexedItem (
"ph_btof1", m_ngch,m_ph_btof1);
220 status = m_tuple4->addIndexedItem (
"zhit_btof1",m_ngch,m_zhit_btof1);
221 status = m_tuple4->addIndexedItem (
"qual_btof1",m_ngch,m_qual_btof1);
222 status = m_tuple4->addIndexedItem (
"b1_toff_e", m_ngch,m_b1_toff_e);
223 status = m_tuple4->addIndexedItem (
"b1_toff_mu",m_ngch,m_b1_toff_mu);
224 status = m_tuple4->addIndexedItem (
"b1_toff_pi",m_ngch,m_b1_toff_pi);
225 status = m_tuple4->addIndexedItem (
"b1_toff_k", m_ngch,m_b1_toff_k);
226 status = m_tuple4->addIndexedItem (
"b1_toff_p", m_ngch,m_b1_toff_p);
227 status = m_tuple4->addIndexedItem (
"b1_tsig_e", m_ngch,m_b1_tsig_e);
228 status = m_tuple4->addIndexedItem (
"b1_tsig_mu",m_ngch,m_b1_tsig_mu);
229 status = m_tuple4->addIndexedItem (
"b1_tsig_pi",m_ngch,m_b1_tsig_pi);
230 status = m_tuple4->addIndexedItem (
"b1_tsig_k", m_ngch,m_b1_tsig_k);
231 status = m_tuple4->addIndexedItem (
"b1_tsig_p", m_ngch,m_b1_tsig_p);
232 status = m_tuple4->addIndexedItem (
"b1_tof", m_ngch,m_b1_tof);
234 status = m_tuple4->addIndexedItem (
"mdedx_pid", m_ngch,m_dedx_pid);
235 status = m_tuple4->addIndexedItem (
"mtof1_pid", m_ngch,m_tof1_pid);
236 status = m_tuple4->addIndexedItem (
"mtof2_pid", m_ngch,m_tof2_pid);
237 status = m_tuple4->addIndexedItem (
"mprob_pid", m_ngch,m_prob_pid);
238 status = m_tuple4->addIndexedItem (
"mptrk_pid", m_ngch,m_ptrk_pid);
239 status = m_tuple4->addIndexedItem (
"mcost_pid", m_ngch,m_cost_pid);
240 status = m_tuple4->addItem (
"mpnp", m_pnp);
241 status = m_tuple4->addItem (
"mpnm", m_pnm);
243 status = m_tuple4->addIndexedItem (
"numHits", m_nggneu,m_numHits);
244 status = m_tuple4->addIndexedItem (
"secondmoment", m_nggneu,m_secondmoment);
245 status = m_tuple4->addIndexedItem (
"mx", m_nggneu,m_x);
246 status = m_tuple4->addIndexedItem (
"my", m_nggneu,m_y);
247 status = m_tuple4->addIndexedItem (
"mz", m_nggneu,m_z);
248 status = m_tuple4->addIndexedItem (
"cosemc", m_nggneu,m_cosemc);
249 status = m_tuple4->addIndexedItem (
"phiemc", m_nggneu,m_phiemc);
250 status = m_tuple4->addIndexedItem (
"energy", m_nggneu,m_energy);
251 status = m_tuple4->addIndexedItem (
"eseed", m_nggneu,m_eSeed);
252 status = m_tuple4->addIndexedItem (
"me9", m_nggneu,m_e3x3);
253 status = m_tuple4->addIndexedItem (
"me25", m_nggneu,m_e5x5);
254 status = m_tuple4->addIndexedItem (
"mlat", m_nggneu,m_lat);
255 status = m_tuple4->addIndexedItem (
"ma20", m_nggneu,m_a20);
256 status = m_tuple4->addIndexedItem (
"ma42", m_nggneu,m_a42);
260 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple4) << endmsg;
261 return StatusCode::FAILURE;
265 if(service(
"THistSvc", m_thsvc).isFailure()) {
266 log << MSG::ERROR <<
"Couldn't get THistSvc" << endreq;
267 return StatusCode::FAILURE;
273 TH1F* mrho0 =
new TH1F(
"mrho0",
"mass for #rho^{0}->#pi^{+}#pi^{-}", 160, 0.0, 3.2);
274 if(m_thsvc->regHist(
"/DQAHist/Rhopi/mrho0", mrho0).isFailure()) {
275 log << MSG::ERROR <<
"Couldn't register mrho0" << endreq;
278 TH1F* mrhop =
new TH1F(
"mrhop",
"mass for #rho^{+}->#pi^{+}#pi^{0}", 160, 0.0,3.2);
279 if(m_thsvc->regHist(
"/DQAHist/Rhopi/mrhop", mrhop).isFailure()) {
280 log << MSG::ERROR <<
"Couldn't register mrhop" << endreq;
283 TH1F* mrhom =
new TH1F(
"mrhom",
"mass for #rho^{-}->#pi^{-}#pi^{0}", 160, 0.0, 3.2);
284 if(m_thsvc->regHist(
"/DQAHist/Rhopi/mrhom", mrhom).isFailure()) {
285 log << MSG::ERROR <<
"Couldn't register mrhom" << endreq;
289 TH1F*
mpi0 =
new TH1F(
"mpi0",
"mass for #pi^{0}->#gamma #gamma", 50,0.08, 0.18);
290 if(m_thsvc->regHist(
"/DQAHist/Rhopi/mpi0",
mpi0).isFailure()) {
291 log << MSG::ERROR <<
"Couldn't register mpi0" << endreq;
298 log << MSG::INFO <<
"successfully return from initialize()" <<endmsg;
299 return StatusCode::SUCCESS;
308 MsgStream log(
msgSvc(), name());
309 log << MSG::INFO <<
"in execute()" << endreq;
311 setFilterPassed(
false);
313 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
314 int run=eventHeader->runNumber();
315 int event=eventHeader->eventNumber();
316 log << MSG::DEBUG <<
"run, evtnum = "
320 m_run = eventHeader->runNumber();
321 m_rec = eventHeader->eventNumber();
326 log << MSG::INFO <<
"get event tag OK" << endreq;
327 log << MSG::DEBUG <<
"ncharg, nneu, tottks = "
328 << evtRecEvent->totalCharged() <<
" , "
329 << evtRecEvent->totalNeutral() <<
" , "
330 << evtRecEvent->totalTracks() <<endreq;
332 m_nch = evtRecEvent->totalCharged();
333 m_nneu = evtRecEvent->totalNeutral();
341 Vint iGood, ipip, ipim, ipnp,ipnm;
347 Vp4 ppip, ppim , ppnp, ppnm;
353 Hep3Vector xorigin(0,0,0);
358 Gaudi::svcLocator()->service(
"VertexDbSvc", vtxsvc);
362 xorigin.setX(dbv[0]);
363 xorigin.setY(dbv[1]);
364 xorigin.setZ(dbv[2]);
368 for(
int i = 0; i < evtRecEvent->totalCharged(); i++){
370 if(!(*itTrk)->isMdcTrackValid())
continue;
371 if (!(*itTrk)->isMdcKalTrackValid())
continue;
375 double pch =mdcTrk->
p();
376 double x0 =mdcTrk->
x();
377 double y0 =mdcTrk->
y();
378 double z0 =mdcTrk->
z();
379 double phi0=mdcTrk->
helix(1);
380 double xv=xorigin.x();
381 double yv=xorigin.y();
382 double Rxy=fabs((x0-xv)*
cos(phi0)+(y0-yv)*
sin(phi0));
385 double m_vz0 = z0-xorigin.z();
389 if(fabs(m_vz0) >= m_vz0cut)
continue;
390 if(m_vr0 >= m_vr0cut)
continue;
391 if(fabs(m_Vct)>=m_cthcut)
continue;
393 iGood.push_back((*itTrk)->trackId());
394 nCharge += mdcTrk->
charge();
401 int nGood = iGood.size();
402 log << MSG::DEBUG <<
"ngood, totcharge = " << nGood <<
" , " << nCharge << endreq;
403 if((nGood != 2)||(nCharge!=0)){
404 return StatusCode::SUCCESS;
410 for(
int i = evtRecEvent->totalCharged(); i< evtRecEvent->totalTracks(); i++) {
412 if(!(*itTrk)->isEmcShowerValid())
continue;
414 Hep3Vector emcpos(emcTrk->
x(), emcTrk->
y(), emcTrk->
z());
419 for(
int j = 0; j < evtRecEvent->totalCharged(); j++) {
421 if(!(*jtTrk)->isExtTrackValid())
continue;
426 double angd = extpos.angle(emcpos);
427 double thed = extpos.theta() - emcpos.theta();
428 double phid = extpos.deltaPhi(emcpos);
429 thed = fmod(thed+CLHEP::twopi+CLHEP::twopi+
pi, CLHEP::twopi) - CLHEP::pi;
430 phid = fmod(phid+CLHEP::twopi+CLHEP::twopi+
pi, CLHEP::twopi) - CLHEP::pi;
432 if(fabs(thed) < fabs(dthe)) dthe = thed;
433 if(fabs(phid) < fabs(dphi)) dphi = phid;
434 if(angd < dang) dang = angd;
436 if(dang>=200)
continue;
437 double eraw = emcTrk->
energy();
438 dthe = dthe * 180 / (CLHEP::pi);
439 dphi = dphi * 180 / (CLHEP::pi);
440 dang = dang * 180 / (CLHEP::pi);
441 double m_dthe = dthe;
442 double m_dphi = dphi;
443 double m_dang = dang;
444 double m_eraw = eraw;
446 if(eraw < m_energyThreshold)
continue;
447 if(dang < m_gammaAngCut)
continue;
451 iGam.push_back((*itTrk)->trackId());
457 int nGam = iGam.size();
459 log << MSG::DEBUG <<
"num Good Photon " << nGam <<
" , " <<evtRecEvent->totalNeutral()<<endreq;
461 return StatusCode::SUCCESS;
472 for(
int i = 0; i < nGam; i++) {
475 double eraw = emcTrk->
energy();
476 double phi = emcTrk->
phi();
477 double the = emcTrk->
theta();
478 HepLorentzVector ptrk;
479 ptrk.setPx(eraw*
sin(the)*
cos(phi));
480 ptrk.setPy(eraw*
sin(the)*
sin(phi));
481 ptrk.setPz(eraw*
cos(the));
486 pGam.push_back(ptrk);
489 log << MSG::DEBUG <<
"liuf1 Good Photon " <<endreq;
492 for(
int i = 0; i < nGood; i++) {
494 if(!(*itTrk)->isMdcTrackValid())
continue;
495 if (!(*itTrk)->isMdcKalTrackValid())
continue;
501 ipip.push_back(iGood[i]);
502 HepLorentzVector ptrk;
503 ptrk.setPx(mdcKalTrk->
px());
504 ptrk.setPy(mdcKalTrk->
py());
505 ptrk.setPz(mdcKalTrk->
pz());
506 double p3 = ptrk.mag();
507 ptrk.setE(sqrt(p3*p3+
mpi*
mpi));
508 ppip.push_back(ptrk);
510 ipim.push_back(iGood[i]);
511 HepLorentzVector ptrk;
512 ptrk.setPx(mdcKalTrk->
px());
513 ptrk.setPy(mdcKalTrk->
py());
514 ptrk.setPz(mdcKalTrk->
pz());
515 double p3 = ptrk.mag();
516 ptrk.setE(sqrt(p3*p3+
mpi*
mpi));
517 ppim.push_back(ptrk);
521 int npip = ipip.size();
522 int npim = ipim.size();
523 log << MSG::DEBUG <<
"num of pion "<< ipip.size()<<
","<<ipim.size()<<endreq;
536 for(
int i=0; i < npip; i++) {
540 Hep3Vector emcpos(ppip[i].px(), ppip[i].py(), ppip[i].pz());
542 for(
int j = 0; j < npim; j++) {
547 HepLorentzVector pippim=ppip[i]+ppim[j];
549 Hep3Vector extpos(ppim[j].px(), ppim[j].py(), ppim[j].pz());
551 double angd = extpos.angle(emcpos);
552 double thed = extpos.theta() - emcpos.theta();
553 double phid = extpos.deltaPhi(emcpos);
554 thed = fmod(thed+CLHEP::twopi+CLHEP::twopi+
pi, CLHEP::twopi) - CLHEP::pi;
555 phid = fmod(phid+CLHEP::twopi+CLHEP::twopi+
pi, CLHEP::twopi) - CLHEP::pi;
557 m_dthec[langcc] = thed * 180 / (CLHEP::pi);
558 m_dphic[langcc] = phid * 180 / (CLHEP::pi);
559 m_dangc[langcc] = angd * 180 / (CLHEP::pi);
560 m_mspippim[langcc] =pippim.m();
570 double m_m2gg,m_momentpi0;
571 HepLorentzVector pTot,p2g;
573 log << MSG::DEBUG <<
"liuf2 Good Photon " <<langcc<<endreq;
578 double m_momentpip,m_momentpim,extmot1,extmot2;
591 double phi01=mdcTrk11->
helix(1);
598 double phi02=mdcTrk12->
helix(1);
600 m_vxpin = mdcTrk11->
x();
601 m_vypin = mdcTrk11->
y();
602 m_vzpin = mdcTrk11->
z()-xorigin.z();
603 m_vrpin = fabs((mdcTrk11->
x()-xorigin.x())*
cos(phi01)+(mdcTrk11->
y()-xorigin.y())*
sin(phi01));
604 m_costhepin =
cos(mdcTrk11->
theta());
606 m_momentpip=mdcTrk11->
p();
607 m_ppx =mdcTrk11->
px();
608 m_ppy =mdcTrk11->
py();
609 m_ppz =mdcTrk11->
pz();
611 m_vxp = mdcKalTrk11->
x();
612 m_vyp = mdcKalTrk11->
y();
613 m_vzp = mdcKalTrk11->
z()-xorigin.z();
614 m_vrp = fabs((mdcKalTrk11->
x()-xorigin.x())*
cos(phi01)+(mdcKalTrk11->
y()-xorigin.y())*
sin(phi01));
615 m_costhep =
cos(mdcKalTrk11->
theta());
617 extmot1=mdcKalTrk11->
p();
618 m_ppxkal =mdcKalTrk11->
px();
619 m_ppykal =mdcKalTrk11->
py();
620 m_ppzkal =mdcKalTrk11->
pz();
622 m_vxmin = mdcTrk12->
x();
623 m_vymin = mdcTrk12->
y();
624 m_vzmin = mdcTrk12->
z();
625 m_vrmin = fabs((mdcTrk12->
x()-xorigin.x())*
cos(phi02)+(mdcTrk12->
y()-xorigin.y())*
sin(phi02));
626 m_costhemin =
cos(mdcTrk12->
theta());
628 m_momentpim=mdcTrk12->
p();
629 m_mpx =mdcTrk12->
px();
630 m_mpy =mdcTrk12->
py();
631 m_mpz =mdcTrk12->
pz();
633 m_vxm = mdcKalTrk12->
x();
634 m_vym = mdcKalTrk12->
y();
635 m_vzm = mdcKalTrk12->
z();
636 m_vrm = fabs((mdcKalTrk12->
x()-xorigin.x())*
cos(phi02)+(mdcKalTrk12->
y()-xorigin.y())*
sin(phi02));
637 m_costhem =
cos(mdcKalTrk12->
theta());
639 extmot2 =mdcKalTrk12->
p();
640 m_mpxkal =mdcKalTrk12->
px();
641 m_mpykal =mdcKalTrk12->
py();
642 m_mpzkal =mdcKalTrk12->
pz();
644 if((*itTrk11)->isEmcShowerValid()){
645 emcTg1 = emcTrk11->
energy();
647 if((*itTrk12)->isEmcShowerValid()){
648 emcTg2 = emcTrk12->
energy();
650 if((*itTrk11)->isMucTrackValid()){
654 if((*itTrk12)->isMucTrackValid()){
664 log << MSG::DEBUG <<
"liuf3 Good Photon " << ipim[0] <<endreq;
666 RecMdcKalTrack *pipTrk = (*(evtRecTrkCol->begin()+ipip[0]))->mdcKalTrack();
667 RecMdcKalTrack *pimTrk = (*(evtRecTrkCol->begin()+ipim[0]))->mdcKalTrack();
669 log << MSG::DEBUG <<
"liuf4 Good Photon " <<endreq;
689 HepSymMatrix Evx(3, 0);
730 double chisq = 9999.;
731 for(
int i = 0; i < nGam-1; i++) {
732 RecEmcShower *g1Trk = (*(evtRecTrkCol->begin()+iGam[i]))->emcShower();
733 for(
int j = i+1; j < nGam; j++) {
734 RecEmcShower *g2Trk = (*(evtRecTrkCol->begin()+iGam[j]))->emcShower();
742 bool oksq = kmfit->
Fit();
744 double chi2 = kmfit->
chisq();
746 HepLorentzVector kpi0 = kmfit->
pfit(2) + kmfit->
pfit(3);
747 HepLorentzVector kpkm = kmfit->
pfit(0) + kmfit->
pfit(1);
748 HepLorentzVector kpp0 = kmfit->
pfit(0) + kpi0;
749 HepLorentzVector kmp0 = kmfit->
pfit(1) + kpi0;
750 chi5 = kmfit->
chisq();
769 if(!vtxfit->
Fit(0))
return SUCCESS;
775 log << MSG::DEBUG <<
"liuf5 Good Photon " <<endreq;
783 double chisq = 9999.;
786 HepLorentzVector gg1,gg2;
787 for(
int i = 0; i < nGam-1; i++) {
788 RecEmcShower *g1Trk = (*(evtRecTrkCol->begin()+iGam[i]))->emcShower();
789 for(
int j = i+1; j < nGam; j++) {
790 RecEmcShower *g2Trk = (*(evtRecTrkCol->begin()+iGam[j]))->emcShower();
798 bool oksq = kmfit->
Fit();
800 double chi2 = kmfit->
chisq();
813 m_pmax=gg1.e()>gg2.e()?gg1.e():gg2.e();
815 m_cosang=(gg1.e()-gg2.e())/p2g.rho();
816 m_momentpi0=sqrt(p2g.px()*p2g.px()+p2g.py()*p2g.py()+p2g.pz()*p2g.pz());
817 log << MSG::DEBUG <<
" chisq for 4c " << chisq <<endreq;
819 return StatusCode::SUCCESS;
825 jGood.push_back(ipip[0]);
826 jGood.push_back(ipim[0]);
827 m_ngch = jGood.size();
831 jGgam.push_back(ig1);
832 jGgam.push_back(ig2);
833 m_nggneu=jGgam.size();
835 HepLorentzVector ppip1=ppip[0];
836 HepLorentzVector ppim1=ppim[0];
838 HepLorentzVector Ppipboost = ppip1.boost(
u_cms);
839 HepLorentzVector Ppimboost = ppim1.boost(
u_cms);
840 Hep3Vector p3pi1 = Ppipboost.vect();
841 Hep3Vector p3pi2 = Ppimboost.vect();
842 m_anglepm = (p3pi1.angle(p3pi2))* 180 / (CLHEP::pi);
846 RecEmcShower *g1Trk = (*(evtRecTrkCol->begin()+ig1))->emcShower();
847 RecEmcShower *g2Trk = (*(evtRecTrkCol->begin()+ig2))->emcShower();
855 bool oksq = kmfit->
Fit();
856 if(!oksq)
return SUCCESS;
858 HepLorentzVector ppi0 = kmfit->
pfit(2) + kmfit->
pfit(3);
859 HepLorentzVector prho0 = kmfit->
pfit(0) + kmfit->
pfit(1);
860 HepLorentzVector prhop = kmfit->
pfit(0) + ppi0;
861 HepLorentzVector prhom = kmfit->
pfit(1) + ppi0;
862 HepLorentzVector pgam2pi1 = prho0 + kmfit->
pfit(2);
863 HepLorentzVector pgam2pi2 = prho0 + kmfit->
pfit(3);
864 HepLorentzVector pgam11 =kmfit->
pfit(2);
865 HepLorentzVector pgam12 =kmfit->
pfit(3);
876 m_chi1 = kmfit->
chisq();
887 m_outpi0=m_momentpi0;
888 m_outpip=m_momentpip;
889 m_outpim=m_momentpim;
894 m_pipf=kmfit->
pfit(0).rho();
895 m_pimf=kmfit->
pfit(1).rho();
903 m_pgam2pi1=pgam2pi1.m();
904 m_pgam2pi2=pgam2pi2.m();
905 cosva1=kmfit->
pfit(2).rho();
906 cosva2=kmfit->
pfit(3).rho();
918 for(
int ii = 0; ii < m_ngch; ii++) {
922 m_chimu[ii] = 9999.0;
923 m_chipi[ii] = 9999.0;
928 m_probPH[ii] = 9999.0;
929 m_normPH[ii] = 9999.0;
932 m_cntr_etof[ii] = 9999.0;
933 m_ptot_etof[ii] = 9999.0;
934 m_ph_etof[ii] = 9999.0;
935 m_rhit_etof[ii] = 9999.0;
936 m_qual_etof[ii] = 9999.0;
937 m_te_etof[ii] = 9999.0;
938 m_tmu_etof[ii] = 9999.0;
939 m_tpi_etof[ii] = 9999.0;
940 m_tk_etof[ii] = 9999.0;
941 m_tp_etof[ii] = 9999.0;
942 m_ec_tof[ii] = 9999.0;
943 m_ec_toff_e[ii] = 9999.0;
944 m_ec_toff_mu[ii] = 9999.0;
945 m_ec_toff_pi[ii] = 9999.0;
946 m_ec_toff_k[ii] = 9999.0;
947 m_ec_toff_p[ii] = 9999.0;
948 m_ec_tsig_e[ii] = 9999.0;
949 m_ec_tsig_mu[ii] = 9999.0;
950 m_ec_tsig_pi[ii] = 9999.0;
951 m_ec_tsig_k[ii] = 9999.0;
952 m_ec_tsig_p[ii] = 9999.0;
955 m_cntr_btof1[ii] = 9999.0;
956 m_ptot_btof1[ii] = 9999.0;
957 m_ph_btof1[ii] = 9999.0;
958 m_zhit_btof1[ii] = 9999.0;
959 m_qual_btof1[ii] = 9999.0;
960 m_te_btof1[ii] = 9999.0;
961 m_tmu_btof1[ii] = 9999.0;
962 m_tpi_btof1[ii] = 9999.0;
963 m_tk_btof1[ii] = 9999.0;
964 m_tp_btof1[ii] = 9999.0;
965 m_b1_tof[ii] = 9999.0;
966 m_b1_toff_e[ii] = 9999.0;
967 m_b1_toff_mu[ii] = 9999.0;
968 m_b1_toff_pi[ii] = 9999.0;
969 m_b1_toff_k[ii] = 9999.0;
970 m_b1_toff_p[ii] = 9999.0;
971 m_b1_tsig_e[ii] = 9999.0;
972 m_b1_tsig_mu[ii] = 9999.0;
973 m_b1_tsig_pi[ii] = 9999.0;
974 m_b1_tsig_k[ii] = 9999.0;
975 m_b1_tsig_p[ii] = 9999.0;
977 m_dedx_pid[ii] = 9999.0;
978 m_tof1_pid[ii] = 9999.0;
979 m_tof2_pid[ii] = 9999.0;
980 m_prob_pid[ii] = 9999.0;
981 m_ptrk_pid[ii] = 9999.0;
982 m_cost_pid[ii] = 9999.0;
987 for(
int i = 0; i < m_ngch; i++) {
989 if(!(*itTrk)->isMdcTrackValid())
continue;
990 if(!(*itTrk)->isMdcDedxValid())
continue;
993 m_ptrk[indx0] = mdcTrk->
p();
995 m_chie[indx0] = dedxTrk->
chiE();
996 m_chimu[indx0] = dedxTrk->
chiMu();
997 m_chipi[indx0] = dedxTrk->
chiPi();
998 m_chik[indx0] = dedxTrk->
chiK();
999 m_chip[indx0] = dedxTrk->
chiP();
1002 m_probPH[indx0] = dedxTrk->
probPH();
1003 m_normPH[indx0] = dedxTrk->
normPH();
1014 for(
int i = 0; i < m_ngch; i++) {
1016 if(!(*itTrk)->isMdcTrackValid())
continue;
1017 if(!(*itTrk)->isTofTrackValid())
continue;
1020 SmartRefVector<RecTofTrack> tofTrkCol = (*itTrk)->tofTrack();
1022 double ptrk = mdcTrk->
p();
1023 SmartRefVector<RecTofTrack>::iterator iter_tof = tofTrkCol.begin();
1024 for(;iter_tof != tofTrkCol.end(); iter_tof++ ) {
1026 status->
setStatus((*iter_tof)->status());
1029 if( status->
layer()!=1 )
continue;
1030 double path=(*iter_tof)->path();
1031 double tof = (*iter_tof)->tof();
1032 double ph = (*iter_tof)->ph();
1033 double rhit = (*iter_tof)->zrhit();
1034 double qual = 0.0 + (*iter_tof)->quality();
1035 double cntr = 0.0 + (*iter_tof)->tofID();
1038 for(
int j = 0; j < 5; j++) {
1039 texp[j] = (*iter_tof)->texp(j);
1043 m_cntr_etof[indx1] = cntr;
1044 m_ptot_etof[indx1] = ptrk;
1045 m_ph_etof[indx1] = ph;
1046 m_rhit_etof[indx1] = rhit;
1047 m_qual_etof[indx1] = qual;
1048 m_te_etof[indx1] = tof - texp[0];
1049 m_tmu_etof[indx1] = tof - texp[1];
1050 m_tpi_etof[indx1] = tof - texp[2];
1051 m_tk_etof[indx1] = tof - texp[3];
1052 m_tp_etof[indx1] = tof - texp[4];
1054 m_ec_tof[indx1] = tof;
1056 m_ec_toff_e[indx1] = (*iter_tof)->toffset(0);
1057 m_ec_toff_mu[indx1] = (*iter_tof)->toffset(1);
1058 m_ec_toff_pi[indx1] = (*iter_tof)->toffset(2);
1059 m_ec_toff_k[indx1] = (*iter_tof)->toffset(3);
1060 m_ec_toff_p[indx1] = (*iter_tof)->toffset(4);
1062 m_ec_tsig_e[indx1] = (*iter_tof)->sigma(0);
1063 m_ec_tsig_mu[indx1] = (*iter_tof)->sigma(1);
1064 m_ec_tsig_pi[indx1] = (*iter_tof)->sigma(2);
1065 m_ec_tsig_k[indx1] = (*iter_tof)->sigma(3);
1066 m_ec_tsig_p[indx1] = (*iter_tof)->sigma(4);
1071 double path=(*iter_tof)->path();
1072 double tof = (*iter_tof)->tof();
1073 double ph = (*iter_tof)->ph();
1074 double rhit = (*iter_tof)->zrhit();
1075 double qual = 0.0 + (*iter_tof)->quality();
1076 double cntr = 0.0 + (*iter_tof)->tofID();
1078 for(
int j = 0; j < 5; j++) {
1079 texp[j] = (*iter_tof)->texp(j);
1081 m_cntr_btof1[indx1] = cntr;
1082 m_ptot_btof1[indx1] = ptrk;
1083 m_ph_btof1[indx1] = ph;
1084 m_zhit_btof1[indx1] = rhit;
1085 m_qual_btof1[indx1] = qual;
1086 m_te_btof1[indx1] = tof - texp[0];
1087 m_tmu_btof1[indx1] = tof - texp[1];
1088 m_tpi_btof1[indx1] = tof - texp[2];
1089 m_tk_btof1[indx1] = tof - texp[3];
1090 m_tp_btof1[indx1] = tof - texp[4];
1092 m_b1_tof[indx1] = tof;
1094 m_b1_toff_e[indx1] = (*iter_tof)->toffset(0);
1095 m_b1_toff_mu[indx1] = (*iter_tof)->toffset(1);
1096 m_b1_toff_pi[indx1] = (*iter_tof)->toffset(2);
1097 m_b1_toff_k[indx1] = (*iter_tof)->toffset(3);
1098 m_b1_toff_p[indx1] = (*iter_tof)->toffset(4);
1100 m_b1_tsig_e[indx1] = (*iter_tof)->sigma(0);
1101 m_b1_tsig_mu[indx1] = (*iter_tof)->sigma(1);
1102 m_b1_tsig_pi[indx1] = (*iter_tof)->sigma(2);
1103 m_b1_tsig_k[indx1] = (*iter_tof)->sigma(3);
1104 m_b1_tsig_p[indx1] = (*iter_tof)->sigma(4);
1117 for(
int i = 0; i < m_ngch; i++) {
1134 m_dedx_pid[indx2] = pid->
chiDedx(2);
1135 m_tof1_pid[indx2] = pid->
chiTof1(2);
1136 m_tof2_pid[indx2] = pid->
chiTof2(2);
1137 m_prob_pid[indx2] = pid->
probPion();
1146 m_ptrk_pid[indx2] = mdcKalTrk->
p();
1147 m_cost_pid[indx2] =
cos(mdcTrk->
theta());
1150 ipnp.push_back(jGood[i]);
1151 HepLorentzVector ptrk;
1152 ptrk.setPx(mdcKalTrk->
px());
1153 ptrk.setPy(mdcKalTrk->
py());
1154 ptrk.setPz(mdcKalTrk->
pz());
1155 double p3 = ptrk.mag();
1156 ptrk.setE(sqrt(p3*p3+
mpi*
mpi));
1159 ppnp.push_back(ptrk);
1162 ipnm.push_back(jGood[i]);
1163 HepLorentzVector ptrk;
1164 ptrk.setPx(mdcKalTrk->
px());
1165 ptrk.setPy(mdcKalTrk->
py());
1166 ptrk.setPz(mdcKalTrk->
pz());
1167 double p3 = ptrk.mag();
1168 ptrk.setE(sqrt(p3*p3+
mpi*
mpi));
1172 ppnm.push_back(ptrk);
1175 int npnp = ipnp.size();
1176 int npnm = ipnm.size();
1182 for (
int i=0; i<m_nggneu; i++)
1185 if (!(*itTrk)->isEmcShowerValid())
continue;
1187 m_numHits[iphoton] = emcTrk->
numHits();
1189 m_x[iphoton] = emcTrk->
x();
1190 m_y[iphoton]= emcTrk->
y();
1191 m_z[iphoton]= emcTrk->
z();
1192 m_cosemc[iphoton] =
cos(emcTrk->
theta());
1193 m_phiemc[iphoton] = emcTrk->
phi();
1194 m_energy[iphoton] = emcTrk->
energy();
1195 m_eSeed[iphoton] = emcTrk->
eSeed();
1196 m_e3x3[iphoton] = emcTrk->
e3x3();
1197 m_e5x5[iphoton] = emcTrk->
e5x5();
1206 if(kmfit->
chisq()>=chi5)
return SUCCESS;
1207 if(pgam2pi2.m()<=1.0)
return SUCCESS;
1208 if(pgam2pi1.m()<=1.0)
return SUCCESS;
1209 if(nGam!=2)
return SUCCESS;
1210 if(emcTg1/extmot1>=0.8)
return SUCCESS;
1211 if(emcTg2/extmot2>=0.8)
return SUCCESS;
1216 if (m_thsvc->getHist(
"/DQAHist/Rhopi/mpi0", h).isSuccess()) {
1219 log << MSG::ERROR <<
"Couldn't retrieve mpi0" << endreq;
1222 if(fabs(ppi0.m()-0.135)>=0.015)
return SUCCESS;
1225 if (m_thsvc->getHist(
"/DQAHist/Rhopi/mrho0", h).isSuccess()) {
1228 log << MSG::ERROR <<
"Couldn't retrieve mrho0" << endreq;
1232 if (m_thsvc->getHist(
"/DQAHist/Rhopi/mrhop", h).isSuccess()) {
1235 log << MSG::ERROR <<
"Couldn't retrieve mrhop" << endreq;
1238 if (m_thsvc->getHist(
"/DQAHist/Rhopi/mrhom", h).isSuccess()) {
1241 log << MSG::ERROR <<
"Couldn't retrieve mrhom" << endreq;
1247 (*(evtRecTrkCol->begin()+ipip[0]))->setPartId(3);
1248 (*(evtRecTrkCol->begin()+ipim[0]))->setPartId(3);
1256 (*(evtRecTrkCol->begin()+ipip[0]))->setQuality(0);
1257 (*(evtRecTrkCol->begin()+ipim[0]))->setQuality(0);
1259 setFilterPassed(
true);
1261 return StatusCode::SUCCESS;
1267 cout<<
"total number: "<<
Ncut0<<endl;
1268 cout<<
"nGood==2, nCharge==0: "<<
Ncut1<<endl;
1269 cout<<
"nGam>=2: "<<
Ncut2<<endl;
1270 cout<<
"Pass Pid: "<<
Ncut3<<endl;
1271 cout<<
"Pass 4C: "<<
Ncut4<<endl;
1272 cout<<
"final cut without pi0:"<<
Ncut5<<endl;
1273 cout<<
"final cut with pi0: "<<
Ncut6<<endl;
1274 MsgStream log(
msgSvc(), name());
1275 log << MSG::INFO <<
"in finalize()" << endmsg;
1276 return StatusCode::SUCCESS;
HepGeom::Point3D< double > HepPoint3D
std::vector< HepLorentzVector > Vp4
EvtRecTrackCol::iterator EvtRecTrackIterator
std::vector< HepLorentzVector > Vp4
double sin(const BesAngle a)
double cos(const BesAngle a)
DQARhopi(const std::string &name, ISvcLocator *pSvcLocator)
double secondMoment() const
const Hep3Vector emcPosition() const
const int emcVolumeNumber() const
const double theta() const
static void setPidType(PidType pidType)
const double theta() const
const HepVector helix() const
......
virtual bool isVertexValid()=0
virtual double * SigmaPrimaryVertex()=0
virtual double * PrimaryVertex()=0
static KinematicFit * instance()
void setDynamicerror(const bool dynamicerror=1)
void AddFourMomentum(int number, HepLorentzVector p4)
HepLorentzVector pfit(int n) const
int methodProbability() const
void setChiMinCut(const double chi=4)
void setRecTrack(EvtRecTrack *trk)
void setMethod(const int method)
double chiTof2(int n) const
void identify(const int pidcase)
void usePidSys(const int pidsys)
static ParticleID * instance()
bool IsPidInfoValid() const
double chiTof1(int n) const
double chiDedx(int n) const
const HepVector & getZHelix() const
const HepSymMatrix & getZError() const
HepSymMatrix & getZErrorK()
unsigned int layer() const
void setStatus(unsigned int status)
void AddTrack(const int number, const double mass, const RecMdcTrack *trk)
WTrackParameter wtrk(int n) const
void AddVertex(int number, VertexParameter vpar, std::vector< int > lis)
static VertexFit * instance()
void setEvx(const HepSymMatrix &eVx)
void setVx(const HepPoint3D &vx)
_EXTERN_ std::string EvtRecEvent
_EXTERN_ std::string EvtRecTrackCol