BOSS 7.0.4
BESIII Offline Software System
Loading...
Searching...
No Matches
EFtoTDS Class Reference

#include <EFtoTDS.h>

+ Inheritance diagram for EFtoTDS:

Public Member Functions

 EFtoTDS (const std::string &name, ISvcLocator *pSvcLocator)
 
virtual ~EFtoTDS ()
 
StatusCode initialize ()
 
StatusCode execute ()
 
StatusCode finalize ()
 
 EFtoTDS (const std::string &name, ISvcLocator *pSvcLocator)
 
virtual ~EFtoTDS ()
 
StatusCode initialize ()
 
StatusCode execute ()
 
StatusCode finalize ()
 

Detailed Description

Constructor & Destructor Documentation

◆ EFtoTDS() [1/2]

EFtoTDS::EFtoTDS ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 22 of file EFtoTDS.cxx.

22 :
23 Algorithm(name, pSvcLocator) {
24 declareProperty("OutputLevel", m_outputLevel);
25}

◆ ~EFtoTDS() [1/2]

EFtoTDS::~EFtoTDS ( )
virtual

Definition at line 27 of file EFtoTDS.cxx.

28{
29}

◆ EFtoTDS() [2/2]

EFtoTDS::EFtoTDS ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

◆ ~EFtoTDS() [2/2]

virtual EFtoTDS::~EFtoTDS ( )
virtual

Member Function Documentation

◆ execute() [1/2]

StatusCode EFtoTDS::execute ( )

Definition at line 45 of file EFtoTDS.cxx.

