BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EFChargedTrack.cxx
Go to the documentation of this file.
1#include "GaudiKernel/MsgStream.h"
2// #include "GaudiKernel/AlgFactory.h"
3// #include "GaudiKernel/ISvcLocator.h"
4// #include "GaudiKernel/IDataProviderSvc.h"
5#include "GaudiKernel/Bootstrap.h"
6#include "GaudiKernel/SmartDataPtr.h"
7// #include "GaudiKernel/PropertyMgr.h"
8#include "EventModel/Event.h"
9#include "EventModel/EventHeader.h"
11#include "MdcRecEvent/RecMdcTrack.h"
12
13using namespace Event;
14
15EFChargedTrack::EFChargedTrack( const std::string& name, ISvcLocator* pSvcLocator )
16 : IEFAlgorithm( name, pSvcLocator ) {
17 int output = ( m_output % 100 ) / 10;
18 // declareProperty("OutputLevel",m_output = MSG::NIL);
19 MsgStream log( msgSvc(), name );
20 msgSvc()->setOutputLevel( name, output );
21 m_ntrk = new CriteriaItemValue;
22 m_acol = new CriteriaItemValue;
23 m_mbal = new CriteriaItemValue;
24 m_pmax1 = new CriteriaItemValue;
25 m_pmax2 = new CriteriaItemValue;
26 m_cost1 = new CriteriaItemValue;
27 m_cost2 = new CriteriaItemValue;
28 m_vr = new CriteriaItemValue;
29 m_vz = new CriteriaItemValue;
30}
31
33 delete m_ntrk;
34 delete m_acol;
35 delete m_mbal;
36 delete m_pmax1;
37 delete m_pmax2;
38 delete m_cost1;
39 delete m_cost2;
40 delete m_vr;
41 delete m_vz;
42}
43
45
46 MsgStream log( msgSvc(), name() );
47 log << MSG::INFO << "in initialize()" << endmsg;
48
50
51 StatusCode sc;
52 sc = m_HltStoreSvc->put( "ntrk", m_ntrk );
53 if ( sc.isFailure() )
54 {
55 log << MSG::ERROR << "m_HltStoreSvc->put(ntrk) wrong" << endmsg;
56 return sc;
57 }
58 sc = m_HltStoreSvc->put( "acol", m_acol );
59 if ( sc.isFailure() )
60 {
61 log << MSG::ERROR << "m_HltStoreSvc->put(acol) wrong" << endmsg;
62 return sc;
63 }
64 sc = m_HltStoreSvc->put( "mbal", m_mbal );
65 if ( sc.isFailure() )
66 {
67 log << MSG::ERROR << "m_HltStoreSvc->put(mbal) wrong" << endmsg;
68 return sc;
69 }
70 sc = m_HltStoreSvc->put( "pmax1", m_pmax1 );
71 if ( sc.isFailure() )
72 {
73 log << MSG::ERROR << "m_HltStoreSvc->put(pmax1) wrong" << endmsg;
74 return sc;
75 }
76 sc = m_HltStoreSvc->put( "pmax2", m_pmax2 );
77 if ( sc.isFailure() )
78 {
79 log << MSG::ERROR << "m_HltStoreSvc->put(pmax2) wrong" << endmsg;
80 return sc;
81 }
82 sc = m_HltStoreSvc->put( "cost1", m_cost1 );
83 if ( sc.isFailure() )
84 {
85 log << MSG::ERROR << "m_HltStoreSvc->put(cost1) wrong" << endmsg;
86 return sc;
87 }
88 sc = m_HltStoreSvc->put( "cost2", m_cost2 );
89 if ( sc.isFailure() )
90 {
91 log << MSG::ERROR << "m_HltStoreSvc->put(cost2) wrong" << endmsg;
92 return sc;
93 }
94 sc = m_HltStoreSvc->put( "vr", m_vr );
95 if ( sc.isFailure() )
96 {
97 log << MSG::ERROR << "m_HltStoreSvc->put(vr) wrong" << endmsg;
98 return sc;
99 }
100 sc = m_HltStoreSvc->put( "vz", m_vz );
101 if ( sc.isFailure() )
102 {
103 log << MSG::ERROR << "m_HltStoreSvc->put(vz) wrong" << endmsg;
104 return sc;
105 }
106
107 log << MSG::DEBUG << "finish initialize()" << endmsg;
108
109 return StatusCode::SUCCESS;
110}
111
113
114 reset();
115
116 MsgStream log( msgSvc(), name() );
117 // DataObject* pObject;
118
119 // Part 1: Get the event header, print out event and run number
120 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(), "/Event/EventHeader" );
121 if ( !eventHeader )
122 {
123 log << MSG::FATAL << "Could not find Event Header" << endmsg;
124 return ( StatusCode::FAILURE );
125 }
126
127 // Part 2: Retrieve Track Collection
128 SmartDataPtr<RecMdcTrackCol> mdcTrackCol( eventSvc(), "/Event/Recon/RecMdcTrackCol" );
129 if ( !mdcTrackCol )
130 {
131 log << MSG::FATAL << "Could not find Mdc track collection!!" << endmsg;
132 return ( StatusCode::FAILURE );
133 }
134 // Part 3:
135 RecMdcTrackCol::iterator iterTrk = mdcTrackCol->begin();
136 double max1 = 0.;
137 double max2 = 0.;
138 double cost1 = -999, cost2 = -999, phi1 = -999, phi2 = -999;
139 int hit1 = -999, hit2 = -999, shit1 = -999, shit2 = -999, charg1 = -999, charg2 = -999;
140 double mdcbalance = -999;
141
142 unsigned int ntrk = mdcTrackCol->size();
143 double kappa = -999, tanl = -999, sint = -999;
144 double p = -999, theta = -999, phi = -999;
145 double vz1 = -999, vz2 = -999, vr1 = -999, vr2 = -999;
146
147 // double theta1=0,theta2=0;
148 for ( ; iterTrk != mdcTrackCol->end(); iterTrk++ )
149 {
150 // z0=(*iterTrk)->getZ0();
151 // x0=(*iterTrk)->getX0();
152 // y0=(*iterTrk)->getY0();
153 phi = ( *iterTrk )->helix( 1 );
154 kappa = ( *iterTrk )->helix( 2 );
155 tanl = ( *iterTrk )->helix( 4 );
156
157 theta = 0.5 * 3.1415926 - atan( tanl );
158 sint = sin( theta );
159 // log << MSG::DEBUG << "FastTrk=>("<<x0<<","<<y0<<","<<z0")=>"
160 // <<(*iterTrk)->getId() << ":"<<(*iterTrk)->getPivot()<<":"
161 // <<kappa<<">"<<tanl<<endmsg;
162 if ( abs( kappa ) > 0.001 && abs( sint ) > 0.01 ) { p = abs( 1. / kappa ) / sint; }
163 else
164 {
165 p = 1000.;
166 log << MSG::WARNING << "FastTrk=>"
167 << " kappa=" << kappa << "; sint=" << sint << endmsg;
168 }
169 if ( p >= max1 )
170 {
171 max2 = max1;
172 cost2 = cost1;
173 phi2 = phi1;
174 max1 = p;
175 cost1 = cos( theta );
176 phi1 = phi;
177 vz2 = vz1;
178 vz1 = ( *iterTrk )->helix( 3 );
179 vr2 = vr1;
180 vr1 = ( *iterTrk )->helix( 0 );
181 hit2 = hit1;
182 hit1 = ( *iterTrk )->getNhits();
183 shit2 = shit1;
184 shit1 = ( *iterTrk )->nster();
185 charg2 = charg1;
186 charg1 = ( *iterTrk )->charge();
187 }
188 else if ( p > max2 )
189 {
190 max2 = p;
191 cost2 = cos( theta );
192 phi2 = phi;
193 vz2 = ( *iterTrk )->helix( 3 );
194 vr2 = ( *iterTrk )->helix( 0 );
195 hit2 = ( *iterTrk )->getNhits();
196 shit2 = ( *iterTrk )->nster();
197 charg2 = ( *iterTrk )->charge();
198 }
199 log << MSG::DEBUG << "p=" << p << ", "
200 << "theta=" << theta << ", phi=" << phi << ", vz=" << ( *iterTrk )->helix( 3 )
201 << ", vr=" << ( *iterTrk )->helix( 0 ) << endmsg;
202 if ( cos( theta ) > 0 ) mdcbalance += 1.;
203 else if ( cos( theta ) < 0 ) mdcbalance -= 1.;
204 }
205 if ( ntrk >= 2 ) mdcbalance /= ntrk;
206 else mdcbalance = 1;
207
208 double acol = 180.;
209 if ( ntrk >= 2 )
210 {
211 acol = 180. -
212 180. / 3.1415926 *
213 acos( cos( phi1 ) * sin( acos( cost1 ) ) * cos( phi2 ) * sin( acos( cost2 ) ) +
214 sin( phi1 ) * sin( acos( cost1 ) ) * sin( phi2 ) * sin( acos( cost2 ) ) +
215 cost1 * cost2 );
216 }
217
218 log << MSG::INFO << "ntrk=" << ntrk << "; mdc balance=" << mdcbalance << "; pmax1=" << max1
219 << "; pmax2=" << max2 << "; acol=" << acol << "; cost1=" << cost1 << "; cost2=" << cost2
220 << endmsg;
221
222 // Part 4: Put the criteria item(s) to HltStoreSvc here
223 m_ntrk->setValue( ntrk );
224 m_acol->setValue( acol );
225 m_mbal->setValue( mdcbalance );
226 m_pmax1->setValue( max1 );
227 m_pmax2->setValue( max2 );
228 m_cost1->setValue( cost1 );
229 m_cost2->setValue( cost2 );
230 m_vr->setValue( vr1 );
231 m_vz->setValue( vz1 );
232
233 m_ef->addToEFVec( ntrk, 6 );
234 m_ef->appToEFVec( max1, 7 );
235 m_ef->appToEFVec( cost1, 8 );
236 m_ef->appToEFVec( vz1, 9 );
237 m_ef->appToEFVec( phi1, 10 );
238 m_ef->appToEFVec( vr1, 11 );
239 m_ef->addToEFVec( hit1, 12 );
240 m_ef->addToEFVec( shit1, 13 );
241 m_ef->appToEFVec( max2, 14 );
242 m_ef->appToEFVec( cost2, 15 );
243 m_ef->appToEFVec( vz2, 16 );
244 m_ef->appToEFVec( phi2, 17 );
245 m_ef->appToEFVec( vr2, 18 );
246 m_ef->addToEFVec( hit2, 19 );
247 m_ef->addToEFVec( shit2, 20 );
248 m_ef->appToEFVec( acol, 21 );
249 m_ef->setVecBit( true, 0, 4 );
250 if ( ntrk == 0 ) m_ef->addToEFVec( 1, 1 );
251 else if ( ntrk == 1 ) m_ef->addToEFVec( 8, 1 );
252 else if ( ntrk >= 2 ) m_ef->addToEFVec( 16, 1 );
253 else m_ef->addToEFVec( 0, 1 );
254
255 m_ef->addToEFVec( charg1, 23 );
256 m_ef->addToEFVec( charg2, 24 );
257
258 m_run = 1;
259
260 return StatusCode::SUCCESS;
261}
262
264 MsgStream log( msgSvc(), name() );
265 log << MSG::INFO << "in finalize()" << endmsg;
266 return StatusCode::SUCCESS;
267}
268
270 // Reset
271 if ( m_run )
272 {
273 m_ntrk->reset();
274 m_acol->reset();
275 m_mbal->reset();
276 m_pmax1->reset();
277 m_pmax2->reset();
278 m_cost1->reset();
279 m_cost2->reset();
280 m_vr->reset();
281 m_vz->reset();
282 m_run = 0;
283 }
284 return;
285}
Double_t phi2
Double_t phi1
*******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 finalize()
virtual ~EFChargedTrack()
virtual StatusCode initialize()
virtual StatusCode execute()
virtual void reset()
EFChargedTrack(const std::string &name, ISvcLocator *pSvcLocator)
EFResult * m_ef
IEFAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize()
HltStoreSvc * m_HltStoreSvc