BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcUtilitySvc.cxx
Go to the documentation of this file.
1#include "MdcUtilitySvc.h"
2#include "CLHEP/Units/PhysicalConstants.h"
3#include "EventModel/EventHeader.h"
4#include "GaudiKernel/Bootstrap.h"
5#include "GaudiKernel/IDataProviderSvc.h"
6#include "GaudiKernel/IPartPropSvc.h"
7#include "GaudiKernel/ISvcLocator.h"
8#include "GaudiKernel/MsgStream.h"
9#include "GaudiKernel/SmartDataPtr.h"
10#include "HepPDT/ParticleDataTable.hh"
11#include "MdcGeom/BesAngle.h"
12#include "MdcGeom/Constants.h"
13#include "MdcGeom/MdcLayer.h"
14#include "TrkBase/HelixTraj.h"
15#include "TrkBase/TrkPoca.h"
16#include <cmath>
17#ifndef ENABLE_BACKWARDS_COMPATIBILITY
18// backwards compatblty wll be enabled ONLY n CLHEP 1.9
19typedef HepGeom::Point3D<double> HepPoint3D;
20#endif
21
22using namespace std;
23using namespace Event;
25MdcUtilitySvc::MdcUtilitySvc( const string& name, ISvcLocator* svcloc )
26 : base_class( name, svcloc ) {
27 declareProperty( "debug", m_debug = 0 );
28}
29
31
33 MsgStream log( msgSvc(), name() );
34 log << MSG::INFO << "MdcUtilitySvc::initialize()" << endmsg;
35
36 StatusCode sc = Service::initialize();
37 if ( sc.isFailure() )
38 {
39 log << MSG::ERROR << "Service::initialize() failure" << endmsg;
40 return sc;
41 }
42
43 // Initalze magnetic flied
44
45 sc = service( "MagneticFieldSvc", m_pIMF );
46 if ( !m_pIMF )
47 {
48 log << MSG::FATAL << " ERROR Unable to open Magnetic field service " << endmsg;
49 return StatusCode::FAILURE;
50 }
51
52 // Initialize MdcGeomSvc
53 IMdcGeomSvc* imdcGeomSvc;
54 sc = service( "MdcGeomSvc", imdcGeomSvc );
55 m_mdcGeomSvc = imdcGeomSvc;
56 if ( !imdcGeomSvc )
57 {
58 log << MSG::FATAL << " Could not load MdcGeomSvc! " << endmsg;
59 return StatusCode::FAILURE;
60 }
61
62 IRawDataProviderSvc* irawDataProviderSvc;
63 sc = service( "RawDataProviderSvc", irawDataProviderSvc );
64 m_RawDataProviderSvc = irawDataProviderSvc;
65 if ( sc.isFailure() )
66 {
67 log << MSG::FATAL << name() << " Could not load RawDataProviderSvc!" << endmsg;
68 return StatusCode::FAILURE;
69 }
70
71 return StatusCode::SUCCESS;
72}
73
75 MsgStream log( msgSvc(), name() );
76 log << MSG::INFO << "MdcUtilitySvc::finalize()" << endmsg;
77
78 return StatusCode::SUCCESS;
79}
80
81vector<MdcDigi*> MdcUtilitySvc::getMdcDigiVec() const {
82 uint32_t getDigiFlag = 0;
83
84 MdcDigiVec mdcDigiVec = m_RawDataProviderSvc->getMdcDigiVec( getDigiFlag );
85 cout << "MdcUtilitySvc::getMdcDigiVec() get " << mdcDigiVec.size()
86 << " MDC digis from RawDataProviderSvc" << endl;
87
88 return mdcDigiVec;
89}
90
91// vector<vector<MdcDigi*> > MdcUtilitySvc::ConnectionHitsGroup(int SameLRange,int DiffLRange)
92// const
93//{
94// vector<MdcDigi*> MdcHits = MdcUtilitySvc::getMdcDigiVec();
95// return MdcUtilitySvc::ConnectionHitsGroup(MdcHits,SameLRange,DiffLRange);
96// }
97
98// vector<vector<MdcDigi*> > MdcUtilitySvc::ConnectionHitsGroup(vector<MdcDigi*> &MdcHits,int
99// SameLRange,int DiffLRange) const
100//{
101// //cout<<"range1 "<<SameLRange<<" range2 "<<DiffLRange<<endl;
102// //group adjacent MdcDigis
103// vector<MdcHitGroup*> wires(6796);
104// for(int i=0;i<6796;i++){
105// wires[i] = new MdcHitGroup();
106// wires[i]->SetWire(m_mdcGeomSvc->Wire(i));
107// }
108//// vector<MdcDigi*> MdcHits = MdcUtilitySvc::getMdcDigiVec();
109// //int nHits = MdcHits.size();
110// for(vector<MdcDigi*>::iterator iter_mdcDigi = MdcHits.begin();iter_mdcDigi!=MdcHits.end();
111// iter_mdcDigi++) {
112// Identifier id = (*iter_mdcDigi)->identify();
113// int layer_id = MdcID::layer(id);
114// int wire_id = MdcID::wire(id);
115// int wireid = m_mdcGeomSvc->Wire(layer_id,wire_id)->Id();
116// wires[wireid]->AddHit(*iter_mdcDigi);
117// int wireT1_tem=wires[wireid]->GetWire()->GetNeighborIDType1();
118// int wireT2_tem=wires[wireid]->GetWire()->GetNeighborIDType2();
119// for(int range=0;range<SameLRange;range++){
120// // int type1 = wires[wireid]->GetWire()->GetNeighborIDType1();
121// int type1 = wireT1_tem;
122// wires[type1]->AddType2(wireid);
123// wireT1_tem = wires[type1]->GetWire()->GetNeighborIDType1();
124// // int type2 = wires[wireid]->GetWire()->GetNeighborIDType2();
125// int type2 = wireT2_tem;
126// wires[type2]->AddType1(wireid);
127// wireT2_tem = wires[type2]->GetWire()->GetNeighborIDType2();
128// }
129//
130// vector<int> wireT3_tem=wires[wireid]->GetWire()->GetNeighborIDType3();
131// vector<int> wireT4_tem=wires[wireid]->GetWire()->GetNeighborIDType4();
132// for(int range=0;range<DiffLRange;range++){
133// //vector<int> type3 = wires[wireid]->GetWire()->GetNeighborIDType3();
134// int flag = 0;
135// vector<int> type3 = wireT3_tem;
136// for(unsigned int i=0;i<type3.size();i++){
137// wires[type3[i]]->AddType4(wireid);
138// vector<int> tem1 = wires[type3[i]]->GetWire()->GetNeighborIDType3();
139// vector<int> tem2 = wireT3_tem;
140// if(i==0){
141// wireT3_tem = wires[type3[i]]->GetWire()->GetNeighborIDType3();
142// }
143// else{
144// for(unsigned int k=0;k<tem1.size();k++){
145// for(unsigned int j=0;j<tem2.size();j++){
146// if(tem1.at(k)==tem2.at(j)){
147// flag = 1;
148// break;
149// }
150// }
151// if(flag==0){
152// wireT3_tem.push_back(tem1.at(k));
153// }
154// flag = 0;
155// }
156//
157// }
158// }
159// //vector<int> type4 = wires[wireid]->GetWire()->GetNeighborIDType4();
160// vector<int> type4 = wireT4_tem;
161// for(unsigned int i=0;i<type4.size();i++){
162// wires[type4[i]]->AddType3(wireid);
163// vector<int> tem1 = wires[type4[i]]->GetWire()->GetNeighborIDType4();
164// vector<int> tem2 = wireT4_tem;
165// if(i==0){
166// wireT3_tem = wires[type4[i]]->GetWire()->GetNeighborIDType4();
167// }
168// else{
169// for(unsigned int k=0;k<tem1.size();k++){
170// for(unsigned int j=0;j<tem2.size();j++){
171// if(tem1.at(k)==tem2.at(j)){
172// flag = 1;
173// break;
174// }
175// }
176// if(flag==0){
177// wireT4_tem.push_back(tem1.at(k));
178// }
179// flag = 0;
180// }
181// }
182// }
183// }
184//}
185// vector<vector<MdcDigi*> > GroupDigis;
186// vector<vector<MdcHitGroup*> > GroupHits;
187// for(int i=0;i<6796;i++){
188// // vector<MdcDigi*> group;
189// vector<MdcHitGroup*> groups;
190// vector<MdcHitGroup*> tem_store;
191// //bool flag=true;
192// if(!wires[i]->Used()){
193// tem_store.push_back(wires[i]);
194// while(!tem_store.empty()){
195// MdcHitGroup* tem_wire = tem_store.back();
196// tem_store.pop_back();
197// if(!tem_wire->Used())
198// {
199// groups.push_back(tem_wire);
200// tem_wire->SetUsedFlag();
201// for(unsigned int k = 0;k<tem_wire->GetNeiborHits().size();k++){
202// int neiID=tem_wire->GetNeiborHits().at(k);
203// if(!wires[neiID]->Used()){
204// tem_store.push_back(wires[neiID]);
205// }
206// }
207// }
208// }
209// }
210// if(!groups.empty()){
211// GroupHits.push_back(groups);
212// }
213// }
214// for(unsigned int i=0;i<GroupHits.size();i++){
215// //cout<<"group: "<<i<<endl;
216// vector<MdcDigi*> aGroup;
217// for(unsigned int j=0;j<GroupHits[i].size();j++){
218// vector<MdcDigi*> testdigis = GroupHits[i].at(j)->GetHit();
219// for(unsigned int k=0;k< testdigis.size();k++){
220// aGroup.push_back(testdigis.at(k));
221// // Identifier id = testdigis.at(k)->identify();
222// // int layer_id = MdcID::layer(id);
223// // int wire_id = MdcID::wire(id);
224// // cout<<"layer: "<<layer_id<<" wire: "<<wire_id<<endl;
225//
226// }
227// }
228// GroupDigis.push_back(aGroup);
229// }
230// for(int i=0;i<6796;i++){
231// delete wires[i];
232// }
233// wires.clear();
234// return GroupDigis;
235//}
236
237double MdcUtilitySvc::dPhi( double phi1, double phi2 ) {
238 double dphi = phi1 - phi2;
239 while ( dphi > M_PI ) dphi -= M_PI * 2.0;
240 while ( dphi < -M_PI ) dphi += M_PI * 2.0;
241 return dphi;
242}
243
244/*StatusCode MdcUtilitySvc::queryInterface(const InterfaceID& riid, void** ppvInterface){
245
246 if( IID_IMdcUtilitySvc.versionMatch(riid) ){
247 *ppvInterface = static_cast<IMdcUtilitySvc*> (this);
248 } else{
249 return Service::queryInterface(riid, ppvInterface);
250 }
251
252 addRef();
253 return StatusCode::SUCCESS;
254}*/
255
256// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
257int MdcUtilitySvc::nLayerTrackPassed( const double helixBes[5] ) const {
258
259 HepVector helixBesParam( 5, 0 );
260 for ( int i = 0; i < 5; ++i ) helixBesParam[i] = helixBes[i];
261
262 return nLayerTrackPassed( helixBesParam );
263}
264
265// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
266int MdcUtilitySvc::nLayerTrackPassed( const HepVector helixBes ) const {
267 HepVector helix = besPar2PatPar( helixBes );
268
269 int nLayer = 0;
270
271 for ( unsigned iLayer = 0; iLayer < 43; iLayer++ )
272 {
273 // flightLength is the path length of track in the x-y plane
274 // guess flightLength by the radius in middle of the wire.
275 double rMidLayer = m_mdcGeomSvc->Layer( iLayer )->Radius();
276 double flightLength = rMidLayer;
277
278 HepPoint3D pivot( 0., 0., 0. );
279 double dz = helix[3];
280 double c = CLHEP::c_light * 100.; // unit from m/s to cm/s
281 double alpha = 1 / ( c * Bz() ); //~333.567
282 double kappa = helix[2];
283 double rc = ( -1. ) * alpha / kappa;
284 // std::cout<<"MdcUtilitySvc alpha "<<alpha<<std::endl;
285 double tanl = helix[4];
286 double phi0 = helix[1];
287 double phi = flightLength / rc + phi0; // turning angle
288 double z = pivot.z() + dz - ( alpha / kappa ) * tanl * phi;
289
290 double layerHalfLength = m_mdcGeomSvc->Layer( iLayer )->Length() / 2.;
291
292 // std::cout<<"MdcUtilitySvc length "<<layerHalfLength<<std::endl;
293
294 if ( fabs( z ) < fabs( layerHalfLength ) ) ++nLayer;
295 }
296
297 return nLayer;
298}
299
300// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
301HepVector MdcUtilitySvc::patPar2BesPar( const HepVector& helixPar ) const {
302 HepVector helix( 5, 0 );
303 double d0 = -helixPar[0]; // cm
304 double phi0 = helixPar[1] + CLHEP::halfpi;
305 double omega = Bz() * helixPar[2] / -333.567;
306 double z0 = helixPar[3]; // cm
307 double tanl = helixPar[4];
308 helix[0] = d0;
309 helix[1] = phi0;
310 helix[2] = omega;
311 helix[3] = z0;
312 helix[4] = tanl;
313 // std::cout<<"helix "<<helix<<std::endl;
314 return helix;
315}
316
317// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
318HepSymMatrix MdcUtilitySvc::patErr2BesErr( const HepSymMatrix& err ) const {
319 // error matrix
320 // std::cout<<" err1 "<<err<<" "<<err.num_row()<<std::endl;
321 // V(Y)=S * V(X) * ST , mS = S , mVy = V(Y) , err() = V(X)
322 // int n = err.num_row();
323 HepSymMatrix mS( err.num_row(), 0 );
324 mS[0][0] = -1.; // dr0=-d0
325 mS[1][1] = 1.;
326
327 mS[2][2] = Bz() / -333.567; // pxy -> cpa
328 mS[3][3] = 1.;
329 mS[4][4] = 1.;
330 HepSymMatrix mVy = err.similarity( mS );
331 // std::cout<<" err2 "<<n<<" "<<mVy<<std::endl;
332 return mVy;
333}
334
335// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
336//-------position of track pass this layer--------------
337HepPoint3D MdcUtilitySvc::pointOnHelix( const HepVector helixBes, int layer,
338 int innerOrOuter ) const {
339 HepVector helixPat = besPar2PatPar( helixBes );
340 return pointOnHelixPatPar( helixPat, layer, innerOrOuter );
341}
342
343// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
344//-------position of track pass this layer--------------
345HepPoint3D MdcUtilitySvc::pointOnHelixPatPar( const HepVector helixPat, int layer,
346 int innerOrOuter ) const {
347
348 double rInner, rOuter;
349 // retrieve Mdc geometry information
350 double rCize1 = 0.1 * m_mdcGeomSvc->Layer( layer )->RCSiz1(); // mm -> cm
351 double rCize2 = 0.1 * m_mdcGeomSvc->Layer( layer )->RCSiz2(); // mm -> cm
352 double rLay = 0.1 * m_mdcGeomSvc->Layer( layer )->Radius(); // mm -> cm
353
354 //(conversion of the units mm(mc)->cm(rec))
355 rInner = rLay - rCize1; // radius of inner field wire
356 rOuter = rLay + rCize2; // radius of outer field wire
357
358 // int sign = -1; //assumed the first half circle
359 HepPoint3D piv( 0., 0., 0. );
360 double r;
361 if ( innerOrOuter ) r = rInner;
362 else r = rOuter;
363
364 double d0 = helixPat[0];
365 double phi0 = helixPat[1];
366 double omega = helixPat[2];
367 double z0 = helixPat[3];
368 double tanl = helixPat[4];
369
370 double rc;
371 if ( abs( omega ) < Constants::epsilon ) rc = 9999.;
372 else rc = 1. / omega;
373 double xc = piv.x() + ( d0 + rc ) * cos( phi0 );
374 double yc = piv.y() + ( d0 + rc ) * sin( phi0 );
375 HepPoint3D helixCenter( xc, yc, 0.0 );
376 rc = sqrt( xc * xc + yc * yc ); //?
377 double a, b, c;
378 a = r;
379 b = d0 + rc;
380 c = rc;
381 double dphi = acos( ( a * a - b * b - c * c ) / ( -2. * b * c ) );
382 double fltlen = dphi * rc;
383 double phi = phi0 * omega * fltlen;
384 double x = piv.x() + d0 * sin( phi ) - ( rc + d0 ) * sin( phi0 );
385 double y = piv.y() + d0 * cos( phi ) + ( rc + d0 ) * cos( phi0 );
386 double z = piv.z() + z0 + fltlen * tanl;
387 // std::cout<<" xc yc "<<xc<<" "<<yc
388 if ( m_debug )
389 {
390 std::cout << " abc " << a << " " << b << " " << c << " omega " << omega << " r " << r
391 << " rc " << rc << " dphi " << dphi << " piv " << piv.z() << " z0 " << z0
392 << " fltlen " << fltlen << " tanl " << tanl << std::endl;
393 std::cout << " pointOnHelixPatPar in Hel " << helixPat << std::endl;
394 cout << "HepPoint3D(x, y, z) = " << HepPoint3D( x, y, z ) << endl;
395 }
396 return HepPoint3D( x, y, z );
397}
398
399// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
400// 1. from five track parameter and layer,cell to calculate the poca postion
401double MdcUtilitySvc::doca( int layer, int cell, const HepVector helixBes,
402 const HepSymMatrix errMatBes, bool passCellRequired,
403 bool doSag ) const {
404 HepVector helixPat = besPar2PatPar( helixBes );
405 HepSymMatrix errMatPat = besErr2PatErr( errMatBes );
406
407 return docaPatPar( layer, cell, helixPat, errMatPat, passCellRequired, doSag ); // call 4.
408}
409
410// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
411// 2. from five track parameter, layer, cell , eastP, westP to calculate the poca postion
412double MdcUtilitySvc::doca( int layer, int cell, HepPoint3D eastP, HepPoint3D westP,
413 const HepVector helixBes, const HepSymMatrix errMatBes,
414 bool passCellRequired, bool doSag ) const {
415 HepVector helixPat = besPar2PatPar( helixBes );
416 HepSymMatrix errMatPat = besErr2PatErr( errMatBes );
417
418 return docaPatPar( layer, cell, eastP, westP, helixPat, errMatPat, passCellRequired,
419 doSag ); // call 5.
420}
421
422// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
423// 3. from five track parameter, layer, cell, sWire to calculate the doca postion
424double MdcUtilitySvc::doca( int layer, int cell, const MdcSWire* sWire,
425 const HepVector helixBes, const HepSymMatrix errMatBes,
426 bool passCellRequired ) const {
427 HepVector helixPat = besPar2PatPar( helixBes );
428 HepSymMatrix errMatPat = besErr2PatErr( errMatBes );
429
430 return docaPatPar( layer, cell, sWire, helixPat, errMatPat, passCellRequired ); // call 6.
431}
432
433// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
434// 4. from five track parameter to calculate the doca postion by Pat Param
435double MdcUtilitySvc::docaPatPar( int layer, int cell, const HepVector helixPat,
436 const HepSymMatrix errMat, bool passCellRequired,
437 bool doSag ) const {
438
439 const MdcGeoWire* geowir = m_mdcGeomSvc->Wire( layer, cell );
440 int id = geowir->Id();
441 double sag = 0.;
442 if ( doSag ) sag = geowir->Sag() / 10.; // mm2cm
443 HepPoint3D eastP = geowir->Backward() / 10.0; // mm2cm
444 HepPoint3D westP = geowir->Forward() / 10.0; // mm2cm
445 const MdcSWire* sWire = new MdcSWire( eastP, westP, sag, id, cell );
446
447 double doca =
448 docaPatPar( layer, cell, sWire, helixPat, errMat, passCellRequired ); // call 6.
449
450 delete sWire;
451 return doca;
452}
453
454// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
455// 5. from five track parameter to calculate the doca postion by Pat Param
456double MdcUtilitySvc::docaPatPar( int layer, int cell, HepPoint3D eastP, HepPoint3D westP,
457 const HepVector helixPat, const HepSymMatrix errMat,
458 bool passCellRequired, bool doSag ) const {
459
460 const MdcGeoWire* geowir = m_mdcGeomSvc->Wire( layer, cell );
461 int id = geowir->Id();
462 double sag = 0.;
463 if ( doSag ) sag = geowir->Sag() / 10.; // mm2cm
464 const MdcSWire* sWire = new MdcSWire( eastP, westP, sag, id, cell ); // cm
465
466 double doca =
467 docaPatPar( layer, cell, sWire, helixPat, errMat, passCellRequired ); // call 6.
468
469 delete sWire;
470 return doca;
471}
472
473// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
474// 6. from five track parameter to calculate the doca postion by Pat Param
475double MdcUtilitySvc::docaPatPar( int layer, int cell, const MdcSWire* sWire,
476 const HepVector helixPat, const HepSymMatrix errMat,
477 bool passCellRequired ) const {
478
479 if ( m_debug ) std::cout << " helixPat " << helixPat << std::endl;
480 if ( m_debug ) std::cout << " layer " << layer << " cell " << cell << std::endl;
481 //-----cell track passed
482 int cellId_in = -1;
483 int cellId_out = -1;
484
485 // cellTrackPassedPatPar(helixPat,layer,cellId_in,cellId_out);//yzhang FIXME 2012-07-11
486 cellTrackPassedByPhiPatPar( helixPat, layer, cellId_in,
487 cellId_out ); // yzhang FIXME 2012-07-11
488
489 if ( m_debug )
490 {
491 std::cout << " cellId in " << cellId_in << " out " << cellId_out << std::endl;
492 cout << "cell = " << cell << ", cellId_in = " << cellId_in
493 << ", cellId_out = " << cellId_out << endl;
494 }
495 if ( passCellRequired && ( cell < cellId_in && cell > cellId_out ) ) return -999.;
496
497 //-----helix trajectory
498 HelixTraj* helixTraj = new HelixTraj( helixPat, errMat );
499 const Trajectory* trajHelix = dynamic_cast<const Trajectory*>( helixTraj );
500
501 //-----pointOnHelix
502 int innerOrOuter = 1;
503 Hep3Vector cell_IO = pointOnHelixPatPar( helixPat, layer, innerOrOuter );
504 double fltTrack = 0.1 * m_mdcGeomSvc->Layer( layer )->Radius();
505 if ( m_debug )
506 {
507 std::cout << " cell_IO " << cell_IO << std::endl;
508 std::cout << " fltTrack " << fltTrack << std::endl;
509 }
510
511 //------wire trajectory
512 const MdcSagTraj* m_wireTraj = sWire->getTraj();
513 const Trajectory* trajWire = dynamic_cast<const Trajectory*>( m_wireTraj );
514 const HepPoint3D* start_In = sWire->getEastPoint();
515 // const HepPoint3D* stop_In = sWire->getWestPoint();
516 if ( m_debug )
517 {
518 std::cout << " sag " << m_wireTraj->sag() << std::endl;
519 std::cout << " east -------- " << start_In->x() << "," << start_In->y() << ","
520 << start_In->z() << std::endl;
521 }
522 // std::cout<< " west -------- "<< stop_In->x()<<","<<stop_In->y()<<","<<stop_In->z()
523 // <<std::endl;
524
525 //------calc poca
526 double doca = -999.;
527 TrkPoca* trkPoca;
528 double zWire = cell_IO.z();
529 // HepPoint3D pos_in(zWire,sWire->xWireDC(zWire),sWire->yWireDC(zWire)) ;
530 HepPoint3D pos_in( sWire->xWireDC( zWire ), sWire->yWireDC( zWire ), zWire );
531 if ( m_debug )
532 std::cout << " zWire " << zWire << " zEndDC " << sWire->zEndDC() << std::endl;
533 // if(m_debug) std::cout<<"pos_in "<<pos_in<<" fltWire "<<fltWire<<std::endl;
534
535 double fltWire = sqrt( ( pos_in.x() - start_In->x() ) * ( pos_in.x() - start_In->x() ) +
536 ( pos_in.y() - start_In->y() ) * ( pos_in.y() - start_In->y() ) +
537 ( pos_in.z() - start_In->z() ) * ( pos_in.z() - start_In->z() ) );
538 trkPoca = new TrkPoca( *trajHelix, fltTrack, *trajWire, fltWire );
539 doca = trkPoca->doca();
540
541 double hitLen = trkPoca->flt2();
542 double startLen = trajWire->lowRange() - 5.;
543 double endLen = trajWire->hiRange() + 5.;
544 if ( hitLen < startLen || hitLen > endLen )
545 {
546 if ( m_debug )
547 std::cout << "WARNING MdcUtilitySvc::docaPatPar() isBeyondEndflange! hitLen=" << hitLen
548 << " startLen=" << startLen << " endLen " << endLen << std::endl;
549 doca = -998.;
550 }
551 // std::cout<<" hitLen "<<hitLen<<" startLen "<<startLen<<" endLen "<<endLen <<" doca
552 // "<<doca<<std::endl;
553
554 if ( m_debug ) std::cout << " doca " << doca << std::endl;
555 delete helixTraj;
556 delete trkPoca;
557
558 return doca;
559
560} //----------end of calculatng the doca ---------------------------------//
561
562/*
563// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
564void MdcUtilitySvc::cellPassed(const RecMdcTrack* tk, bool cellTkPassed[43][288]) const{
565HepVector helix(5);
566helix[0]=tk->helix(0);
567helix[1]=tk->helix(1);
568helix[2]=tk->helix(2);
569helix[3]=tk->helix(3);
570helix[4]=tk->helix(4);
571
572for(int i=0;i<43;i++){
573for(int j=0; j<288; j++){
574cellTkPassed[i][j]=false;
575}
576}
577
578for (int layer=0; layer<43; layer++){
579//-----cell track passed
580
581int cellId_in = -1;
582int cellId_out = -1;
583cellTrackPassed(helix,layer,cellId_in,cellId_out);
584cellTkPassed[layer][cellId_in] = true;
585cellTkPassed[layer][cellId_out] = true;
586}
587}
588*/
589// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
590bool MdcUtilitySvc::cellTrackPassedByPhi( const HepVector helixBes, int layer, int& cellId_in,
591 int& cellId_out ) const {
592 HepVector helixPat = besPar2PatPar( helixBes );
593 return cellTrackPassedByPhiPatPar( helixPat, layer, cellId_in, cellId_out );
594}
595
596// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
597// guess cell number of track passed given layer,
598// if passed more than one cell return 0, else return 1.
599// calc with phi , PAT track parameter convention
600bool MdcUtilitySvc::cellTrackPassedByPhiPatPar( const HepVector helixPat, int layer,
601 int& cellId_in, int& cellId_out ) const {
602 int nCell = m_mdcGeomSvc->Layer( layer )->NCell();
603
604 double dPhiz = ( m_mdcGeomSvc->Wire( layer, 0 )->Forward().phi() -
605 m_mdcGeomSvc->Wire( layer, 0 )->Backward().phi() ) *
606 0.5;
607 double rEnd = m_mdcGeomSvc->Wire( layer, 0 )->Backward().rho() / 10.; // mm2cm
608 double rMid = rEnd * cos( dPhiz );
609 // std::cout<<"( cell "<<0<<" westPphi "<<m_mdcGeomSvc->Wire(layer,0)->Forward().phi() <<"
610 // eastPphi "
611 //<<m_mdcGeomSvc->Wire(layer,0)->Backward().phi()<<" twist "<<dPhiz<<" rend
612 //"<<rEnd<<std::endl;
613 double fltLenIn = rMid;
614 double phiIn = helixPat[1] + helixPat[2] * fltLenIn; // phi0 + omega * L
615
616 double phiEPOffset =
617 m_mdcGeomSvc->Wire( layer, 0 )->Backward().phi(); // east.phi()= BackWard.phi
618 BesAngle tmp( phiIn - phiEPOffset );
619 if ( m_debug )
620 std::cout << "cellTrackPassed nCell " << nCell << " layer " << layer << " fltLenIn "
621 << fltLenIn << " phiEPOffset " << phiEPOffset << std::endl;
622 // BesAngle tmp(phiIn - layPtr->phiEPOffset());
623 int wlow = (int)floor( nCell * tmp.rad() / twopi );
624 int wbig = (int)ceil( nCell * tmp.rad() / twopi );
625 if ( tmp == 0 )
626 {
627 wlow = -1;
628 wbig = 1;
629 }
630
631 if ( ( wlow % nCell ) < 0 ) wlow += nCell;
632 cellId_in = wlow;
633
634 if ( ( wbig % nCell ) < 0 ) wbig += nCell;
635 cellId_out = wbig;
636
637 bool passedOneCell = ( cellId_in == cellId_out );
638
639 return passedOneCell; // pass more than one cell
640}
641
642// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
643bool MdcUtilitySvc::cellTrackPassedPatPar( HepVector helixPat, int layer, int& cellId_in,
644 int& cellId_out ) const {
645 HepVector helixBes = patPar2BesPar( helixPat );
646 return cellTrackPassed( helixBes, layer, cellId_in, cellId_out );
647}
648
649// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
650// calc with Belle method, bes3 track parameter convention
651bool MdcUtilitySvc::cellTrackPassed( HepVector helixBes, int lay, int& cellId_in,
652 int& cellId_out ) const {
653 int charge, type, nCell;
654 double dr0, phi0, kappa, dz0, tanl;
655 double ALPHA_loc, rho, phi, cosphi0, sinphi0, x_hc, y_hc, z_hc;
656 double dphi0, IO_phi, C_alpha, xx, yy;
657 double inlow, inup, outlow, outup, phi_in, phi_out, phi_bin;
658 double rCize1, rCize2, rLay, length, phioffset, slant, shift;
659 double m_crio[2], phi_io[2], stphi[2], phioff[2], dphi[2];
660
661 dr0 = helixBes[0];
662 phi0 = helixBes[1];
663 kappa = helixBes[2];
664 dz0 = helixBes[3];
665 tanl = helixBes[4];
666
667 ALPHA_loc = 1000 / ( 2.99792458 * Bz() ); // magnetic field const
668 charge = ( kappa >= 0 ) ? 1 : -1;
669 rho = ALPHA_loc / kappa;
670 double pi = Constants::pi;
671 phi = fmod( phi0 + 4 * pi, 2 * pi );
672 cosphi0 = cos( phi );
673 sinphi0 = ( 1.0 - cosphi0 ) * ( 1.0 + cosphi0 );
674 sinphi0 = sqrt( ( sinphi0 > 0. ) ? sinphi0 : 0. );
675 if ( phi > pi ) sinphi0 = -sinphi0;
676
677 x_hc = 0. + ( dr0 + rho ) * cosphi0;
678 y_hc = 0. + ( dr0 + rho ) * sinphi0;
679 z_hc = 0. + dz0;
680
681 HepPoint3D piv( 0., 0., 0. );
682 HepPoint3D hcenter( x_hc, y_hc, 0.0 );
683
684 double m_c_perp( hcenter.perp() );
685 Hep3Vector m_c_unit( (HepPoint3D)hcenter.unit() );
686 HepPoint3D IO = ( -1 ) * charge * m_c_unit;
687
688 dphi0 = fmod( IO.phi() + 4 * pi, 2 * pi ) - phi;
689 IO_phi = fmod( IO.phi() + 4 * pi, 2 * pi );
690
691 if ( dphi0 > pi ) dphi0 -= 2 * pi;
692 else if ( dphi0 < -pi ) dphi0 += 2 * pi;
693
694 phi_io[0] = -( 1 + charge ) * pi / 2 - charge * dphi0;
695 phi_io[1] = phi_io[0] + 1.5 * pi;
696
697 bool outFlag = false;
698 // retrieve Mdc geometry information
699 rCize1 = 0.1 * m_mdcGeomSvc->Layer( lay )->RCSiz1(); // mm -> cm
700 rCize2 = 0.1 * m_mdcGeomSvc->Layer( lay )->RCSiz2(); // mm -> cm
701 rLay = 0.1 * m_mdcGeomSvc->Layer( lay )->Radius(); // mm -> cm
702 length = 0.1 * m_mdcGeomSvc->Layer( lay )->Length(); // mm -> cm
703 // double halfLength=length/2.;
704 //(conversion of the units mm(mc)->cm(rec))
705 nCell = m_mdcGeomSvc->Layer( lay )->NCell();
706 phioffset = m_mdcGeomSvc->Layer( lay )->Offset();
707 slant = m_mdcGeomSvc->Layer( lay )->Slant();
708 shift = m_mdcGeomSvc->Layer( lay )->Shift();
709 type = m_mdcGeomSvc->Layer( lay )->Sup()->Type();
710
711 m_crio[0] = rLay - rCize1; // radius of inner field wir ( beam pipe)
712 m_crio[1] = rLay + rCize2; // radius of outer field wir ( beam pipe)
713
714 int sign = -1; // assumed the first half circle
715
716 Hep3Vector iocand[2];
717 Hep3Vector cell_IO[2];
718
719 for ( int ii = 0; ii < 2; ii++ )
720 {
721 // By law of cosines to calculate the alpha(up and down field wir_Ge)
722 double cos_alpha = ( m_c_perp * m_c_perp + m_crio[ii] * m_crio[ii] - rho * rho ) /
723 ( 2 * m_c_perp * m_crio[ii] );
724 if ( fabs( cos_alpha ) > 1 && ( ii == 0 ) )
725 {
726 cos_alpha = -1;
727 outFlag = true;
728 }
729 if ( fabs( cos_alpha ) > 1 && ( ii == 1 ) )
730 {
731 cos_alpha = ( m_c_perp * m_c_perp + m_crio[0] * m_crio[0] - rho * rho ) /
732 ( 2 * m_c_perp * m_crio[0] );
733 C_alpha = 2 * pi - acos( cos_alpha );
734 }
735 else { C_alpha = acos( cos_alpha ); }
736
737 iocand[ii] = m_c_unit;
738 iocand[ii].rotateZ( charge * sign * C_alpha );
739 iocand[ii] *= m_crio[ii];
740
741 xx = iocand[ii].x() - x_hc;
742 yy = iocand[ii].y() - y_hc;
743
744 dphi[ii] = atan2( yy, xx ) - phi0 - 0.5 * pi * ( 1 - charge );
745 dphi[ii] = fmod( dphi[ii] + 8.0 * pi, 2 * pi );
746
747 if ( dphi[ii] < phi_io[0] ) { dphi[ii] += 2 * pi; }
748 else if ( dphi[ii] > phi_io[1] )
749 { // very very nausea
750 dphi[ii] -= 2 * pi;
751 }
752
753 cell_IO[ii] = Hel( piv, dr0, phi, ALPHA_loc, kappa, dz0, dphi[ii], tanl );
754
755 // cout<<" cell_IO["<<ii<<"] : "<<cell_IO[ii]<<endl;
756 if ( ( cell_IO[ii].x() == 0 ) && ( cell_IO[ii].y() == 0 ) && ( cell_IO[ii].z() == 0 ) )
757 continue;
758 }
759 // if(((fabs(cell_IO[0].z())*10-halfLength)>-7.) &&
760 // ((fabs(cell_IO[1].z())*10-halfLength)>-7.))return true; //Out sensitive area
761
762 cellId_in = cellId_out = -1;
763 phi_in = cell_IO[0].phi();
764 phi_in = fmod( phi_in + 4 * pi, 2 * pi );
765 phi_out = cell_IO[1].phi();
766 phi_out = fmod( phi_out + 4 * pi, 2 * pi );
767 phi_bin = 2.0 * pi / nCell;
768
769 // determine the in/out cell id
770 stphi[0] = shift * phi_bin * ( 0.5 - cell_IO[0].z() / length );
771 stphi[1] = shift * phi_bin * ( 0.5 - cell_IO[1].z() / length );
772 // stphi[0],stphi[1] to position fo z axis ,the angle of deflxsion in x_Y
773
774 phioff[0] = phioffset + stphi[0];
775 phioff[1] = phioffset + stphi[1];
776
777 for ( int kk = 0; kk < nCell; kk++ )
778 {
779 // for stereo layer
780 inlow = phioff[0] + phi_bin * kk - phi_bin * 0.5;
781 inlow = fmod( inlow + 4.0 * pi, 2.0 * pi );
782 inup = phioff[0] + phi_bin * kk + phi_bin * 0.5;
783 inup = fmod( inup + 4.0 * pi, 2.0 * pi );
784 outlow = phioff[1] + phi_bin * kk - phi_bin * 0.5;
785 outlow = fmod( outlow + 4.0 * pi, 2.0 * pi );
786 outup = phioff[1] + phi_bin * kk + phi_bin * 0.5;
787 outup = fmod( outup + 4.0 * pi, 2.0 * pi );
788
789 if ( ( phi_in >= inlow && phi_in <= inup ) ) cellId_in = kk;
790 if ( ( phi_out >= outlow && phi_out < outup ) ) cellId_out = kk;
791 if ( inlow > inup )
792 {
793 if ( ( phi_in >= inlow && phi_in < 2.0 * pi ) || ( phi_in >= 0.0 && phi_in < inup ) )
794 cellId_in = kk;
795 }
796 if ( outlow > outup )
797 {
798 if ( ( phi_out >= outlow && phi_out <= 2.0 * pi ) ||
799 ( phi_out >= 0.0 && phi_out < outup ) )
800 cellId_out = kk;
801 }
802 } // end of nCell loop
803
804 return ( cellId_in == cellId_out );
805}
806
807HepPoint3D MdcUtilitySvc::Hel( HepPoint3D piv, double dr, double phi0, double Alpha_L,
808 double kappa, double dz, double dphi, double tanl ) const {
809 double x =
810 piv.x() + dr * cos( phi0 ) + ( Alpha_L / kappa ) * ( cos( phi0 ) - cos( phi0 + dphi ) );
811 double y =
812 piv.y() + dr * sin( phi0 ) + ( Alpha_L / kappa ) * ( sin( phi0 ) - sin( phi0 + dphi ) );
813 double z = piv.z() + dz - ( Alpha_L / kappa ) * dphi * tanl;
814 // cout<<"HepPoint3D(x, y, z) = "<<HepPoint3D(x, y, z)<<endl;
815 if ( ( x > -1000. && x < 1000. ) || ( y > -1000. && y < 1000. ) ||
816 ( z > -1000. && z < 1000. ) )
817 { return HepPoint3D( x, y, z ); }
818 else { return HepPoint3D( 0, 0, 0 ); }
819}
820
821// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
822HepVector MdcUtilitySvc::besPar2PatPar( const HepVector& helixPar ) const {
823 HepVector helix( 5, 0 );
824 double d0 = -helixPar[0]; // cm
825 double phi0 = helixPar[1] + CLHEP::halfpi;
826 double omega = Bz() * helixPar[2] / -333.567;
827 double z0 = helixPar[3]; // cm
828 double tanl = helixPar[4];
829 helix[0] = d0;
830 helix[1] = phi0;
831 helix[2] = omega;
832 helix[3] = z0;
833 helix[4] = tanl;
834 return helix;
835}
836
837// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
838HepSymMatrix MdcUtilitySvc::besErr2PatErr( const HepSymMatrix& err ) const {
839 // error matrix
840 // std::cout<<" err1 "<<err<<" "<<err.num_row()<<std::endl;
841 // V(Y)=S * V(X) * ST , mS = S , mVy = V(Y) , err() = V(X)
842 // int n = err.num_row();
843 HepSymMatrix mS( err.num_row(), 0 );
844 mS[0][0] = -1.; // dr0=-d0
845 mS[1][1] = 1.;
846 mS[2][2] = Bz() / -333.567; // pxy -> cpa
847 mS[3][3] = 1.;
848 mS[4][4] = 1.;
849 HepSymMatrix mVy = err.similarity( mS );
850 // std::cout<<" err2 "<<n<<" "<<mVy<<std::endl;
851 return mVy;
852}
853
854double MdcUtilitySvc::p_cms( HepVector helix, int runNo, double mass ) const {
855 HepLorentzVector p4;
856 p4.setPx( -sin( helix[1] ) / fabs( helix[2] ) );
857 p4.setPy( cos( helix[1] ) / fabs( helix[2] ) );
858 p4.setPz( helix[4] / fabs( helix[2] ) );
859 double p3 = p4.mag();
860 mass = 0.000511;
861 p4.setE( sqrt( p3 * p3 + mass * mass ) );
862
863 double ecm;
864 if ( runNo > 9815 ) { ecm = 3.097; }
865 else { ecm = 3.68632; }
866 double zboost = 0.0075;
867 // HepLorentzVector psip(0.011 * 3.68632, 0, 0.0075, 3.68632);
868 HepLorentzVector psip( 0.011 * ecm, 0, zboost, ecm );
869 // cout << setw(15) << ecm << setw(15) << zboost << endl;
870 Hep3Vector boostv = psip.boostVector();
871
872 // std::cout<<__FILE__<<" boostv "<<boostv<< std::endl;
873 p4.boost( -boostv );
874
875 // std::cout<<__FILE__<<" p4 "<<p4<< std::endl;
876 double p_cms = p4.rho();
877 // phicms = p4.phi();
878 // p4.boost(boostv);
879
880 return p_cms;
881}
882
883Hep3Vector MdcUtilitySvc::momentum( const RecMdcTrack* trk ) const {
884 // double dr = trk->helix(0);
885 double fi0 = trk->helix( 1 );
886 double cpa = trk->helix( 2 );
887 double tanl = trk->helix( 4 );
888
889 double pxy = 0.;
890 if ( cpa != 0 ) pxy = 1 / fabs( cpa );
891
892 double px = pxy * ( -sin( fi0 ) );
893 double py = pxy * cos( fi0 );
894 double pz = pxy * tanl;
895
896 Hep3Vector p;
897 p.set( px, py, pz ); // MeV/c
898 return p;
899}
900
901double MdcUtilitySvc::probab( const int& ndof, const double& chisq ) const {
902
903 // constants
904 double srtopi = 2.0 / sqrt( 2.0 * M_PI );
905 double upl = 100.0;
906
907 double prob = 0.0;
908 if ( ndof <= 0 ) { return prob; }
909 if ( chisq < 0.0 ) { return prob; }
910 if ( ndof <= 60 )
911 {
912 // full treatment
913 if ( chisq > upl ) { return prob; }
914 double sum = exp( -0.5 * chisq );
915 double term = sum;
916
917 int m = ndof / 2;
918 if ( 2 * m == ndof )
919 {
920 if ( m == 1 ) { return sum; }
921 for ( int i = 2; i <= m; i++ )
922 {
923 term = 0.5 * term * chisq / ( i - 1 );
924 sum += term;
925 } //(int i=2; i<=m)
926 return sum;
927 // even
928 }
929 else
930 {
931 // odd
932 double srty = sqrt( chisq );
933 double temp = srty / M_SQRT2;
934 prob = erfc( temp );
935 if ( ndof == 1 ) { return prob; }
936 if ( ndof == 3 ) { return ( srtopi * srty * sum + prob ); }
937 m = m - 1;
938 for ( int i = 1; i <= m; i++ )
939 {
940 term = term * chisq / ( 2 * i + 1 );
941 sum += term;
942 } //(int i=1; i<=m; i++)
943 return ( srtopi * srty * sum + prob );
944
945 } //(2*m==ndof)
946 }
947 else
948 {
949 // asymtotic Gaussian approx
950 double srty = sqrt( chisq ) - sqrt( ndof - 0.5 );
951 if ( srty < 12.0 ) { prob = 0.5 * erfc( srty ); };
952
953 } // ndof<30
954
955 return prob;
956} // endof probab
957
959 // get PartPropSvc
960 IPartPropSvc* partPropSvc;
961 static const bool CREATEIFNOTTHERE( true );
962 StatusCode sc = service( "PartPropSvc", partPropSvc, CREATEIFNOTTHERE );
963 if ( !sc.isSuccess() || nullptr == partPropSvc )
964 { cout << " Could not initialize Particle Properties Service" << endl; }
965 HepPDT::ParticleDataTable* particleTable = partPropSvc->PDT();
966 if ( particleTable->particle( mcParticle->particleProperty() ) )
967 { return particleTable->particle( mcParticle->particleProperty() )->charge(); }
968 return -1e6;
969}
970
972 HepVector3D& pos, HepVector3D& mom ) {
973 if ( nullptr == mcParticle ) return;
974 pos.setX( mcParticle->initialPosition().x() );
975 pos.setY( mcParticle->initialPosition().y() );
976 pos.setZ( mcParticle->initialPosition().z() );
977 mom.setX( mcParticle->initialFourMomentum().px() );
978 mom.setY( mcParticle->initialFourMomentum().py() );
979 mom.setZ( mcParticle->initialFourMomentum().pz() );
980}
981
983 if ( nullptr == mcParticle ) return;
984 Hep3Vector pos, mom;
985 pos.setX( mcParticle->initialPosition().x() );
986 pos.setY( mcParticle->initialPosition().y() );
987 pos.setZ( mcParticle->initialPosition().z() );
988 mom.setX( mcParticle->initialFourMomentum().px() );
989 mom.setY( mcParticle->initialFourMomentum().py() );
990 mom.setZ( mcParticle->initialFourMomentum().pz() );
991
992 Helix helixTemp( pos, mom, getChargeOfMcParticle( mcParticle ) );
993 helixTemp.pivot( HepPoint3D( 0, 0, 0 ) );
994 helix.set( helixTemp.pivot(), helixTemp.a(), helixTemp.Ea() );
995}
996
998 int trackIndex, const std::map<int, std::map<MdcDigi*, MdcMcHit*>> mdcMCAssociation,
999 MdcDigiVec& mdcDigiInput, MdcDigiVec& mdcDigiAssociated ) {
1000 MdcDigiVec::iterator iter = mdcDigiInput.begin();
1001 // auto iter=mdcDigiVecInput.begin();
1002 for ( ; iter != mdcDigiInput.end(); iter++ )
1003 {
1004 std::map<int, std::map<MdcDigi*, MdcMcHit*>>::const_iterator itMap0 =
1005 mdcMCAssociation.find( trackIndex );
1006 if ( itMap0 != mdcMCAssociation.end() )
1007 {
1008 std::map<MdcDigi*, MdcMcHit*>::const_iterator itMap = ( *itMap0 ).second.find( *iter );
1009 MdcMcHit* mcHit = nullptr;
1010 if ( itMap != ( *itMap0 ).second.end() ) { mcHit = itMap->second; }
1011 if ( ( trackIndex == mcHit->getTrackIndex() ) &&
1012 ( mcHit->getCreatorProcess() == "Generator" ||
1013 mcHit->getCreatorProcess() == "Decay" ) )
1014 { mdcDigiAssociated.push_back( *iter ); }
1015 }
1016 }
1017}
1018
1020 int trackIndex, const MdcDigiVec mdcDigiVecInput,
1021 std::map<int, std::map<MdcDigi*, MdcMcHit*>>& mdcMCAssociation ) {
1022
1023 ///---get MDC MC hits and make a map vs wire id
1024 IDataProviderSvc* eventSvc = NULL;
1025 Gaudi::svcLocator()->service( "EventDataSvc", eventSvc );
1026 SmartDataPtr<Event::MdcMcHitCol> mdcMcHitCol( eventSvc, "/Event/MC/MdcMcHitCol" );
1027 if ( !mdcMcHitCol )
1028 {
1029 std::cout << "MdcUtilitySvc::getMdcMCAssoiciation() does not find MdcMcHitCol!"
1030 << std::endl;
1031 return;
1032 }
1033 std::map<int, Event::MdcMcHit*> mdcMcHitMap;
1034 Event::MdcMcHitCol::iterator iterMdcMcHit = mdcMcHitCol->begin();
1035 for ( ; iterMdcMcHit != mdcMcHitCol->end(); iterMdcMcHit++ )
1036 {
1037 int id = m_mdcGeomSvc
1038 ->Wire( MdcID::layer( ( *iterMdcMcHit )->identify() ),
1039 MdcID::wire( ( *iterMdcMcHit )->identify() ) )
1040 ->Id();
1041 mdcMcHitMap.insert( std::pair<int, Event::MdcMcHit*>( id, *iterMdcMcHit ) );
1042 }
1043
1044 /// loop over MdcDigi
1045 MdcDigiVec::const_iterator iterMdcDigi = mdcDigiVecInput.begin();
1046 for ( ; iterMdcDigi != mdcDigiVecInput.end(); iterMdcDigi++ )
1047 {
1048 int digiTrackIndex = ( *iterMdcDigi )->getTrackIndex();
1049 std::cout << __FILE__ << " " << __LINE__ << " " << digiTrackIndex << std::endl;
1050 if ( digiTrackIndex > 999 ) digiTrackIndex -= 1000; // FIXME
1051 if ( digiTrackIndex != digiTrackIndex ) continue;
1052 int id = m_mdcGeomSvc
1053 ->Wire( MdcID::layer( ( *iterMdcMcHit )->identify() ),
1054 MdcID::wire( ( *iterMdcMcHit )->identify() ) )
1055 ->Id();
1056 std::map<MdcDigi*, MdcMcHit*> temp;
1057 std::map<int, Event::MdcMcHit*>::iterator itMdcMcHit = mdcMcHitMap.find( id );
1058 if ( itMdcMcHit != mdcMcHitMap.end() )
1059 {
1060 temp.insert( make_pair( *iterMdcDigi, ( *itMdcMcHit ).second ) );
1061 mdcMCAssociation.insert( make_pair( trackIndex, temp ) );
1062 // mdcMCAssociation.insert(std::pair<int,std::map<MdcDigi*,MdcMcHit*> >
1063 //(trackIndex,make_pair(*iterMdcDigi,mdcMcHitMap[id])));
1064 }
1065 }
1066
1067} // end of getMdcMCAssoiciation
DECLARE_COMPONENT(BesBdkRc)
double mass
HepGeom::Point3D< double > HepPoint3D
int runNo
Definition DQA_TO_DB.cxx:13
Double_t phi2
Double_t x[10]
Double_t phi1
EvtComplex exp(const EvtComplex &c)
double alpha
double pi
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
HepGeom::Point3D< double > HepPoint3D
HepGeom::Vector3D< double > HepVector3D
IMessageSvc * msgSvc()
#define M_PI
Definition TConstant.h:4
const HepVector helix() const
......
const HepLorentzVector & initialPosition() const
Retrieve pointer to the start, end vertex positions.
const HepLorentzVector & initialFourMomentum() const
StdHepId particleProperty() const
Retrieve particle property.
Definition McParticle.cxx:7
unsigned int getTrackIndex() const
Definition MdcMcHit.cxx:38
void set(const HepPoint3D &pivot, const HepVector &a, const HepSymMatrix &Ea)
sets helix pivot position, parameters, and error matrix.
const HepSymMatrix & Ea(void) const
returns error matrix.
const HepVector & a(void) const
returns helix parameters.
const HepPoint3D & pivot(void) const
returns pivot position.
const double Sag(void) const
static int layer(const Identifier &id)
Values of different levels (failure returns 0).
Definition MdcID.cxx:47
static int wire(const Identifier &id)
Definition MdcID.cxx:52
MdcUtilitySvc(const std::string &name, ISvcLocator *svcloc)
HepVector besPar2PatPar(const HepVector &helixPar) const
bool cellTrackPassedByPhi(const HepVector helix, int layer, int &cellId_in, int &cellId_out) const
virtual StatusCode initialize()
HepSymMatrix patErr2BesErr(const HepSymMatrix &err) const
HepPoint3D Hel(HepPoint3D piv, double dr, double phi0, double Alpha_L, double kappa, double dz, double dphi, double tanl) const
MdcDigiVec getMdcDigiVec() const
HepSymMatrix besErr2PatErr(const HepSymMatrix &err) const
float getChargeOfMcParticle(const Event::McParticle *mcParticle)
void getMdcMCAssoiciation(int trackIndex, const std::vector< MdcDigi * > mdcDigiVecInput, std::map< int, std::map< MdcDigi *, Event::MdcMcHit * > > &mdcMCAssociation)
Get association of MdcDigi and MdcMcHit according to track id.
bool cellTrackPassedByPhiPatPar(const HepVector helix, int layer, int &cellId_in, int &cellId_out) const
HepVector patPar2BesPar(const HepVector &helixPar) const
void getHelixOfMcParticle(const Event::McParticle *mcParticle, Helix &helix)
virtual StatusCode finalize()
void getMomPosOfMcParticle(const Event::McParticle *mcParticle, HepVector3D &pos, HepVector3D &mom)
double probab(const int &ndof, const double &chisq) const
Hep3Vector momentum(const RecMdcTrack *trk) const
double doca(int layer, int cell, const HepVector helix, const HepSymMatrix errMat, bool passCellRequired=true, bool doSag=true) const
int nLayerTrackPassed(const HepVector helix) const
bool cellTrackPassed(const HepVector helix, int layer, int &cellId_in, int &cellId_out) const
void getMdcDigiOnMcParticle(int trackIndex, const std::map< int, std::map< MdcDigi *, Event::MdcMcHit * > > mdcMCAssociation, MdcDigiVec &mdcDigiInput, MdcDigiVec &mdcDigiAssociated)
double p_cms(HepVector helix, int runNo, double mass) const
double docaPatPar(int layer, int cell, const HepVector helixPat, const HepSymMatrix errMatPat, bool passCellRequired=true, bool doSag=true) const
HepPoint3D pointOnHelixPatPar(const HepVector helixPat, int lay, int innerOrOuter) const
HepPoint3D pointOnHelix(const HepVector helixPar, int lay, int innerOrOuter) const
bool cellTrackPassedPatPar(const HepVector helix, int layer, int &cellId_in, int &cellId_out) const