CMS 3D CMS Logo

dEdxHitAnalyzer.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author Loic Quertenmont
5  */
7 
12 
14 
18 
19 #include <string>
20 #include "TMath.h"
21 
23  : fullconf_(iConfig),
24  conf_(fullconf_.getParameter<edm::ParameterSet>("dEdxParameters")),
25  doAllPlots_(conf_.getParameter<bool>("doAllPlots")),
26  doDeDxPlots_(conf_.getParameter<bool>("doDeDxPlots")),
27  genTriggerEventFlag_(new GenericTriggerEventFlag(
28  conf_.getParameter<edm::ParameterSet>("genericTriggerEventPSet"), consumesCollector(), *this)) {
30  trackToken_ = consumes<reco::TrackCollection>(trackInputTag_);
31 
32  dEdxInputList_ = conf_.getParameter<std::vector<std::string> >("deDxHitProducers");
33  for (auto const& tag : dEdxInputList_) {
34  dEdxTokenList_.push_back(consumes<reco::DeDxHitInfoAss>(edm::InputTag(tag)));
35  }
36 
37  // parameters from the configuration
38  MEFolderName = conf_.getParameter<std::string>("FolderName");
39 
40  dEdxNHitBin = conf_.getParameter<int>("dEdxNHitBin");
41  dEdxNHitMin = conf_.getParameter<double>("dEdxNHitMin");
42  dEdxNHitMax = conf_.getParameter<double>("dEdxNHitMax");
43 
44  dEdxStripBin = conf_.getParameter<int>("dEdxStripBin");
45  dEdxStripMin = conf_.getParameter<double>("dEdxStripMin");
46  dEdxStripMax = conf_.getParameter<double>("dEdxStripMax");
47 
48  dEdxPixelBin = conf_.getParameter<int>("dEdxPixelBin");
49  dEdxPixelMin = conf_.getParameter<double>("dEdxPixelMin");
50  dEdxPixelMax = conf_.getParameter<double>("dEdxPixelMax");
51 
52  dEdxHarm2Bin = conf_.getParameter<int>("dEdxHarm2Bin");
53  dEdxHarm2Min = conf_.getParameter<double>("dEdxHarm2Min");
54  dEdxHarm2Max = conf_.getParameter<double>("dEdxHarm2Max");
55 }
56 
59  delete genTriggerEventFlag_;
60 }
61 
62 // -- BeginRun
63 //---------------------------------------------------------------------------------//
64 void dEdxHitAnalyzer::dqmBeginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
65  // Initialize the GenericTriggerEventFlag
66  if (genTriggerEventFlag_->on())
67  genTriggerEventFlag_->initRun(iRun, iSetup);
68 }
69 
70 void dEdxHitAnalyzer::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) {
72 
73  // book the Hit Property histograms
74  // ---------------------------------------------------------------------------------//
75 
76  if (doDeDxPlots_ || doAllPlots_) {
77  for (unsigned int i = 0; i < dEdxInputList_.size(); i++) {
79  dEdxMEsVector.push_back(dEdxMEs());
80 
81  histname = "Strip_dEdxPerCluster_";
83  dEdxMEsVector[i].ME_StripHitDeDx->setAxisTitle("dEdx of on-track strip cluster (ADC)");
84  dEdxMEsVector[i].ME_StripHitDeDx->setAxisTitle("Number of Strip clusters", 2);
85 
86  histname = "Pixel_dEdxPerCluster_";
88  dEdxMEsVector[i].ME_PixelHitDeDx->setAxisTitle("dEdx of on-track pixel cluster (ADC)");
89  dEdxMEsVector[i].ME_PixelHitDeDx->setAxisTitle("Number of Pixel clusters", 2);
90 
91  histname = "NumberOfdEdxHitsPerTrack_";
93  dEdxMEsVector[i].ME_NHitDeDx->setAxisTitle("Number of dEdxHits per Track");
94  dEdxMEsVector[i].ME_NHitDeDx->setAxisTitle("Number of Tracks", 2);
95 
96  histname = "Harm2_dEdxPerTrack_";
98  dEdxMEsVector[i].ME_Harm2DeDx->setAxisTitle("Harmonic2 dEdx estimator for each Track");
99  dEdxMEsVector[i].ME_Harm2DeDx->setAxisTitle("Number of Tracks", 2);
100  }
101  }
102 }
103 
105  if (!dedxHits)
106  return -1;
107  std::vector<double> vect;
108  for (unsigned int h = 0; h < dedxHits->size(); h++) {
109  DetId detid(dedxHits->detId(h));
110  double Norm = (detid.subdetId() < 3) ? 3.61e-06 : 3.61e-06 * 265;
111  double ChargeOverPathlength = Norm * dedxHits->charge(h) / dedxHits->pathlength(h);
112  vect.push_back(ChargeOverPathlength); //save charge
113  }
114 
115  int size = vect.size();
116  if (size <= 0)
117  return -1;
118  double result = 0;
119  double expo = -2;
120  for (int i = 0; i < size; i++) {
121  result += pow(vect[i], expo);
122  }
123  return pow(result / size, 1. / expo);
124 }
125 
126 // -- Analyse
127 // ---------------------------------------------------------------------------------//
129  // Filter out events if Trigger Filtering is requested
131  return;
132 
133  if (doDeDxPlots_ || doAllPlots_) {
134  edm::Handle<reco::TrackCollection> trackCollectionHandle;
135  iEvent.getByToken(trackToken_, trackCollectionHandle);
136  if (!trackCollectionHandle.isValid())
137  return;
138 
139  for (unsigned int i = 0; i < dEdxInputList_.size(); i++) {
140  edm::Handle<reco::DeDxHitInfoAss> dEdxObjectHandle;
141  iEvent.getByToken(dEdxTokenList_[i], dEdxObjectHandle);
142  if (!dEdxObjectHandle.isValid())
143  continue;
144 
145  for (unsigned int t = 0; t < trackCollectionHandle->size(); t++) {
146  reco::TrackRef track = reco::TrackRef(trackCollectionHandle, t);
147 
148  if (track->quality(reco::TrackBase::highPurity)) {
149  const reco::DeDxHitInfo* dedxHits = nullptr;
150  if (!track.isNull()) {
151  reco::DeDxHitInfoRef dedxHitsRef = (*dEdxObjectHandle)[track];
152  if (!dedxHitsRef.isNull())
153  dedxHits = &(*dedxHitsRef);
154  }
155  if (!dedxHits)
156  continue;
157 
158  for (unsigned int h = 0; h < dedxHits->size(); h++) {
159  DetId detid(dedxHits->detId(h));
160  if (detid.subdetId() >= 3)
161  dEdxMEsVector[i].ME_StripHitDeDx->Fill(dedxHits->charge(h));
162  if (detid.subdetId() < 3)
163  dEdxMEsVector[i].ME_PixelHitDeDx->Fill(dedxHits->charge(h));
164  }
165  dEdxMEsVector[i].ME_NHitDeDx->Fill(dedxHits->size());
166  dEdxMEsVector[i].ME_Harm2DeDx->Fill(harmonic2(dedxHits));
167  }
168  }
169  }
170  }
171 }
172 
173 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
175  //The following says we do not know what parameters are allowed so do no validation
176  // Please change this to state exactly what you do use, even if it is no parameters
178  desc.setUnknown();
179  descriptions.addDefault(desc);
180 }
181 
dEdxHitAnalyzer.h
reco::DeDxHitInfo::detId
DetId detId(size_t i) const
Definition: DeDxHitInfo.h:44
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
dEdxHitAnalyzer::dEdxMEsVector
std::vector< dEdxMEs > dEdxMEsVector
Definition: dEdxHitAnalyzer.h:71
MessageLogger.h
dEdxHitAnalyzer::dEdxPixelBin
int dEdxPixelBin
Definition: dEdxHitAnalyzer.h:86
dEdxHitAnalyzer::dEdxStripBin
int dEdxStripBin
Definition: dEdxHitAnalyzer.h:82
edm::Run
Definition: Run.h:45
edm::Ref::isNull
bool isNull() const
Checks for null.
Definition: Ref.h:235
edm
HLT enums.
Definition: AlignableModifier.h:19
dEdxHitAnalyzer::dEdxInputList_
std::vector< std::string > dEdxInputList_
Definition: dEdxHitAnalyzer.h:66
dEdxHitAnalyzer::analyze
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition: dEdxHitAnalyzer.cc:128
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
dEdxHitAnalyzer::dEdxStripMax
double dEdxStripMax
Definition: dEdxHitAnalyzer.h:84
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
DQMStore.h
dEdxHitAnalyzer::conf_
edm::ParameterSet conf_
Definition: dEdxHitAnalyzer.h:49
dEdxHitAnalyzer::dEdxPixelMax
double dEdxPixelMax
Definition: dEdxHitAnalyzer.h:88
dEdxHitAnalyzer::dEdxHarm2Min
double dEdxHarm2Min
Definition: dEdxHitAnalyzer.h:91
TransientTrack.h
dEdxHitAnalyzer::doDeDxPlots_
bool doDeDxPlots_
Definition: dEdxHitAnalyzer.h:52
dEdxHitAnalyzer::dEdxNHitMax
double dEdxNHitMax
Definition: dEdxHitAnalyzer.h:80
edm::Handle< reco::TrackCollection >
reco::DeDxHitInfo::charge
float charge(size_t i) const
Definition: DeDxHitInfo.h:42
edm::Ref< TrackCollection >
DetId
Definition: DetId.h:17
dEdxHitAnalyzer::dEdxMEs
Definition: dEdxHitAnalyzer.h:54
reco::DeDxHitInfo::pathlength
float pathlength(size_t i) const
Definition: DeDxHitInfo.h:43
dEdxHitAnalyzer
Definition: dEdxHitAnalyzer.h:34
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
GenericTriggerEventFlag.h
dEdxHitAnalyzer::dEdxTokenList_
std::vector< edm::EDGetTokenT< reco::DeDxHitInfoAss > > dEdxTokenList_
Definition: dEdxHitAnalyzer.h:67
dEdxHitAnalyzer::dEdxHitAnalyzer
dEdxHitAnalyzer(const edm::ParameterSet &)
Definition: dEdxHitAnalyzer.cc:22
dEdxHitAnalyzer::dEdxHarm2Max
double dEdxHarm2Max
Definition: dEdxHitAnalyzer.h:92
h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
reco::TrackRef
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
reco::DeDxHitInfo
Definition: DeDxHitInfo.h:14
GenericTriggerEventFlag::accept
bool accept(const edm::Event &event, const edm::EventSetup &setup)
To be called from analyze/filter() methods.
Definition: GenericTriggerEventFlag.cc:266
TransientTrackBuilder.h
edm::ParameterSet
Definition: ParameterSet.h:47
dEdxHitAnalyzer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: dEdxHitAnalyzer.cc:174
ParameterSet
Definition: Functions.h:16
GenericTriggerEventFlag
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
Definition: GenericTriggerEventFlag.h:42
iEvent
int iEvent
Definition: GenABIO.cc:224
MagneticField.h
edm::EventSetup
Definition: EventSetup.h:57
dEdxHitAnalyzer::dEdxStripMin
double dEdxStripMin
Definition: dEdxHitAnalyzer.h:83
reco::DeDxHitInfo::size
size_t size() const
Definition: DeDxHitInfo.h:41
dEdxHitAnalyzer::harmonic2
double harmonic2(const reco::DeDxHitInfo *dedxHits)
Definition: dEdxHitAnalyzer.cc:104
TransientTrackRecord.h
InputTag.h
dEdxHitAnalyzer::dqmBeginRun
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
Definition: dEdxHitAnalyzer.cc:64
dEdxHitAnalyzer::trackToken_
edm::EDGetTokenT< reco::TrackCollection > trackToken_
Definition: dEdxHitAnalyzer.h:64
GenericTriggerEventFlag::on
bool on()
Definition: GenericTriggerEventFlag.h:135
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
dEdxHitAnalyzer::trackInputTag_
edm::InputTag trackInputTag_
Definition: dEdxHitAnalyzer.h:63
dEdxHitAnalyzer::dEdxNHitBin
int dEdxNHitBin
Definition: dEdxHitAnalyzer.h:78
dEdxHitAnalyzer::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: dEdxHitAnalyzer.cc:70
dEdxHitAnalyzer::histname
std::string histname
Definition: dEdxHitAnalyzer.h:72
GenericTriggerEventFlag::initRun
void initRun(const edm::Run &run, const edm::EventSetup &setup)
To be called from beginRun() methods.
Definition: GenericTriggerEventFlag.cc:153
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
dEdxHitAnalyzer::dEdxPixelMin
double dEdxPixelMin
Definition: dEdxHitAnalyzer.h:87
dqm::implementation::IBooker
Definition: DQMStore.h:43
dEdxHitAnalyzer::genTriggerEventFlag_
GenericTriggerEventFlag * genTriggerEventFlag_
Definition: dEdxHitAnalyzer.h:74
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
mps_fire.result
result
Definition: mps_fire.py:311
dEdxHitAnalyzer::MEFolderName
std::string MEFolderName
Definition: dEdxHitAnalyzer.h:76
dEdxHitAnalyzer::doAllPlots_
bool doAllPlots_
Definition: dEdxHitAnalyzer.h:51
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
dEdxHitAnalyzer::dEdxNHitMin
double dEdxNHitMin
Definition: dEdxHitAnalyzer.h:79
edm::Event
Definition: Event.h:73
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
dEdxHitAnalyzer::dEdxHarm2Bin
int dEdxHarm2Bin
Definition: dEdxHitAnalyzer.h:90
dEdxHitAnalyzer::~dEdxHitAnalyzer
~dEdxHitAnalyzer() override
Definition: dEdxHitAnalyzer.cc:57
edm::InputTag
Definition: InputTag.h:15
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
reco::TrackBase::highPurity
Definition: TrackBase.h:154