79 MsgStream log(
msgSvc(), name() );
83 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(),
"/Event/EventHeader" );
86 log << MSG::FATAL <<
"Could not find Event Header" << endmsg;
87 return ( StatusCode::FAILURE );
103 unsigned int idBarrel_Endcap, iphi;
108 if ( tofDataVec.size() > 1 )
110 TofDataVector::iterator iterTOF = tofDataVec.begin();
111 for ( ; iterTOF != tofDataVec.end(); iterTOF++ )
113 if ( ( *iterTOF )->barrel() )
116 int id = ( *iterTOF )->tofId();
118 int ilayer =
id / 88;
119 double t1 = ( *iterTOF )->tdc1();
120 double t2 = ( *iterTOF )->tdc2();
122 if ( t1 < 1500 && t2 < 1500 && t1 > 0 && t2 > 0 ) tof = 0.5 * ( t1 + t2 );
123 else if ( t1 < 1500 && t1 > 0 ) tof = t1;
124 else if ( t2 < 1500 && t2 > 0 ) tof = t2;
126 log << MSG::DEBUG <<
"hit: "
127 <<
"(" << idBarrel_Endcap <<
"," << ilayer <<
"," << iphi <<
")-->" << tof <<
" ns"
133 if ( iphi < 41 && iphi > 2 )
134 { topTOF.push_back(
EFTofHitsCol( idBarrel_Endcap, ilayer, iphi, tof ) ); }
135 else if ( iphi > 46 && iphi < 85 )
136 { bottomTOF.push_back(
EFTofHitsCol( idBarrel_Endcap, ilayer, iphi, tof ) ); }
140 int iphi = ( *iterTOF )->tofId();
141 double tof = ( *iterTOF )->tdc();
147 else idBarrel_Endcap = 0;
148 if ( iphi > 1 && iphi < 22 && tof > 0 && tof < 1500 )
149 { topTOF.push_back(
EFTofHitsCol( idBarrel_Endcap, 0, iphi, tof ) ); }
150 else if ( iphi > 25 && iphi < 46 && tof > 0 && tof < 1500 )
151 { bottomTOF.push_back(
EFTofHitsCol( idBarrel_Endcap, 0, iphi, tof ) ); }
159 if ( topTOF.size() >= 1 && bottomTOF.size() >= 1 )
161 for (
unsigned int i = 0; i < topTOF.size(); i++ )
164 if ( topTOF[i].ib_e() == 1 ) { topPhi = topTOF[i].iphi() * 360. / 88.; }
165 else if ( topTOF[i].ib_e() == 0 || topTOF[i].ib_e() == 2 )
166 { topPhi = topTOF[i].iphi() * 360. / 48.; }
167 else { log << MSG::ERROR <<
"TOF Barrel_Encap ID not right!" << endmsg; }
168 for (
unsigned int j = 0; j < bottomTOF.size(); j++ )
170 double bottomPhi = 0.;
171 if ( bottomTOF[j].ib_e() == 1 ) { bottomPhi = bottomTOF[j].iphi() * 360. / 88.; }
172 else if ( bottomTOF[j].ib_e() == 0 || bottomTOF[j].ib_e() == 2 )
173 { bottomPhi = bottomTOF[j].iphi() * 360. / 48.; }
174 else { log << MSG::ERROR <<
"TOF Barrel_Encap ID not right!" << endmsg; }
175 double tmp1 = fabs( topTOF[i].GetT() - bottomTOF[j].GetT() );
176 double tmp2 = fabs( topTOF[i].GetT() - bottomTOF[j].GetT() + 7. );
177 if ( tmp2 < fabs( dtof2 + 7. ) )
179 dtof2 = topTOF[i].GetT() - bottomTOF[j].GetT();
180 dphi2 =
abs( fabs( topPhi - bottomPhi ) - 180. );
182 if ( tmp1 < fabs( dtof1 ) )
184 dphi1 =
abs( fabs( topPhi - bottomPhi ) - 180. );
185 dtof1 = topTOF[i].GetT() - bottomTOF[j].GetT();
191 log << MSG::INFO <<
"dtof1=" << dtof1 <<
", dphi1=" << dphi1 <<
"dtof2=" << dtof2
192 <<
", dphi2=" << dphi2 << endmsg;
195 m_dtof1->setValue( dtof1 );
196 m_dphi1->setValue( dphi1 );
197 m_dtof2->setValue( dtof2 );
198 m_dphi2->setValue( dphi2 );
199 m_ef->appToEFVec( dtof1, 26 );
200 m_ef->appToEFVec( dphi1, 27 );
201 m_ef->appToEFVec( dtof2, 28 );
202 m_ef->appToEFVec( dphi2, 29 );
203 m_ef->setVecBit(
true, 0, 5 );
204 m_ef->addToEFVec( 4 << 8, 1 );
207 return StatusCode::SUCCESS;