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