BOSS 7.0.4
BESIII Offline Software System
Loading...
Searching...
No Matches
LumTau.cxx
Go to the documentation of this file.
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"
10
11#include "EventModel/EventModel.h"
12#include "EventModel/Event.h"
13#include "EventModel/EventHeader.h"
14#include "McTruth/McParticle.h"
15
16#include "EvtRecEvent/EvtRecEvent.h"
17#include "EvtRecEvent/EvtRecTrack.h"
18#include "DstEvent/TofHitStatus.h"
19#include "EvTimeEvent/RecEsTime.h"
20#include "EventModel/EventHeader.h"
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/KalmanKinematicFit.h"
38#include "VertexFit/VertexFit.h"
39#include "VertexFit/Helix.h"
40#include "VertexFit/SecondVertexFit.h"
41#include "ParticleID/ParticleID.h"
42#include "LumTauAlg/LumTau.h"
43#include <vector>
44typedef std::vector<int> Vint;
45typedef std::vector<HepLorentzVector> Vp4;
46const double ecms = 3.097;
47const double velc = 299.792458;
48const double xmass[5] =
49{
50 0.000511, 0.105658, 0.139570, 0.493677, 0.938272
51};
52const double pai=3.1415926;
53////////////////////////////////////////////////////////////////////
54LumTau::LumTau(const std::string& name, ISvcLocator* pSvcLocator) :
55 Algorithm(name, pSvcLocator)
56{
57}
58
59// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
61{
62 MsgStream log(msgSvc(), name());
63
64 log << MSG::INFO << "in initialize()" << endmsg;
65
66 StatusCode status;
67
68 NTuplePtr nt2(ntupleSvc(), "LumTau/event");
69 if ( nt2 ) m_tuple2 = nt2;
70 else
71 {
72 m_tuple2 = ntupleSvc()->book ("LumTau/event", CLID_ColumnWiseTuple, "Bhabha N-Tuple signal");
73 if ( m_tuple2 )
74 {
75 status = m_tuple2->addItem ("run", m_run);
76 status = m_tuple2->addItem ("rec", m_rec);
77 status = m_tuple2->addItem ("time", m_time);
78 status = m_tuple2->addItem ("etot", m_etot);
79 status = m_tuple2->addItem ("e1", m_e1);
80 status = m_tuple2->addItem ("e2", m_e2);
81 status = m_tuple2->addItem ("costht1", m_costht1);
82 status = m_tuple2->addItem ("costht2", m_costht2);
83 status = m_tuple2->addItem ("dltphi", m_dltphi);
84 status = m_tuple2->addItem ("dlttht", m_dlttht);
85 status = m_tuple2->addItem ("phi1", m_phi1);
86 status = m_tuple2->addItem ("phi2", m_phi2);
87 }
88 else
89 {
90 log << MSG::ERROR << "Cannot book N-tuple2:"<<long(m_tuple2)<<endmsg;
91 return StatusCode::FAILURE;
92 }
93 }
94 return StatusCode::SUCCESS;
95}
96//*************************************************
97StatusCode LumTau::execute()
98{
99 StatusCode sc=StatusCode::SUCCESS;
100
101 MsgStream log(msgSvc(),name());
102 log<<MSG::INFO<<"in execute()"<<endreq;
103
104 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
105 SmartDataPtr<EvtRecEvent> evtRecEvent(eventSvc(), EventModel::EvtRec::EvtRecEvent);
106
107 log<<MSG::DEBUG<<"ncharg, nneu, tottks = "<<evtRecEvent->totalCharged()<<" , "<<evtRecEvent->totalNeutral()<<" , "<<evtRecEvent->totalTracks()<<endreq;
108 SmartDataPtr<EvtRecTrackCol> evtRecTrkCol(eventSvc(),EventModel::EvtRec::EvtRecTrackCol);
109
110 log<<MSG::DEBUG <<"ncharg, nneu, tottks = "<<evtRecEvent->totalCharged()<<" , "<<evtRecEvent->totalNeutral()<<" , "<<evtRecEvent->totalTracks()<<endreq;
111 SmartDataPtr<RecEsTimeCol> evTimeCol(eventSvc(),"/Event/Recon/RecEsTimeCol");
112
113 double time = eventHeader->time();
114 m_time = time;
115
116 m_run = eventHeader->runNumber();
117 m_rec = eventHeader->eventNumber();
118
119 if(m_rec%1000==0)cout<<"Run "<<m_run<<" Event "<<m_rec<<endl;
120
121 double Emax1 = -1;
122 double Emax2 = -1;
123 int Imax[2];
124
125 if((evtRecEvent->totalTracks() >= 2)){
126 double etot = 0.;
127 for(int i = 0;i < evtRecEvent->totalTracks(); i++)
128 {
129 if(i>=evtRecTrkCol->size()) break;
130 EvtRecTrackIterator itTrk=evtRecTrkCol->begin() + i;
131 if(!(*itTrk)->isEmcShowerValid()) continue;
132 RecEmcShower *emcTrk = (*itTrk)->emcShower();
133 double Ener=emcTrk->energy();
134 if(Ener>Emax2)
135 {
136 Emax2=Ener;
137 Imax[1]=i;
138 }
139 if(Ener>Emax1)
140 {
141 Emax2=Emax1;
142 Imax[1]=Imax[0];
143 Emax1=Ener;
144 Imax[0]=i;
145 }
146 etot += Ener;
147 }
148
149 m_etot = etot;
150 m_e1 = Emax1;
151 m_e2 = Emax2;
152
153 log << MSG::INFO << "Emax1 = " << Emax1 <<"Emax2= "<<Emax2<< endreq;
154 if(Emax1 > 0 && Emax2 > 0){
155 double emcphi[2],emctht[2];
156 for(int i = 0;i < 2; i++)
157 {
158 if(i>=evtRecTrkCol->size()) break;
159 EvtRecTrackIterator itTrk=evtRecTrkCol->begin() + Imax[i];
160 if(!(*itTrk)->isEmcShowerValid()) continue;
161 RecEmcShower *emcTrk = (*itTrk)->emcShower();
162 emcphi[i]=emcTrk->phi();
163 emctht[i]=emcTrk->theta();
164 }
165
166 double dltphi=(fabs(emcphi[0]-emcphi[1])-pai)*180./pai;
167 double dlttht=(fabs(emctht[0]+emctht[1])-pai)*180./pai;
168 m_costht1=cos(emctht[0]);
169 m_costht2=cos(emctht[1]);
170 m_phi1=emcphi[0];
171 m_phi2=emcphi[1];
172 m_dlttht=dlttht;
173 m_dltphi=dltphi;
174 }
175 else{
176 m_etot = -1;
177 m_e1 = -1;
178 m_e2 = -1;
179 m_costht1 = -1;
180 m_costht2 = -1;
181 m_phi1 = -1;
182 m_phi2 = -1;
183 m_dlttht = -1;
184 m_dltphi = -1;
185 }
186 }
187 else{
188 m_etot = -1;
189 m_e1 = -1;
190 m_e2 = -1;
191 m_costht1 = -1;
192 m_costht2 = -1;
193 m_phi1 = -1;
194 m_phi2 = -1;
195 m_dlttht = -1;
196 m_dltphi = -1;
197 }
198
199// m_tuple2->write();
200
201 int DiskWrite = m_tuple2->write();
202 if(DiskWrite != 1){
203 log<<MSG::FATAL<<"ERROR In LumTau DiskWrite!"<<endreq;
204 exit(1);
205 }
206
207 return StatusCode::SUCCESS;
208}
209
210StatusCode LumTau::finalize()
211{
212 cout<<"Event Finalize"<<endl;
213 return StatusCode::SUCCESS;
214}
215
const double pai
Definition: BbEmc.cxx:48
Double_t etot
Double_t dltphi
Double_t time
double cos(const BesAngle a)
HepGeom::Point3D< double > HepPoint3D
Definition: LumTau.cxx:34
std::vector< HepLorentzVector > Vp4
Definition: LumTau.cxx:45
const double xmass[5]
Definition: LumTau.cxx:48
const double pai
Definition: LumTau.cxx:52
const double velc
Definition: LumTau.cxx:47
const double ecms
Definition: LumTau.cxx:46
std::vector< int > Vint
Definition: LumTau.cxx:44
StatusCode execute()
Definition: LumTau.cxx:97
StatusCode finalize()
Definition: LumTau.cxx:210
StatusCode initialize()
Definition: LumTau.cxx:60
LumTau(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LumTau.cxx:54