CMS 3D CMS Logo

dEdxAnalyzer.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  : dqmStore_(edm::Service<DQMStore>().operator->()),
24  fullconf_(iConfig),
25  conf_(fullconf_.getParameter<edm::ParameterSet>("dEdxParameters")),
26  doAllPlots_(conf_.getParameter<bool>("doAllPlots")),
27  doDeDxPlots_(conf_.getParameter<bool>("doDeDxPlots")),
28  genTriggerEventFlag_(new GenericTriggerEventFlag(
29  conf_.getParameter<edm::ParameterSet>("genericTriggerEventPSet"), consumesCollector(), *this)) {
31  trackToken_ = consumes<reco::TrackCollection>(trackInputTag_);
32 
33  dEdxInputList_ = conf_.getParameter<std::vector<std::string> >("deDxProducers");
34  for (auto const& tag : dEdxInputList_) {
35  dEdxTokenList_.push_back(consumes<reco::DeDxDataValueMap>(edm::InputTag(tag)));
36  }
37 }
38 
41  delete genTriggerEventFlag_;
42 }
43 
44 /*
45 // -- BeginRun
46 //---------------------------------------------------------------------------------//
47 void dEdxAnalyzer::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup)
48 {
49 
50  // Initialize the GenericTriggerEventFlag
51  if ( genTriggerEventFlag_->on() ) genTriggerEventFlag_->initRun( iRun, iSetup );
52 }
53 */
54 
55 void dEdxAnalyzer::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) {
56  // Initialize the GenericTriggerEventFlag
57  if (genTriggerEventFlag_->on())
58  genTriggerEventFlag_->initRun(iRun, iSetup);
59 
60  // parameters from the configuration
61  std::string MEFolderName = conf_.getParameter<std::string>("FolderName");
62 
63  // get binning from the configuration
64  TrackHitMin = conf_.getParameter<double>("TrackHitMin");
65  HIPdEdxMin = conf_.getParameter<double>("HIPdEdxMin");
66  HighPtThreshold = conf_.getParameter<double>("HighPtThreshold");
67 
68  dEdxK = conf_.getParameter<double>("dEdxK");
69  dEdxC = conf_.getParameter<double>("dEdxC");
70 
71  int dEdxNHitBin = conf_.getParameter<int>("dEdxNHitBin");
72  double dEdxNHitMin = conf_.getParameter<double>("dEdxNHitMin");
73  double dEdxNHitMax = conf_.getParameter<double>("dEdxNHitMax");
74 
75  int dEdxBin = conf_.getParameter<int>("dEdxBin");
76  double dEdxMin = conf_.getParameter<double>("dEdxMin");
77  double dEdxMax = conf_.getParameter<double>("dEdxMax");
78 
79  int dEdxHIPmassBin = conf_.getParameter<int>("dEdxHIPmassBin");
80  double dEdxHIPmassMin = conf_.getParameter<double>("dEdxHIPmassMin");
81  double dEdxHIPmassMax = conf_.getParameter<double>("dEdxHIPmassMax");
82 
83  int dEdxMIPmassBin = conf_.getParameter<int>("dEdxMIPmassBin");
84  double dEdxMIPmassMin = conf_.getParameter<double>("dEdxMIPmassMin");
85  double dEdxMIPmassMax = conf_.getParameter<double>("dEdxMIPmassMax");
86 
87  ibooker.setCurrentFolder(MEFolderName);
88 
89  // book the Hit Property histograms
90  // ---------------------------------------------------------------------------------//
91 
92  if (doDeDxPlots_ || doAllPlots_) {
93  for (unsigned int i = 0; i < dEdxInputList_.size(); i++) {
94  ibooker.setCurrentFolder(MEFolderName + "/" + dEdxInputList_[i]);
95  dEdxMEsVector.push_back(dEdxMEs());
96 
97  histname = "MIP_dEdxPerTrack_";
98  dEdxMEsVector[i].ME_MipDeDx = ibooker.book1D(histname, histname, dEdxBin, dEdxMin, dEdxMax);
99  dEdxMEsVector[i].ME_MipDeDx->setAxisTitle("dEdx of each MIP Track (MeV/cm)");
100  dEdxMEsVector[i].ME_MipDeDx->setAxisTitle("Number of Tracks", 2);
101 
102  histname = "MIP_NumberOfdEdxHitsPerTrack_";
103  dEdxMEsVector[i].ME_MipDeDxNHits = ibooker.book1D(histname, histname, dEdxNHitBin, dEdxNHitMin, dEdxNHitMax);
104  dEdxMEsVector[i].ME_MipDeDxNHits->setAxisTitle("Number of dEdxHits of each MIP Track");
105  dEdxMEsVector[i].ME_MipDeDxNHits->setAxisTitle("Number of Tracks", 2);
106 
107  histname = "MIP_FractionOfSaturateddEdxHitsPerTrack_";
108  dEdxMEsVector[i].ME_MipDeDxNSatHits = ibooker.book1D(histname, histname, 2 * dEdxNHitBin, 0, 1);
109  dEdxMEsVector[i].ME_MipDeDxNSatHits->setAxisTitle("Fraction of Saturated dEdxHits of each MIP Track");
110  dEdxMEsVector[i].ME_MipDeDxNSatHits->setAxisTitle("Number of Tracks", 2);
111 
112  histname = "MIP_MassPerTrack_";
113  dEdxMEsVector[i].ME_MipDeDxMass =
115  dEdxMEsVector[i].ME_MipDeDxMass->setAxisTitle("dEdx Mass of each MIP Track (GeV/c^{2})");
116  dEdxMEsVector[i].ME_MipDeDxMass->setAxisTitle("Number of Tracks", 2);
117 
118  histname = "HIP_MassPerTrack_";
119  dEdxMEsVector[i].ME_HipDeDxMass =
121  dEdxMEsVector[i].ME_HipDeDxMass->setAxisTitle("dEdx Mass of each HIP Track (GeV/c^{2})");
122  dEdxMEsVector[i].ME_HipDeDxMass->setAxisTitle("Number of Tracks", 2);
123 
124  histname = "MIPOfHighPt_dEdxPerTrack_";
125  dEdxMEsVector[i].ME_MipHighPtDeDx = ibooker.book1D(histname, histname, dEdxBin, dEdxMin, dEdxMax);
126  dEdxMEsVector[i].ME_MipHighPtDeDx->setAxisTitle("dEdx of each MIP (of High pT) Track (MeV/cm)");
127  dEdxMEsVector[i].ME_MipHighPtDeDx->setAxisTitle("Number of Tracks", 2);
128 
129  histname = "MIPOfHighPt_NumberOfdEdxHitsPerTrack_";
130  dEdxMEsVector[i].ME_MipHighPtDeDxNHits =
132  dEdxMEsVector[i].ME_MipHighPtDeDxNHits->setAxisTitle("Number of dEdxHits of each MIP (of High pT) Track");
133  dEdxMEsVector[i].ME_MipHighPtDeDxNHits->setAxisTitle("Number of Tracks", 2);
134  }
135  }
136 }
137 
138 double dEdxAnalyzer::mass(double P, double I) {
139  if (I - dEdxC < 0)
140  return -1;
141  return sqrt((I - dEdxC) / dEdxK) * P;
142 }
143 
144 // -- Analyse
145 // ---------------------------------------------------------------------------------//
147  // Filter out events if Trigger Filtering is requested
149  return;
150 
151  if (doDeDxPlots_ || doAllPlots_) {
152  edm::Handle<reco::TrackCollection> trackCollectionHandle = iEvent.getHandle(trackToken_);
153  if (!trackCollectionHandle.isValid())
154  return;
155 
156  for (unsigned int i = 0; i < dEdxInputList_.size(); i++) {
157  edm::Handle<reco::DeDxDataValueMap> dEdxObjectHandle = iEvent.getHandle(dEdxTokenList_[i]);
158  if (!dEdxObjectHandle.isValid())
159  continue;
160  const edm::ValueMap<reco::DeDxData> dEdxColl = *dEdxObjectHandle.product();
161 
162  for (unsigned int t = 0; t < trackCollectionHandle->size(); t++) {
163  reco::TrackRef track = reco::TrackRef(trackCollectionHandle, t);
164 
165  if (track->quality(reco::TrackBase::highPurity)) {
166  //MIPs
167  if (track->pt() >= 5.0 && track->numberOfValidHits() > TrackHitMin) {
168  dEdxMEsVector[i].ME_MipDeDx->Fill(dEdxColl[track].dEdx());
169  dEdxMEsVector[i].ME_MipDeDxNHits->Fill(dEdxColl[track].numberOfMeasurements());
170  if (dEdxColl[track].numberOfMeasurements() != 0)
171  dEdxMEsVector[i].ME_MipDeDxNSatHits->Fill((1.0 * dEdxColl[track].numberOfSaturatedMeasurements()) /
172  dEdxColl[track].numberOfMeasurements());
173  dEdxMEsVector[i].ME_MipDeDxMass->Fill(mass(track->p(), dEdxColl[track].dEdx()));
174 
175  if (track->pt() >= HighPtThreshold) {
176  dEdxMEsVector[i].ME_MipHighPtDeDx->Fill(dEdxColl[track].dEdx());
177  dEdxMEsVector[i].ME_MipHighPtDeDxNHits->Fill(dEdxColl[track].numberOfMeasurements());
178  }
179 
180  //HighlyIonizing particles
181  } else if (track->pt() < 2 && dEdxColl[track].dEdx() > HIPdEdxMin) {
182  dEdxMEsVector[i].ME_HipDeDxMass->Fill(mass(track->p(), dEdxColl[track].dEdx()));
183  }
184  }
185  }
186  }
187  }
188 }
189 
190 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
192  //The following says we do not know what parameters are allowed so do no validation
193  // Please change this to state exactly what you do use, even if it is no parameters
195  desc.setUnknown();
196  descriptions.addDefault(desc);
197 }
198 
dEdxAnalyzer::trackToken_
edm::EDGetTokenT< reco::TrackCollection > trackToken_
Definition: dEdxAnalyzer.h:78
dEdxAnalyzer::dEdxMEs
Definition: dEdxAnalyzer.h:55
dEdxAnalyzer::mass
double mass(double P, double I)
Definition: dEdxAnalyzer.cc:138
electrons_cff.bool
bool
Definition: electrons_cff.py:366
mps_fire.i
i
Definition: mps_fire.py:428
dEdxAnalyzer_cfi.dEdxHIPmassMin
dEdxHIPmassMin
Definition: dEdxAnalyzer_cfi.py:44
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11724
dEdxAnalyzer::doAllPlots_
bool doAllPlots_
Definition: dEdxAnalyzer.h:52
MessageLogger.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
dEdxAnalyzer_cfi.dEdxMax
dEdxMax
Definition: dEdxAnalyzer_cfi.py:35
dEdxAnalyzer_cfi.dEdxMin
dEdxMin
Definition: dEdxAnalyzer_cfi.py:34
dEdxAnalyzer_cfi.dEdxBin
dEdxBin
Definition: dEdxAnalyzer_cfi.py:33
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
dEdxAnalyzer.h
dEdxAnalyzer::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: dEdxAnalyzer.cc:55
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
DQMStore.h
dEdxAnalyzer_cfi.dEdxHIPmassBin
dEdxHIPmassBin
Definition: dEdxAnalyzer_cfi.py:43
TransientTrack.h
dEdxAnalyzer::histname
std::string histname
Definition: dEdxAnalyzer.h:86
edm::Handle< reco::TrackCollection >
dEdxAnalyzer_cfi.dEdxMIPmassMax
dEdxMIPmassMax
Definition: dEdxAnalyzer_cfi.py:40
dEdxAnalyzer::~dEdxAnalyzer
~dEdxAnalyzer() override
Definition: dEdxAnalyzer.cc:39
plot_hgcal_utils.dEdx
dEdx
Definition: plot_hgcal_utils.py:213
edm::Ref< TrackCollection >
Utilities.operator
operator
Definition: Utilities.py:24
dEdxAnalyzer::genTriggerEventFlag_
GenericTriggerEventFlag * genTriggerEventFlag_
Definition: dEdxAnalyzer.h:88
dEdxAnalyzer::analyze
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition: dEdxAnalyzer.cc:146
dEdxAnalyzer::HIPdEdxMin
double HIPdEdxMin
Definition: dEdxAnalyzer.h:74
dEdxAnalyzer::TrackHitMin
double TrackHitMin
Definition: dEdxAnalyzer.h:74
dEdxAnalyzer::dEdxMEsVector
std::vector< dEdxMEs > dEdxMEsVector
Definition: dEdxAnalyzer.h:85
dEdxAnalyzer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: dEdxAnalyzer.cc:191
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
dqm::legacy::DQMStore
Definition: DQMStore.h:728
dEdxAnalyzer_cfi.dEdxNHitMin
dEdxNHitMin
Definition: dEdxAnalyzer_cfi.py:30
Exhume::I
const std::complex< double > I
Definition: I.h:8
GenericTriggerEventFlag.h
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
dEdxAnalyzer_cfi.dEdxNHitMax
dEdxNHitMax
Definition: dEdxAnalyzer_cfi.py:31
Service
dEdxAnalyzer::trackInputTag_
edm::InputTag trackInputTag_
Definition: dEdxAnalyzer.h:77
dEdxAnalyzer::doDeDxPlots_
bool doDeDxPlots_
Definition: dEdxAnalyzer.h:53
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
reco::TrackRef
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
dEdxAnalyzer::HighPtThreshold
double HighPtThreshold
Definition: dEdxAnalyzer.h:74
GenericTriggerEventFlag::accept
bool accept(const edm::Event &event, const edm::EventSetup &setup)
To be called from analyze/filter() methods.
Definition: GenericTriggerEventFlag.cc:266
dEdxAnalyzer::dEdxTokenList_
std::vector< edm::EDGetTokenT< reco::DeDxDataValueMap > > dEdxTokenList_
Definition: dEdxAnalyzer.h:81
TransientTrackBuilder.h
edm::ParameterSet
Definition: ParameterSet.h:47
dEdxAnalyzer_cfi.dEdxNHitBin
dEdxNHitBin
Definition: dEdxAnalyzer_cfi.py:29
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
makeGlobalPositionRcd_cfg.tag
tag
Definition: makeGlobalPositionRcd_cfg.py:6
iEvent
int iEvent
Definition: GenABIO.cc:224
MagneticField.h
edm::EventSetup
Definition: EventSetup.h:58
TransientTrackRecord.h
dEdxAnalyzer_cfi.dEdxMIPmassMin
dEdxMIPmassMin
Definition: dEdxAnalyzer_cfi.py:39
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
InputTag.h
dEdxAnalyzer::dEdxInputList_
std::vector< std::string > dEdxInputList_
Definition: dEdxAnalyzer.h:80
dEdxAnalyzer::dEdxAnalyzer
dEdxAnalyzer(const edm::ParameterSet &)
Definition: dEdxAnalyzer.cc:22
GenericTriggerEventFlag::on
bool on()
Definition: GenericTriggerEventFlag.h:135
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
edm::ValueMap
Definition: ValueMap.h:107
dEdxAnalyzer::conf_
edm::ParameterSet conf_
Definition: dEdxAnalyzer.h:50
dEdxAnalyzer_cfi.dEdxMIPmassBin
dEdxMIPmassBin
Definition: dEdxAnalyzer_cfi.py:38
dEdxAnalyzer
Definition: dEdxAnalyzer.h:34
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
dqm::implementation::IBooker
Definition: DQMStore.h:43
dEdxAnalyzer::dEdxK
double dEdxK
Definition: dEdxAnalyzer.h:75
dEdxAnalyzer_cfi.dEdxHIPmassMax
dEdxHIPmassMax
Definition: dEdxAnalyzer_cfi.py:45
dEdxAnalyzer::dEdxC
double dEdxC
Definition: dEdxAnalyzer.h:75
P
std::pair< OmniClusterRef, TrackingParticleRef > P
Definition: BDHadronTrackMonitoringAnalyzer.cc:203
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
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
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
reco::TrackBase::highPurity
Definition: TrackBase.h:154