CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 =
114  ibooker.book1D(histname, histname, dEdxMIPmassBin, dEdxMIPmassMin, dEdxMIPmassMax);
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 =
120  ibooker.book1D(histname, histname, dEdxHIPmassBin, dEdxHIPmassMin, dEdxHIPmassMax);
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 =
131  ibooker.book1D(histname, histname, dEdxNHitBin, dEdxNHitMin, dEdxNHitMax);
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
148  if (genTriggerEventFlag_->on() && !genTriggerEventFlag_->accept(iEvent, iSetup))
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++) {
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 
double HighPtThreshold
Definition: dEdxAnalyzer.h:74
~dEdxAnalyzer() override
Definition: dEdxAnalyzer.cc:39
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
edm::EDGetTokenT< reco::TrackCollection > trackToken_
Definition: dEdxAnalyzer.h:78
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
double dEdxC
Definition: dEdxAnalyzer.h:75
double TrackHitMin
Definition: dEdxAnalyzer.h:74
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
edm::ParameterSet conf_
Definition: dEdxAnalyzer.h:50
double dEdxK
Definition: dEdxAnalyzer.h:75
dEdxAnalyzer(const edm::ParameterSet &)
Definition: dEdxAnalyzer.cc:22
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:563
int iEvent
Definition: GenABIO.cc:224
void addDefault(ParameterSetDescription const &psetDescription)
std::vector< std::string > dEdxInputList_
Definition: dEdxAnalyzer.h:80
T sqrt(T t)
Definition: SSEVec.h:19
bool accept(const edm::Event &event, const edm::EventSetup &setup)
To be called from analyze/filter() methods.
GenericTriggerEventFlag * genTriggerEventFlag_
Definition: dEdxAnalyzer.h:88
const std::complex< double > I
Definition: I.h:8
bool doAllPlots_
Definition: dEdxAnalyzer.h:52
bool isValid() const
Definition: HandleBase.h:70
bool doDeDxPlots_
Definition: dEdxAnalyzer.h:53
edm::InputTag trackInputTag_
Definition: dEdxAnalyzer.h:77
double mass(double P, double I)
T const * product() const
Definition: Handle.h:70
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: dEdxAnalyzer.cc:55
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::pair< OmniClusterRef, TrackingParticleRef > P
double HIPdEdxMin
Definition: dEdxAnalyzer.h:74
std::string histname
Definition: dEdxAnalyzer.h:86
std::vector< edm::EDGetTokenT< reco::DeDxDataValueMap > > dEdxTokenList_
Definition: dEdxAnalyzer.h:81
std::vector< dEdxMEs > dEdxMEsVector
Definition: dEdxAnalyzer.h:85
void initRun(const edm::Run &run, const edm::EventSetup &setup)
To be called from beginRun() methods.
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
Definition: Run.h:45