CMS 3D CMS Logo

HGCalTrackCollectionProducer.cc
Go to the documentation of this file.
1 // S. Zenz, 12 February 2015
2 //
3 // Splits a track collection into two, based on whether they propagate to the HGCal or not
4 // Tracks with bad pt resolution (suspected fakes) are dropped and not in either collection
5 
7 
13 
17 
18 //#include "DataFormats/TrackReco/interface/Track.h"
22 
23 // for track propagation through HGC
24 // N.B. we are only propogating to first layer, so check these later
32 
33 //geometry records
37 
40 
41 #include <memory>
42 
43 #include <unordered_map>
44 
46 public:
48 
49 private:
50  void produce(edm::Event&, const edm::EventSetup&) override;
51  void beginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) override;
52 
54 
55  // variables needed for copied goodPtResolution function
56  // need to go back and figure out sensible values
57 
59  const std::vector<double> DPtovPtCut_;
60  const std::vector<unsigned> NHitCut_;
61  const bool useIterTracking_;
62  // const bool _useFirstLayerOnly; // always true now
63 
64  // variables needed for copied extrapolation
67  std::array<std::string, 1> hgc_names_; // 3 --> 1; extrapolate to hgcee only
68  std::array<edm::ESHandle<HGCalGeometry>, 1> hgcGeometries_; // 3 --> 1; extrapolate to hgcee only
69  std::array<std::vector<ReferenceCountingPointer<BoundDisk> >, 1> plusSurface_,
70  minusSurface_; // 3 --> 1; extrapolate to hgcee only
71  std::unique_ptr<PropagatorWithMaterial> mat_prop_;
72 
75 };
76 
78  : src_(consumes<edm::View<reco::PFRecTrack> >(iConfig.getParameter<edm::InputTag>("src"))),
79  trackQuality_((iConfig.existsAs<std::string>("trackQuality"))
80  ? reco::TrackBase::qualityByName(iConfig.getParameter<std::string>("trackQuality"))
81  : reco::TrackBase::highPurity),
82  DPtovPtCut_(iConfig.getParameter<std::vector<double> >("DPtOverPtCuts_byTrackAlgo")),
83  NHitCut_(iConfig.getParameter<std::vector<unsigned> >("NHitCuts_byTrackAlgo")),
84  useIterTracking_(iConfig.getParameter<bool>("useIterativeTracking")) {
85  LogDebug("HGCalTrackCollectionProducer")
86  << " HGCalTrackCollectionProducer::HGCalTrackCollectionProducer " << std::endl;
87 
88  const edm::ParameterSet& geoconf = iConfig.getParameterSet("hgcalGeometryNames");
89  hgc_names_[0] = geoconf.getParameter<std::string>("HGC_ECAL");
90 
91  produces<reco::PFRecTrackCollection>("TracksInHGCal");
92  produces<reco::PFRecTrackCollection>("TracksNotInHGCal");
93 }
94 
95 // From https://github.com/cms-sw/cmssw/blob/CMSSW_6_2_X_SLHC/RecoParticleFlow/PFClusterProducer/src/HGCClusterizer.cc#L441-L447 and beyond
96 // TODO: we only need the front of the calorimeter, so modify this
98  constexpr float m_pion = 0.1396;
99  // get dependencies for setting up propagator
102  // get HGC geometries (assume that layers are ordered in Z!)
103  for (unsigned i = 0; i < hgcGeometries_.size(); ++i) {
105  }
106 
107  // make propagator
108  mat_prop_ = std::make_unique<PropagatorWithMaterial>(alongMomentum, m_pion, bField_.product());
109  // setup HGC layers for track propagation
110  Surface::RotationType rot; //unit rotation matrix
111  for (unsigned i = 0; i < hgcGeometries_.size(); ++i) {
112  minusSurface_[i].clear();
113  plusSurface_[i].clear();
114  const HGCalDDDConstants& dddCons = hgcGeometries_[i]->topology().dddConstants();
115  std::map<float, float> zrhoCoord;
116  std::map<float, float> innerRadiusCoord;
117  auto theTrForms = dddCons.getTrForms();
118  const auto& firstLayerIt = theTrForms.back();
119  float Z(std::abs(firstLayerIt.h3v.z()));
120  // use hardcoded radii for now (FIX ME)
121  diskInnerRadius_ = 31.5;
122  diskOuterRadius_ = 161.0f;
123  LogDebug("HGCalTrackCollectionProducer") << "O HAI I'm making a bound disk with Outer R=" << diskOuterRadius_
124  << " Inner R=" << diskInnerRadius_ << " and Z=" << Z << std::endl;
129  }
130 }
131 
134  evt.getByToken(src_, trackHandle);
135  const auto& tracks = *trackHandle;
136 
137  auto outputInHGCal = std::make_unique<reco::PFRecTrackCollection>();
138  auto outputNotInHGCal = std::make_unique<reco::PFRecTrackCollection>();
139 
140  for (unsigned int i = 0; i < tracks.size(); i++) {
141  const auto track = tracks.ptrAt(i);
142  bool isGood =
144  LogDebug("HGCalTrackCollectionProducer") << "HGCalTrackCollectionProducer Track number " << i
145  << " has a goodPtResolution result of " << isGood << std::endl;
146  if (!isGood)
147  continue;
148  bool found = false;
149  const TrajectoryStateOnSurface myTSOS =
151  auto detbegin = myTSOS.globalPosition().z() > 0 ? plusSurface_.begin() : minusSurface_.begin();
152  auto detend = myTSOS.globalPosition().z() > 0 ? plusSurface_.end() : minusSurface_.end();
153  for (auto det = detbegin; det != detend; ++det) {
154  LogDebug("HGCalTrackCollectionProducer") << "at HGC detector: " << std::distance(detbegin, det) << std::endl;
155  unsigned layer_count = 1;
156  for (const auto& layer : *det) {
157  LogDebug("HGCalTrackCollectionProducer") << " at DET layer: " << layer_count++ << std::endl;
158  TrajectoryStateOnSurface piStateAtSurface = mat_prop_->propagate(myTSOS, *layer);
159  if (piStateAtSurface.isValid()) {
160  LogDebug("HGCalTrackCollectionProducer") << "Extrapolation is valid!" << std::endl;
161  GlobalPoint pt = piStateAtSurface.globalPosition();
162  if (pt.perp() < diskOuterRadius_) {
163  if (pt.perp() > diskInnerRadius_) {
164  LogDebug("HGCalTrackCollectionProducer")
165  << "(x,y,z,r)=(" << pt.x() << ", " << pt.y() << ", " << pt.z() << ", "
166  << sqrt(pt.x() * pt.x() + pt.y() * pt.y()) << ")" << std::endl;
167  if (std::abs(track->trackRef()->eta()) < 1.47)
168  LogDebug("HGCalTrackCollectionProducer") << " ETA IN BARREL REGION: " << track->trackRef()->eta()
169  << " (PT: " << track->trackRef()->pt() << ")" << std::endl;
170  found = true;
171  } else {
172  LogDebug("HGCalTrackCollectionProducer")
173  << " but r=" << pt.perp() << " < diskInnerRadius=" << diskInnerRadius_ << " so skipping "
174  << std::endl;
175  }
176  } else {
177  LogDebug("HGCalTrackCollectionProducer")
178  << " but r=" << pt.perp() << " > diskOuterRadius=" << diskOuterRadius_ << " so skipping " << std::endl;
179  }
180  } else {
181  LogDebug("HGCalTrackCollectionProducer") << "Extrapolation is NOT valid!" << std::endl;
182  }
183  }
184  }
185  if (found) {
186  LogDebug("HGCalTrackCollectionProducer") << " Track going to outputInHGCal pt eta " << track->trackRef()->pt()
187  << " " << track->trackRef()->eta() << std::endl;
188  outputInHGCal->push_back(*track);
189  } else {
190  outputNotInHGCal->push_back(*track);
191  }
192  } // track loop
193 
194  evt.put(std::move(outputInHGCal), "TracksInHGCal");
195  evt.put(std::move(outputNotInHGCal), "TracksNotInHGCal");
196 }
197 
HGCalTrackCollectionProducer::bField_
edm::ESHandle< MagneticField > bField_
Definition: HGCalTrackCollectionProducer.cc:65
HGCalTrackCollectionProducer::src_
edm::EDGetTokenT< edm::View< reco::PFRecTrack > > src_
Definition: HGCalTrackCollectionProducer.cc:53
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
TkRotation< float >
Handle.h
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
electrons_cff.bool
bool
Definition: electrons_cff.py:393
mps_fire.i
i
Definition: mps_fire.py:428
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
InitialClusteringStepBase.h
MessageLogger.h
HGCalTrackCollectionProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: HGCalTrackCollectionProducer.cc:132
HGCalTrackCollectionProducer::beginLuminosityBlock
void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override
Definition: HGCalTrackCollectionProducer.cc:97
TrackerGeometry.h
ESHandle.h
sistrip::View
View
Definition: ConstantsForView.h:26
BoundDisk.h
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
HGCalTrackCollectionProducer::diskOuterRadius_
float diskOuterRadius_
Definition: HGCalTrackCollectionProducer.cc:73
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
HGCalTrackCollectionProducer::diskInnerRadius_
float diskInnerRadius_
Definition: HGCalTrackCollectionProducer.cc:74
reco::TrackBase::TrackQuality
TrackQuality
track quality
Definition: TrackBase.h:150
EDProducer.h
HGCalTrackCollectionProducer::useIterTracking_
const bool useIterTracking_
Definition: HGCalTrackCollectionProducer.cc:61
ReferenceCountingPointer< BoundDisk >
HGCalTrackCollectionProducer::tkGeom_
edm::ESHandle< TrackerGeometry > tkGeom_
Definition: HGCalTrackCollectionProducer.cc:66
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
edm::Handle
Definition: AssociativeIterator.h:50
HGCalTrackCollectionProducer::DPtovPtCut_
const std::vector< double > DPtovPtCut_
Definition: HGCalTrackCollectionProducer.cc:59
HGCalDDDConstants
Definition: HGCalDDDConstants.h:26
ForwardSubdetector.h
trajectoryStateTransform::outerStateOnSurface
TrajectoryStateOnSurface outerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field, bool withErr=true)
Definition: TrajectoryStateTransform.cc:118
HGCalTrackCollectionProducer::hgc_names_
std::array< std::string, 1 > hgc_names_
Definition: HGCalTrackCollectionProducer.cc:67
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
SimpleDiskBounds
Definition: SimpleDiskBounds.h:11
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
MakerMacros.h
Track.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
HGCalTrackCollectionProducer::mat_prop_
std::unique_ptr< PropagatorWithMaterial > mat_prop_
Definition: HGCalTrackCollectionProducer.cc:71
IdealMagneticFieldRecord.h
edm::ESHandle< MagneticField >
HGCalTrackCollectionProducer::NHitCut_
const std::vector< unsigned > NHitCut_
Definition: HGCalTrackCollectionProducer.cc:60
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
Point3DBase< float, GlobalTag >
PFCPositionCalculatorBase.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TrackerDigiGeometryRecord.h
PFTrackAlgoTools.h
HGCalGeometry.h
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
PropagatorWithMaterial.h
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
HGCalDDDConstants::getTrForms
std::vector< HGCalParameters::hgtrform > getTrForms() const
Definition: HGCalDDDConstants.cc:412
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::stream::EDProducer
Definition: EDProducer.h:38
IdealGeometryRecord.h
MagneticField.h
edm::EventSetup
Definition: EventSetup.h:57
HGCalTrackCollectionProducer::minusSurface_
std::array< std::vector< ReferenceCountingPointer< BoundDisk > >, 1 > minusSurface_
Definition: HGCalTrackCollectionProducer.cc:69
get
#define get
PFTrackAlgoTools::goodPtResolution
bool goodPtResolution(const reco::TrackRef &, const std::vector< double > &DPtovPtCut, const std::vector< unsigned > &NHitCut, bool useIterTracking, const reco::TrackBase::TrackQuality trackQuality)
Definition: PFTrackAlgoTools.cc:236
PFRecTrack.h
PropagationDirection.h
PFRecHitFraction.h
HGCalTrackCollectionProducer::trackQuality_
const reco::TrackBase::TrackQuality trackQuality_
Definition: HGCalTrackCollectionProducer.cc:58
HGCalTrackCollectionProducer::hgcGeometries_
std::array< edm::ESHandle< HGCalGeometry >, 1 > hgcGeometries_
Definition: HGCalTrackCollectionProducer.cc:68
HGCalTrackCollectionProducer
Definition: HGCalTrackCollectionProducer.cc:45
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
HGCalTrackCollectionProducer::plusSurface_
std::array< std::vector< ReferenceCountingPointer< BoundDisk > >, 1 > plusSurface_
Definition: HGCalTrackCollectionProducer.cc:69
muons_cff.highPurity
highPurity
Definition: muons_cff.py:136
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TrajectoryStateTransform.h
PFRecTrackFwd.h
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
BeamSpotPI::Z
Definition: BeamSpotPayloadInspectorHelper.h:32
edm::Event
Definition: Event.h:73
HLT_FULL_cff.distance
distance
Definition: HLT_FULL_cff.py:7733
lumi
Definition: LumiSectionData.h:20
BoundDisk
Disk BoundDisk
Definition: BoundDisk.h:54
HGCalTrackCollectionProducer::HGCalTrackCollectionProducer
HGCalTrackCollectionProducer(const edm::ParameterSet &)
Definition: HGCalTrackCollectionProducer.cc:77
alongMomentum
Definition: PropagationDirection.h:4
IdealGeometryRecord
Definition: IdealGeometryRecord.h:25
edm::ParameterSet::getParameterSet
ParameterSet const & getParameterSet(std::string const &) const
Definition: ParameterSet.cc:2128
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54