CMS 3D CMS Logo

InterestingTrackEcalDetIdProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: InterestingTrackEcalDetIdProducer
4 // Class: InterestingTrackEcalDetIdProducer
5 //
13 //
14 // Original Author:
15 // Created: Wed Sep 22 17:02:51 CEST 2010
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
28 
32 
37 
39 
42 
43 //
44 // class declaration
45 //
46 
48 public:
50 
51 private:
52  void produce(edm::Event&, const edm::EventSetup&) override;
53 
54  // ----------member data ---------------------------
57 
58  double minTrackPt_;
59 
63 };
64 
65 //
66 // constants, enums and typedefs
67 //
68 
69 //
70 // static data member definitions
71 //
72 
73 //
74 // constructors and destructor
75 //
77  : minTrackPt_(iConfig.getParameter<double>("MinTrackPt")),
78  caloTopologyToken_(esConsumes())
79 
80 {
81  trackCollectionToken_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("TrackCollection"));
83  edm::ConsumesCollector iC = consumesCollector();
84  trackAssociatorParameters_.loadParameters(iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters"), iC);
85 
86  produces<DetIdCollection>();
87 }
88 
89 //
90 // member functions
91 //
92 
93 // ------------ method called to produce the data ------------
95  using namespace edm;
96 
97  auto interestingDetIdCollection = std::make_unique<DetIdCollection>();
98 
99  // Get tracks from event
101  iEvent.getByToken(trackCollectionToken_, tracks);
102 
103  const auto& caloTopology = iSetup.getData(caloTopologyToken_);
104 
105  // Loop over tracks
106  for (reco::TrackCollection::const_iterator tkItr = tracks->begin(); tkItr != tracks->end(); ++tkItr) {
107  if (tkItr->pt() < minTrackPt_)
108  continue;
109 
111  iEvent,
112  iSetup,
115 
116  DetId centerId = info.findMaxDeposition(TrackDetMatchInfo::EcalRecHits);
117 
118  if (centerId.rawId() == 0)
119  continue;
120 
121  // Find 5x5 around max
122  const CaloSubdetectorTopology* topology = caloTopology.getSubdetectorTopology(DetId::Ecal, centerId.subdetId());
123  const std::vector<DetId>& ids = topology->getWindow(centerId, 5, 5);
124  for (std::vector<DetId>::const_iterator idItr = ids.begin(); idItr != ids.end(); ++idItr) {
125  if (std::find(interestingDetIdCollection->begin(), interestingDetIdCollection->end(), *idItr) ==
127  interestingDetIdCollection->push_back(*idItr);
128  }
129  }
130 
132 }
133 
134 //define this as a plug-in
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
static const TGPicture * info(bool iBackgroundIsBlack)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
InterestingTrackEcalDetIdProducer(const edm::ParameterSet &)
void useDefaultPropagator()
use the default propagator
void loadParameters(const edm::ParameterSet &, edm::ConsumesCollector &)
edm::EDGetTokenT< reco::TrackCollection > trackCollectionToken_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
int iEvent
Definition: GenABIO.cc:224
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > bFieldToken
void produce(edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
Definition: DetId.h:17
edm::ESGetToken< CaloTopology, CaloTopologyRecord > caloTopologyToken_
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
static FreeTrajectoryState getFreeTrajectoryState(const MagneticField *, const reco::Track &)
get FreeTrajectoryState from different track representations
HLT enums.
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
def move(src, dest)
Definition: eostools.py:511