BOSS 7.0.9
BESIII Offline Software System
Loading...
Searching...
No Matches
EmcTimeRec.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"
10
11using namespace std;
12using namespace Event;
13
14/////////////////////////////////////////////////////////////////////////////
15
16EmcTimeRec::EmcTimeRec(const std::string& name, ISvcLocator* pSvcLocator) :
17 Algorithm(name, pSvcLocator)
18{
19 declareProperty("Output",m_output=false);
20}
21
22// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
24
25 MsgStream log(msgSvc(), name());
26 log << MSG::INFO << "in initialize()" << endreq;
27
28 if(m_output) {
29 NTuplePtr nt(ntupleSvc(),"FILE303/n1");
30 if ( nt ) m_tuple = nt;
31 else {
32 m_tuple=ntupleSvc()->book("FILE303/n1",CLID_ColumnWiseTuple,"EmcTimeRec");
33 if( m_tuple ) {
34 m_tuple->addItem ("emcTime", m_nt_emcTime);
35 m_tuple->addItem ("estTime", m_nt_estTime);
36 m_tuple->addItem ("corTime", m_nt_corTime);
37 m_tuple->addItem ("npart", m_nt_npart);
38 m_tuple->addItem ("ntheta", m_nt_ntheta);
39 m_tuple->addItem ("nphi", m_nt_nphi);
40 m_tuple->addItem ("e5x5", m_nt_e5x5);
41 m_tuple->addItem ("status", m_nt_status);
42 }
43 else { // did not manage to book the N tuple....
44 log << MSG::ERROR << "Cannot book N-tuple:" << long(m_tuple) << endmsg;
45 return StatusCode::FAILURE;
46 }
47 }
48 }
49
50 return StatusCode::SUCCESS;
51}
52
53// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
54StatusCode EmcTimeRec::execute() {
55
56 MsgStream log(msgSvc(), name());
57 log << MSG::DEBUG << "in execute()" << endreq;
58
59 SmartDataPtr<RecEsTimeCol> estimeCol(eventSvc(),"/Event/Recon/RecEsTimeCol");
60
61 if( !estimeCol || ( estimeCol->size() == 0 ) ) {
62 log << MSG::WARNING << "Could not find RecEsTimeCol!" << endreq;
63 return StatusCode::SUCCESS;
64 }
65
66 RecEsTimeCol::iterator iter_ESTime=estimeCol->begin();
67 double t0 = (*iter_ESTime)->getTest(); //get t0
68
69 SmartDataPtr<RecEmcShowerCol> emcRecShowerCol(eventSvc(), EventModel::Recon::RecEmcShowerCol);
70 if(!emcRecShowerCol) {
71 log << MSG::WARNING << "Could not find RecEmcShowerCol!" << endreq;
72 return StatusCode::SUCCESS;
73 }
74
75 RecEmcShowerCol::iterator iShowerCol;
76 for(iShowerCol=emcRecShowerCol->begin();
77 iShowerCol!=emcRecShowerCol->end();
78 iShowerCol++) {
79
80 if((*iShowerCol)->status()>=100) continue; //estTime has been subtracted
81
82 double tEmc = (*iShowerCol)->time();
83 (*iShowerCol)->setTime(tEmc-(int)(t0/50));
84 (*iShowerCol)->setStatus((*iShowerCol)->status()%100+100);
85
86 if(m_output) {
87 m_nt_emcTime = tEmc;
88 m_nt_estTime = (double)(int)(t0/50);
89 m_nt_corTime = (*iShowerCol)->time();
90 RecEmcID id((*iShowerCol)->getShowerId());
91 m_nt_npart = EmcID::barrel_ec(id);
92 m_nt_ntheta = EmcID::theta_module(id);
93 m_nt_nphi = EmcID::phi_module(id);
94 m_nt_e5x5 = (*iShowerCol)->e5x5();
95 m_nt_status = (*iShowerCol)->status();
96 m_tuple->write();
97 }
98 }
99
100 return StatusCode::SUCCESS;
101}
102
103// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
105
106 MsgStream log(msgSvc(), name());
107 log << MSG::INFO << "in finalize()" << endreq;
108
109 return StatusCode::SUCCESS;
110}
INTupleSvc * ntupleSvc()
IMessageSvc * msgSvc()
static unsigned int barrel_ec(const Identifier &id)
Values of different levels (failure returns 0)
Definition: EmcID.cxx:38
static unsigned int theta_module(const Identifier &id)
Definition: EmcID.cxx:43
static unsigned int phi_module(const Identifier &id)
Definition: EmcID.cxx:48
StatusCode finalize()
Definition: EmcTimeRec.cxx:104
StatusCode initialize()
Definition: EmcTimeRec.cxx:23
EmcTimeRec(const std::string &name, ISvcLocator *pSvcLocator)
Definition: EmcTimeRec.cxx:16
StatusCode execute()
Definition: EmcTimeRec.cxx:54
_EXTERN_ std::string RecEmcShowerCol
Definition: EventModel.h:103
Definition: Event.h:21