2#include "GaudiKernel/MsgStream.h"
4#include "GaudiKernel/SmartDataPtr.h"
6#include "EventModel/Event.h"
7#include "EventModel/EventHeader.h"
8#include "Identifier/Identifier.h"
12#include "RawDataProviderSvc/TofData.h"
14#include "HltAlgorithms/EFFlightTime.h"
17typedef std::vector<EFTofHitsCol>
VTOF;
23 MsgStream log(
msgSvc(), name);
40 MsgStream log(
msgSvc(), name());
41 log << MSG::INFO <<
"in initialize()" << endreq;
47 if ( sc.isFailure() ) {
48 log << MSG::ERROR <<
"m_HltStoreSvc->put(dtof1) wrong" << endreq;
52 if ( sc.isFailure() ) {
53 log << MSG::ERROR <<
"m_HltStoreSvc->put(dphi1) wrong" << endreq;
57 if ( sc.isFailure() ) {
58 log << MSG::ERROR <<
"m_HltStoreSvc->put(dtof2) wrong" << endreq;
62 if ( sc.isFailure() ) {
63 log << MSG::ERROR <<
"m_HltStoreSvc->put(dphi2) wrong" << endreq;
67 log << MSG::DEBUG <<
"finish initialize()" << endreq;
68 return StatusCode::SUCCESS;
75 MsgStream log(
msgSvc(), name());
79 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
81 log << MSG::FATAL <<
"Could not find Event Header" << endreq;
82 return( StatusCode::FAILURE);
98 unsigned int idBarrel_Endcap,iphi;
103 if(tofDataVec.size()>1){
104 TofDataVector::iterator iterTOF=tofDataVec.begin();
105 for(;iterTOF!= tofDataVec.end();iterTOF++) {
106 if((*iterTOF)->barrel()) {
108 int id=(*iterTOF)->tofId();
111 double t1=(*iterTOF)->tdc1();
112 double t2=(*iterTOF)->tdc2();
114 if(t1<1500&&t2<1500&&t1>0&&t2>0) tof=0.5*(t1+t2);
115 else if(t1<1500&&t1>0) tof=t1;
116 else if(t2<1500&&t2>0) tof=t2;
118 log <<MSG::DEBUG<<
"hit: " <<
"("<<idBarrel_Endcap<<
","<<ilayer<<
","<<iphi<<
")-->"<< tof <<
" ns"<<endreq;
123 topTOF.push_back(
EFTofHitsCol(idBarrel_Endcap,ilayer,iphi,tof));
125 else if(iphi>46&&iphi<85){
126 bottomTOF.push_back(
EFTofHitsCol(idBarrel_Endcap,ilayer,iphi,tof));
130 int iphi=(*iterTOF)->tofId();
131 double tof=(*iterTOF)->tdc();
136 else idBarrel_Endcap=0;
137 if(iphi>1&&iphi<22&&tof>0&&tof<1500){
138 topTOF.push_back(
EFTofHitsCol(idBarrel_Endcap,0,iphi,tof));
140 else if(iphi>25&&iphi<46&&tof>0&&tof<1500){
141 bottomTOF.push_back(
EFTofHitsCol(idBarrel_Endcap,0,iphi,tof));
150 if(topTOF.size()>=1&&bottomTOF.size()>=1){
151 for(
unsigned int i=0;i<topTOF.size();i++){
153 if(topTOF[i].ib_e()==1){
154 topPhi=topTOF[i].iphi()*360./88.;
156 else if(topTOF[i].ib_e()==0||topTOF[i].ib_e()==2){
157 topPhi=topTOF[i].iphi()*360./48.;
160 log << MSG::ERROR <<
"TOF Barrel_Encap ID not right!" << endreq;
162 for(
unsigned int j=0;j<bottomTOF.size();j++){
164 if(bottomTOF[j].ib_e()==1){
165 bottomPhi=bottomTOF[j].iphi()*360./88.;
167 else if(bottomTOF[j].ib_e()==0||bottomTOF[j].ib_e()==2){
168 bottomPhi=bottomTOF[j].iphi()*360./48.;
171 log << MSG::ERROR <<
"TOF Barrel_Encap ID not right!" << endreq;
173 double tmp1=fabs(topTOF[i].GetT()-bottomTOF[j].GetT());
174 double tmp2=fabs(topTOF[i].GetT()-bottomTOF[j].GetT()+7.);
175 if(tmp2<fabs(dtof2+7.)){
176 dtof2=topTOF[i].GetT()-bottomTOF[j].GetT();
177 dphi2=
abs(fabs(topPhi-bottomPhi)-180.);
179 if(tmp1<fabs(dtof1)){
180 dphi1=
abs(fabs(topPhi-bottomPhi)-180.);
181 dtof1=topTOF[i].GetT()-bottomTOF[j].GetT();
187 log << MSG::INFO <<
"dtof1=" << dtof1 <<
", dphi1=" << dphi1
188 <<
"dtof2=" << dtof2 <<
", dphi2=" << dphi2 <<endreq;
203 return StatusCode::SUCCESS;
207 MsgStream log(
msgSvc(), name());
208 log << MSG::INFO <<
"in finalize()" << endmsg;
209 return StatusCode::SUCCESS;
224VTOF::iterator EFFlightTime::FindHit(
VTOF& tof,
225 const unsigned int ilayer,
const unsigned int iphi,
const unsigned int ibe){
226 VTOF::iterator it=tof.begin();
227 for(;it!=tof.end();it++){
228 if(ibe!=it->ib_e())
continue;
229 if(ilayer==it->ilayer()){
230 if(iphi==it->iphi())
return it;
231 if(iphi+1==it->iphi())
return it;
232 if(iphi-1==it->iphi())
return it;
235 if(iphi==it->iphi())
return it;
236 if(iphi+(it->ilayer()-ilayer)==it->iphi())
return it;
std::vector< EFTofHitsCol > VTOF
std::vector< EFTofHitsCol > VTOF
std::vector< TofData * > TofDataVector
double abs(const EvtComplex &c)
*******INTEGER m_nBinMax INTEGER m_NdiMax !No of bins in histogram for cell exploration division $ !Last vertex $ !Last active cell $ !Last cell in buffer $ !No of sampling when dividing cell $ !No of function total $ !Flag for random ceel for $ !Flag for type of for WtMax $ !Flag which decides whether vertices are included in the sampling $ entire domain is hyp !Maximum effective eevents per saves r n generator level $ !Flag for chat level in output
void setValue(float value)
virtual StatusCode initialize()
EFFlightTime(const std::string &name, ISvcLocator *pSvcLocator)
bool addToEFVec(uint32_t val, uint32_t pos)
bool appToEFVec(double val, uint32_t pos)
bool setVecBit(uint32_t val, uint32_t vecpos, uint32_t bbegin, uint32_t bend)
bool put(const std::string &name, const T &value)
virtual StatusCode initialize()
IRawDataProviderSvc * m_rawDigiSvc
HltStoreSvc * m_HltStoreSvc
virtual TofDataVector & tofDataVectorOnlineMode(uint32_t control=1)=0