72 MsgStream log(
msgSvc(), name());
74 log << MSG::INFO <<
"in initialize()" << endmsg;
78 if ( nt ) m_tuple = nt;
80 m_tuple =
ntupleSvc()->book (
"FILE1/dimu", CLID_ColumnWiseTuple,
"ks N-Tuple example");
82 status = m_tuple->addItem (
"npart", m_npart);
83 status = m_tuple->addItem (
"number", m_number);
84 status = m_tuple->addItem (
"adc1", m_adc1);
85 status = m_tuple->addItem (
"adc2", m_adc2);
86 status = m_tuple->addItem (
"tdc1", m_tdc1);
87 status = m_tuple->addItem (
"tdc2", m_tdc2);
88 status = m_tuple->addItem (
"zpos", m_zpos);
89 status = m_tuple->addItem (
"length", m_length);
90 status = m_tuple->addItem (
"energy", m_energy);
91 status = m_tuple->addItem (
"lengthext", m_length_ext);
92 status = m_tuple->addItem (
"energyext", m_energy_ext);
93 status = m_tuple->addItem (
"ztdc", m_ztdc);
94 status = m_tuple->addItem (
"q", m_q);
98 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple) << endmsg;
99 return StatusCode::FAILURE;
106 log << MSG::INFO <<
"successfully return from initialize()" <<endmsg;
107 return StatusCode::SUCCESS;
120 MsgStream log(
msgSvc(), name());
121 log << MSG::INFO <<
"in execute()" << endreq;
123 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
124 int run = eventHeader->runNumber();
128 int event = eventHeader->eventNumber();
129 if(m_event%1000==0) {
130 std::cout << m_event <<
"-------------TofEnergyCalib run,event: " << run <<
"," <<
event << std::endl;
137 log << MSG::DEBUG <<
"ncharg, nneu, tottks = "
138 << evtRecEvent->totalCharged() <<
" , "
139 << evtRecEvent->totalNeutral() <<
" , "
140 << evtRecEvent->totalTracks() <<endreq;
142 if(evtRecEvent->totalCharged() != 2) {
143 return StatusCode::SUCCESS;
148 StatusCode sc = service(
"RawDataProviderSvc",
tofDigiSvc);
149 if (sc != StatusCode::SUCCESS) {
150 log << MSG::ERROR <<
"TofRec Get Tof Raw Data Service Failed !! " << endreq;
151 return StatusCode::SUCCESS;
156 StatusCode scc = service(
"TofCaliSvc",
tofCaliSvc);
157 if (scc != StatusCode::SUCCESS) {
158 log << MSG::ERROR <<
"TofRec Get Calibration Service Failed !! " << endreq;
159 return StatusCode::SUCCESS;
165 if (sc != StatusCode::SUCCESS) {
166 log << MSG::ERROR <<
"TofRec Get QCorr Service Failed !! " << endreq;
167 return StatusCode::SUCCESS;
172 if (sc != StatusCode::SUCCESS) {
173 log << MSG::ERROR <<
"TofRec Get QElec Service Failed !! " << endreq;
174 return StatusCode::SUCCESS;
178 std::vector<TofData*> tofDataVec;
180 const unsigned int ADC_MASK = 0x00001FFF;
182 for(
int i = 0; i < evtRecEvent->totalCharged(); i++) {
185 if(!(*itTrk)->isExtTrackValid())
continue;
188 if(!(*itTrk)->isTofTrackValid())
continue;
191 int npart, tof1, tof2;
192 Hep3Vector pos1, pos2;
200 if(tof1>=0 && tof1<88 && tof2>=88 && tof2<176) {
202 }
else if(tof1>=176 && tof1<224) {
205 }
else if(tof1>=224 && tof1<272) {
218 double zpos1=0, zpos2=0, l1=0, l2=0, lext=0;
219 double z1, xy1, z2, xy2;
223 const double tofDPhi = CLHEP::twopi / 88.;
224 double tofPhi1 = tof1*tofDPhi + tofDPhi/2;
225 double tofPhi2 = (tof2-88)*tofDPhi;
228 double extTheta1, extTheta2, extPhi1, extPhi2;
229 extTheta1 = pos1.theta();
230 extTheta2 = pos2.theta();
231 extPhi1 = pos1.phi();
232 extPhi2 = pos2.phi();
236 z1 = 5/
tan(extTheta1);
237 xy1 = 5/
cos(extPhi1-tofPhi1);
238 l1 = sqrt(z1*z1+xy1*xy1);
239 z2 = 5/
tan(extTheta2);
240 xy2 = 5/
cos(extPhi2-tofPhi2);
241 l2 = sqrt(z2*z2+xy2*xy2);
242 zpos1 = (pos1.z()+z1/2)/100;
243 zpos2 = (pos2.z()+z2/2)/100;
251 double extTheta1 = pos1.theta();
255 l1 = 5./fabs(
cos(extTheta1));
256 zpos1 = (sqrt(pos1.x()*pos1.x()+pos1.y()*pos1.y())+5.*
tan(extTheta1)/2)/100;
259 vector<TofData*>::iterator it;
262 for(it=tofDataVec.begin();
263 it!=tofDataVec.end();
269 if(im+layer*88==tof1-1 || im+layer*88==tof1+1 ||
270 im+layer*88==tof1-2 || im+layer*88==tof1+2) {
272 return StatusCode::SUCCESS;
276 for(it=tofDataVec.begin();
277 it!=tofDataVec.end();
284 double adc1,adc2,tdc1,tdc2,ztdc,tofq;
285 if((*it)->barrel()) {
287 tdc1 = bTofData->
tdc1();
288 tdc2 = bTofData->
tdc2();
289 adc1 = bTofData->
adc1();
290 adc2 = bTofData->
adc2();
294 if(tofq<100||tofq>10000)
continue;
301 adc1 = eTofData->
adc();
302 tdc1 = eTofData->
tdc();
307 if(im+layer*88==tof1) {
320 m_energy = l1*10.25/5.;
321 m_energy_ext = lext*10.25/5.;
324 if(
abs(m_zpos)<0.6&&m_q>500&&m_q<4000){
326 m_EvsQ = m_EvsQ+ m_energy/m_q;
329 }
else if((*it)->barrel() && im+layer*88 == tof2) {
342 m_energy = l2*10.25/5.;
343 m_energy_ext = lext*10.25/5.;
347 if(
abs(m_zpos)<0.6&&m_q>500&&m_q<4000){
349 m_EvsQ = m_EvsQ+m_energy/m_q;
const double tof1Path() const
const Hep3Vector tof1Position() const
const int tof1VolumeNumber() const
const Hep3Vector tof2Momentum() const
const Hep3Vector tof1Momentum() const
const double tof2Path() const
const int tof2VolumeNumber() const
const Hep3Vector tof2Position() const