BOSS 7.0.4
BESIII Offline Software System
Loading...
Searching...
No Matches
PipiJpsi.cxx
Go to the documentation of this file.
1//psi'--> J/psi pion pion, J/psi --> di-leptons
2//Kai Zhu ([email protected])
3#include "GaudiKernel/MsgStream.h"
4#include "GaudiKernel/AlgFactory.h"
5#include "GaudiKernel/ISvcLocator.h"
6#include "GaudiKernel/SmartDataPtr.h"
7#include "GaudiKernel/IDataProviderSvc.h"
8#include "GaudiKernel/PropertyMgr.h"
9
10#include "EventModel/EventModel.h"
11#include "EventModel/EventHeader.h"
12#include "EventModel/Event.h"
13#include "TrigEvent/TrigEvent.h"
14#include "TrigEvent/TrigData.h"
15#include "McTruth/McParticle.h"
16
17#include "EvtRecEvent/EvtRecEvent.h"
18#include "EvtRecEvent/EvtRecTrack.h"
19#include "DstEvent/TofHitStatus.h"
20
21#include "TMath.h"
22#include "GaudiKernel/INTupleSvc.h"
23#include "GaudiKernel/NTuple.h"
24#include "GaudiKernel/Bootstrap.h"
25#include "GaudiKernel/IHistogramSvc.h"
26#include "CLHEP/Vector/ThreeVector.h"
27#include "CLHEP/Vector/LorentzVector.h"
28#include "CLHEP/Vector/TwoVector.h"
29using CLHEP::Hep3Vector;
30using CLHEP::Hep2Vector;
31using CLHEP::HepLorentzVector;
32#include "CLHEP/Geometry/Point3D.h"
33#ifndef ENABLE_BACKWARDS_COMPATIBILITY
35#endif
36#include "VertexFit/KinematicFit.h"
37#include "VertexFit/VertexFit.h"
38#include "VertexFit/SecondVertexFit.h"
39#include "VertexFit/WTrackParameter.h"
40#include "ParticleID/ParticleID.h"
41#include "MdcRecEvent/RecMdcKalTrack.h"
42
43#include "PipiJpsiAlg/PipiJpsi.h"
44
45#include <vector>
46//const double twopi = 6.2831853;
47
48const double me = 0.000511;
49const double mpi = 0.13957;
50const double mproton = 0.938272;
51const double mmu = 0.105658;
52const double mpsip = 3.686;
53const double xmass[5] = {0.000511, 0.105658, 0.139570,0.493677, 0.938272};
54const double velc = 29.9792458; // tof_path unit in cm.
55const double PI = 3.1415926;
56// const double velc = 299.792458; // tof path unit in mm
57typedef std::vector<int> Vint;
58typedef std::vector<HepLorentzVector> Vp4;
59
60// counter for efficiency
61static long m_cout_all(0), m_cout_col(0), m_cout_charge(0), m_cout_nGood(0), m_cout_mom(0), m_cout_recoil(0), m_cout_everat(0);
62/////////////////////////////////////////////////////////////////////////////
63
64PipiJpsi::PipiJpsi(const std::string& name, ISvcLocator* pSvcLocator) :
65 Algorithm(name, pSvcLocator) {
66 //Declare the properties
67 declareProperty("Vr0cut", m_vr0cut=1.0);
68 declareProperty("Vz0cut", m_vz0cut=5.0);
69 declareProperty("TrackCosThetaCut",m_cosThetaCut=0.93);
70 declareProperty("PipiDangCut",m_pipi_dang_cut=0.98);
71
72 declareProperty("CheckDedx", m_checkDedx = true);
73 declareProperty("CheckTof", m_checkTof = true);
74
75 declareProperty("Subsample", m_subsample_flag=false);
76 declareProperty("Trigger", m_trigger_flag=false);
77 declareProperty("DistinEMuon", m_distin_emuon=2.0);
78
79 declareProperty("EventRate", m_eventrate=false);
80 declareProperty("ChanDet", m_chan_det=1);
81}
82
83// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
85 MsgStream log(msgSvc(), name());
86
87 log << MSG::INFO << "in initialize()" << endmsg;
88
89 StatusCode status;
90
91 NTuplePtr nt1(ntupleSvc(), "FILE1/vxyz");
92 if ( nt1 ) m_tuple1 = nt1;
93 else {
94 m_tuple1 = ntupleSvc()->book ("FILE1/vxyz", CLID_ColumnWiseTuple, "ks N-Tuple example");
95 if ( m_tuple1 ) {
96 status = m_tuple1->addItem ("vx0", m_vx0);
97 status = m_tuple1->addItem ("vy0", m_vy0);
98 status = m_tuple1->addItem ("vz0", m_vz0);
99 status = m_tuple1->addItem ("vr0", m_vr0);
100 }
101 else {
102 log << MSG::ERROR << " Cannot book N-tuple:" << long(m_tuple1) << endmsg;
103 return StatusCode::FAILURE;
104 }
105 }
106
107 NTuplePtr nt2(ntupleSvc(), "FILE1/photon");
108 if ( nt2 ) m_tuple2 = nt2;
109 else {
110 m_tuple2 = ntupleSvc()->book ("FILE1/photon", CLID_ColumnWiseTuple, "ks N-Tuple example");
111 if ( m_tuple2 ) {
112 status = m_tuple2->addItem ("dthe", m_dthe);
113 status = m_tuple2->addItem ("dphi", m_dphi);
114 status = m_tuple2->addItem ("dang", m_dang);
115 status = m_tuple2->addItem ("eraw", m_eraw);
116 status = m_tuple2->addItem ("nGam", m_nGam);
117 }
118 else {
119 log << MSG::ERROR << " Cannot book N-tuple:" << long(m_tuple2) << endmsg;
120 return StatusCode::FAILURE;
121 }
122 }
123
124
125 if(m_checkDedx) {
126 NTuplePtr nt3(ntupleSvc(), "FILE1/dedx");
127 if ( nt3 ) m_tuple3 = nt3;
128 else {
129 m_tuple3 = ntupleSvc()->book ("FILE1/dedx", CLID_ColumnWiseTuple, "ks N-Tuple example");
130 if ( m_tuple3 ) {
131 status = m_tuple3->addItem ("ptrk", m_ptrk);
132 status = m_tuple3->addItem ("chie", m_chie);
133 status = m_tuple3->addItem ("chimu", m_chimu);
134 status = m_tuple3->addItem ("chipi", m_chipi);
135 status = m_tuple3->addItem ("chik", m_chik);
136 status = m_tuple3->addItem ("chip", m_chip);
137 status = m_tuple3->addItem ("probPH", m_probPH);
138 status = m_tuple3->addItem ("normPH", m_normPH);
139 status = m_tuple3->addItem ("ghit", m_ghit);
140 status = m_tuple3->addItem ("thit", m_thit);
141 }
142 else {
143 log << MSG::ERROR << " Cannot book N-tuple:" << long(m_tuple3) << endmsg;
144 return StatusCode::FAILURE;
145 }
146 }
147 } // check dE/dx
148
149 if(m_checkTof) {
150 NTuplePtr nt4(ntupleSvc(), "FILE1/tofe");
151 if ( nt4 ) m_tuple4 = nt4;
152 else {
153 m_tuple4 = ntupleSvc()->book ("FILE1/tofe",CLID_ColumnWiseTuple, "ks N-Tuple example");
154 if ( m_tuple4 ) {
155 status = m_tuple4->addItem ("ptrk", m_ptot_etof);
156 status = m_tuple4->addItem ("cntr", m_cntr_etof);
157 status = m_tuple4->addItem ("path", m_path_etof);
158 status = m_tuple4->addItem ("ph", m_ph_etof);
159 status = m_tuple4->addItem ("rhit", m_rhit_etof);
160 status = m_tuple4->addItem ("qual", m_qual_etof);
161 status = m_tuple4->addItem ("tof", m_tof_etof);
162 status = m_tuple4->addItem ("te", m_te_etof);
163 status = m_tuple4->addItem ("tmu", m_tmu_etof);
164 status = m_tuple4->addItem ("tpi", m_tpi_etof);
165 status = m_tuple4->addItem ("tk", m_tk_etof);
166 status = m_tuple4->addItem ("tp", m_tp_etof);
167 }
168 else {
169 log << MSG::ERROR << " Cannot book N-tuple:" << long(m_tuple4) << endmsg;
170 return StatusCode::FAILURE;
171 }
172 }
173 } // check Tof:endcap
174
175
176
177 if(m_checkTof) {
178 NTuplePtr nt5(ntupleSvc(), "FILE1/tof1");
179 if ( nt5 ) m_tuple5 = nt5;
180 else {
181 m_tuple5 = ntupleSvc()->book ("FILE1/tof1", CLID_ColumnWiseTuple, "ks N-Tuple example");
182 if ( m_tuple5 ) {
183 status = m_tuple5->addItem ("ptrk", m_ptot_btof1);
184 status = m_tuple5->addItem ("cntr", m_cntr_btof1);
185 status = m_tuple5->addItem ("path", m_path_btof1);
186 status = m_tuple5->addItem ("ph", m_ph_btof1);
187 status = m_tuple5->addItem ("zhit", m_zhit_btof1);
188 status = m_tuple5->addItem ("qual", m_qual_btof1);
189 status = m_tuple5->addItem ("tof", m_tof_btof1);
190 status = m_tuple5->addItem ("te", m_te_btof1);
191 status = m_tuple5->addItem ("tmu", m_tmu_btof1);
192 status = m_tuple5->addItem ("tpi", m_tpi_btof1);
193 status = m_tuple5->addItem ("tk", m_tk_btof1);
194 status = m_tuple5->addItem ("tp", m_tp_btof1);
195 }
196 else {
197 log << MSG::ERROR << " Cannot book N-tuple:" << long(m_tuple5) << endmsg;
198 return StatusCode::FAILURE;
199 }
200 }
201 } // check Tof:barrel inner Tof
202
203
204 if(m_checkTof) {
205 NTuplePtr nt6(ntupleSvc(), "FILE1/tof2");
206 if ( nt6 ) m_tuple6 = nt6;
207 else {
208 m_tuple6 = ntupleSvc()->book ("FILE1/tof2", CLID_ColumnWiseTuple, "ks N-Tuple example");
209 if ( m_tuple6 ) {
210 status = m_tuple6->addItem ("ptrk", m_ptot_btof2);
211 status = m_tuple6->addItem ("cntr", m_cntr_btof2);
212 status = m_tuple6->addItem ("path", m_path_btof2);
213 status = m_tuple6->addItem ("ph", m_ph_btof2);
214 status = m_tuple6->addItem ("zhit", m_zhit_btof2);
215 status = m_tuple6->addItem ("qual", m_qual_btof2);
216 status = m_tuple6->addItem ("tof", m_tof_btof2);
217 status = m_tuple6->addItem ("te", m_te_btof2);
218 status = m_tuple6->addItem ("tmu", m_tmu_btof2);
219 status = m_tuple6->addItem ("tpi", m_tpi_btof2);
220 status = m_tuple6->addItem ("tk", m_tk_btof2);
221 status = m_tuple6->addItem ("tp", m_tp_btof2);
222 }
223 else {
224 log << MSG::ERROR << " Cannot book N-tuple:" << long(m_tuple6) << endmsg;
225 return StatusCode::FAILURE;
226 }
227 }
228 } // check Tof:barrel outter Tof
229
230 NTuplePtr nt8(ntupleSvc(), "FILE1/infmom");
231 if ( nt8 ) m_tuple8 = nt8;
232 else {
233 m_tuple8 = ntupleSvc()->book ("FILE1/infmom", CLID_ColumnWiseTuple, "information with momentum method");
234 if ( m_tuple8 ) {
235 status = m_tuple8->addItem ("momlepp", m_mom_lepp );
236 status = m_tuple8->addItem ("momlepmm", m_mom_lepm );
237 status = m_tuple8->addItem ("mompionm", m_mom_pionm );
238 status = m_tuple8->addItem ("mompionp", m_mom_pionp );
239 status = m_tuple8->addItem ("pipidang", m_pipi_dang );
240 status = m_tuple8->addItem ("cmslepp", m_cms_lepp );
241 status = m_tuple8->addItem ("cmslepm", m_cms_lepm );
242 status = m_tuple8->addItem ("invtwopi", m_mass_twopi );
243 status = m_tuple8->addItem ("invjpsi", m_mass_jpsi );
244 status = m_tuple8->addItem ("recoil", m_mass_recoil);
245 status = m_tuple8->addItem ("invmass", m_inv_mass );
246 status = m_tuple8->addItem ("totene", m_tot_e );
247 status = m_tuple8->addItem ("totpx", m_tot_px );
248 status = m_tuple8->addItem ("totpy", m_tot_py );
249 status = m_tuple8->addItem ("totpz", m_tot_pz );
250 status = m_tuple8->addItem ("epratio", m_ep_ratio );
251 status = m_tuple8->addItem ("eveflag", m_event_flag );
252 status = m_tuple8->addItem ("tplepratiom", m_trans_ratio_lepm );
253 status = m_tuple8->addItem ("tplepratiop", m_trans_ratio_lepp );
254 status = m_tuple8->addItem ("tppionratiom", m_trans_ratio_pionm );
255 status = m_tuple8->addItem ("tppionratiop", m_trans_ratio_pionp );
256 status = m_tuple8->addItem ("run", m_run );
257 status = m_tuple8->addItem ("event", m_event );
258 status = m_tuple8->addItem ("ntrack", m_index, 0, 4 );
259 status = m_tuple8->addIndexedItem ("costhe", m_index, m_cos_theta );
260 status = m_tuple8->addIndexedItem ("phi", m_index, m_phi );
261 status = m_tuple8->addIndexedItem ("fourmom", m_index, 4, m_four_mom);
262 status = m_tuple8->addItem ("pionmat", m_pion_matched);
263 status = m_tuple8->addItem ("lepmat", m_lep_matched);
264 //MCtruth
265 status = m_tuple8->addItem("indexmc", m_idxmc, 0, 100);
266 status = m_tuple8->addIndexedItem("pdgid", m_idxmc, m_pdgid);
267 status = m_tuple8->addIndexedItem("motheridx", m_idxmc, m_motheridx);
268 status = m_tuple8->addItem("truepp", m_true_pionp);
269 status = m_tuple8->addItem("truepm", m_true_pionm);
270 }
271 else {
272 log << MSG::ERROR << " Cannot book N-tuple:" << long(m_tuple8) << endmsg;
273 return StatusCode::FAILURE;
274 }
275 }
276
277 //
278 //--------end of book--------
279 //
280
281 log << MSG::INFO << "successfully return from initialize()" <<endmsg;
282 return StatusCode::SUCCESS;
283
284}
285
286// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
287StatusCode PipiJpsi::execute() {
288
289 //std::cout << "execute()" << std::endl;
290
291 MsgStream log(msgSvc(), name());
292 log << MSG::INFO << "in execute()" << endreq;
293 m_cout_all ++;
294 StatusCode sc=StatusCode::SUCCESS;
295 //save the events passed selection to a new file
296 setFilterPassed(false);
297
298 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
299 if(!eventHeader){
300 log << MSG::ERROR << "EventHeader not found" << endreq;
301 return StatusCode::SUCCESS;
302 }
303 int run(eventHeader->runNumber());
304 int event(eventHeader->eventNumber());
305 if(event%1000==0) cout << "run: " << run << " event: " << event << endl;
306
307 SmartDataPtr<EvtRecEvent> evtRecEvent(eventSvc(), "/Event/EvtRec/EvtRecEvent");
308 if(!evtRecEvent){
309 log << MSG::ERROR << "EvtRecEvent not found" << endreq;
310 return StatusCode::SUCCESS;
311 }
312 log << MSG::DEBUG <<"ncharg, nneu, tottks = "
313 << evtRecEvent->totalCharged() << " , "
314 << evtRecEvent->totalNeutral() << " , "
315 << evtRecEvent->totalTracks() <<endreq;
316
317 SmartDataPtr<EvtRecTrackCol> evtRecTrkCol(eventSvc(), "/Event/EvtRec/EvtRecTrackCol");
318 if(!evtRecTrkCol){
319 log << MSG::ERROR << "EvtRecTrackCol" << endreq;
320 return StatusCode::SUCCESS;
321 }
322
323 if(m_trigger_flag){
324 SmartDataPtr<TrigData> trigData(eventSvc(),EventModel::Trig::TrigData);
325 if (!trigData) {
326 log << MSG::FATAL << "Could not find Trigger Data for physics analysis" << endreq;
327 return StatusCode::FAILURE;
328 }
329 /// Print trigger information once:
330 log << MSG::DEBUG << "Trigger conditions: " << endreq;
331 for(int i=0; i < 48; i++){
332 log << MSG::DEBUG << "i:" << i << " name:" << trigData->getTrigCondName(i) << " cond:" << trigData->getTrigCondition(i) << endreq;
333 }
334 // test event rate
335 int m_trig_tot(0), m_trig_which(-1);
336 if(m_eventrate){
337 for(int j=0; j<16; j++){
338 if(trigData->getTrigChannel(j)){
339 m_trig_tot ++;
340 m_trig_which = j+1;
341 }
342 }
343 if(m_trig_tot==1 && m_trig_which==m_chan_det) m_cout_everat++;
344 return sc;
345 }
346 }
347
348 m_cout_col ++;
349 if(evtRecEvent->totalCharged()<3 || evtRecTrkCol->size()<3 || evtRecEvent->totalTracks()>99 || evtRecTrkCol->size()>99) return StatusCode::SUCCESS;
350 m_cout_charge ++;
351
352 // Asign four-momentum with KalmanTrack
353 Vint iGood; iGood.clear();
354 int m_num[4]={0,0,0,0}; // number of different particles: pi+, pi-, l+, l-
355 int nCharge = 0;
356 m_pion_matched = 0; m_lep_matched = 0;
357 HepLorentzVector m_lv_pionp, m_lv_pionm, m_lv_lepp, m_lv_lepm, m_lv_ele, m_lv_pos, m_lv_mum, m_lv_mup;
358
359 for(int i = 0; i < evtRecEvent->totalCharged(); i++){
360 EvtRecTrackIterator itTrk=evtRecTrkCol->begin() + i;
361 if(!(*itTrk)->isMdcKalTrackValid()) continue;
362 RecMdcKalTrack* mdcTrk = (*itTrk)->mdcKalTrack();
363
364 m_vx0 = mdcTrk->x();
365 m_vy0 = mdcTrk->y();
366 m_vz0 = mdcTrk->z();
367 m_vr0 = mdcTrk->r();
368 if(fabs(m_vz0) >= m_vz0cut) continue;
369 if(m_vr0 >= m_vr0cut) continue;
370 iGood.push_back(i);
371 nCharge += mdcTrk->charge();
372 if(mdcTrk->p()<1.0){ if((*itTrk)->isEmcShowerValid()) m_pion_matched ++; }
373 else{ if((*itTrk)->isEmcShowerValid()) m_lep_matched ++; }
374
375 if(mdcTrk->charge()>0){
376 if(mdcTrk->p()<1.0){
378 // Warning: for ones who do not modify the DstMdcKalTrack package, the following p4() function cannot be used, you should get momentum from MdcKalTrack, then calculate the energy by yourself
379 m_lv_pionp = mdcTrk->p4(xmass[2]);
380 m_num[0] ++;
381 }
382 else{
384 m_lv_pos = mdcTrk->p4(xmass[0]);
386 m_lv_mup = mdcTrk->p4(xmass[1]);
387 m_num[2] ++;
388 }
389 }
390 else{
391 if(mdcTrk->p()<1.0){
393 m_lv_pionm = mdcTrk->p4(xmass[2]);
394 m_num[1] ++;
395 }
396 else{
398 m_lv_ele = mdcTrk->p4(xmass[0]);
400 m_lv_mum = mdcTrk->p4(xmass[1]);
401 m_num[3] ++;
402 }
403 }
404 }
405
406 int nGood = iGood.size();
407 log << MSG::DEBUG << "With KalmanTrack, ngood, totcharge = " << nGood << " , " << nCharge << endreq;
408 if(nGood<3 || nGood>4) return sc;
409 m_cout_nGood ++;
410
411 m_ep_ratio = 0;
412 for(int i=0; i< evtRecEvent->totalTracks(); i++){
413 EvtRecTrackIterator itTrk=evtRecTrkCol->begin() + i;
414 if(!(*itTrk)->isEmcShowerValid()) continue;
415 RecEmcShower *emcTrk = (*itTrk)->emcShower();
416 m_ep_ratio += emcTrk->energy();
417 }
418
419 if(m_ep_ratio > m_distin_emuon){
420 m_lv_lepp = m_lv_pos;
421 m_lv_lepm = m_lv_ele;
422 }
423 else{
424 m_lv_lepp = m_lv_mup;
425 m_lv_lepm = m_lv_mum;
426 }
427
428 HepLorentzVector m_lv_lab(0.04,0,0,3.686);
429 if(nGood==4){
430 if(nCharge) return sc;
431 m_event_flag = 4;
432 }
433 else{
434 if(m_num[0]>1 || m_num[1]>1 || m_num[2]>1 || m_num[3]>1) return sc;
435 if(m_num[0]==0){
436 if(nCharge != -1) return StatusCode::SUCCESS;
437 m_lv_pionp = m_lv_lab - m_lv_pionm - m_lv_lepp - m_lv_lepm;
438 if(m_lv_pionp.vect().cosTheta()>m_cosThetaCut)return StatusCode::SUCCESS;
439 m_event_flag = 0;
440 }
441 if(m_num[1]==0){
442 if(nCharge != 1) return StatusCode::SUCCESS;
443 m_lv_pionm = m_lv_lab - m_lv_pionp - m_lv_lepp - m_lv_lepm;
444 if(m_lv_pionm.vect().cosTheta()>m_cosThetaCut)return StatusCode::SUCCESS;
445 m_event_flag = 1;
446 }
447 if(m_num[2]==0){
448 if(nCharge != -1) return StatusCode::SUCCESS;
449 m_lv_lepp = m_lv_lab - m_lv_pionp - m_lv_pionm - m_lv_lepm;
450 if(m_lv_lepp.vect().cosTheta()>m_cosThetaCut)return StatusCode::SUCCESS;
451 m_event_flag = 2;
452 }
453 if(m_num[3]==0){
454 if(nCharge != 1) return StatusCode::SUCCESS;
455 m_lv_lepm = m_lv_lab - m_lv_pionp - m_lv_pionm - m_lv_lepp;
456 if(m_lv_lepm.vect().cosTheta()>m_cosThetaCut)return StatusCode::SUCCESS;
457 m_event_flag = 3;
458 }
459 }
460 m_cout_mom ++;
461
462 // With momentum method calculate the invariant mass of Jpsi
463 // actually we use the recoil mass
464 HepLorentzVector m_lv_recoil, m_lv_jpsi;
465 m_lv_recoil = m_lv_lab - m_lv_pionp - m_lv_pionm;
466 m_lv_jpsi = m_lv_lepp + m_lv_lepm;
467
468 m_mass_twopi = (m_lv_pionp + m_lv_pionm).m();
469 m_mass_recoil = m_lv_recoil.m();
470 m_mass_jpsi = m_lv_jpsi.m();
471
472 // Jpsi mass cut
473 if( m_mass_recoil < 3.05 || m_mass_recoil > 3.15 ) return sc;
474 if( m_mass_jpsi < 3.0 || m_mass_jpsi > 3.2 ) return sc;
475 m_cout_recoil ++;
476
477 HepLorentzVector m_ttm(m_lv_jpsi + m_lv_pionp + m_lv_pionm);
478 if(m_ttm.m()>4 || m_ttm.m()<3) return sc;
479
480 // dangle between pions, suppress gamma convertion
481 m_pipi_dang = m_lv_pionp.vect().cosTheta(m_lv_pionm.vect());
482
483 m_mom_pionp = m_lv_pionp.vect().mag();
484 m_mom_pionm = m_lv_pionm.vect().mag();
485 m_mom_lepp = m_lv_lepp.vect().mag();
486 m_mom_lepm = m_lv_lepm.vect().mag();
487 m_trans_ratio_lepp = m_lv_lepp.vect().perp()/m_lv_lepp.vect().mag();
488 m_trans_ratio_lepm = m_lv_lepm.vect().perp()/m_lv_lepm.vect().mag();
489 m_trans_ratio_pionp = m_lv_pionp.vect().perp()/m_lv_pionp.vect().mag();
490 m_trans_ratio_pionm = m_lv_pionm.vect().perp()/m_lv_pionm.vect().mag();
491
492 Hep3Vector m_boost_jpsi(m_lv_recoil.boostVector());
493 HepLorentzVector m_lv_cms_lepp(boostOf(m_lv_lepp,-m_boost_jpsi));
494 HepLorentzVector m_lv_cms_lepm(boostOf(m_lv_lepm,-m_boost_jpsi));
495 m_cms_lepm = m_lv_cms_lepm.vect().mag();
496 m_cms_lepp = m_lv_cms_lepp.vect().mag();
497 log << MSG::DEBUG << "jpsi four momentum in cms " << m_lv_cms_lepp + m_lv_cms_lepm <<endreq;
498
499 m_inv_mass = m_ttm.m();
500 m_tot_e = m_ttm.e();
501 m_tot_px = m_ttm.px();
502 m_tot_py = m_ttm.py();
503 m_tot_pz = m_ttm.pz();
504 m_run = run;
505 m_event = event;
506 HepLorentzVector m_lv_book(0,0,0,0); // assume one track is missing
507 for(m_index=0; m_index<4; m_index++){
508 switch(m_index){
509 case 0: m_lv_book = m_lv_pionp;
510 break;
511 case 1: m_lv_book = m_lv_pionm;
512 break;
513 case 2: m_lv_book = m_lv_lepp;
514 break;
515 case 3: m_lv_book = m_lv_lepm;
516 break;
517 default: m_lv_book.setE(2008);
518 }
519 m_cos_theta[m_index] = m_lv_book.vect().cosTheta();
520 m_phi[m_index] = m_lv_book.vect().phi();
521 m_four_mom[m_index][0] = m_lv_book.e();
522 m_four_mom[m_index][1] = m_lv_book.px();
523 m_four_mom[m_index][2] = m_lv_book.py();
524 m_four_mom[m_index][3] = m_lv_book.pz();
525 }
526
527 if(m_subsample_flag) setFilterPassed(true);
528 else if(m_mass_recoil>3.08 && m_mass_recoil<3.12 && m_mass_jpsi>3.0 && m_mass_jpsi<3.2 && m_cms_lepp<1.7 && m_cms_lepp>1.4 && m_cms_lepm<1.7 && m_cms_lepm>1.4 && m_event_flag==4 && m_pipi_dang<m_pipi_dang_cut) setFilterPassed(true);
529 //cout << "passed" << endl;
530
531 //MC information
532 SmartDataPtr<Event::McParticleCol> mcParticleCol(eventSvc(), "/Event/MC/McParticleCol");
533 if(m_run<0){
534 int m_numParticle(0), m_true_pid(0);
535 if(!mcParticleCol){
536 log << MSG::ERROR << "Could not retrieve McParticelCol" << endreq;
537 return StatusCode::FAILURE;
538 }
539 else{
540 bool psipDecay(false);
541 int rootIndex(-1);
542 Event::McParticleCol::iterator iter_mc = mcParticleCol->begin();
543 for (; iter_mc != mcParticleCol->end(); iter_mc++){
544 if ((*iter_mc)->primaryParticle()) continue;
545 if (!(*iter_mc)->decayFromGenerator()) continue;
546 //if ( ((*iter_mc)->mother()).trackIndex()<3 ) continue;
547 if ((*iter_mc)->particleProperty()==100443){
548 psipDecay = true;
549 rootIndex = (*iter_mc)->trackIndex();
550 }
551 if (!psipDecay) continue;
552 int mcidx = ((*iter_mc)->mother()).trackIndex() - rootIndex;
553 int pdgid = (*iter_mc)->particleProperty();
554 m_pdgid[m_numParticle] = pdgid;
555 m_motheridx[m_numParticle] = mcidx;
556 m_numParticle ++;
557
558 //if(!(*iter_mc)->leafParticle()) continue;
559 if((*iter_mc)->particleProperty() == 211) m_true_pionp = (*iter_mc)->initialFourMomentum().vect().mag();
560 if((*iter_mc)->particleProperty() == -211) m_true_pionm = (*iter_mc)->initialFourMomentum().vect().mag();
561 }
562 m_idxmc = m_numParticle;
563 }
564 }
565
566 m_tuple1->write();
567 m_tuple8->write();
568
569
570 // next is good photon selection
571 Vint iGam; iGam.clear();
572 for(int i = evtRecEvent->totalCharged(); i< evtRecEvent->totalTracks(); i++) {
573 EvtRecTrackIterator itTrk=evtRecTrkCol->begin() + i;
574 if(!(*itTrk)->isEmcShowerValid()) continue;
575 RecEmcShower *emcTrk = (*itTrk)->emcShower();
576 Hep3Vector emcpos(emcTrk->x(), emcTrk->y(), emcTrk->z());
577 // find the nearest charged track
578 double dthe = 200.;
579 double dphi = 200.;
580 double dang = 200.;
581 for(int j = 0; j < evtRecEvent->totalCharged(); j++) {
582 EvtRecTrackIterator jtTrk = evtRecTrkCol->begin() + j;
583 if(!(*jtTrk)->isExtTrackValid()) continue;
584 RecExtTrack *extTrk = (*jtTrk)->extTrack();
585 if(extTrk->emcVolumeNumber() == -1) continue;
586 Hep3Vector extpos = extTrk->emcPosition();
587 // double ctht = extpos.cosTheta(emcpos);
588 double angd = extpos.angle(emcpos);
589 double thed = extpos.theta() - emcpos.theta();
590 double phid = extpos.deltaPhi(emcpos);
591 thed = fmod(thed+CLHEP::twopi+CLHEP::twopi+pi, CLHEP::twopi) - CLHEP::pi;
592 phid = fmod(phid+CLHEP::twopi+CLHEP::twopi+pi, CLHEP::twopi) - CLHEP::pi;
593
594 if(fabs(thed) < fabs(dthe)) dthe = thed;
595 if(fabs(phid) < fabs(dphi)) dphi = phid;
596 if(angd < dang) dang = angd;
597 }
598 if(dang>=200) continue;
599 double eraw = emcTrk->energy();
600 dthe = dthe * 180 / (CLHEP::pi);
601 dphi = dphi * 180 / (CLHEP::pi);
602 dang = dang * 180 / (CLHEP::pi);
603 m_dthe = dthe;
604 m_dphi = dphi;
605 m_dang = dang;
606 m_eraw = eraw;
607 // if(eraw < m_energyThreshold) continue;
608 // if((fabs(dthe) < m_gammaThetaCut) && (fabs(dphi)<m_gammaPhiCut) ) continue;
609 // good photon cut will be set here
610 iGam.push_back((*itTrk)->trackId());
611 }
612 // Finish Good Photon Selection
613 m_nGam = iGam.size();
614 log << MSG::DEBUG << "num Good Photon " << m_nGam << " , " <<evtRecEvent->totalNeutral()<<endreq;
615 m_tuple2->write();
616
617 //
618 // check dedx infomation
619 //
620 if(m_checkDedx) {
621 int m_dedx_cout(0);
622 for(int i = 0; i < nGood; i++) {
623 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + iGood[i];
624 if(!(*itTrk)->isMdcDedxValid())continue;
625 RecMdcKalTrack *mdcTrk = (*itTrk)->mdcKalTrack();
626 RecMdcDedx *dedxTrk = (*itTrk)->mdcDedx();
627
628 m_ptrk = mdcTrk->p();
629 m_chie = dedxTrk->chiE();
630 m_chimu = dedxTrk->chiMu();
631 m_chipi = dedxTrk->chiPi();
632 m_chik = dedxTrk->chiK();
633 m_chip = dedxTrk->chiP();
634 m_ghit = dedxTrk->numGoodHits();
635 m_thit = dedxTrk->numTotalHits();
636 m_probPH = dedxTrk->probPH();
637 m_normPH = dedxTrk->normPH();
638
639 m_tuple3->write();
640 }
641 }
642
643 //
644 // check TOF infomation
645 //
646 if(m_checkTof) {
647 int m_endcap_cout(0), m_layer1_cout(0), m_layer2_cout(0);
648 for(int i = 0; i < nGood; i++) {
649 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + iGood[i];
650 if(!(*itTrk)->isTofTrackValid()) continue;
651
652 RecMdcKalTrack *mdcTrk = (*itTrk)->mdcKalTrack();
653 SmartRefVector<RecTofTrack> tofTrkCol = (*itTrk)->tofTrack();
654
655 double ptrk = mdcTrk->p();
656
657 for( SmartRefVector<RecTofTrack>::iterator iter_tof = tofTrkCol.begin() ;iter_tof != tofTrkCol.end(); iter_tof++ ) {
658 TofHitStatus *status = new TofHitStatus;
659 status->setStatus((*iter_tof)->status());
660 if(!(status->is_barrel())){//endcap
661 if( !(status->is_counter()) ) continue; // ?
662 if( status->layer()!=0 ) continue;//layer1
663 double path = (*iter_tof)->path(); // ? the unit is cm
664 double tof = (*iter_tof)->tof(); // the unit is ns/100
665 double ph = (*iter_tof)->ph();
666 double rhit = (*iter_tof)->zrhit();
667 double qual = 0.0 + (*iter_tof)->quality();
668 double cntr = 0.0 + (*iter_tof)->tofID();
669 double texp[5];
670 for(int j = 0; j < 5; j++) {
671 double gb = xmass[j]/ptrk;
672 double beta = sqrt(1+gb*gb);
673 texp[j] = path*beta/velc; // the unit here is ns
674 }
675 m_cntr_etof = cntr;
676 m_ptot_etof = ptrk;
677 m_path_etof = path;
678 m_ph_etof = ph;
679 m_rhit_etof = rhit;
680 m_qual_etof = qual;
681 m_tof_etof = tof;
682 m_te_etof = tof - texp[0];
683 m_tmu_etof = tof - texp[1];
684 m_tpi_etof = tof - texp[2];
685 m_tk_etof = tof - texp[3];
686 m_tp_etof = tof - texp[4];
687
688 m_tuple4->write();
689 }
690 else {//barrel
691 if( !(status->is_counter()) ) continue; // ?
692 if(status->layer()==1){ //layer1
693 double path=(*iter_tof)->path(); // ?
694 double tof = (*iter_tof)->tof();
695 double ph = (*iter_tof)->ph();
696 double rhit = (*iter_tof)->zrhit();
697 double qual = 0.0 + (*iter_tof)->quality();
698 double cntr = 0.0 + (*iter_tof)->tofID();
699 double texp[5];
700 for(int j = 0; j < 5; j++) {
701 double gb = xmass[j]/ptrk;
702 double beta = sqrt(1+gb*gb);
703 texp[j] = path*beta/velc;
704 }
705
706 m_cntr_btof1 = cntr;
707 m_ptot_btof1 = ptrk;
708 m_path_btof1 = path;
709 m_ph_btof1 = ph;
710 m_zhit_btof1 = rhit;
711 m_qual_btof1 = qual;
712 m_tof_btof1 = tof;
713 m_te_btof1 = tof - texp[0];
714 m_tmu_btof1 = tof - texp[1];
715 m_tpi_btof1 = tof - texp[2];
716 m_tk_btof1 = tof - texp[3];
717 m_tp_btof1 = tof - texp[4];
718
719 m_tuple5->write();
720 }
721
722 if(status->layer()==2){//layer2
723 double path=(*iter_tof)->path(); // ?
724 double tof = (*iter_tof)->tof();
725 double ph = (*iter_tof)->ph();
726 double rhit = (*iter_tof)->zrhit();
727 double qual = 0.0 + (*iter_tof)->quality();
728 double cntr = 0.0 + (*iter_tof)->tofID();
729 double texp[5];
730 for(int j = 0; j < 5; j++) {
731 double gb = xmass[j]/ptrk;
732 double beta = sqrt(1+gb*gb);
733 texp[j] = path*beta/velc;
734 }
735
736 m_cntr_btof2 = cntr;
737 m_ptot_btof2 = ptrk;
738 m_path_btof2 = path;
739 m_ph_btof2 = ph;
740 m_zhit_btof2 = rhit;
741 m_qual_btof2 = qual;
742 m_tof_btof2 = tof;
743 m_te_btof2 = tof - texp[0];
744 m_tmu_btof2 = tof - texp[1];
745 m_tpi_btof2 = tof - texp[2];
746 m_tk_btof2 = tof - texp[3];
747 m_tp_btof2 = tof - texp[4];
748
749 m_tuple6->write();
750 }
751 }
752
753 delete status;
754 }
755 } // loop all charged track
756 } // check tof
757
758
759 return StatusCode::SUCCESS;
760}
761
762// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
763StatusCode PipiJpsi::finalize() {
764
765 MsgStream log(msgSvc(), name());
766 log << MSG::INFO << "in finalize()" << endmsg;
767 if(m_eventrate) cout << "all event: " << m_cout_all << endl << "only channel " << m_chan_det << ": " << m_cout_everat << endl;
768 cout << "all event: " << m_cout_all << endl << "all collection point is OK: " << m_cout_col << endl << "charged tracks >=3: " << m_cout_charge << endl << "good charged tracks [3,4]: " << m_cout_nGood << endl << "after momentum assign: " << m_cout_mom << endl << "after recoild mass cut: " << m_cout_recoil << endl;
769 return StatusCode::SUCCESS;
770}
771
772
const double xmass[5]
Definition: Gam4pikp.cxx:50
const double velc
Definition: Gam4pikp.cxx:51
std::vector< int > Vint
Definition: Gam4pikp.cxx:52
static long m_cout_col(0)
HepGeom::Point3D< double > HepPoint3D
Definition: PipiJpsi.cxx:34
const double mpsip
Definition: PipiJpsi.cxx:52
const double mproton
Definition: PipiJpsi.cxx:50
const double mmu
Definition: PipiJpsi.cxx:51
std::vector< HepLorentzVector > Vp4
Definition: PipiJpsi.cxx:58
const double xmass[5]
Definition: PipiJpsi.cxx:53
static long m_cout_everat(0)
const double me
Definition: PipiJpsi.cxx:48
const double velc
Definition: PipiJpsi.cxx:54
const double PI
Definition: PipiJpsi.cxx:55
static long m_cout_charge(0)
static long m_cout_nGood(0)
const double mpi
Definition: PipiJpsi.cxx:49
std::vector< int > Vint
Definition: PipiJpsi.cxx:57
static long m_cout_recoil(0)
static long m_cout_mom(0)
const HepLorentzVector p4() const
StatusCode finalize()
Definition: PipiJpsi.cxx:763
StatusCode execute()
Definition: PipiJpsi.cxx:287
PipiJpsi(const std::string &name, ISvcLocator *pSvcLocator)
Definition: PipiJpsi.cxx:64
StatusCode initialize()
Definition: PipiJpsi.cxx:84
void setStatus(unsigned int status)