BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
LumTau.cxx
Go to the documentation of this file.
1#include "GaudiKernel/Bootstrap.h"
2#include "GaudiKernel/IDataProviderSvc.h"
3#include "GaudiKernel/ISvcLocator.h"
4#include "GaudiKernel/MsgStream.h"
5#include "GaudiKernel/PropertyMgr.h"
6#include "GaudiKernel/SmartDataPtr.h"
7// #include "VertexFit/IVertexDbSvc.h"
8
9#include "EventModel/Event.h"
10#include "EventModel/EventHeader.h"
11#include "EventModel/EventModel.h"
12// #include "McTruth/McParticle.h"
13
14// #include "CLHEP/Vector/LorentzVector.h"
15// #include "CLHEP/Vector/ThreeVector.h"
16// #include "CLHEP/Vector/TwoVector.h"
17// #include "DstEvent/TofHitStatus.h"
18#include "EvTimeEvent/RecEsTime.h"
19#include "EventModel/EventHeader.h"
20#include "EvtRecEvent/EvtRecEvent.h"
21#include "EvtRecEvent/EvtRecTrack.h"
22// #include "GaudiKernel/Bootstrap.h"
23// #include "GaudiKernel/IHistogramSvc.h"
24// #include "GaudiKernel/INTupleSvc.h"
25// #include "GaudiKernel/NTuple.h"
26// #include "TMath.h"
27// using CLHEP::Hep2Vector;
28// using CLHEP::Hep3Vector;
29// using CLHEP::HepLorentzVector;
30// #include "CLHEP/Geometry/Point3D.h"
31// #ifndef ENABLE_BACKWARDS_COMPATIBILITY
32// typedef HepGeom::Point3D<double> HepPoint3D;
33// #endif
34#include "LumTau.h"
35// #include "ParticleID/ParticleID.h"
36// #include "VertexFit/Helix.h"
37// #include "VertexFit/KalmanKinematicFit.h"
38// #include "VertexFit/KinematicFit.h"
39// #include "VertexFit/SecondVertexFit.h"
40// #include "VertexFit/VertexFit.h"
41// #include <vector>
42// typedef std::vector<int> Vint;
43// typedef std::vector<HepLorentzVector> Vp4;
44// const double ecms = 3.097;
45// const double velc = 299.792458;
46// const double xmass[5] = { 0.000511, 0.105658, 0.139570, 0.493677, 0.938272 };
47const double pai = 3.1415926;
48////////////////////////////////////////////////////////////////////
50LumTau::LumTau( const std::string& name, ISvcLocator* pSvcLocator )
51 : Algorithm( name, pSvcLocator ) {}
52
53// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
54StatusCode LumTau::initialize() {
55 MsgStream log( msgSvc(), name() );
56
57 log << MSG::INFO << "in initialize()" << endmsg;
58
59 StatusCode status;
60
61 status = service( "InjSigIntervalSvc", m_intervalSvc );
62 if ( status != StatusCode::SUCCESS )
63 { log << MSG::FATAL << "can not use InjSigIntervalSvc" << endmsg; }
64
65 NTuplePtr nt2( ntupleSvc(), "LumTau/event" );
66 if ( nt2 ) m_tuple2 = nt2;
67 else
68 {
69 m_tuple2 =
70 ntupleSvc()->book( "LumTau/event", CLID_ColumnWiseTuple, "Bhabha N-Tuple signal" );
71 if ( m_tuple2 )
72 {
73 status = m_tuple2->addItem( "topup", m_topup );
74 status = m_tuple2->addItem( "run", m_run );
75 status = m_tuple2->addItem( "rec", m_rec );
76 status = m_tuple2->addItem( "time", m_time );
77 status = m_tuple2->addItem( "etsT1", m_etsT1 );
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 StatusCode sc = StatusCode::SUCCESS;
99
100 MsgStream log( msgSvc(), name() );
101 log << MSG::INFO << "in execute()" << endmsg;
102
103 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(), "/Event/EventHeader" );
104 SmartDataPtr<EvtRecEvent> evtRecEvent( eventSvc(), EventModel::EvtRec::EvtRecEvent );
105
106 log << MSG::DEBUG << "ncharg, nneu, tottks = " << evtRecEvent->totalCharged() << " , "
107 << evtRecEvent->totalNeutral() << " , " << evtRecEvent->totalTracks() << endmsg;
108 SmartDataPtr<EvtRecTrackCol> evtRecTrkCol( eventSvc(), EventModel::EvtRec::EvtRecTrackCol );
109
110 log << MSG::DEBUG << "ncharg, nneu, tottks = " << evtRecEvent->totalCharged() << " , "
111 << evtRecEvent->totalNeutral() << " , " << evtRecEvent->totalTracks() << endmsg;
112 SmartDataPtr<RecEsTimeCol> evTimeCol( eventSvc(), "/Event/Recon/RecEsTimeCol" );
113
114 int interval = 200;
115 interval = m_intervalSvc->getTInterval();
116 log << MSG::DEBUG << "interval = " << interval << endmsg;
117 m_topup = false;
118 if ( interval <= 0 )
119 {
120 log << MSG::FATAL << "error in reading the interval!" << endmsg;
121 return StatusCode::FAILURE;
122 }
123 else if ( interval < 100 )
124 { // top-up mode
125 m_topup = true;
126 }
127
128 double time = eventHeader->time();
129 log << MSG::DEBUG << "time = " << time << endmsg;
130 if ( time <= 0 ) return StatusCode::SUCCESS;
131 m_time = time;
132 m_etsT1 = eventHeader->etsT1() / 2000000.; // convert to second
133 log << MSG::DEBUG << "ets time = " << m_etsT1 << endmsg;
134
135 m_run = eventHeader->runNumber();
136 m_rec = eventHeader->eventNumber();
137
138 if ( m_rec % 1000 == 0 )
139 log << MSG::INFO << "Run " << m_run << " Event " << m_rec << endmsg;
140
141 double Emax1 = -1;
142 double Emax2 = -1;
143 int Imax[2];
144
145 if ( ( evtRecEvent->totalTracks() >= 2 ) )
146 {
147 double etot = 0.;
148 for ( int i = 0; i < evtRecEvent->totalTracks(); i++ )
149 {
150 if ( i >= evtRecTrkCol->size() ) break;
151 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + i;
152 if ( !( *itTrk )->isEmcShowerValid() ) continue;
153 RecEmcShower* emcTrk = ( *itTrk )->emcShower();
154 double Ener = emcTrk->energy();
155 if ( Ener > Emax2 )
156 {
157 Emax2 = Ener;
158 Imax[1] = i;
159 }
160 if ( Ener > Emax1 )
161 {
162 Emax2 = Emax1;
163 Imax[1] = Imax[0];
164 Emax1 = Ener;
165 Imax[0] = i;
166 }
167 etot += Ener;
168 }
169
170 m_etot = etot;
171 m_e1 = Emax1;
172 m_e2 = Emax2;
173
174 log << MSG::INFO << "Emax1 = " << Emax1 << "Emax2= " << Emax2 << endmsg;
175 if ( Emax1 > 0 && Emax2 > 0 )
176 {
177 double emcphi[2], emctht[2];
178 for ( int i = 0; i < 2; i++ )
179 {
180 if ( i >= evtRecTrkCol->size() ) break;
181 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + Imax[i];
182 if ( !( *itTrk )->isEmcShowerValid() ) continue;
183 RecEmcShower* emcTrk = ( *itTrk )->emcShower();
184 emcphi[i] = emcTrk->phi();
185 emctht[i] = emcTrk->theta();
186 }
187
188 double dltphi = ( fabs( emcphi[0] - emcphi[1] ) - pai ) * 180. / pai;
189 double dlttht = ( fabs( emctht[0] + emctht[1] ) - pai ) * 180. / pai;
190 m_costht1 = cos( emctht[0] );
191 m_costht2 = cos( emctht[1] );
192 m_phi1 = emcphi[0];
193 m_phi2 = emcphi[1];
194 m_dlttht = dlttht;
195 m_dltphi = dltphi;
196 }
197 else
198 {
199 m_etot = -1;
200 m_e1 = -1;
201 m_e2 = -1;
202 m_costht1 = -1;
203 m_costht2 = -1;
204 m_phi1 = -1;
205 m_phi2 = -1;
206 m_dlttht = -1;
207 m_dltphi = -1;
208 }
209 }
210 else
211 {
212 m_etot = -1;
213 m_e1 = -1;
214 m_e2 = -1;
215 m_costht1 = -1;
216 m_costht2 = -1;
217 m_phi1 = -1;
218 m_phi2 = -1;
219 m_dlttht = -1;
220 m_dltphi = -1;
221 }
222
223 // m_tuple2->write();
224
225 StatusCode DiskWrite = m_tuple2->write();
226 if ( DiskWrite != StatusCode::SUCCESS )
227 {
228 log << MSG::FATAL << "ERROR In LumTau DiskWrite!" << endmsg;
229 exit( 1 );
230 }
231
232 return StatusCode::SUCCESS;
233}
234
235StatusCode LumTau::finalize() {
236 MsgStream log( msgSvc(), name() );
237 log << MSG::INFO << "Event Finalize" << endmsg;
238 return StatusCode::SUCCESS;
239}
const double pai
Definition BbEmc.cxx:47
DECLARE_COMPONENT(BesBdkRc)
Double_t etot
Double_t dltphi
Double_t time
EvtRecTrackCol::iterator EvtRecTrackIterator
INTupleSvc * ntupleSvc()
IMessageSvc * msgSvc()
Definition LumTau.h:9
StatusCode execute()
Definition LumTau.cxx:97
StatusCode finalize()
Definition LumTau.cxx:235
StatusCode initialize()
Definition LumTau.cxx:54
LumTau(const std::string &name, ISvcLocator *pSvcLocator)
Definition LumTau.cxx:50