BOSS 7.0.6
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"
8#include "GaudiKernel/Bootstrap.h"
9#include "GaudiKernel/ISvcLocator.h"
10
12#include "EventModel/Event.h"
14#include "McTruth/McParticle.h"
15
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
38#include "VertexFit/VertexFit.h"
39#include "VertexFit/Helix.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 status = service("InjSigIntervalSvc", m_intervalSvc);
69 if ( status != StatusCode::SUCCESS ){
70 log << MSG::FATAL << "can not use InjSigIntervalSvc" << endreq;
71 }
72
73 NTuplePtr nt2(ntupleSvc(), "LumTau/event");
74 if ( nt2 ) m_tuple2 = nt2;
75 else
76 {
77 m_tuple2 = ntupleSvc()->book ("LumTau/event", CLID_ColumnWiseTuple, "Bhabha N-Tuple signal");
78 if ( m_tuple2 )
79 {
80 status = m_tuple2->addItem ("topup", m_topup);
81 status = m_tuple2->addItem ("run", m_run);
82 status = m_tuple2->addItem ("rec", m_rec);
83 status = m_tuple2->addItem ("time", m_time);
84 status = m_tuple2->addItem ("etot", m_etot);
85 status = m_tuple2->addItem ("e1", m_e1);
86 status = m_tuple2->addItem ("e2", m_e2);
87 status = m_tuple2->addItem ("costht1", m_costht1);
88 status = m_tuple2->addItem ("costht2", m_costht2);
89 status = m_tuple2->addItem ("dltphi", m_dltphi);
90 status = m_tuple2->addItem ("dlttht", m_dlttht);
91 status = m_tuple2->addItem ("phi1", m_phi1);
92 status = m_tuple2->addItem ("phi2", m_phi2);
93 }
94 else
95 {
96 log << MSG::ERROR << "Cannot book N-tuple2:"<<long(m_tuple2)<<endmsg;
97 return StatusCode::FAILURE;
98 }
99 }
100 return StatusCode::SUCCESS;
101}
102//*************************************************
103StatusCode LumTau::execute()
104{
105 StatusCode sc=StatusCode::SUCCESS;
106
107 MsgStream log(msgSvc(),name());
108 log<<MSG::INFO<<"in execute()"<<endreq;
109
110 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
111 SmartDataPtr<EvtRecEvent> evtRecEvent(eventSvc(), EventModel::EvtRec::EvtRecEvent);
112
113 log<<MSG::DEBUG<<"ncharg, nneu, tottks = "<<evtRecEvent->totalCharged()<<" , "<<evtRecEvent->totalNeutral()<<" , "<<evtRecEvent->totalTracks()<<endreq;
114 SmartDataPtr<EvtRecTrackCol> evtRecTrkCol(eventSvc(),EventModel::EvtRec::EvtRecTrackCol);
115
116 log<<MSG::DEBUG <<"ncharg, nneu, tottks = "<<evtRecEvent->totalCharged()<<" , "<<evtRecEvent->totalNeutral()<<" , "<<evtRecEvent->totalTracks()<<endreq;
117 SmartDataPtr<RecEsTimeCol> evTimeCol(eventSvc(),"/Event/Recon/RecEsTimeCol");
118
119 int interval = m_intervalSvc->getTInterval();
120 log<<MSG::DEBUG << "interval = " << interval << endreq;
121 m_topup = false;
122 if ( interval < 100 ) { // top-up mode
123 m_topup = true;
124 }
125
126 double time = eventHeader->time();
127 log << MSG::DEBUG << "time = " << time << endreq;
128 m_time = time;
129
130 m_run = eventHeader->runNumber();
131 m_rec = eventHeader->eventNumber();
132
133 if(m_rec%1000==0)cout<<"Run "<<m_run<<" Event "<<m_rec<<endl;
134
135 double Emax1 = -1;
136 double Emax2 = -1;
137 int Imax[2];
138
139 if((evtRecEvent->totalTracks() >= 2)){
140 double etot = 0.;
141 for(int i = 0;i < evtRecEvent->totalTracks(); i++)
142 {
143 if(i>=evtRecTrkCol->size()) break;
144 EvtRecTrackIterator itTrk=evtRecTrkCol->begin() + i;
145 if(!(*itTrk)->isEmcShowerValid()) continue;
146 RecEmcShower *emcTrk = (*itTrk)->emcShower();
147 double Ener=emcTrk->energy();
148 if(Ener>Emax2)
149 {
150 Emax2=Ener;
151 Imax[1]=i;
152 }
153 if(Ener>Emax1)
154 {
155 Emax2=Emax1;
156 Imax[1]=Imax[0];
157 Emax1=Ener;
158 Imax[0]=i;
159 }
160 etot += Ener;
161 }
162
163 m_etot = etot;
164 m_e1 = Emax1;
165 m_e2 = Emax2;
166
167 log << MSG::INFO << "Emax1 = " << Emax1 <<"Emax2= "<<Emax2<< endreq;
168 if(Emax1 > 0 && Emax2 > 0){
169 double emcphi[2],emctht[2];
170 for(int i = 0;i < 2; i++)
171 {
172 if(i>=evtRecTrkCol->size()) break;
173 EvtRecTrackIterator itTrk=evtRecTrkCol->begin() + Imax[i];
174 if(!(*itTrk)->isEmcShowerValid()) continue;
175 RecEmcShower *emcTrk = (*itTrk)->emcShower();
176 emcphi[i]=emcTrk->phi();
177 emctht[i]=emcTrk->theta();
178 }
179
180 double dltphi=(fabs(emcphi[0]-emcphi[1])-pai)*180./pai;
181 double dlttht=(fabs(emctht[0]+emctht[1])-pai)*180./pai;
182 m_costht1=cos(emctht[0]);
183 m_costht2=cos(emctht[1]);
184 m_phi1=emcphi[0];
185 m_phi2=emcphi[1];
186 m_dlttht=dlttht;
187 m_dltphi=dltphi;
188 }
189 else{
190 m_etot = -1;
191 m_e1 = -1;
192 m_e2 = -1;
193 m_costht1 = -1;
194 m_costht2 = -1;
195 m_phi1 = -1;
196 m_phi2 = -1;
197 m_dlttht = -1;
198 m_dltphi = -1;
199 }
200 }
201 else{
202 m_etot = -1;
203 m_e1 = -1;
204 m_e2 = -1;
205 m_costht1 = -1;
206 m_costht2 = -1;
207 m_phi1 = -1;
208 m_phi2 = -1;
209 m_dlttht = -1;
210 m_dltphi = -1;
211 }
212
213// m_tuple2->write();
214
215 int DiskWrite = m_tuple2->write();
216 if(DiskWrite != 1){
217 log<<MSG::FATAL<<"ERROR In LumTau DiskWrite!"<<endreq;
218 exit(1);
219 }
220
221 return StatusCode::SUCCESS;
222}
223
224StatusCode LumTau::finalize()
225{
226 cout<<"Event Finalize"<<endl;
227 return StatusCode::SUCCESS;
228}
229
const double pai
Definition: BbEmc.cxx:48
double cos(const BesAngle a)
Definition: BesAngle.h:213
EvtRecTrackCol::iterator EvtRecTrackIterator
Definition: EvtRecTrack.h:111
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
INTupleSvc * ntupleSvc()
IMessageSvc * msgSvc()
double theta() const
Definition: DstEmcShower.h:38
double phi() const
Definition: DstEmcShower.h:39
double energy() const
Definition: DstEmcShower.h:45
virtual int getTInterval() const =0
StatusCode execute()
Definition: LumTau.cxx:103
StatusCode finalize()
Definition: LumTau.cxx:224
StatusCode initialize()
Definition: LumTau.cxx:60
LumTau(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LumTau.cxx:54
_EXTERN_ std::string EvtRecEvent
Definition: EventModel.h:116
_EXTERN_ std::string EvtRecTrackCol
Definition: EventModel.h:117