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 
20 
21 // for track propagation through HGC
22 // N.B. we are only propogating to first layer, so check these later
30 
31 //geometry records
35 
36 #include <memory>
37 #include <unordered_map>
38 
40 public:
42 
43 private:
44  void produce(edm::Event&, const edm::EventSetup&) override;
45  void beginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) override;
46 
48 
49  // variables needed for copied goodPtResolution function
50  // need to go back and figure out sensible values
51 
53  const std::vector<double> DPtovPtCut_;
54  const std::vector<unsigned> NHitCut_;
55  const bool useIterTracking_;
56  // const bool _useFirstLayerOnly; // always true now
57 
58  // variables needed for copied extrapolation
63  std::array<std::string, 1> hgc_names_; // 3 --> 1; extrapolate to hgcee only
64  std::array<edm::ESGetToken<HGCalGeometry, IdealGeometryRecord>, 1>
65  hgcGeometryTokens_; // 3 --> 1; extrapolate to hgcee only
66  std::array<const HGCalGeometry*, 1> hgcGeometries_; // 3 --> 1; extrapolate to hgcee only
67  std::array<std::vector<ReferenceCountingPointer<BoundDisk> >, 1> plusSurface_,
68  minusSurface_; // 3 --> 1; extrapolate to hgcee only
69  std::unique_ptr<PropagatorWithMaterial> mat_prop_;
70 
73 };
74 
76  : src_(consumes<edm::View<reco::PFRecTrack> >(iConfig.getParameter<edm::InputTag>("src"))),
77  trackQuality_((iConfig.existsAs<std::string>("trackQuality"))
78  ? reco::TrackBase::qualityByName(iConfig.getParameter<std::string>("trackQuality"))
79  : reco::TrackBase::highPurity),
80  DPtovPtCut_(iConfig.getParameter<std::vector<double> >("DPtOverPtCuts_byTrackAlgo")),
81  NHitCut_(iConfig.getParameter<std::vector<unsigned> >("NHitCuts_byTrackAlgo")),
82  useIterTracking_(iConfig.getParameter<bool>("useIterativeTracking")),
83  magneticFieldToken_(esConsumes<edm::Transition::BeginLuminosityBlock>()),
84  tkerGeomToken_(esConsumes<edm::Transition::BeginLuminosityBlock>()) {
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  for (unsigned i = 0; i < hgcGeometryTokens_.size(); i++) {
91  hgcGeometryTokens_[i] = esConsumes<edm::Transition::BeginLuminosityBlock>(edm::ESInputTag("", hgc_names_[i]));
92  }
93 
94  produces<reco::PFRecTrackCollection>("TracksInHGCal");
95  produces<reco::PFRecTrackCollection>("TracksNotInHGCal");
96 }
97 
98 // From https://github.com/cms-sw/cmssw/blob/CMSSW_6_2_X_SLHC/RecoParticleFlow/PFClusterProducer/src/HGCClusterizer.cc#L441-L447 and beyond
99 // TODO: we only need the front of the calorimeter, so modify this
101  constexpr float m_pion = 0.1396;
102  // get dependencies for setting up propagator
105  // get HGC geometries (assume that layers are ordered in Z!)
106  for (unsigned i = 0; i < hgcGeometries_.size(); ++i) {
108  }
109 
110  // make propagator
111  mat_prop_ = std::make_unique<PropagatorWithMaterial>(alongMomentum, m_pion, bField_);
112  // setup HGC layers for track propagation
113  Surface::RotationType rot; //unit rotation matrix
114  for (unsigned i = 0; i < hgcGeometries_.size(); ++i) {
115  minusSurface_[i].clear();
116  plusSurface_[i].clear();
117  const HGCalDDDConstants& dddCons = hgcGeometries_[i]->topology().dddConstants();
118  std::map<float, float> zrhoCoord;
119  std::map<float, float> innerRadiusCoord;
120  auto theTrForms = dddCons.getTrForms();
121  const auto& firstLayerIt = theTrForms.back();
122  float Z(std::abs(firstLayerIt.h3v.z()));
123  // use hardcoded radii for now (FIX ME)
124  diskInnerRadius_ = 31.5;
125  diskOuterRadius_ = 161.0f;
126  LogDebug("HGCalTrackCollectionProducer") << "O HAI I'm making a bound disk with Outer R=" << diskOuterRadius_
127  << " Inner R=" << diskInnerRadius_ << " and Z=" << Z << std::endl;
132  }
133 }
134 
137  evt.getByToken(src_, trackHandle);
138  const auto& tracks = *trackHandle;
139 
140  auto outputInHGCal = std::make_unique<reco::PFRecTrackCollection>();
141  auto outputNotInHGCal = std::make_unique<reco::PFRecTrackCollection>();
142 
143  for (unsigned int i = 0; i < tracks.size(); i++) {
144  const auto track = tracks.ptrAt(i);
145  bool isGood =
147  LogDebug("HGCalTrackCollectionProducer") << "HGCalTrackCollectionProducer Track number " << i
148  << " has a goodPtResolution result of " << isGood << std::endl;
149  if (!isGood)
150  continue;
151  bool found = false;
152  const TrajectoryStateOnSurface myTSOS =
154  auto detbegin = myTSOS.globalPosition().z() > 0 ? plusSurface_.begin() : minusSurface_.begin();
155  auto detend = myTSOS.globalPosition().z() > 0 ? plusSurface_.end() : minusSurface_.end();
156  for (auto det = detbegin; det != detend; ++det) {
157  LogDebug("HGCalTrackCollectionProducer") << "at HGC detector: " << std::distance(detbegin, det) << std::endl;
158  unsigned layer_count = 1;
159  for (const auto& layer : *det) {
160  LogDebug("HGCalTrackCollectionProducer") << " at DET layer: " << layer_count++ << std::endl;
161  TrajectoryStateOnSurface piStateAtSurface = mat_prop_->propagate(myTSOS, *layer);
162  if (piStateAtSurface.isValid()) {
163  LogDebug("HGCalTrackCollectionProducer") << "Extrapolation is valid!" << std::endl;
164  GlobalPoint pt = piStateAtSurface.globalPosition();
165  if (pt.perp() < diskOuterRadius_) {
166  if (pt.perp() > diskInnerRadius_) {
167  LogDebug("HGCalTrackCollectionProducer")
168  << "(x,y,z,r)=(" << pt.x() << ", " << pt.y() << ", " << pt.z() << ", "
169  << sqrt(pt.x() * pt.x() + pt.y() * pt.y()) << ")" << std::endl;
170  if (std::abs(track->trackRef()->eta()) < 1.47)
171  LogDebug("HGCalTrackCollectionProducer") << " ETA IN BARREL REGION: " << track->trackRef()->eta()
172  << " (PT: " << track->trackRef()->pt() << ")" << std::endl;
173  found = true;
174  } else {
175  LogDebug("HGCalTrackCollectionProducer")
176  << " but r=" << pt.perp() << " < diskInnerRadius=" << diskInnerRadius_ << " so skipping "
177  << std::endl;
178  }
179  } else {
180  LogDebug("HGCalTrackCollectionProducer")
181  << " but r=" << pt.perp() << " > diskOuterRadius=" << diskOuterRadius_ << " so skipping " << std::endl;
182  }
183  } else {
184  LogDebug("HGCalTrackCollectionProducer") << "Extrapolation is NOT valid!" << std::endl;
185  }
186  }
187  }
188  if (found) {
189  LogDebug("HGCalTrackCollectionProducer") << " Track going to outputInHGCal pt eta " << track->trackRef()->pt()
190  << " " << track->trackRef()->eta() << std::endl;
191  outputInHGCal->push_back(*track);
192  } else {
193  outputNotInHGCal->push_back(*track);
194  }
195  } // track loop
196 
197  evt.put(std::move(outputInHGCal), "TracksInHGCal");
198  evt.put(std::move(outputNotInHGCal), "TracksNotInHGCal");
199 }
200 
HGCalTrackCollectionProducer::src_
edm::EDGetTokenT< edm::View< reco::PFRecTrack > > src_
Definition: HGCalTrackCollectionProducer.cc:47
TkRotation< float >
Handle.h
electrons_cff.bool
bool
Definition: electrons_cff.py:366
mps_fire.i
i
Definition: mps_fire.py:428
edm::ESInputTag
Definition: ESInputTag.h:87
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11724
InitialClusteringStepBase.h
MessageLogger.h
HGCalTrackCollectionProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: HGCalTrackCollectionProducer.cc:135
HGCalTrackCollectionProducer::beginLuminosityBlock
void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override
Definition: HGCalTrackCollectionProducer.cc:100
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:71
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
HGCalTrackCollectionProducer::diskInnerRadius_
float diskInnerRadius_
Definition: HGCalTrackCollectionProducer.cc:72
reco::TrackBase::TrackQuality
TrackQuality
track quality
Definition: TrackBase.h:150
EDProducer.h
HGCalTrackCollectionProducer::useIterTracking_
const bool useIterTracking_
Definition: HGCalTrackCollectionProducer.cc:55
ReferenceCountingPointer< BoundDisk >
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
edm::Handle
Definition: AssociativeIterator.h:50
HGCalTrackCollectionProducer::DPtovPtCut_
const std::vector< double > DPtovPtCut_
Definition: HGCalTrackCollectionProducer.cc:53
HGCalDDDConstants
Definition: HGCalDDDConstants.h:27
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:63
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
SimpleDiskBounds
Definition: SimpleDiskBounds.h:11
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
MakerMacros.h
Track.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HGCalTrackCollectionProducer::magneticFieldToken_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
Definition: HGCalTrackCollectionProducer.cc:59
HGCalTrackCollectionProducer::hgcGeometries_
std::array< const HGCalGeometry *, 1 > hgcGeometries_
Definition: HGCalTrackCollectionProducer.cc:66
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
HGCalTrackCollectionProducer::mat_prop_
std::unique_ptr< PropagatorWithMaterial > mat_prop_
Definition: HGCalTrackCollectionProducer.cc:69
IdealMagneticFieldRecord.h
HGCalTrackCollectionProducer::NHitCut_
const std::vector< unsigned > NHitCut_
Definition: HGCalTrackCollectionProducer.cc:54
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
Point3DBase< float, GlobalTag >
PFCPositionCalculatorBase.h
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
TrackerDigiGeometryRecord.h
PFTrackAlgoTools.h
HGCalGeometry.h
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
edm::Transition
Transition
Definition: Transition.h:12
Event.h
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:176
PropagatorWithMaterial.h
HGCalTrackCollectionProducer::tkerGeomToken_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkerGeomToken_
Definition: HGCalTrackCollectionProducer.cc:60
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:413
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::stream::EDProducer
Definition: EDProducer.h:36
IdealGeometryRecord.h
MagneticField.h
edm::EventSetup
Definition: EventSetup.h:58
HGCalTrackCollectionProducer::minusSurface_
std::array< std::vector< ReferenceCountingPointer< BoundDisk > >, 1 > minusSurface_
Definition: HGCalTrackCollectionProducer.cc:67
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
HGCalTrackCollectionProducer::bField_
const MagneticField * bField_
Definition: HGCalTrackCollectionProducer.cc:61
PFRecTrack.h
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord >
PropagationDirection.h
PFRecHitFraction.h
HGCalTrackCollectionProducer::trackQuality_
const reco::TrackBase::TrackQuality trackQuality_
Definition: HGCalTrackCollectionProducer.cc:52
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
HGCalTrackCollectionProducer
Definition: HGCalTrackCollectionProducer.cc:39
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:67
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
pixelTrack::qualityByName
Quality qualityByName(std::string const &name)
Definition: TrackSoAHeterogeneousT.h:16
PFRecTrackFwd.h
HGCalTrackCollectionProducer::hgcGeometryTokens_
std::array< edm::ESGetToken< HGCalGeometry, IdealGeometryRecord >, 1 > hgcGeometryTokens_
Definition: HGCalTrackCollectionProducer.cc:65
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
BeamSpotPI::Z
Definition: BeamSpotPayloadInspectorHelper.h:33
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
HLT_FULL_cff.distance
distance
Definition: HLT_FULL_cff.py:7746
MagneticField
Definition: MagneticField.h:19
lumi
Definition: LumiSectionData.h:20
BoundDisk
Disk BoundDisk
Definition: BoundDisk.h:54
HGCalTrackCollectionProducer::HGCalTrackCollectionProducer
HGCalTrackCollectionProducer(const edm::ParameterSet &)
Definition: HGCalTrackCollectionProducer.cc:75
alongMomentum
Definition: PropagationDirection.h:4
edm::ParameterSet::getParameterSet
ParameterSet const & getParameterSet(std::string const &) const
Definition: ParameterSet.cc:2128
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
HGCalTrackCollectionProducer::tkGeom_
const TrackerGeometry * tkGeom_
Definition: HGCalTrackCollectionProducer.cc:62
TrackerGeometry
Definition: TrackerGeometry.h:14