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