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
61
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 {
71 log << MSG::DEBUG << "Unvalid EFResult(AnswerIndex=-1)" << endreq;
72 answer="Error";
73 }
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;
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++;
116 uint32_t alg8=alg&0xFF;
118 aEF->push_back(efAlg);
119 id++;
120 uint32_t cri=alg>>8;
123 aEF->push_back(efCri);
124 id++;
127 aEF->push_back(efVer);
129 id++;
132 aEF->push_back(efEtot);
133
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;
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{
157 int i=1;
158 for(int j=5;j<5+nmdc;j++){
160 ++i;
161 }
162 for(int j=25;j<25+ntof;j++){
164 ++i;
165 }
166 for(int j=30;j<30+nemc;j++){
168 ++i;
169 }
170 for(int j=52;j<52+nmuc;j++){
172 ++i;
173 }
174 if(ndec>0) {
175 var[i]=ndec;
176 ++i;
177 for(int j=54;j<54+ndec;++j){
179 ++i;
180 }
181 }
182 if(i!=ndata) log << MSG::FATAL << "number of datat error!" << endreq;
183 }
184
185 id++;
188 aEF->push_back(efTag);
189
190 for(int i=1;i<ndata;i++){
191 id++;
195 aEF->push_back(efVar);
196 }
197 delete var;
198 }
199
200 uint32_t atype=0,alg=0,cri=0,ver=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;
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++ ) {
230 }
231 log<<MSG::DEBUG<<"old type="<<atype<<", alg="<<alg<<", criteria="<<cri
232 <<
", version="<<ver<<
", energy="<<
etot<<endreq;
233
234 sc = eventSvc()->unregisterObject("/Event/Hlt/HltRawCol");
235 delete aHltRawEvent;
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
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++ ) {
264 }
265 log<<MSG::DEBUG<<" type="<<atype<<", alg="<<alg<<", criteria="<<cri
266 <<
", version="<<ver<<
", energy="<<
etot<<endreq;
267
268 return StatusCode::SUCCESS;
269}
ObjectVector< HltRaw > HltRawCol
const int getDecNum() const
const std::string getAnswer() const
const int getAnswerIndex() const
const std::vector< uint32_t > getEFVec() const
static bool is_version(const Identifier &id)
static bool is_eventtype(const Identifier &id)
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)
static bool is_algorithm(const Identifier &id)
static bool is_criteria(const Identifier &id)
static bool is_energy(const Identifier &id)
void setIntChannel(const unsigned int intChannel)
void setFloatChannel(const float value)
bool get(const std::string &name, T &value)
_EXTERN_ std::string Event
_EXTERN_ std::string HltRawCol