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"
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
44typedef std::vector<int>
Vint;
45typedef std::vector<HepLorentzVector>
Vp4;
47const double velc = 299.792458;
50 0.000511, 0.105658, 0.139570, 0.493677, 0.938272
52const double pai=3.1415926;
55 Algorithm(name, pSvcLocator)
62 MsgStream log(
msgSvc(), name());
64 log << MSG::INFO <<
"in initialize()" << endmsg;
68 status = service(
"InjSigIntervalSvc", m_intervalSvc);
69 if ( status != StatusCode::SUCCESS ){
70 log << MSG::FATAL <<
"can not use InjSigIntervalSvc" << endreq;
73 NTuplePtr nt2(
ntupleSvc(),
"LumTau/event");
74 if ( nt2 ) m_tuple2 = nt2;
77 m_tuple2 =
ntupleSvc()->book (
"LumTau/event", CLID_ColumnWiseTuple,
"Bhabha N-Tuple signal");
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 (
"etsT1", m_etsT1);
85 status = m_tuple2->addItem (
"etot", m_etot);
86 status = m_tuple2->addItem (
"e1", m_e1);
87 status = m_tuple2->addItem (
"e2", m_e2);
88 status = m_tuple2->addItem (
"costht1", m_costht1);
89 status = m_tuple2->addItem (
"costht2", m_costht2);
90 status = m_tuple2->addItem (
"dltphi", m_dltphi);
91 status = m_tuple2->addItem (
"dlttht", m_dlttht);
92 status = m_tuple2->addItem (
"phi1", m_phi1);
93 status = m_tuple2->addItem (
"phi2", m_phi2);
97 log << MSG::ERROR <<
"Cannot book N-tuple2:"<<long(m_tuple2)<<endmsg;
98 return StatusCode::FAILURE;
101 return StatusCode::SUCCESS;
106 StatusCode sc=StatusCode::SUCCESS;
108 MsgStream log(
msgSvc(),name());
109 log<<MSG::INFO<<
"in execute()"<<endreq;
112 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
115 log<<MSG::DEBUG<<
"ncharg, nneu, tottks = "<<evtRecEvent->totalCharged()<<
" , "<<evtRecEvent->totalNeutral()<<
" , "<<evtRecEvent->totalTracks()<<endreq;
118 log<<MSG::DEBUG <<
"ncharg, nneu, tottks = "<<evtRecEvent->totalCharged()<<
" , "<<evtRecEvent->totalNeutral()<<
" , "<<evtRecEvent->totalTracks()<<endreq;
119 SmartDataPtr<RecEsTimeCol> evTimeCol(eventSvc(),
"/Event/Recon/RecEsTimeCol");
123 log<<MSG::DEBUG <<
"interval = " << interval << endreq;
125 if (interval <= 0 ) {
126 log << MSG::FATAL <<
"error in reading the interval!" << endreq;
127 return StatusCode::FAILURE;
129 else if ( interval < 100 ) {
133 double time = eventHeader->time();
134 log << MSG::DEBUG <<
"time = " <<
time << endreq;
135 if (
time <=0 )
return StatusCode::SUCCESS;
137 m_etsT1 = eventHeader->etsT1()/2000000.;
138 log << MSG::DEBUG <<
"ets time = " << m_etsT1 << endreq;
140 m_run = eventHeader->runNumber();
141 m_rec = eventHeader->eventNumber();
143 if(m_rec%1000==0) log << MSG::INFO <<
"Run "<<m_run<<
" Event "<<m_rec<<endreq;
149 if((evtRecEvent->totalTracks() >= 2)){
151 for(
int i = 0;i < evtRecEvent->totalTracks(); i++)
153 if(i>=evtRecTrkCol->size())
break;
155 if(!(*itTrk)->isEmcShowerValid())
continue;
157 double Ener=emcTrk->
energy();
177 log << MSG::INFO <<
"Emax1 = " << Emax1 <<
"Emax2= "<<Emax2<< endreq;
178 if(Emax1 > 0 && Emax2 > 0){
179 double emcphi[2],emctht[2];
180 for(
int i = 0;i < 2; i++)
182 if(i>=evtRecTrkCol->size())
break;
184 if(!(*itTrk)->isEmcShowerValid())
continue;
186 emcphi[i]=emcTrk->
phi();
187 emctht[i]=emcTrk->
theta();
191 double dlttht=(fabs(emctht[0]+emctht[1])-
pai)*180./
pai;
192 m_costht1=
cos(emctht[0]);
193 m_costht2=
cos(emctht[1]);
225 int DiskWrite = m_tuple2->write();
227 log<<MSG::FATAL<<
"ERROR In LumTau DiskWrite!"<<endreq;
231 return StatusCode::SUCCESS;
236 MsgStream log(
msgSvc(),name());
237 log << MSG::INFO <<
"Event Finalize"<<endreq;
238 return StatusCode::SUCCESS;
double cos(const BesAngle a)
EvtRecTrackCol::iterator EvtRecTrackIterator
HepGeom::Point3D< double > HepPoint3D
std::vector< HepLorentzVector > Vp4
virtual int getTInterval() const =0
LumTau(const std::string &name, ISvcLocator *pSvcLocator)
_EXTERN_ std::string EvtRecEvent
_EXTERN_ std::string EvtRecTrackCol