CMS 3D CMS Logo

Phase2ITValidateTrackingRecHit.cc
Go to the documentation of this file.
1 // Package: Phase2ITValidateTrackingRecHit
2 // Class: Phase2ITValidateTrackingRecHit
3 //
7 //
8 // Author: Shubhi Parolia, Suvankar Roy Chowdhury
9 // Date: June 2020
10 //
11 // system include files
12 #include <memory>
13 #include <map>
14 #include <vector>
15 #include <algorithm>
39 //--- for SimHit association
44 //DQM
48 // base class
51 
53 public:
56  void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override;
57  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
58 
59 private:
60  void fillITHistos(const edm::Event& iEvent,
61  const TrackerHitAssociator& associateRecHit,
63  const std::map<unsigned int, SimTrack>& selectedSimTrackMap);
66  const double simtrackminpt_;
69  std::vector<edm::EDGetTokenT<edm::PSimHitContainer>> simHitTokens_;
70 };
71 
73  : Phase2ITValidateRecHitBase(iConfig),
74  config_(iConfig),
75  trackerHitAssociatorConfig_(iConfig, consumesCollector()),
76  simtrackminpt_(iConfig.getParameter<double>("SimTrackMinPt")),
77  tokenTracks_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("tracksSrc"))),
78  simTracksToken_(consumes<edm::SimTrackContainer>(iConfig.getParameter<edm::InputTag>("simTracksSrc"))) {
79  edm::LogInfo("Phase2ITValidateRecHit") << ">>> Construct Phase2ITValidateRecHit ";
80  for (const auto& itName : config_.getParameter<std::vector<std::string>>("ROUList")) {
81  simHitTokens_.push_back(consumes<std::vector<PSimHit>>(edm::InputTag("g4SimHits", itName)));
82  }
83 }
84 //
86  edm::LogInfo("Phase2ITValidateTrackingRecHit") << ">>> Destroy Phase2ITValidateTrackingRecHit ";
87 }
88 
90  std::vector<edm::Handle<edm::PSimHitContainer>> simHits;
91  for (const auto& itoken : simHitTokens_) {
92  const auto& simHitHandle = iEvent.getHandle(itoken);
93  if (!simHitHandle.isValid())
94  continue;
95  simHits.emplace_back(simHitHandle);
96  }
97  // Get the SimTracks and push them in a map of id, SimTrack
98  const auto& simTracks = iEvent.getHandle(simTracksToken_);
99 
100  std::map<unsigned int, SimTrack> selectedSimTrackMap;
101  for (const auto& simTrackIt : *simTracks) {
102  if (simTrackIt.momentum().pt() > simtrackminpt_) {
103  selectedSimTrackMap.emplace(simTrackIt.trackId(), simTrackIt);
104  }
105  }
107  fillITHistos(iEvent, associateRecHit, simHits, selectedSimTrackMap);
108 }
109 
111  const TrackerHitAssociator& associateRecHit,
113  const std::map<unsigned int, SimTrack>& selectedSimTrackMap) {
114  const auto& tracks = iEvent.getHandle(tokenTracks_);
115  if (!tracks.isValid())
116  return;
117 
118  std::map<std::string, unsigned int> nrechitLayerMap_primary;
119 
120  // loop over tracks
121  for (const auto& track : *tracks) {
122  // loop over hits
123  for (auto const& hit : track.recHits()) {
124  if (!hit->isValid())
125  continue;
126 
127  auto id = hit->geographicalId();
128  // check that we are in the pixel
129  auto subdetid = (id.subdetId());
130  if (!(subdetid == PixelSubdetector::PixelBarrel) && !(subdetid == PixelSubdetector::PixelEndcap))
131  continue;
132 
133  const GeomDetUnit* geomDetunit(tkGeom_->idToDetUnit(id));
134  if (!geomDetunit)
135  continue;
136  // determine the detector we are in
138  if (nrechitLayerMap_primary.find(key) == nrechitLayerMap_primary.end()) {
139  nrechitLayerMap_primary.emplace(key, 1);
140  } else {
141  nrechitLayerMap_primary[key] += 1;
142  }
143 
144  const SiPixelRecHit* rechit = dynamic_cast<const SiPixelRecHit*>(hit);
145  if (!rechit)
146  continue;
147 
148  const std::vector<SimHitIdpr>& matchedId = associateRecHit.associateHitId(*rechit);
149  const PSimHit* simhitClosest = nullptr;
150  float minx = 10000;
151  LocalPoint lp = rechit->localPosition();
152  for (const auto& simHitCol : simHits) {
153  for (const auto& simhitIt : *simHitCol) {
154  if (id.rawId() != simhitIt.detUnitId())
155  continue;
156  for (const auto& mId : matchedId) {
157  if (simhitIt.trackId() == mId.first) {
158  if (!simhitClosest || std::abs(simhitIt.localPosition().x() - lp.x()) < minx) {
159  minx = std::abs(simhitIt.localPosition().x() - lp.x());
160  simhitClosest = &simhitIt;
161  }
162  }
163  }
164  } //end loop over PSimhitcontainers
165  } //end loop over simHits
166 
167  if (!simhitClosest)
168  continue;
169 
170  // call the base class method to fill the plots
171  fillRechitHistos(simhitClosest, rechit, selectedSimTrackMap, nrechitLayerMap_primary);
172 
173  } // loop over tracking rechits
174  } // loop over tracks
175 
176  //fill nRecHit counter per layer
177  for (const auto& lme : nrechitLayerMap_primary) {
178  layerMEs_[lme.first].numberRecHitsprimary->Fill(nrechitLayerMap_primary[lme.first]);
179  }
180 }
181 
183  // rechitValidIT
185 
186  // call the base fillPsetDescription for the plots bookings
188 
189  //to be used in TrackerHitAssociator
190  desc.add<bool>("associatePixel", true);
191  desc.add<bool>("associateStrip", false);
192  desc.add<bool>("usePhase2Tracker", true);
193  desc.add<bool>("associateRecoTracks", false);
194  desc.add<bool>("associateHitbySimTrack", true);
195  desc.add<edm::InputTag>("pixelSimLinkSrc", edm::InputTag("simSiPixelDigis", "Pixel"));
196  desc.add<std::vector<std::string>>("ROUList",
197  {
198  "TrackerHitsPixelBarrelLowTof",
199  "TrackerHitsPixelBarrelHighTof",
200  "TrackerHitsPixelEndcapLowTof",
201  "TrackerHitsPixelEndcapHighTof",
202  });
203  //
204  desc.add<edm::InputTag>("simTracksSrc", edm::InputTag("g4SimHits"));
205  desc.add<edm::InputTag>("SimVertexSource", edm::InputTag("g4SimHits"));
206  desc.add<double>("SimTrackMinPt", 2.0);
207  desc.add<edm::InputTag>("tracksSrc", edm::InputTag("generalTracks"));
208  desc.add<std::string>("TopFolderName", "TrackerPhase2ITTrackingRecHitV");
209  desc.add<bool>("Verbosity", false);
210  descriptions.add("Phase2ITValidateTrackingRecHit", desc);
211 }
212 //define this as a plug-in
Phase2ITValidateTrackingRecHit::Phase2ITValidateTrackingRecHit
Phase2ITValidateTrackingRecHit(const edm::ParameterSet &)
Definition: Phase2ITValidateTrackingRecHit.cc:72
Phase2ITValidateRecHitBase::layerMEs_
std::map< std::string, RecHitME > layerMEs_
Definition: Phase2ITValidateRecHitBase.h:85
Handle.h
PixelSubdetector.h
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11724
MessageLogger.h
PixelSubdetector::PixelEndcap
Definition: PixelSubdetector.h:11
GeomDet
Definition: GeomDet.h:27
PixelSubdetector::PixelBarrel
Definition: PixelSubdetector.h:11
ESHandle.h
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
edm::EDGetTokenT< reco::TrackCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
PSimHitContainer.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
Phase2ITValidateTrackingRecHit::analyze
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition: Phase2ITValidateTrackingRecHit.cc:89
Phase2ITValidateTrackingRecHit::simTracksToken_
const edm::EDGetTokenT< edm::SimTrackContainer > simTracksToken_
Definition: Phase2ITValidateTrackingRecHit.cc:68
FastTrackerRecHitCombiner_cfi.simHits
simHits
Definition: FastTrackerRecHitCombiner_cfi.py:5
TrackCandidateProducer_cfi.simTracks
simTracks
Definition: TrackCandidateProducer_cfi.py:15
DQMStore.h
TrackerHitAssociator.h
Phase2ITValidateTrackingRecHit::~Phase2ITValidateTrackingRecHit
~Phase2ITValidateTrackingRecHit() override
Definition: Phase2ITValidateTrackingRecHit.cc:85
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
TrackerHitAssociator::Config
Definition: TrackerHitAssociator.h:57
Phase2ITValidateRecHitBase::tkGeom_
const TrackerGeometry * tkGeom_
Definition: Phase2ITValidateRecHitBase.h:59
edm::Handle< edm::PSimHitContainer >
SiPixelRecHit
Our base class.
Definition: SiPixelRecHit.h:23
Phase2ITValidateTrackingRecHit::config_
edm::ParameterSet config_
Definition: Phase2ITValidateTrackingRecHit.cc:64
TrackerGeometry::idToDetUnit
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: TrackerGeometry.cc:183
MakerMacros.h
TrackerTopology.h
PSimHit.h
TrackerTopologyRcd.h
Track.h
TrackFwd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
Service.h
TrackerPhase2DQMUtil.h
Phase2ITValidateTrackingRecHit::simHitTokens_
std::vector< edm::EDGetTokenT< edm::PSimHitContainer > > simHitTokens_
Definition: Phase2ITValidateTrackingRecHit.cc:69
Point3DBase< float, LocalTag >
PixelGeomDetType.h
DQMEDAnalyzer.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
Phase2ITValidateRecHitBase.h
Phase2ITValidateTrackingRecHit::tokenTracks_
const edm::EDGetTokenT< reco::TrackCollection > tokenTracks_
Definition: Phase2ITValidateTrackingRecHit.cc:67
SiPixelRecHitCollection.h
MonitorElement.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:176
TrackerGeomDet.h
Phase2ITValidateTrackingRecHit::simtrackminpt_
const double simtrackminpt_
Definition: Phase2ITValidateTrackingRecHit.cc:66
iEvent
int iEvent
Definition: GenABIO.cc:224
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::EventSetup
Definition: EventSetup.h:58
DetSetVector.h
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
InputTag.h
Phase2ITValidateRecHitBase::fillPSetDescription
static void fillPSetDescription(edm::ParameterSetDescription &desc)
Definition: Phase2ITValidateRecHitBase.cc:179
Phase2ITValidateRecHitBase::tTopo_
const TrackerTopology * tTopo_
Definition: Phase2ITValidateRecHitBase.h:60
TrackerHitAssociator
Definition: TrackerHitAssociator.h:55
GeomDet.h
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
phase2tkutil::getITHistoId
std::string getITHistoId(uint32_t det_id, const TrackerTopology *tTopo)
Definition: TrackerPhase2DQMUtil.cc:2
BaseTrackerRecHit::localPosition
LocalPoint localPosition() const override
Definition: BaseTrackerRecHit.h:56
edm::SimTrackContainer
std::vector< SimTrack > SimTrackContainer
Definition: SimTrackContainer.h:12
DetId.h
Frameworkfwd.h
ESWatcher.h
PixelGeomDetUnit.h
Phase2ITValidateTrackingRecHit
Definition: Phase2ITValidateTrackingRecHit.cc:52
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Phase2ITValidateRecHitBase
Definition: Phase2ITValidateRecHitBase.h:41
Phase2ITValidateTrackingRecHit::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: Phase2ITValidateTrackingRecHit.cc:182
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
Phase2ITValidateTrackingRecHit::fillITHistos
void fillITHistos(const edm::Event &iEvent, const TrackerHitAssociator &associateRecHit, const std::vector< edm::Handle< edm::PSimHitContainer >> &simHits, const std::map< unsigned int, SimTrack > &selectedSimTrackMap)
Definition: Phase2ITValidateTrackingRecHit.cc:110
PSimHit
Definition: PSimHit.h:15
edm::Event
Definition: Event.h:73
crabWrapper.key
key
Definition: crabWrapper.py:19
Phase2ITValidateRecHitBase::fillRechitHistos
void fillRechitHistos(const PSimHit *simhitClosest, const SiPixelRecHit *rechit, const std::map< unsigned int, SimTrack > &selectedSimTrackMap, std::map< std::string, unsigned int > &nrechitLayerMap_primary)
Definition: Phase2ITValidateRecHitBase.cc:123
TrackerHitAssociator::associateHitId
std::vector< SimHitIdpr > associateHitId(const TrackingRecHit &thit) const
Definition: TrackerHitAssociator.cc:332
SimTrackContainer.h
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
hit
Definition: SiStripHitEffFromCalibTree.cc:88
Phase2ITValidateTrackingRecHit::trackerHitAssociatorConfig_
TrackerHitAssociator::Config trackerHitAssociatorConfig_
Definition: Phase2ITValidateTrackingRecHit.cc:65