CMS 3D CMS Logo

CosmicTrackFinder.cc
Go to the documentation of this file.
1 // Package: RecoTracker/SingleTrackPattern
2 // Class: CosmicTrackFinder
3 // Original Author: Michele Pioppi-INFN perugia
4 #include <memory>
5 #include <string>
6 
23 
25 
26 namespace cms {
27 
29  : cosmicTrajectoryBuilder_(conf), crackTrajectoryBuilder_(conf) {
30  geometry = conf.getUntrackedParameter<std::string>("GeometricStructure", "STANDARD");
31  useHitsSplitting_ = conf.getParameter<bool>("useHitsSplitting");
33  consumes<SiStripMatchedRecHit2DCollection>(conf.getParameter<edm::InputTag>("matchedRecHits"));
34  rphirecHitsToken_ = consumes<SiStripRecHit2DCollection>(conf.getParameter<edm::InputTag>("rphirecHits"));
35  stereorecHitsToken_ = consumes<SiStripRecHit2DCollection>(conf.getParameter<edm::InputTag>("stereorecHits"));
36  pixelRecHitsToken_ = consumes<SiPixelRecHitCollection>(conf.getParameter<edm::InputTag>("pixelRecHits"));
37  seedToken_ = consumes<TrajectorySeedCollection>(conf.getParameter<edm::InputTag>("cosmicSeeds"));
38 
39  produces<TrackCandidateCollection>();
40  }
41 
42  // Virtual destructor needed.
44 
45  // Functions that gets called by framework every event
47  using namespace std;
48 
49  // retrieve seeds
51  e.getByToken(seedToken_, seed);
52 
53  //retrieve PixelRecHits
54  static const SiPixelRecHitCollection s_empty;
57  if (geometry != "MTCC" && (geometry != "CRACK")) {
58  if (e.getByToken(pixelRecHitsToken_, pixelHits)) {
59  pixelHitCollection = pixelHits.product();
60  } else {
61  Labels l;
62  labelsForToken(pixelRecHitsToken_, l);
63  edm::LogWarning("CosmicTrackFinder") << "Collection SiPixelRecHitCollection with InputTag " << l.module
64  << " cannot be found, using empty collection of same type.";
65  }
66  }
67 
68  //retrieve StripRecHits
72  e.getByToken(rphirecHitsToken_, rphirecHits);
74  e.getByToken(stereorecHitsToken_, stereorecHits);
75 
76  // Step B: create empty output collection
77  auto output = std::make_unique<TrackCandidateCollection>();
78 
81  edm::LogVerbatim("CosmicTrackFinder") << "========== Cosmic Track Finder Info ==========";
82  edm::LogVerbatim("CosmicTrackFinder") << " Numbers of Seeds " << (*seed).size();
83  if (!(*seed).empty()) {
84  std::vector<Trajectory> trajoutput;
85 
86  const TransientTrackingRecHitBuilder* hitBuilder = nullptr;
87  if (geometry != "CRACK") {
90  hitBuilder = cosmicTrajectoryBuilder_.hitBuilder();
91  } else {
94  hitBuilder = crackTrajectoryBuilder_.hitBuilder();
95  }
96  assert(hitBuilder);
97  Traj2TrackHits t2t(hitBuilder, true);
98 
99  edm::LogVerbatim("CosmicTrackFinder") << " Numbers of Temp Trajectories " << trajoutput.size();
100  edm::LogVerbatim("CosmicTrackFinder") << "========== END Info ==========";
101  if (!trajoutput.empty()) {
102  // crazyness...
103  std::vector<Trajectory*> tmpTraj;
104  std::vector<Trajectory>::iterator itr;
105  for (itr = trajoutput.begin(); itr != trajoutput.end(); itr++)
106  tmpTraj.push_back(&(*itr));
107 
108  //The best track is selected
109  //FOR MTCC the criteria are:
110  //1)# of layers,2) # of Hits,3)Chi2
111  if (geometry == "MTCC")
112  stable_sort(tmpTraj.begin(), tmpTraj.end(), CompareTrajLay());
113  else
114  stable_sort(tmpTraj.begin(), tmpTraj.end(), CompareTrajChi());
115 
117 
118  const Trajectory theTraj = *(*tmpTraj.begin());
119  bool seedplus = (theTraj.seed().direction() == alongMomentum);
120 
121  // std::cout << "CosmicTrackFinder " <<"Reconstruction " << (seedplus ? "along" : "opposite to") << " momentum" << std::endl;
122  LogDebug("CosmicTrackFinder") << "Reconstruction " << (seedplus ? "along" : "opposite to") << " momentum";
123 
124  /*
125  // === the convention is to save always final tracks with hits sorted *along* momentum
126  // --- this is NOT what was necessaraly happening before and not consistent with what done in standard CKF (this is a candidate not a track)
127  */
129  if (theTraj.direction() == alongMomentum)
130  std::cout << "cosmic: along momentum... " << std::endl;
131  t2t(theTraj, recHits, useHitsSplitting_);
132  recHits.reverse(); // according to original code
133 
134  /*
135  Trajectory::RecHitContainer thits;
136  //it->recHitsV(thits);
137  theTraj.recHitsV(thits,useHitsSplitting_);
138  edm::OwnVector<TrackingRecHit> recHits;
139  recHits.reserve(thits.size());
140  // reverse hit order
141  for (Trajectory::RecHitContainer::const_iterator hitIt = thits.end()-1;
142  hitIt >= thits.begin(); hitIt--) {
143  recHits.push_back( (**hitIt).hit()->clone());
144  }
145  */
146 
147  TSOS firstState;
148  unsigned int firstId;
149 
150  // assume not along momentum....
151  firstState = theTraj.lastMeasurement().updatedState();
152  firstId = theTraj.lastMeasurement().recHitR().rawId();
153  //firstId = recHits.front().rawId();
154 
155  /*
156  cout << "firstState y, z: " << firstState.globalPosition().y()
157  << " , " << firstState.globalPosition().z() << endl;
158 
159  */
160 
162  TSOS startingState(
163  firstState.localParameters(), LocalTrajectoryError(C), firstState.surface(), firstState.magneticField());
164 
165  // protection againt invalid initial states
166  if (!firstState.isValid()) {
167  edm::LogWarning("CosmicTrackFinder") << "invalid innerState, will not make TrackCandidate";
169  return;
170  }
171 
172  // FIXME in case of slitting this can happen see CkfTrackCandidateMakerBase
173  if (firstId != recHits.front().rawId()) {
174  edm::LogWarning("CosmicTrackFinder") << "Mismatch in DetID of first hit: firstID= " << firstId
175  << " DetId= " << recHits.front().geographicalId().rawId();
177  return;
178  }
179 
181 
182  output->push_back(TrackCandidate(recHits, theTraj.seed(), state, theTraj.seedRef()));
183  }
184  }
186  }
187 } // namespace cms
TrackExtra.h
Handle.h
cms::CosmicTrackFinder::matchedrecHitsToken_
edm::EDGetTokenT< SiStripMatchedRecHit2DCollection > matchedrecHitsToken_
Definition: CosmicTrackFinder.h:86
MessageLogger.h
CRackTrajectoryBuilder::run
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.
Definition: CRackTrajectoryBuilder.cc:82
edm::Handle::product
T const * product() const
Definition: Handle.h:70
ESHandle.h
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
SiStripMatchedRecHit2DCollection.h
cms::CompareTrajChi
Definition: CosmicTrackFinder.h:61
cms::CosmicTrackFinder::produce
void produce(edm::Event &e, const edm::EventSetup &c) override
Definition: CosmicTrackFinder.cc:46
cms::CosmicTrackFinder::pixelRecHitsToken_
edm::EDGetTokenT< SiPixelRecHitCollection > pixelRecHitsToken_
Definition: CosmicTrackFinder.h:89
trajectoryStateTransform::persistentState
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
Definition: TrajectoryStateTransform.cc:14
gather_cfg.cout
cout
Definition: gather_cfg.py:144
geometry
Definition: geometry.py:1
cms::CompareTrajLay
Definition: CosmicTrackFinder.h:19
convBremSeeds_cfi.stereorecHits
stereorecHits
Definition: convBremSeeds_cfi.py:13
AlignmentTrackSelector_cfi.matchedrecHits
matchedrecHits
Definition: AlignmentTrackSelector_cfi.py:64
cms::cuda::assert
assert(be >=bs)
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::Handle
Definition: AssociativeIterator.h:50
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
cms::CosmicTrackFinder::useHitsSplitting_
bool useHitsSplitting_
Definition: CosmicTrackFinder.h:85
AlgebraicMatrixID
ROOT::Math::SMatrixIdentity AlgebraicMatrixID
Definition: AlgebraicROOTObjects.h:72
fileCollector.seed
seed
Definition: fileCollector.py:127
cms::CosmicTrackFinder::CosmicTrackFinder
CosmicTrackFinder(const edm::ParameterSet &conf)
Definition: CosmicTrackFinder.cc:28
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
Track.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
TrackFwd.h
cms::CosmicTrackFinder::crackTrajectoryBuilder_
CRackTrajectoryBuilder crackTrajectoryBuilder_
Definition: CosmicTrackFinder.h:81
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
edm::ESHandle< TrackerGeometry >
Traj2TrackHits.h
TrajTrackAssociation.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
CosmicTrajectoryBuilder::run
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.
Definition: CosmicTrajectoryBuilder.cc:68
TrajectoryStateOnSurface::localParameters
const LocalTrajectoryParameters & localParameters() const
Definition: TrajectoryStateOnSurface.h:73
PbPb_ZMuSkimMuonDPG_cff.tracker
tracker
Definition: PbPb_ZMuSkimMuonDPG_cff.py:60
LocalTrajectoryError
Definition: LocalTrajectoryError.h:20
SiPixelRecHitCollection.h
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
edm::ParameterSet
Definition: ParameterSet.h:47
cms::CosmicTrackFinder::stereorecHitsToken_
edm::EDGetTokenT< SiStripRecHit2DCollection > stereorecHitsToken_
Definition: CosmicTrackFinder.h:88
TrackCandidate
Definition: TrackCandidate.h:24
Traj2TrackHits
Definition: Traj2TrackHits.h:16
cms::CosmicTrackFinder::~CosmicTrackFinder
~CosmicTrackFinder() override
Definition: CosmicTrackFinder.cc:43
cms::CosmicTrackFinder::cosmicTrajectoryBuilder_
CosmicTrajectoryBuilder cosmicTrajectoryBuilder_
Definition: CosmicTrackFinder.h:80
SiStripRecHit2DCollection.h
CRackTrajectoryBuilder::hitBuilder
const TransientTrackingRecHitBuilder * hitBuilder() const
Definition: CRackTrajectoryBuilder.h:192
cms::CosmicTrackFinder::seedToken_
edm::EDGetTokenT< TrajectorySeedCollection > seedToken_
Definition: CosmicTrackFinder.h:90
edm::EventSetup
Definition: EventSetup.h:57
itr
std::vector< std::pair< float, float > >::iterator itr
Definition: HGCDigitizer.cc:29
TSCPBuilderNoMaterial.h
get
#define get
TrajectorySeedCollection.h
cms::CosmicTrackFinder::rphirecHitsToken_
edm::EDGetTokenT< SiStripRecHit2DCollection > rphirecHitsToken_
Definition: CosmicTrackFinder.h:87
InputTag.h
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
Trajectory.h
edmNew::DetSetVector
Definition: DetSetNew.h:13
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
edm::OrphanHandle
Definition: EDProductfwd.h:39
RunInfoPI::state
state
Definition: RunInfoPayloadInspectoHelper.h:16
gen::C
C
Definition: PomwigHadronizer.cc:78
Trajectory
Definition: Trajectory.h:38
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
AlignmentTrackSelector_cfi.rphirecHits
rphirecHits
Definition: AlignmentTrackSelector_cfi.py:63
EventSetup.h
CosmicTrackFinder.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TrajectoryStateOnSurface::surface
const SurfaceType & surface() const
Definition: TrajectoryStateOnSurface.h:78
PTrajectoryStateOnDet
Definition: PTrajectoryStateOnDet.h:10
edm::Event
Definition: Event.h:73
AlgebraicSymMatrix55
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
Definition: AlgebraicROOTObjects.h:23
TransientTrackingRecHitBuilder
Definition: TransientTrackingRecHitBuilder.h:6
CosmicTrajectoryBuilder::hitBuilder
const TransientTrackingRecHitBuilder * hitBuilder() const
Definition: CosmicTrajectoryBuilder.h:96
TrajectoryStateOnSurface::magneticField
const MagneticField * magneticField() const
Definition: TrajectoryStateOnSurface.h:62
edm::InputTag
Definition: InputTag.h:15
alongMomentum
Definition: PropagationDirection.h:4
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
edm::OwnVector< TrackingRecHit >
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
beampixel_dqm_sourceclient-live_cfg.pixelHitCollection
pixelHitCollection
Definition: beampixel_dqm_sourceclient-live_cfg.py:134