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