BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EFFlightTime.cxx
Go to the documentation of this file.
1#include "GaudiKernel/MsgStream.h"
2#include <cmath>
3// #include "GaudiKernel/AlgFactory.h"
4#include "GaudiKernel/SmartDataPtr.h"
5// #include "GaudiKernel/PropertyMgr.h"
6#include "EventModel/Event.h"
7#include "EventModel/EventHeader.h"
8#include "Identifier/Identifier.h"
9// #include "TofRawEvent/TofDigi.h"
10// #include "Identifier/TofID.h"
11// #include "RawEvent/RawDataUtil.h"
12#include "RawDataProviderSvc/TofData.h"
13
15
16// using namespace Event;
17typedef std::vector<EFTofHitsCol> VTOF;
18
19EFFlightTime::EFFlightTime( const std::string& name, ISvcLocator* pSvcLocator )
20 : IEFAlgorithm( name, pSvcLocator ) {
21 int output = ( m_output % 10 ) / 1;
22 // declareProperty("OutputLevel",m_output = MSG::NIL);
23 MsgStream log( msgSvc(), name );
24 msgSvc()->setOutputLevel( name, output );
25 m_dtof1 = new CriteriaItemValue;
26 m_dphi1 = new CriteriaItemValue;
27 m_dtof2 = new CriteriaItemValue;
28 m_dphi2 = new CriteriaItemValue;
29}
30
32 delete m_dtof1;
33 delete m_dphi1;
34 delete m_dtof2;
35 delete m_dphi2;
36}
37
39
40 MsgStream log( msgSvc(), name() );
41 log << MSG::INFO << "in initialize()" << endmsg;
42
44
45 StatusCode sc;
46 sc = m_HltStoreSvc->put( "dtof1", m_dtof1 );
47 if ( sc.isFailure() )
48 {
49 log << MSG::ERROR << "m_HltStoreSvc->put(dtof1) wrong" << endmsg;
50 return sc;
51 }
52 sc = m_HltStoreSvc->put( "dphi1", m_dphi1 );
53 if ( sc.isFailure() )
54 {
55 log << MSG::ERROR << "m_HltStoreSvc->put(dphi1) wrong" << endmsg;
56 return sc;
57 }
58 sc = m_HltStoreSvc->put( "dtof2", m_dtof2 );
59 if ( sc.isFailure() )
60 {
61 log << MSG::ERROR << "m_HltStoreSvc->put(dtof2) wrong" << endmsg;
62 return sc;
63 }
64 sc = m_HltStoreSvc->put( "dphi2", m_dphi2 );
65 if ( sc.isFailure() )
66 {
67 log << MSG::ERROR << "m_HltStoreSvc->put(dphi2) wrong" << endmsg;
68 return sc;
69 }
70
71 log << MSG::DEBUG << "finish initialize()" << endmsg;
72 return StatusCode::SUCCESS;
73}
74
76
77 reset();
78
79 MsgStream log( msgSvc(), name() );
80 // DataObject* pObject;
81
82 // Part 1: Get the event header, print out event and run number
83 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(), "/Event/EventHeader" );
84 if ( !eventHeader )
85 {
86 log << MSG::FATAL << "Could not find Event Header" << endmsg;
87 return ( StatusCode::FAILURE );
88 }
89
90 // Part 2: Retrieve Hits Collection
91 // SmartDataPtr<TofDigiCol> tofDigiCol(eventSvc(),"/Event/Digi/TofDigiCol");
92 // if (!tofDigiCol) {
93 // log << MSG::FATAL << "EmcRec could not find Tof digi!!" << endmsg;
94 // return( StatusCode::FAILURE);
95 // }
96 // Part 3: Calculate time difference and back-to-back
97 // TofDigiCol::iterator iterTOF=tofDigiCol->begin();
98 VTOF topTOF;
99 VTOF bottomTOF;
100 topTOF.clear();
101 bottomTOF.clear();
102 Identifier id;
103 unsigned int idBarrel_Endcap, iphi;
104 double tdc;
105
106 TofDataVector tofDataVec = m_rawDigiSvc->tofDataVectorOnlineMode();
107 // TofDataVec tofDataVec=m_rawDigiSvc->tofDataVector(false,false,false,true);
108 if ( tofDataVec.size() > 1 )
109 {
110 TofDataVector::iterator iterTOF = tofDataVec.begin();
111 for ( ; iterTOF != tofDataVec.end(); iterTOF++ )
112 {
113 if ( ( *iterTOF )->barrel() )
114 {
115 idBarrel_Endcap = 1;
116 int id = ( *iterTOF )->tofId();
117 iphi = id % 88;
118 int ilayer = id / 88;
119 double t1 = ( *iterTOF )->tdc1();
120 double t2 = ( *iterTOF )->tdc2();
121 double tof = -999;
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;
125 else continue;
126 log << MSG::DEBUG << "hit: "
127 << "(" << idBarrel_Endcap << "," << ilayer << "," << iphi << ")-->" << tof << " ns"
128 << endmsg;
129 // if(idBarrel_Endcap!=1&&idBarrel_Endcap!=0&&idBarrel_Endcap!=2)
130 // log << MSG::WARNING <<"TOF(" <<idBarrel_Endcap <<","<< ilayer << "," << iphi <<
131 // ")=>"
132 // << tdc <<endmsg;
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 ) ); }
137 }
138 else
139 {
140 int iphi = ( *iterTOF )->tofId();
141 double tof = ( *iterTOF )->tdc();
142 if ( iphi >= 48 )
143 {
144 idBarrel_Endcap = 2;
145 iphi %= 48;
146 }
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 ) ); }
152 }
153 }
154 }
155 double dtof1 = 99;
156 double dphi1 = 180;
157 double dtof2 = 99;
158 double dphi2 = 180;
159 if ( topTOF.size() >= 1 && bottomTOF.size() >= 1 )
160 {
161 for ( unsigned int i = 0; i < topTOF.size(); i++ )
162 {
163 double topPhi = 0.;
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++ )
169 {
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. ) )
178 {
179 dtof2 = topTOF[i].GetT() - bottomTOF[j].GetT();
180 dphi2 = abs( fabs( topPhi - bottomPhi ) - 180. );
181 }
182 if ( tmp1 < fabs( dtof1 ) )
183 {
184 dphi1 = abs( fabs( topPhi - bottomPhi ) - 180. );
185 dtof1 = topTOF[i].GetT() - bottomTOF[j].GetT();
186 }
187 }
188 }
189 }
190
191 log << MSG::INFO << "dtof1=" << dtof1 << ", dphi1=" << dphi1 << "dtof2=" << dtof2
192 << ", dphi2=" << dphi2 << endmsg;
193
194 // Part 4: Put the criteria item(s) to HltStoreSvc here
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 );
205
206 m_run = 1;
207 return StatusCode::SUCCESS;
208}
209
211 MsgStream log( msgSvc(), name() );
212 log << MSG::INFO << "in finalize()" << endmsg;
213 return StatusCode::SUCCESS;
214}
215
217
218 if ( m_run )
219 {
220 m_dtof1->reset();
221 m_dphi1->reset();
222 m_dtof2->reset();
223 m_dphi2->reset();
224 m_run = 0;
225 }
226 return;
227}
228
229VTOF::iterator EFFlightTime::FindHit( VTOF& tof, const unsigned int ilayer,
230 const unsigned int iphi, const unsigned int ibe ) {
231 VTOF::iterator it = tof.begin();
232 for ( ; it != tof.end(); it++ )
233 {
234 if ( ibe != it->ib_e() ) continue;
235 if ( ilayer == it->ilayer() )
236 {
237 if ( iphi == it->iphi() ) return it;
238 if ( iphi + 1 == it->iphi() ) return it;
239 if ( iphi - 1 == it->iphi() ) return it;
240 }
241 else
242 {
243 if ( iphi == it->iphi() ) return it;
244 if ( iphi + ( it->ilayer() - ilayer ) == it->iphi() ) return it;
245 }
246 }
247 return it;
248}
std::vector< EFTofHitsCol > VTOF
*******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
Definition FoamA.h:89
IMessageSvc * msgSvc()
virtual StatusCode initialize()
EFFlightTime(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode finalize()
virtual ~EFFlightTime()
StatusCode execute()
EFResult * m_ef
IEFAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize()
IRawDataProviderSvc * m_rawDigiSvc
HltStoreSvc * m_HltStoreSvc