BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
EFTest.cxx
Go to the documentation of this file.
1#include "GaudiKernel/SmartDataPtr.h"
2//#include "GaudiKernel/PropertyMgr.h"
3#include "EventModel/Event.h"
4#include "EventModel/EventHeader.h"
5#include "Identifier/HltID.h"
6#include "HltEvent/HltInf.h"
7#include "HltEvent/DstHltInf.h"
8
9#include "EventFilter/EventFilter.h"
10
11#include "EventFilter/EFTest.h"
12
13EFTest::EFTest(const std::string& name, ISvcLocator* pSvcLocator) :
14 Algorithm(name, pSvcLocator) {
15 // Declare the properties
16 // declareProperty("Cut", m_acolCut = 10);
17 declareProperty("OutputLevel", m_outputLevel = MSG::NIL);
18}
19
21}
22
23StatusCode EFTest::initialize(){
24
25 MsgStream log(msgSvc(), name());
26 log << MSG::INFO << "in initialize()" << endreq;
27 // user code
28
29 StatusCode status=StatusCode::SUCCESS;
30 NTuplePtr nt1(ntupleSvc(), "FILE1/EventFilter");
31 if ( nt1 ) m_tuple = nt1;
32 else {
33 m_tuple = ntupleSvc()->book ("FILE1/EventFilter", CLID_ColumnWiseTuple, "EventFilter N-Tuple");
34 if ( m_tuple ) {
35 status = m_tuple->addItem ("type", m_type);
36 status = m_tuple->addItem ("alg", m_alg);
37 status = m_tuple->addItem ("endEE", m_endEE);
38 status = m_tuple->addItem ("version", m_version);
39 status = m_tuple->addItem ("etot", m_etot);
40 status = m_tuple->addItem ("nMDCdata", m_nmdc0);
41 status = m_tuple->addItem ("nTOFdata", m_ntof0);
42 status = m_tuple->addItem ("nEMCdata", m_nemc0);
43 status = m_tuple->addItem ("nMUCdata", m_nmuc0);
44 status = m_tuple->addItem ("nCONdata", m_ncon0);
45 status = m_tuple->addItem ("nMDCfill", m_nmdc, 0, (int)HltID::getID_MDC_MAX() );
46 status = m_tuple->addItem ("nTOFfill", m_ntof, 0, (int)HltID::getID_TOF_MAX() );
47 status = m_tuple->addItem ("nEMCfill", m_nemc, 0, (int)HltID::getID_EMC_MAX() );
48 status = m_tuple->addItem ("nMUCfill", m_nmuc, 0, (int)HltID::getID_MUC_MAX() );
49 status = m_tuple->addItem ("nCONfill", m_ncon, 0, 100 );
50 status = m_tuple->addIndexedItem ("MDCdata", m_nmdc, m_mdcData);
51 status = m_tuple->addIndexedItem ("TOFdata", m_ntof, m_tofData);
52 status = m_tuple->addIndexedItem ("EMCdata", m_nemc, m_emcData);
53 status = m_tuple->addIndexedItem ("MUCdata", m_nmuc, m_mucData);
54 status = m_tuple->addIndexedItem ("CONdata", m_ncon, m_conData);
55 if (!status) {
56 log << MSG::ERROR << " Cannot add item into N-tuple" << endreq;
57 return status;
58 }
59 }
60 else {
61 log << MSG::ERROR << " Cannot book N-tuple:" << long(m_tuple) << endreq;
62 return StatusCode::FAILURE;
63 }
64 }
65
66 return StatusCode::SUCCESS;
67}
68
69StatusCode EFTest::execute() {
70
71 MsgStream log(msgSvc(), name());
72 log << MSG::INFO << "in execute()" << endreq;
73
75 // this event refused by event filter
76 log << MSG::DEBUG << "this event refused by event filter: "
77 << EventFilter::getName() <<endreq;
78 // user code
79
80 }
81 else {
82 // this event accepted by event filter
83 log << MSG::DEBUG << "this event accepteded by event filter: "
84 << EventFilter::getName() <<endreq;
85 // user code
86
87 }
88 SmartDataPtr<HltInf> hlt(eventSvc(),"/Event/Hlt/HltInf");
89 bool dstFlag=false;
90 if(!hlt) {
91 log << MSG::WARNING << "Could not find Event HltInf (try DstHltInf now)" << endreq;
92 SmartDataPtr<DstHltInf> hltDst(eventSvc(),"/Event/Hlt/DstHltInf");
93 if(!hltDst){
94 log << MSG::FATAL << "Could not find Event DstHltInf too ( please re-generate data)" << endreq;
95 return( StatusCode::FAILURE);
96 }
97 else{
98 hlt=hltDst;
99 dstFlag=true;
100 }
101 }
102
103 uint32_t type = hlt->getEventType();
104 for(int i=0;i<32;i++) {
105 if((1<<i)&type) m_type=i;
106 }
107 m_alg = hlt->getAlgProcess();
108 m_endEE = hlt->getCriteriaTable();
109 m_version = hlt->getVersion();
110 m_etot = hlt->getTotalEnergy();
111 m_nmdc0 = hlt->getNMDC();
112 m_ntof0 = hlt->getNTOF();
113 m_nemc0 = hlt->getNEMC();
114 m_nmuc0 = hlt->getNMUC();
115 m_ncon0 = hlt->getNCON();
116 m_nmdc = 0;
117 m_ntof = 0;
118 m_nemc = 0;
119 m_nmuc = 0;
120 m_ncon = 0;
121 if(!dstFlag) {
122 vector<uint32_t>::iterator it;
123
124 vector<uint32_t> mdcData= hlt->getDataVec(HltID::MDC);
125 it = mdcData.begin();
126 for(;it!=mdcData.end();it++,m_nmdc++){
127 if(m_nmdc>1) m_mdcData[m_nmdc]= *((float*) &(*it));
128 else m_mdcData[m_nmdc]= *it; //*((int*) &(*it));
129 }
130
131 vector<uint32_t> tofData= hlt->getDataVec(HltID::TOF);
132 it = tofData.begin();
133 for(;it!=tofData.end();it++,m_ntof++){
134 if(m_ntof>0) m_tofData[m_ntof]= *((float*) &(*it));
135 else m_tofData[m_ntof]= *it; //*((int*) &(*it));
136 }
137
138 vector<uint32_t> emcData= hlt->getDataVec(HltID::EMC);
139 it = emcData.begin();
140 for(;it!=emcData.end();it++,m_nemc++){
141 if(!(m_nemc==0||m_nemc==7||m_nemc==8)) m_emcData[m_nemc]= *((float*) &(*it));
142 else m_emcData[m_nemc]= *it; //*((int*) &(*it));
143 }
144
145 vector<uint32_t> mucData= hlt->getDataVec(HltID::MUC);
146 it = mucData.begin();
147 for(;it!=mucData.end();it++,m_nmuc++){
148 if(m_nmuc>1) m_mucData[m_nmuc]= *((float*) &(*it));
149 else m_mucData[m_nmuc]= *it; //*((int*) &(*it));
150 }
151
152 vector<uint32_t> conData= hlt->getDataVec(HltID::CON);
153 it = conData.begin();
154 for(;it!=conData.end();it++,m_ncon++){
155 m_conData[m_ncon]= *it; //*((int*) &(*it));
156 }
157 }
158
159 m_tuple->write();
160
161 return StatusCode::SUCCESS ;
162}
163
164StatusCode EFTest::finalize() {
165
166 MsgStream log(msgSvc(), name());
167 log << MSG::INFO << "in finalize()" << endreq;
168 // event number
169 long unsigned ntot=EventFilter::getNEvt();
170 long unsigned npass=EventFilter::getNPass();
171 log << MSG::ALWAYS << "=========================================" <<endreq
172 << "total "<< ntot <<" events with " << npass << " effective events " <<endreq
173 << "========================================="<< endreq;
174 // user code
175
176 return StatusCode::SUCCESS;
177}
StatusCode finalize()
Definition: EFTest.cxx:164
~EFTest()
Definition: EFTest.cxx:20
StatusCode execute()
Definition: EFTest.cxx:69
EFTest(const std::string &name, ISvcLocator *pSvcLocator)
Definition: EFTest.cxx:13
StatusCode initialize()
Definition: EFTest.cxx:23