BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcxCosmicSewer Class Reference

#include <MdcxCosmicSewer.h>

Inheritance diagram for MdcxCosmicSewer:

Public Member Functions

 MdcxCosmicSewer (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~MdcxCosmicSewer ()
StatusCode initialize ()
StatusCode execute ()
StatusCode finalize ()
StatusCode beginRun ()
void MdcxHitsToHots (HepVector &helix, TrkRecoTrk *trk, HitRefVec &hits, HitRefVec &skiped)
void store (TrkRecoTrk *tk, HitRefVec &skip)
void clearRecMdcTrackHit ()
void dumpTdsTrack (RecMdcTrackCol *trackList)

Detailed Description

Definition at line 44 of file MdcxCosmicSewer.h.

Constructor & Destructor Documentation

◆ MdcxCosmicSewer()

MdcxCosmicSewer::MdcxCosmicSewer ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 59 of file MdcxCosmicSewer.cxx.

60 : Algorithm( name, pSvcLocator ) {
61
62 declareProperty( "debug", m_debug = false );
63 declareProperty( "hist", m_hist = false );
64
65 declareProperty( "doSag", m_doSag = false );
66
67 declareProperty( "cosmicSewPar", m_cosmicSewPar );
68 declareProperty( "cosmicSewSkip", m_cosmicSewSkip = false );
69
70 declareProperty( "countPropTime", m_countPropTime = true );
71 declareProperty( "lineFit", m_lineFit = false );
72}

Referenced by MdcxCosmicSewer().

◆ ~MdcxCosmicSewer()

MdcxCosmicSewer::~MdcxCosmicSewer ( )
virtual

Definition at line 77 of file MdcxCosmicSewer.cxx.

77 {
78 if ( m_bfield ) delete m_bfield;
79 if ( m_context ) delete m_context;
80}

Member Function Documentation

◆ beginRun()

StatusCode MdcxCosmicSewer::beginRun ( )

Definition at line 82 of file MdcxCosmicSewer.cxx.

82 {
83 // Initailize MdcDetector
84 m_gm = MdcDetector::instance( m_doSag );
85 if ( NULL == m_gm ) return StatusCode::FAILURE;
86
87 return StatusCode::SUCCESS;
88}
static MdcDetector * instance()

Referenced by execute().

◆ clearRecMdcTrackHit()

void MdcxCosmicSewer::clearRecMdcTrackHit ( )

Definition at line 697 of file MdcxCosmicSewer.cxx.

697 {
698 MsgStream log( msgSvc(), name() );
699 StatusCode sc;
700 //-------------------------------------------------------
701 // clear TDS
702 //-------------------------------------------------------
703 // IDataManagerSvc *dataManSvc;
704 SmartIF<IDataManagerSvc> dataManSvc( eventSvc() );
705 DataObject* aTrackCol;
706 eventSvc()->findObject( "/Event/Recon/RecMdcTrackCol", aTrackCol );
707 if ( aTrackCol != NULL )
708 {
709 dataManSvc->clearSubTree( "/Event/Recon/RecMdcTrackCol" );
710 eventSvc()->unregisterObject( "/Event/Recon/RecMdcTrackCol" );
711 }
712 DataObject* aRecHitCol;
713 eventSvc()->findObject( "/Event/Recon/RecMdcHitCol", aRecHitCol );
714 if ( aRecHitCol != NULL )
715 {
716 dataManSvc->clearSubTree( "/Event/Recon/RecMdcHitCol" );
717 eventSvc()->unregisterObject( "/Event/Recon/RecMdcHitCol" );
718 }
719 SmartDataPtr<RecMdcTrackCol> trackListTemp( eventSvc(), EventModel::Recon::RecMdcTrackCol );
720 if ( !trackListTemp )
721 {
722 RecMdcTrackCol* trackListTemp = new RecMdcTrackCol;
723 sc = eventSvc()->registerObject( EventModel::Recon::RecMdcTrackCol, trackListTemp );
724 if ( !sc.isSuccess() )
725 { log << MSG::FATAL << " Could not register RecMdcTrack collection" << endmsg; }
726 }
727 SmartDataPtr<RecMdcHitCol> hitListTemp( eventSvc(), EventModel::Recon::RecMdcHitCol );
728 if ( !hitListTemp )
729 {
730 RecMdcHitCol* hitListTemp = new RecMdcHitCol;
731 sc = eventSvc()->registerObject( EventModel::Recon::RecMdcHitCol, hitListTemp );
732 if ( !sc.isSuccess() )
733 { log << MSG::FATAL << " Could not register RecMdcHit collection" << endmsg; }
734 }
735}
IMessageSvc * msgSvc()

Referenced by execute().

◆ dumpTdsTrack()

void MdcxCosmicSewer::dumpTdsTrack ( RecMdcTrackCol * trackList)

◆ execute()

StatusCode MdcxCosmicSewer::execute ( )

Definition at line 170 of file MdcxCosmicSewer.cxx.

170 {
171 if ( !m_beginRun )
172 {
173 StatusCode sc = beginRun();
174 if ( sc.isFailure() )
175 {
176 error() << "beginRun failed" << endmsg;
177 return StatusCode::FAILURE;
178 }
179 m_beginRun = true;
180 }
181
182 MsgStream log( msgSvc(), name() );
183 log << MSG::INFO << "in execute()" << endmsg;
184
185 setFilterPassed( false );
186 // Get event No.
187 SmartDataPtr<Event::EventHeader> evtHead( eventSvc(), "/Event/EventHeader" );
188 if ( !evtHead )
189 {
190 log << MSG::FATAL << "Could not retrieve event header" << endmsg;
191 return StatusCode::FAILURE;
192 }
193 long t_runNo = evtHead->runNumber();
194 long t_evtNo = evtHead->eventNumber();
195 if ( m_debug )
196 std::cout << "sew " << ++i_evt << " run " << t_runNo << " evt " << t_evtNo << std::endl;
197
198 // Get bunch time t0 (ns)
199 m_bunchT0 = -999.;
200 SmartDataPtr<RecEsTimeCol> aevtimeCol( eventSvc(), "/Event/Recon/RecEsTimeCol" );
201 if ( !aevtimeCol || aevtimeCol->size() == 0 )
202 {
203 log << MSG::WARNING << "Could not find RecEsTimeCol" << endmsg;
204 return StatusCode::SUCCESS;
205 }
206 RecEsTimeCol::iterator iter_evt = aevtimeCol->begin();
207 for ( ; iter_evt != aevtimeCol->end(); iter_evt++ ) { m_bunchT0 = ( *iter_evt )->getTest(); }
208
209 // read event data
210 SmartDataPtr<RecMdcTrackCol> recMdcTrackCol( eventSvc(), EventModel::Recon::RecMdcTrackCol );
211 SmartDataPtr<RecMdcHitCol> recMdcHitCol( eventSvc(), EventModel::Recon::RecMdcHitCol );
212 if ( !recMdcTrackCol || !recMdcHitCol ) return StatusCode::SUCCESS;
213 if ( 2 != recMdcTrackCol->size() )
214 {
216 return StatusCode::SUCCESS;
217 }
218 if ( m_debug ) std::cout << name() << " nTk==2 begin sewing" << std::endl;
219
220 // get best track
221 double dParam[5] = { 0., 0., 0., 0., 0. };
222 float bprob = 0.;
223 float chisum = 0.;
224 RecMdcTrackCol::iterator besthel;
225
226 int besthelId = -999;
227 RecMdcTrackCol::iterator it = recMdcTrackCol->begin();
228 for ( int iTk = 0; it != recMdcTrackCol->end(); it++, iTk++ )
229 {
230 RecMdcTrack* tk = *it;
231 double Bz = m_bfield->bFieldNominal();
232 double d0 = -tk->helix( 0 ); // cm
233 double phi0 = tk->helix( 1 ) + CLHEP::halfpi;
234 double omega = Bz * tk->helix( 2 ) / -333.567;
235 double z0 = tk->helix( 3 ); // cm
236 double tanl = tk->helix( 4 ); // cm
237
238 if ( phi0 > Constants::pi ) phi0 -= Constants::twoPi;
239 if ( phi0 < -Constants::pi ) phi0 += Constants::twoPi;
240
241 if ( m_debug )
242 std::cout << __FILE__ << " " << __LINE__ << "tk" << iTk << "(" << d0 << "," << phi0
243 << ","
244 << "," << omega << "," << z0 << "," << tanl << ")" << std::endl;
245
246 if ( iTk == 0 )
247 { // store param1
248 dParam[0] = d0;
249 dParam[1] = phi0;
250 dParam[2] = omega;
251 dParam[3] = z0;
252 dParam[4] = tanl;
253 }
254 else
255 { // calc. diff between param1 and param2
256 dParam[0] += d0;
257 dParam[1] -= ( phi0 + Constants::pi );
258 dParam[2] -= omega;
259 dParam[3] -= z0;
260 dParam[4] += tanl;
261 }
262
263 if ( phi0 < 0 )
264 {
265 besthelId = iTk;
266 besthel = it;
267 }
268 float bchisq = tk->chi2();
269 int bndof = tk->ndof();
270 bprob = Mdcxprobab( bndof, bchisq );
271 chisum += bchisq;
272 // if (bprob > bestprob){
273 // bestprob = bprob;
274 // besthel = it;
275 // }
276 } // end for recMdcTrackCol
277
278 if ( besthelId == -999 ) return StatusCode::SUCCESS;
279
280 TrkHelixMaker helixfactory;
281 TrkLineMaker linefactory;
282
283 if ( m_debug )
284 {
285 std::cout << __FILE__ << " param diff: "
286 << "\n D0 " << dParam[0] << "\n Phi0 " << dParam[1] << "\n Omega " << dParam[2]
287 << "\n Z0 " << dParam[3] << "\n Tanl " << dParam[4] << std::endl;
288 }
289
290 if ( m_hist )
291 {
292 m_csmcD0 = dParam[0];
293 m_csmcPhi0 = dParam[1];
294 m_csmcOmega = dParam[2];
295 m_csmcZ0 = dParam[3];
296 m_csmcTanl = dParam[4];
297 m_xtupleCsmcSew->write();
298 }
299
300 // get track 5 parameters
301 if ( ( fabs( dParam[0] ) > m_cosmicSewPar[0] ) ||
302 ( fabs( dParam[1] ) > m_cosmicSewPar[1] ) ||
303 ( fabs( dParam[2] ) > m_cosmicSewPar[2] ) ||
304 ( fabs( dParam[3] ) > m_cosmicSewPar[3] ) || ( fabs( dParam[4] ) > m_cosmicSewPar[4] ) )
305 {
306 if ( m_debug ) std::cout << __FILE__ << " 2 trk param not satisfied skip!" << std::endl;
307 if ( m_debug )
308 {
309 if ( fabs( dParam[0] ) > m_cosmicSewPar[0] ) std::cout << " cut by d0 " << std::endl;
310 if ( fabs( dParam[1] ) > m_cosmicSewPar[1] ) std::cout << " cut by phi0 " << std::endl;
311 if ( fabs( dParam[2] ) > m_cosmicSewPar[2] ) std::cout << " cut by omega " << std::endl;
312 if ( fabs( dParam[3] ) > m_cosmicSewPar[3] ) std::cout << " cut by z0" << std::endl;
313 if ( fabs( dParam[4] ) > m_cosmicSewPar[4] ) std::cout << " cut by tanl" << std::endl;
314 }
316 return StatusCode::SUCCESS;
317 }
318
319 // got 2 sew-able trks, get helix param
320 RecMdcTrack* tk = *besthel;
321 double Bz = m_bfield->bFieldNominal();
322 double d0 = -tk->helix( 0 ); // cm
323 double phi0 = tk->helix( 1 ) + CLHEP::halfpi;
324 double omega = Bz * tk->helix( 2 ) / -333.567;
325 double z0 = tk->helix( 3 ); // cm
326 double tanl = tk->helix( 4 ); // cm
327
328 TrkExchangePar tt( d0, phi0, omega, z0, tanl );
329 if ( m_debug )
330 std::cout << __FILE__ << " best helix: No." << tk->trackId() << " Pat param=(" << d0 << " "
331 << phi0 << " " << omega << " " << z0 << " " << tanl << ")" << std::endl;
332
333 // new track
334 TrkRecoTrk* newTrack;
335 if ( m_lineFit )
336 {
337 newTrack = linefactory.makeTrack( tt, chisum, *m_context, m_bunchT0 * 1.e-9 );
338 linefactory.setFlipAndDrop( *newTrack, true, true );
339 }
340 else
341 {
342 newTrack = helixfactory.makeTrack( tt, chisum, *m_context, m_bunchT0 * 1.e-9 );
343 helixfactory.setFlipAndDrop( *newTrack, true, true );
344 }
345
346 // combine hit list
347 HitRefVec skippedHits;
348 it = recMdcTrackCol->begin();
349 for ( int iTk = 0; it != recMdcTrackCol->end(); it++, iTk++ )
350 {
351 RecMdcTrack* tk = *it;
352 HitRefVec hits = tk->getVecHits();
353 HepVector helixPatPar = m_mdcUtilitySvc->besPar2PatPar( tk->helix() );
354 MdcxHitsToHots( helixPatPar, newTrack, hits, skippedHits );
355 }
356
357 //------------------------------------
358 // do fit
359 //------------------------------------
360 TrkErrCode err = newTrack->hits()->fit();
361 const TrkFit* newFit = newTrack->fitResult();
362
363 if ( !newFit )
364 {
365 // Fit bad
366 if ( m_debug ) std::cout << __FILE__ << " sew fit failed!!!" << std::endl;
367 HitRefVec::iterator it = skippedHits.begin();
368 for ( ; it != skippedHits.end(); ++it ) { delete it->data(); }
369 delete newTrack;
371 }
372 else
373 {
374 //------------------------------------
375 // Fit good
376 //------------------------------------
377 if ( m_lineFit ) { linefactory.setFlipAndDrop( *newTrack, false, false ); }
378 else { helixfactory.setFlipAndDrop( *newTrack, false, false ); }
379 if ( m_debug )
380 {
381 std::cout << __FILE__ << " sew cosmic fit good " << std::endl;
382 newTrack->print( std::cout );
383 }
384
385 SmartDataPtr<MdcHitCol> m_hitCol( eventSvc(), "/Event/Hit/MdcHitCol" );
386 if ( !m_hitCol )
387 {
388 m_hitCol = new MdcHitCol;
389 StatusCode sc = eventSvc()->registerObject( "/Event/Hit/MdcHitCol", m_hitCol );
390 if ( !sc.isSuccess() )
391 {
392 std::cout << " Could not register MdcHitCol" << endmsg;
393 return StatusCode::FAILURE;
394 }
395 }
396 uint32_t getDigiFlag = 0;
397 MdcDigiVec mdcDigiVec = m_rawDataProviderSvc->getMdcDigiVec( getDigiFlag );
398 const MdcDigi* m_digiMap[43][288];
399 MdcDigiVec::iterator iter = mdcDigiVec.begin();
400 for ( ; iter != mdcDigiVec.end(); iter++ )
401 {
402 const MdcDigi* aDigi = *iter;
403 const Identifier id = aDigi->identify();
404 int layer = MdcID::layer( id );
405 int wire = MdcID::wire( id );
406 m_digiMap[layer][wire] = aDigi;
407 }
408
409 // calc. doca of skipped hits
410 HitRefVec::iterator itHitSkipped = skippedHits.begin();
411 for ( ; itHitSkipped != skippedHits.end(); ++itHitSkipped )
412 {
413 RecMdcHit* h = *itHitSkipped;
414 Identifier id( h->getMdcId() );
415 int layer = MdcID::layer( id );
416 int wire = MdcID::wire( id );
417 double fltLen = 0.;
418 HepVector helix = newFit->helix( fltLen ).params();
419 HepSymMatrix err = newFit->helix( fltLen ).covariance();
420 double docaFltLen = h->getFltLen();
421 // double doca = m_mdcUtilitySvc->docaPatPar(layer,wire,docaFltLen,helix,err);//yzhang
422 // 2012-07-19
423 double doca = m_mdcUtilitySvc->docaPatPar( layer, wire, helix, err );
424 double newDoca = fabs( doca );
425 int flagLR = h->getFlagLR();
426 if ( flagLR == 0 ) { newDoca = -fabs( doca ); } // left driftDist <0
427 h->setDoca( newDoca );
428 if ( m_debug >= 3 )
429 std::cout << "(" << layer << "," << wire << ") new doca " << newDoca << " resid "
430 << fabs( fabs( newDoca ) - fabs( h->getDriftDistLeft() ) ) << std::endl;
431 if ( m_debug >= 3 && fabs( fabs( newDoca ) - fabs( h->getDriftDistLeft() ) ) > 0.02 )
432 std::cout << " bad resid " << fabs( fabs( newDoca ) - fabs( h->getDriftDistLeft() ) )
433 << " doca " << newDoca << " dd " << h->getDriftDistLeft() << std::endl;
434
435 // calc drift dist of skipped hit
436 MdcHit* thehit = new MdcHit( m_digiMap[layer][wire], m_gm );
437 thehit->setCosmicFit( true );
438 thehit->setCalibSvc( m_mdcCalibFunSvc );
439 thehit->setCountPropTime( m_countPropTime );
440 m_hitCol->push_back( thehit );
441
442 HepPoint3D poca;
443 Hep3Vector tempDir;
444 getInfo( helix, 0, poca, tempDir );
445 if ( m_debug > 3 ) std::cout << "track poca " << poca << std::endl;
446 HepPoint3D pos;
447 Hep3Vector dir;
448 getInfo( helix, docaFltLen, pos, dir );
449 // std::cout<<" pos "<<pos<<" dir "<<dir<<" "<<std::endl;
450 if ( pos.y() > poca.y() )
451 {
452 int wireAmb = patAmbig( flagLR );
453 // double tofold = (docaFltLen/Constants::c + m_bunchT0)*1.e-9;
454 double tof = docaFltLen / Constants::c + ( m_bunchT0 ) * 1.e-9;
455 // std::cout<<layer<<" "<<wire<<" tofold "<<tofold*1.e9-m_bunchT0 <<" tof
456 // "<<tof*1.e9-m_bunchT0<<" diff
457 // "<<(tof-tofold)*1.e9<<std::endl; tof = tofold;
458 double eAngle = EntranceAngle( dir.phi() - thehit->phi( pos.z() ) );
459 double dAngle = Constants::pi / 2 - 1. * dir.theta();
460 double z = pos.z();
461 double dist = thehit->driftDist( tof, wireAmb, eAngle, dAngle, z );
462 double sigma = thehit->sigma( dist, wireAmb, eAngle, dAngle, z );
463
464 if ( m_debug > 3 && fabs( fabs( h->getDoca() ) - fabs( dist ) ) > 0.02 )
465 std::cout << "(" << layer << "," << wire << ") old doca " << h->getDoca()
466 << " old ddr " << h->getDriftDistRight() << " new dd " << dist
467 << " newAmbig "
468 << wireAmb
469 //<<" tof "<<tof <<" z "<<z <<" eAngle "<<eAngle <<" dTime
470 //"<<thehit->driftTime(tof,z)
471 << " old sigma " << h->getErrDriftDistLeft() << " new sigma " << sigma
472 << " " << std::endl;
473 h->setDriftDistLeft( -1. * abs( dist ) );
474 h->setDriftDistRight( abs( dist ) );
475 h->setErrDriftDistLeft( sigma );
476 h->setErrDriftDistRight( sigma );
477 }
478 }
479
480 //-------------------------------------------------------
481 // Store TDS
482 //-------------------------------------------------------
483 store( newTrack, skippedHits ); // newTrack have been deleted
484
485 setFilterPassed( true );
486 m_nSewed++;
487 } // end if newFit
488
489 if ( m_debug ) { m_mdcPrintSvc->printRecMdcTrackCol(); }
490
491 return StatusCode::SUCCESS;
492}
HepGeom::Point3D< double > HepPoint3D
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
float Mdcxprobab(int &ndof, float &chisq)
Definition Mdcxprobab.cxx:4
const HepVector helix() const
......
double sigma(double, int, double, double, double) const
Definition MdcHit.cxx:183
double driftDist(double, int, double, double, double) const
Definition MdcHit.cxx:157
void setCalibSvc(const IMdcCalibFunSvc *calibSvc)
Definition MdcHit.cxx:136
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
void MdcxHitsToHots(HepVector &helix, TrkRecoTrk *trk, HitRefVec &hits, HitRefVec &skiped)
void store(TrkRecoTrk *tk, HitRefVec &skip)
StatusCode beginRun()
virtual Identifier identify() const
Definition RawData.cxx:15
virtual TrkExchangePar helix(double fltL) const =0
TrkErrCode fit()
virtual void print(std::ostream &) const
const TrkFit * fitResult() const
bool setFlipAndDrop(TrkRecoTrk &, bool allowFlips, bool allowDrops) const
TrkRecoTrk * makeTrack(const TrkExchangePar &helix, const double chi2, const TrkContext &, double trackT0) const

◆ finalize()

StatusCode MdcxCosmicSewer::finalize ( )

Definition at line 494 of file MdcxCosmicSewer.cxx.

494 {
495 MsgStream log( msgSvc(), name() );
496 log << MSG::INFO << "in finalize()" << endmsg;
497 std::cout << name() << " after sewed got " << m_nSewed << " cosmic tracks" << std::endl;
498 return StatusCode::SUCCESS;
499}

◆ initialize()

StatusCode MdcxCosmicSewer::initialize ( )

Definition at line 93 of file MdcxCosmicSewer.cxx.

93 {
94 MsgStream log( msgSvc(), name() );
95 StatusCode sc;
96 log << MSG::INFO << "in initialize()" << endmsg;
97
98 i_evt = 0;
99 m_nSewed = 0;
100
101 // Initailize magnetic filed
102 sc = service( "MagneticFieldSvc", m_pIMF );
103 if ( sc != StatusCode::SUCCESS )
104 { log << MSG::ERROR << "Unable to open Magnetic field service" << endmsg; }
105 m_bfield = new BField( m_pIMF );
106 log << MSG::INFO << "field z = " << m_bfield->bFieldNominal() << endmsg;
107 m_context = new TrkContextEv( m_bfield );
108
109 // Get MdcCalibFunSvc
110 sc = service( "MdcCalibFunSvc", m_mdcCalibFunSvc );
111 if ( sc.isFailure() )
112 {
113 log << MSG::FATAL << "Could not load MdcCalibFunSvc!" << endmsg;
114 return StatusCode::FAILURE;
115 }
116
117 // Get RawDataProviderSvc
118 sc = service( "RawDataProviderSvc", m_rawDataProviderSvc );
119 if ( sc.isFailure() )
120 {
121 log << MSG::FATAL << "Could not load RawDataProviderSvc!" << endmsg;
122 return StatusCode::FAILURE;
123 }
124
125 // Initailize MdcUtilitySvc
126 sc = service( "MdcUtilitySvc", m_mdcUtilitySvc );
127 if ( sc.isFailure() )
128 {
129 log << MSG::FATAL << "Could not load MdcUtilitySvc!" << endmsg;
130 return StatusCode::FAILURE;
131 }
132
133 // Initailize MdcPrintSvc
134 sc = service( "MdcPrintSvc", m_mdcPrintSvc );
135 if ( sc.isFailure() )
136 {
137 log << MSG::FATAL << "Could not load MdcPrintSvc!" << endmsg;
138 return StatusCode::FAILURE;
139 }
140
141 if ( m_hist )
142 {
143 // book ntuple
144 NTuplePtr ntCsmcSew( ntupleSvc(), "MdcxReco/csmc" );
145 if ( ntCsmcSew ) { m_xtupleCsmcSew = ntCsmcSew; }
146 else
147 {
148 m_xtupleCsmcSew = ntupleSvc()->book( "MdcxReco/csmc", CLID_ColumnWiseTuple,
149 "MdcxReco reconsturction results" );
150 if ( m_xtupleCsmcSew )
151 {
152 sc = m_xtupleCsmcSew->addItem( "dD0", m_csmcD0 );
153 sc = m_xtupleCsmcSew->addItem( "dPhi0", m_csmcPhi0 );
154 sc = m_xtupleCsmcSew->addItem( "dZ0", m_csmcZ0 );
155 sc = m_xtupleCsmcSew->addItem( "dOmega", m_csmcOmega );
156 sc = m_xtupleCsmcSew->addItem( "dPt", m_csmcPt );
157 sc = m_xtupleCsmcSew->addItem( "dTanl", m_csmcTanl );
158 }
159 else
160 {
161 log << MSG::FATAL << "Could not book MdcxReco/csmc!" << endmsg;
162 return StatusCode::FAILURE;
163 }
164 } // end of book
165 }
166
167 return StatusCode::SUCCESS;
168}
INTupleSvc * ntupleSvc()

◆ MdcxHitsToHots()

void MdcxCosmicSewer::MdcxHitsToHots ( HepVector & helix,
TrkRecoTrk * trk,
HitRefVec & hits,
HitRefVec & skiped )

Definition at line 501 of file MdcxCosmicSewer.cxx.

502 {
503
504 TrkHitList* trkHitList = newTrack->hits();
505 // store new MdcHit
506 SmartDataPtr<MdcHitCol> m_hitCol( eventSvc(), "/Event/Hit/MdcHitCol" );
507 if ( !m_hitCol )
508 {
509 m_hitCol = new MdcHitCol;
510 StatusCode sc = eventSvc()->registerObject( "/Event/Hit/MdcHitCol", m_hitCol );
511 if ( !sc.isSuccess() )
512 {
513 std::cout << " Could not register MdcHitCol" << endmsg;
514 return;
515 }
516 }
517
518 // get MdcDigi pointer
519 uint32_t getDigiFlag = 0;
520 MdcDigiVec mdcDigiVec = m_rawDataProviderSvc->getMdcDigiVec( getDigiFlag );
521 if ( 0 == mdcDigiVec.size() )
522 {
523 std::cout << " No hits in MdcDigiVec" << std::endl;
524 return;
525 }
526 const MdcDigi* m_digiMap[43][288];
527 MdcDigiVec::iterator iter = mdcDigiVec.begin();
528 for ( ; iter != mdcDigiVec.end(); iter++ )
529 {
530 const MdcDigi* aDigi = *iter;
531 const Identifier id = aDigi->identify();
532 int layer = MdcID::layer( id );
533 int wire = MdcID::wire( id );
534 m_digiMap[layer][wire] = aDigi;
535 }
536
537 HepPoint3D poca;
538 Hep3Vector tempDir;
539 getInfo( helix, 0, poca, tempDir );
540 if ( m_debug > 3 ) std::cout << "track poca " << poca << std::endl;
541 // new MdcRecoHitOnTracks
542 HitRefVec::iterator itHit = recMdcHits.begin();
543 for ( ; itHit != recMdcHits.end(); ++itHit )
544 {
545 RecMdcHit* h = *itHit;
546 int layer = MdcID::layer( h->getMdcId() );
547 int wire = MdcID::wire( h->getMdcId() );
548 // new fltLen and ambig
549 double newFltLen = h->getFltLen();
550 HepPoint3D pos;
551 Hep3Vector dir;
552 getInfo( helix, h->getFltLen(), pos, dir );
553 int newAmbig = patAmbig( h->getFlagLR() );
554 if ( pos.y() > poca.y() )
555 { // yzhang TEMP 2012-07-17
556 newFltLen *= -1.;
557 newAmbig *= -1;
558 if ( m_debug > 3 ) std::cout << " Up track, change sign of fltLen " << std::endl;
559 }
560 int newFlagLR = bes3FlagLR( newAmbig );
561 // calc. position of this point
562 if ( m_cosmicSewSkip && layer < 20 )
563 {
564 RecMdcHit* newSkippedHit = new RecMdcHit();
565 newSkippedHit->setDriftDistLeft( h->getDriftDistLeft() );
566 newSkippedHit->setDriftDistRight( h->getDriftDistRight() );
567 newSkippedHit->setErrDriftDistLeft( h->getErrDriftDistLeft() );
568 newSkippedHit->setErrDriftDistRight( h->getErrDriftDistRight() );
569 newSkippedHit->setChisqAdd( h->getChisqAdd() );
570 newSkippedHit->setFlagLR( newFlagLR );
571 newSkippedHit->setStat( h->getStat() );
572 newSkippedHit->setMdcId( h->getMdcId() );
573 newSkippedHit->setTdc( h->getTdc() );
574 newSkippedHit->setAdc( h->getAdc() );
575 newSkippedHit->setDriftT( h->getDriftT() );
576 newSkippedHit->setDoca( 999. );
577 // newSkippedHit->setDoca(h->getDoca());
578 newSkippedHit->setEntra( h->getEntra() );
579 newSkippedHit->setZhit( h->getZhit() );
580 newSkippedHit->setFltLen( newFltLen );
581 skippedHits.push_back( newSkippedHit );
582 }
583 else
584 {
585 MdcHit* thehit = new MdcHit( m_digiMap[layer][wire], m_gm );
586 thehit->setCosmicFit( true );
587 thehit->setCalibSvc( m_mdcCalibFunSvc );
588 thehit->setCountPropTime( m_countPropTime );
589 m_hitCol->push_back( thehit );
590
591 MdcRecoHitOnTrack temp( *thehit, newAmbig, m_bunchT0 ); // m_bunchT0 nano second here
592 MdcHitOnTrack* newhot = &temp;
593 newhot->setFltLen( newFltLen );
594 if ( m_debug > 3 )
595 std::cout << name() << " (" << layer << "," << wire << ") fltLen " << h->getFltLen()
596 << " newFltLen " << newFltLen << " newAmbig " << newAmbig << " pos.y() "
597 << pos.y() << std::endl;
598
599 trkHitList->appendHot( newhot );
600 }
601 } // end of loop hits
602}
TrkHitOnTrk * appendHot(const TrkHitOnTrk *theHot)

Referenced by execute().

◆ store()

void MdcxCosmicSewer::store ( TrkRecoTrk * tk,
HitRefVec & skip )

Definition at line 604 of file MdcxCosmicSewer.cxx.

604 {
605 StatusCode sc;
606 MsgStream log( msgSvc(), name() );
607
608 assert( aTrack != NULL );
609
610 // IDataManagerSvc *dataManSvc;
611 SmartIF<IDataManagerSvc> dataManSvc( eventSvc() );
612 DataObject* aTrackCol;
613 eventSvc()->findObject( "/Event/Recon/RecMdcTrackCol", aTrackCol );
614 if ( aTrackCol != NULL )
615 {
616 dataManSvc->clearSubTree( "/Event/Recon/RecMdcTrackCol" );
617 eventSvc()->unregisterObject( "/Event/Recon/RecMdcTrackCol" );
618 }
619
620 DataObject* aRecHitCol;
621 eventSvc()->findObject( "/Event/Recon/RecMdcHitCol", aRecHitCol );
622 if ( aRecHitCol != NULL )
623 {
624 dataManSvc->clearSubTree( "/Event/Recon/RecMdcHitCol" );
625 eventSvc()->unregisterObject( "/Event/Recon/RecMdcHitCol" );
626 }
627
628 SmartDataPtr<RecMdcTrackCol> trackList( eventSvc(), EventModel::Recon::RecMdcTrackCol );
629 if ( !trackList )
630 {
631 RecMdcTrackCol* trackList = new RecMdcTrackCol;
632 sc = eventSvc()->registerObject( EventModel::Recon::RecMdcTrackCol, trackList );
633 if ( !sc.isSuccess() )
634 { log << MSG::FATAL << " Could not register RecMdcTrack collection" << endmsg; }
635 }
636
637 SmartDataPtr<RecMdcHitCol> hitList( eventSvc(), EventModel::Recon::RecMdcHitCol );
638 if ( !hitList )
639 {
640 hitList = new RecMdcHitCol;
641 sc = eventSvc()->registerObject( EventModel::Recon::RecMdcHitCol, hitList );
642 if ( !sc.isSuccess() )
643 { log << MSG::FATAL << " Could not register RecMdcHit collection" << endmsg; }
644 }
645 int trackId = trackList->size() - 1;
646
647 if ( m_debug ) std::cout << __FILE__ << " " << __LINE__ << " STORED" << std::endl;
648 MdcTrack mdcTrack( aTrack ); // aTrack have been deleted in ~MdcTrack()
649
650 // tkStat: 0,PatRec; 1,MdcxReco; 2,Tsf; 3,CurlFinder; -1,Combined cosmic
651 int tkStat = -1;
652 mdcTrack.storeTrack( trackId, trackList, hitList, tkStat );
653
654 // store hits on track
655 RecMdcTrackCol::iterator it = trackList->begin();
656 HitRefVec hl = ( *it )->getVecHits();
657 HitRefVec hitRefVec;
658 HitRefVec::iterator itHit = hl.begin();
659 int ihl = 0;
660 for ( ; itHit != hl.end(); ++itHit )
661 {
662 ihl++;
663 RecMdcHit* h = *itHit;
664 SmartRef<RecMdcHit> refHit( h );
665 hitRefVec.push_back( refHit );
666 }
667
668 if ( m_debug )
669 std::cout << __FILE__ << " " << __LINE__ << "refHit stored " << ihl << std::endl;
670 // store skipped hits
671 HitRefVec::iterator itHitSkipped = skippedHits.begin();
672 int iskipped = 0;
673 for ( ; itHitSkipped != skippedHits.end(); ++itHitSkipped )
674 {
675 iskipped++;
676 ( *itHitSkipped )->setTrkId( trackId );
677 hitList->push_back( *itHitSkipped );
678 SmartRef<RecMdcHit> refHitSkipped( *itHitSkipped );
679 hitRefVec.push_back( refHitSkipped );
680 }
681 if ( m_debug )
682 std::cout << __FILE__ << " " << __LINE__ << "skippedHits stored " << iskipped << std::endl;
683 ( *it )->setVecHits( hitRefVec );
684
685 ( *it )->setNhits( ( *it )->getVecHits().size() );
686 ( *it )->setNster( -1 );
687 // omega==0, line fit :ndof = nhit-4
688 // omega>0, helix fit :ndof = nhit-5
689 if ( ( *it )->helix( 2 ) < 0.00001 ) ( *it )->setNdof( ( *it )->getNhits() - 4 );
690 else ( *it )->setNdof( ( *it )->getNhits() - 5 );
691
692 if ( m_debug )
693 std::cout << __FILE__ << " " << __LINE__ << " stored " << ( *it )->getVecHits().size()
694 << std::endl;
695}

Referenced by execute().


The documentation for this class was generated from the following files: