CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Attributes
cms::CosmicTrackFinder Class Reference

#include <CosmicTrackFinder.h>

Inheritance diagram for cms::CosmicTrackFinder:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 CosmicTrackFinder (const edm::ParameterSet &conf)
 
virtual void produce (edm::Event &e, const edm::EventSetup &c)
 
virtual ~CosmicTrackFinder ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

typedef TrajectoryStateOnSurface TSOS
 

Private Attributes

edm::ParameterSet conf_
 
CosmicTrajectoryBuilder cosmicTrajectoryBuilder_
 
CRackTrajectoryBuilder crackTrajectoryBuilder_
 
std::string geometry
 
bool trinevents
 
bool useHitsSplitting_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 67 of file CosmicTrackFinder.h.

Member Typedef Documentation

Definition at line 70 of file CosmicTrackFinder.h.

Constructor & Destructor Documentation

cms::CosmicTrackFinder::CosmicTrackFinder ( const edm::ParameterSet conf)
explicit

Definition at line 30 of file CosmicTrackFinder.cc.

References conf_, geometry, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), AlCaHLTBitMon_QueryRunRegistry::string, and useHitsSplitting_.

30  :
33  conf_(conf)
34  {
35  geometry=conf_.getUntrackedParameter<std::string>("GeometricStructure","STANDARD");
36  useHitsSplitting_=conf.getParameter<bool>("useHitsSplitting");
37  produces<TrackCandidateCollection>();
38  }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
CosmicTrajectoryBuilder cosmicTrajectoryBuilder_
CRackTrajectoryBuilder crackTrajectoryBuilder_
edm::ParameterSet conf_
cms::CosmicTrackFinder::~CosmicTrackFinder ( )
virtual

Definition at line 42 of file CosmicTrackFinder.cc.

42 { }

Member Function Documentation

void cms::CosmicTrackFinder::produce ( edm::Event e,
const edm::EventSetup c 
)
virtual

.....

Implements edm::EDProducer.

Definition at line 45 of file CosmicTrackFinder.cc.

References alongMomentum, funct::C, conf_, cosmicTrajectoryBuilder_, gather_cfg::cout, crackTrajectoryBuilder_, edm::OwnVector< T, P >::front(), TrackingRecHit::geographicalId(), geometry, edm::EventSetup::get(), edm::Event::getByLabel(), edm::ParameterSet::getParameter(), CosmicTrajectoryBuilder::hitBuilder(), CRackTrajectoryBuilder::hitBuilder(), TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localParameters(), LogDebug, TrajectoryStateOnSurface::magneticField(), convertSQLitetoXML_cfg::output, trajectoryStateTransform::persistentState(), edm::Handle< T >::product(), edm::Event::put(), DetId::rawId(), TrackingRecHit::rawId(), edm::OwnVector< T, P >::reverse(), CosmicTrajectoryBuilder::run(), CRackTrajectoryBuilder::run(), fileCollector::seed, TrajectoryStateOnSurface::surface(), patCandidatesForDimuonsSequences_cff::tracker, and useHitsSplitting_.

46  {
47  using namespace std ;
48  edm::InputTag matchedrecHitsTag = conf_.getParameter<edm::InputTag>("matchedRecHits");
49  edm::InputTag rphirecHitsTag = conf_.getParameter<edm::InputTag>("rphirecHits");
50  edm::InputTag stereorecHitsTag = conf_.getParameter<edm::InputTag>("stereorecHits");
51  edm::InputTag pixelRecHitsTag = conf_.getParameter<edm::InputTag>("pixelRecHits");
52 
53 
54  edm::InputTag seedTag = conf_.getParameter<edm::InputTag>("cosmicSeeds");
55  // retrieve seeds
57  e.getByLabel(seedTag,seed);
58 
59  //retrieve PixelRecHits
60  static const SiPixelRecHitCollection s_empty;
61  const SiPixelRecHitCollection *pixelHitCollection = &s_empty;
63  if (geometry!="MTCC" && (geometry!="CRACK" )) {
64  if( e.getByLabel(pixelRecHitsTag, pixelHits)) {
65  pixelHitCollection = pixelHits.product();
66  } else {
67  edm::LogWarning("CosmicTrackFinder") << "Collection SiPixelRecHitCollection with InputTag " << pixelRecHitsTag << " cannot be found, using empty collection of same type.";
68  }
69  }
70 
71 
72 
73 
74  //retrieve StripRecHits
76  e.getByLabel( matchedrecHitsTag ,matchedrecHits);
78  e.getByLabel( rphirecHitsTag ,rphirecHits);
80  e.getByLabel( stereorecHitsTag, stereorecHits);
81 
82  // Step B: create empty output collection
83  std::auto_ptr<TrackCandidateCollection> output(new TrackCandidateCollection);
84 
86  es.get<TrackerDigiGeometryRecord>().get(tracker);
87  edm::LogVerbatim("CosmicTrackFinder") << "========== Cosmic Track Finder Info ==========";
88  edm::LogVerbatim("CosmicTrackFinder") << " Numbers of Seeds " << (*seed).size();
89  if((*seed).size()>0){
90 
91  std::vector<Trajectory> trajoutput;
92 
93 
94  const TransientTrackingRecHitBuilder * hitBuilder = nullptr;
95  if(geometry!="CRACK" ) {
97  *stereorecHits,
98  *rphirecHits,
99  *matchedrecHits,
100  *pixelHitCollection,
101  es,
102  e,
103  trajoutput);
104  hitBuilder = cosmicTrajectoryBuilder_.hitBuilder();
105  } else {
107  *stereorecHits,
108  *rphirecHits,
109  *matchedrecHits,
110  *pixelHitCollection,
111  es,
112  e,
113  trajoutput);
114  hitBuilder = crackTrajectoryBuilder_.hitBuilder();
115  }
116  assert(hitBuilder);
117  Traj2TrackHits t2t(hitBuilder,true);
118 
119  edm::LogVerbatim("CosmicTrackFinder") << " Numbers of Temp Trajectories " << trajoutput.size();
120  edm::LogVerbatim("CosmicTrackFinder") << "========== END Info ==========";
121  if(trajoutput.size()>0){
122 
123  // crazyness...
124  std::vector<Trajectory*> tmpTraj;
125  std::vector<Trajectory>::iterator itr;
126  for (itr=trajoutput.begin();itr!=trajoutput.end();itr++)tmpTraj.push_back(&(*itr));
127 
128  //The best track is selected
129  //FOR MTCC the criteria are:
130  //1)# of layers,2) # of Hits,3)Chi2
131  if (geometry=="MTCC") stable_sort(tmpTraj.begin(),tmpTraj.end(),CompareTrajLay());
132  else stable_sort(tmpTraj.begin(),tmpTraj.end(),CompareTrajChi());
133 
135 
136  const Trajectory theTraj = *(*tmpTraj.begin());
137  bool seedplus=(theTraj.seed().direction()==alongMomentum);
138 
139  // std::cout << "CosmicTrackFinder " <<"Reconstruction " << (seedplus ? "along" : "opposite to") << " momentum" << std::endl;
140  LogDebug("CosmicTrackFinder")<<"Reconstruction " << (seedplus ? "along" : "opposite to") << " momentum";
141 
142  /*
143  // === the convention is to save always final tracks with hits sorted *along* momentum
144  // --- this is NOT what was necessaraly happening before and not consistent with what done in standard CKF (this is a candidate not a track)
145  */
147  if(theTraj.direction() == alongMomentum) std::cout << "cosmic: along momentum... " << std::endl;
148  t2t(theTraj,recHits,useHitsSplitting_);
149  recHits.reverse(); // according to original code
150 
151  /*
152  Trajectory::RecHitContainer thits;
153  //it->recHitsV(thits);
154  theTraj.recHitsV(thits,useHitsSplitting_);
155  edm::OwnVector<TrackingRecHit> recHits;
156  recHits.reserve(thits.size());
157  // reverse hit order
158  for (Trajectory::RecHitContainer::const_iterator hitIt = thits.end()-1;
159  hitIt >= thits.begin(); hitIt--) {
160  recHits.push_back( (**hitIt).hit()->clone());
161  }
162  */
163 
164  TSOS firstState;
165  unsigned int firstId;
166 
167  // assume not along momentum....
168  firstState=theTraj.lastMeasurement().updatedState();
169  firstId = theTraj.lastMeasurement().recHitR().rawId();
170  //firstId = recHits.front().rawId();
171 
172  /*
173  cout << "firstState y, z: " << firstState.globalPosition().y()
174  << " , " << firstState.globalPosition().z() << endl;
175 
176  */
177 
179  TSOS startingState( firstState.localParameters(), LocalTrajectoryError(C),
180  firstState.surface(),
181  firstState.magneticField() );
182 
183  // protection againt invalid initial states
184  if (! firstState.isValid()) {
185  edm::LogWarning("CosmicTrackFinder") << "invalid innerState, will not make TrackCandidate";
187  return;
188  }
189 
190  // FIXME in case of slitting this can happen see CkfTrackCandidateMakerBase
191  if(firstId != recHits.front().rawId()){
192  edm::LogWarning("CosmicTrackFinder") <<"Mismatch in DetID of first hit: firstID= " <<firstId
193  << " DetId= " << recHits.front().geographicalId().rawId();
195  return;
196  }
197 
198  PTrajectoryStateOnDet const & state = trajectoryStateTransform::persistentState( startingState, firstId);
199 
200 
201  output->push_back(TrackCandidate(recHits,theTraj.seed(),state,theTraj.seedRef() ) );
202 
203  }
204 
205  }
207  }
#define LogDebug(id)
T getParameter(std::string const &) const
const LocalTrajectoryParameters & localParameters() const
ROOT::Math::SMatrixIdentity AlgebraicMatrixID
std::vector< TrackCandidate > TrackCandidateCollection
CosmicTrajectoryBuilder cosmicTrajectoryBuilder_
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
const MagneticField * magneticField() const
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
const TransientTrackingRecHitBuilder * hitBuilder() const
void reverse()
Definition: OwnVector.h:143
const SurfaceType & surface() const
void run(const TrajectorySeedCollection &collseed, const SiStripRecHit2DCollection &collstereo, const SiStripRecHit2DCollection &collrphi, const SiStripMatchedRecHit2DCollection &collmatched, const SiPixelRecHitCollection &collpixel, const edm::EventSetup &es, edm::Event &e, std::vector< Trajectory > &trajoutput)
Runs the algorithm.
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
CRackTrajectoryBuilder crackTrajectoryBuilder_
const TransientTrackingRecHitBuilder * hitBuilder() const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
void run(const TrajectorySeedCollection &collseed, const SiStripRecHit2DCollection &collstereo, const SiStripRecHit2DCollection &collrphi, const SiStripMatchedRecHit2DCollection &collmatched, const SiPixelRecHitCollection &collpixel, const edm::EventSetup &es, edm::Event &e, std::vector< Trajectory > &trajoutput)
Runs the algorithm.
T const * product() const
Definition: Handle.h:81
tuple cout
Definition: gather_cfg.py:121
DetId geographicalId() const
edm::ParameterSet conf_
reference front()
Definition: OwnVector.h:349
id_type rawId() const

Member Data Documentation

edm::ParameterSet cms::CosmicTrackFinder::conf_
private

Definition at line 82 of file CosmicTrackFinder.h.

Referenced by CosmicTrackFinder(), and produce().

CosmicTrajectoryBuilder cms::CosmicTrackFinder::cosmicTrajectoryBuilder_
private

Definition at line 80 of file CosmicTrackFinder.h.

Referenced by produce().

CRackTrajectoryBuilder cms::CosmicTrackFinder::crackTrajectoryBuilder_
private

Definition at line 81 of file CosmicTrackFinder.h.

Referenced by produce().

std::string cms::CosmicTrackFinder::geometry
private
bool cms::CosmicTrackFinder::trinevents
private

Definition at line 84 of file CosmicTrackFinder.h.

bool cms::CosmicTrackFinder::useHitsSplitting_
private

Definition at line 85 of file CosmicTrackFinder.h.

Referenced by CosmicTrackFinder(), and produce().