45 {
46
47 MsgStream log(msgSvc(), name());
48 log << MSG::DEBUG << "in execute()" << endreq;
49
50 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
51 if (!eventHeader) {
52 log << MSG::FATAL << "Could not find Event Header" << endreq;
53 return StatusCode::FAILURE;
54 }
55
56 int eventId = eventHeader->eventNumber() ;
57 int runId = eventHeader->runNumber();
58 log << MSG::INFO << "retrieved event: " <<"Event Number "<<eventId<<" run: "<<runId<<endreq;
59
60 HltRawCol* aEF=new HltRawCol;
61
62 EFResult* efResult;
63 string answer="";
64 StatusCode sc = m_HltStoreSvc->get("EventType", efResult);
65 if ( sc.isFailure() ) {
66 log << MSG::ERROR << "Could not find EFResult (EventType)" << endreq;
67 answer="Error";
68 }
69 else {
70 if (efResult->getAnswerIndex() == -1) {
71 log << MSG::DEBUG << "Unvalid EFResult(AnswerIndex=-1)" << endreq;
72 answer="Error";
73 }
74 answer = efResult->getAnswer();
75 }
76 log << MSG::INFO << "The answer is " << answer << endreq;
77
78 uint32_t type=0;
79 if(answer=="Junk") type=1<<0;
80 else if(answer=="GJunk") type=(1<<1);
81 else if(answer=="Beamgas") type=1<<2;
82 else if(answer=="GBeamgas") type=(1<<3);
83 else if(answer=="Cosmic") type=1<<4;
84 else if(answer=="GCosmic") type=(1<<5);
85 else if(answer=="EBhabha") type=1<<6;
86 else if(answer=="GEBhabha") type=(1<<7);
87 else if(answer=="BBhabha") type=1<<8;
88 else if(answer=="GBBhabha") type=(1<<9);
89 else if(answer=="Dimuon") type=1<<10;
90 else if(answer=="GDimuon") type=(1<<11);
91 else if(answer=="Diphoton") type=1<<12;
92 else if(answer=="GDiphoton") type=(1<<13);
93 else if(answer=="Hadron") type=1<<14;
94 else if(answer=="GHadron") type=(1<<15);
95 else if(answer=="Twophoton") type=1<<16;
96 else if(answer=="GTwophoton") type=(1<<17);
97 else if(answer=="RandomTrg") type=1<<31;
98 else if(answer=="Error") type=1<<30;
99 else if(answer=="Other") type=1<<29;
100 else type=1<<28;
101
102 uint32_t id=0x50000000;
103 HltRaw* efType=new HltRaw(id);
104 efType->setIntChannel(type);
105 aEF->push_back(efType);
106
107 sc = m_HltStoreSvc->get("EFResult", efResult) ;
108 if ( sc.isFailure() ) {
109 log << MSG::FATAL << "Could not find EFResult (EFResult)" << endreq;
110 return StatusCode::FAILURE;
111 }
112 else {
113 uint32_t alg= efResult->getEFVec(0);
114 id++;
115 HltRaw* efAlg=new HltRaw(id);
116 uint32_t alg8=alg&0xFF;
117 efAlg->setIntChannel(alg8);
118 aEF->push_back(efAlg);
119 id++;
120 uint32_t cri=alg>>8;
121 HltRaw* efCri=new HltRaw(id);
122 efCri->setIntChannel(cri);
123 aEF->push_back(efCri);
124 id++;
125 HltRaw* efVer=new HltRaw(id);
126 efVer->setIntChannel(0);
127 aEF->push_back(efVer);
128 uint32_t etot= efResult->getEFVec(31);
129 id++;
130 HltRaw* efEtot=new HltRaw(id);
131 efEtot->setFloatChannel(*((float*)&etot));
132 aEF->push_back(efEtot);
133
134 uint32_t num=efResult->getEFVec(1);
135 int nmdc=num&0xFF;
136 int ntof=(num>>8)&0xFF;
137 int nemc=(num>>16)&0xFF;
138 int nmuc=(num>>24)&0xFF;
139 int ndata=1;
140
141 uint32_t ndatap = nmdc+ntof+nemc+nmuc;
142 ndata += ndatap;
143 int ndec=efResult->getDecNum();
144 if(ndec>0) ndata +=(ndec+1);
145
146 log << MSG::DEBUG << "ndata=" << ndata << "; nmdc=" << nmdc << ", ntof=" << ntof
147 << ", nemc=" << nemc << ", nmuc=" << nmuc << ", ndec=" << ndec << endreq;
148
149 if((alg&4)&&(!(alg&2))) log << MSG::WARNING<<"sub-algorithms error!"<<endreq;
150
151 uint32_t* var=new uint32_t[ndata];
152 if(ndata==1){
153 var[0]=0;
154 }
155 else{
156 var[0]=num;
157 int i=1;
158 for(int j=5;j<5+nmdc;j++){
159 var[i]=efResult->getEFVec(j);
160 ++i;
161 }
162 for(int j=25;j<25+ntof;j++){
163 var[i]=efResult->getEFVec(j);
164 ++i;
165 }
166 for(int j=30;j<30+nemc;j++){
167 var[i]=efResult->getEFVec(j);
168 ++i;
169 }
170 for(int j=52;j<52+nmuc;j++){
171 var[i]=efResult->getEFVec(j);
172 ++i;
173 }
174 if(ndec>0) {
175 var[i]=ndec;
176 ++i;
177 for(int j=54;j<54+ndec;++j){
178 var[i]=efResult->getEFVec(j);
179 ++i;
180 }
181 }
182 if(i!=ndata) log << MSG::FATAL << "number of datat error!" << endreq;
183 }
184
185 id++;
186 HltRaw* efTag=new HltRaw(id);
187 efTag->setIntChannel(var[0]);
188 aEF->push_back(efTag);
189
190 for(int i=1;i<ndata;i++){
191 id++;
192 HltRaw* efVar=new HltRaw(HltID::convert(id,nmdc,ntof,nemc,nmuc));
193 efVar->setFloatChannel(*((float*)&var[i]));
194 efVar->setIntChannel(var[i]);
195 aEF->push_back(efVar);
196 }
197 delete var;
198 }
199
200 uint32_t atype=0,alg=0,cri=0,ver=0;
201 float etot=0.;
202
203 DataObject *aHltEvent;
204 eventSvc()->findObject("/Event/Hlt", aHltEvent);
205 if(aHltEvent==NULL){
206 log<<MSG::INFO<< "HltEvent has not existed, so register it now!" <<endreq;
207 HltEvent* aHlt=new HltEvent();
208 sc = eventSvc()->registerObject(EventModel::Hlt::Event,aHlt);
209 if(sc!=StatusCode::SUCCESS) {
210 log<<MSG::FATAL<< "Could not register Hlt!!!" <<endreq;
211 return( StatusCode::FAILURE);
212 }
213 }
214 else{
215 log<<MSG::WARNING<< "HltEvent has existed!" <<endreq;
216 }
217
218 DataObject *aHltRawEvent;
219 eventSvc()->findObject("/Event/Hlt/HltRawCol", aHltRawEvent);
220 if(aHltRawEvent!=NULL) {
221 SmartDataPtr<HltRawCol> hltRawCol(eventSvc(),"/Event/Hlt/HltRawCol");
222 HltRawCol::iterator iter = hltRawCol->begin();
223 for (;iter != hltRawCol->end(); iter++ ) {
224 Identifier id = (*iter)->identify();
225 if(HltID::is_eventtype(id)) atype=(*iter)->getIntChannel();
226 if(HltID::is_algorithm(id)) alg=(*iter)->getIntChannel();
227 if(HltID::is_criteria(id)) cri=(*iter)->getIntChannel();
228 if(HltID::is_version(id)) ver=(*iter)->getIntChannel();
229 if(HltID::is_energy(id)) etot=(*iter)->getFloatChannel();
230 }
231 log<<MSG::DEBUG<<"old type="<<atype<<", alg="<<alg<<", criteria="<<cri
232 <<", version="<<ver<<", energy="<<etot<<endreq;
233 //then unregister HltRawCol
234 sc = eventSvc()->unregisterObject("/Event/Hlt/HltRawCol");
235 delete aHltRawEvent; //it must be delete to avoid memory leakage
236 log << MSG::INFO << "Old raw collection has been unregistered" << endreq;
237 if(sc!=StatusCode::SUCCESS) {
238 log << MSG::FATAL << "Could not unregister HLT raw collection" << endreq;
239 return( StatusCode::FAILURE);
240 }
241 }
242
243 // register
244 sc = eventSvc()->registerObject(EventModel::Hlt::HltRawCol,aEF);
245 if(sc!=StatusCode::SUCCESS) {
246 log<<MSG::FATAL<< "Still could not register HltRawCol" <<endreq;
247 return StatusCode::FAILURE;
248 }
249
250 SmartDataPtr<HltRawCol> hltRawCol(eventSvc(),"/Event/Hlt/HltRawCol");
251 if (!hltRawCol) {
252 log << MSG::FATAL << "Could not find HltRawCol!" << endreq;
253 return StatusCode::FAILURE;
254 }
255
256 HltRawCol::iterator iter = hltRawCol->begin();
257 for (;iter != hltRawCol->end(); iter++ ) {
258 Identifier id = (*iter)->identify();
259 if(HltID::is_eventtype(id)) atype=(*iter)->getIntChannel();
260 if(HltID::is_algorithm(id)) alg=(*iter)->getIntChannel();
261 if(HltID::is_criteria(id)) cri=(*iter)->getIntChannel();
262 if(HltID::is_version(id)) ver=(*iter)->getIntChannel();
263 if(HltID::is_energy(id)) etot=(*iter)->getFloatChannel();
264 }
265 log<<MSG::DEBUG<<" type="<<atype<<", alg="<<alg<<", criteria="<<cri
266 <<", version="<<ver<<", energy="<<etot<<endreq;
267
268 return StatusCode::SUCCESS;
269}
Double_t etot
ObjectVector< HltRaw > HltRawCol
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
const std::string getAnswer() const
Definition: EFResult.cxx:166
const int getAnswerIndex() const
Definition: EFResult.cxx:168
const std::vector< uint32_t > getEFVec() const
Definition: EFResult.cxx:51
static bool is_version(const Identifier &id)
Definition: HltID.cxx:90
static bool is_eventtype(const Identifier &id)
Definition: HltID.cxx:72
static Identifier convert(const unsigned int id, const int nmdc=0, const int ntof=0, const int nemc=0, const int nmuc=0)
convert global id to sub-id(Identifier)
Definition: HltID.cxx:12
static bool is_algorithm(const Identifier &id)
Definition: HltID.cxx:78
static bool is_criteria(const Identifier &id)
Definition: HltID.cxx:84
static bool is_energy(const Identifier &id)
Definition: HltID.cxx:96
void setIntChannel(const unsigned int intChannel)
void setFloatChannel(const float value)

◆ execute() [2/2]

StatusCode EFtoTDS::execute ( )

◆ finalize() [1/2]

StatusCode EFtoTDS::finalize ( )

Definition at line 271 of file EFtoTDS.cxx.

271 {
272
273 MsgStream log(msgSvc(), name());
274 log << MSG::INFO << "in finalize()" << endreq;
275
276 return StatusCode::SUCCESS;
277}

◆ finalize() [2/2]

StatusCode EFtoTDS::finalize ( )

◆ initialize() [1/2]

StatusCode EFtoTDS::initialize ( )

Definition at line 31 of file EFtoTDS.cxx.

31 {
32
33 MsgStream log(msgSvc(), name());
34 log << MSG::INFO << "in initialize()" << endreq;
35
36 StatusCode sc = service( "HltStoreSvc", m_HltStoreSvc);
37 if( sc.isFailure() ) {
38 log << MSG::FATAL << name() << ": Unable to locate Service HltStoreSvc" << endreq;
39 return sc;
40 }
41
42 return StatusCode::SUCCESS;
43}

◆ initialize() [2/2]

StatusCode EFtoTDS::initialize ( )

The documentation for this class was generated from the following files: