71 {
72
74
75 MsgStream log(
msgSvc(), name());
76
77
78
79 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
80 if (!eventHeader) {
81 log << MSG::FATAL << "Could not find Event Header" << endreq;
82 return( StatusCode::FAILURE);
83 }
84
85
86
87
88
89
90
91
92
95 topTOF.clear();
96 bottomTOF.clear();
98 unsigned int idBarrel_Endcap,iphi;
99 double tdc;
100
102
103 if(tofDataVec.size()>1){
104 TofDataVector::iterator iterTOF=tofDataVec.begin();
105 for(;iterTOF!= tofDataVec.end();iterTOF++) {
106 if((*iterTOF)->barrel()) {
107 idBarrel_Endcap=1;
108 int id=(*iterTOF)->tofId();
109 iphi = id%88;
110 int ilayer = id/88;
111 double t1=(*iterTOF)->tdc1();
112 double t2=(*iterTOF)->tdc2();
113 double tof=-999;
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;
117 else continue;
118 log <<MSG::DEBUG<< "hit: " <<"("<<idBarrel_Endcap<<","<<ilayer<<","<<iphi<<")-->"<< tof <<" ns"<<endreq;
119
120
121
122 if(iphi<41&&iphi>2){
123 topTOF.push_back(
EFTofHitsCol(idBarrel_Endcap,ilayer,iphi,tof));
124 }
125 else if(iphi>46&&iphi<85){
126 bottomTOF.push_back(
EFTofHitsCol(idBarrel_Endcap,ilayer,iphi,tof));
127 }
128 }
129 else{
130 int iphi=(*iterTOF)->tofId();
131 double tof=(*iterTOF)->tdc();
132 if(iphi>=48) {
133 idBarrel_Endcap=2;
134 iphi %=48;
135 }
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));
139 }
140 else if(iphi>25&&iphi<46&&tof>0&&tof<1500){
141 bottomTOF.push_back(
EFTofHitsCol(idBarrel_Endcap,0,iphi,tof));
142 }
143 }
144 }
145 }
146 double dtof1=99;
147 double dphi1=180;
148 double dtof2=99;
149 double dphi2=180;
150 if(topTOF.size()>=1&&bottomTOF.size()>=1){
151 for(unsigned int i=0;i<topTOF.size();i++){
152 double topPhi=0.;
153 if(topTOF[i].ib_e()==1){
154 topPhi=topTOF[i].iphi()*360./88.;
155 }
156 else if(topTOF[i].ib_e()==0||topTOF[i].ib_e()==2){
157 topPhi=topTOF[i].iphi()*360./48.;
158 }
159 else{
160 log << MSG::ERROR << "TOF Barrel_Encap ID not right!" << endreq;
161 }
162 for(unsigned int j=0;j<bottomTOF.size();j++){
163 double bottomPhi=0.;
164 if(bottomTOF[j].ib_e()==1){
165 bottomPhi=bottomTOF[j].iphi()*360./88.;
166 }
167 else if(bottomTOF[j].ib_e()==0||bottomTOF[j].ib_e()==2){
168 bottomPhi=bottomTOF[j].iphi()*360./48.;
169 }
170 else{
171 log << MSG::ERROR << "TOF Barrel_Encap ID not right!" << endreq;
172 }
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.);
178 }
179 if(tmp1<fabs(dtof1)){
180 dphi1=
abs(fabs(topPhi-bottomPhi)-180.);
181 dtof1=topTOF[i].GetT()-bottomTOF[j].GetT();
182 }
183 }
184 }
185 }
186
187 log << MSG::INFO << "dtof1=" << dtof1 << ", dphi1=" << dphi1
188 << "dtof2=" << dtof2 << ", dphi2=" << dphi2 <<endreq;
189
190
201
203 return StatusCode::SUCCESS;
204}
std::vector< EFTofHitsCol > VTOF
std::vector< TofData * > TofDataVector
void setValue(float value)
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)
IRawDataProviderSvc * m_rawDigiSvc
virtual TofDataVector & tofDataVectorOnlineMode(uint32_t control=1)=0