CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
dEdxAnalyzer.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * $Date: 2012/10/16 10:07:42 $
5  * $Revision: 1.3 $
6  * \author Loic Quertenmont
7  */
9 
13 
18 
20 
24 
25 #include <string>
26 #include "TMath.h"
27 
29  : dqmStore_( edm::Service<DQMStore>().operator->() )
30  , fullconf_( iConfig )
31  , conf_ (fullconf_.getParameter<edm::ParameterSet>("dEdxParameters") )
32  , doAllPlots_ ( conf_.getParameter<bool>("doAllPlots") )
33  , doDeDxPlots_ ( conf_.getParameter<bool>("doDeDxPlots") )
34  , genTriggerEventFlag_( new GenericTriggerEventFlag(conf_) )
35 {
36 }
37 
39 {
40 
42 }
43 
44 // ------------ method called once each job just after ending the event loop ------------
45 void
47 {
48  bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
49  std::string outputFileName = conf_.getParameter<std::string>("OutputFileName");
50  if(outputMEsInRootFile)
51  {
53  dqmStore_->save(outputFileName);
54  }
55 }
56 
57 // -- BeginRun
58 //---------------------------------------------------------------------------------//
59 void dEdxAnalyzer::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup)
60 {
61 
62  // Initialize the GenericTriggerEventFlag
63  if ( genTriggerEventFlag_->on() ) genTriggerEventFlag_->initRun( iRun, iSetup );
64 }
65 
66 
68 {
69  // parameters from the configuration
70  AlgoNames = conf_.getParameter<std::vector<std::string> >("deDxProducers");
71  TrackName = conf_.getParameter<std::string>("TracksForDeDx");
72  std::string MEFolderName = conf_.getParameter<std::string>("FolderName");
73 
74  // get binning from the configuration
75  TrackHitMin = conf_.getParameter<double>("TrackHitMin");
76  HIPdEdxMin = conf_.getParameter<double>("HIPdEdxMin");
77 
78  dEdxK = conf_.getParameter<double>("dEdxK");
79  dEdxC = conf_.getParameter<double>("dEdxC");
80 
81 
82  int dEdxNHitBin = conf_.getParameter<int>( "dEdxNHitBin");
83  double dEdxNHitMin = conf_.getParameter<double>("dEdxNHitMin");
84  double dEdxNHitMax = conf_.getParameter<double>("dEdxNHitMax");
85 
86  int dEdxBin = conf_.getParameter<int>( "dEdxBin");
87  double dEdxMin = conf_.getParameter<double>("dEdxMin");
88  double dEdxMax = conf_.getParameter<double>("dEdxMax");
89 
90  int dEdxHIPmassBin = conf_.getParameter<int>( "dEdxHIPmassBin");
91  double dEdxHIPmassMin = conf_.getParameter<double>("dEdxHIPmassMin");
92  double dEdxHIPmassMax = conf_.getParameter<double>("dEdxHIPmassMax");
93 
94  int dEdxMIPmassBin = conf_.getParameter<int>( "dEdxMIPmassBin");
95  double dEdxMIPmassMin = conf_.getParameter<double>("dEdxMIPmassMin");
96  double dEdxMIPmassMax = conf_.getParameter<double>("dEdxMIPmassMax");
97 
98  dqmStore_->setCurrentFolder(MEFolderName);
99 
100  // book the Hit Property histograms
101  // ---------------------------------------------------------------------------------//
102 
103  if ( doDeDxPlots_ || doAllPlots_ ){
104  for(unsigned int i=0;i<AlgoNames.size();i++){
105  dqmStore_->setCurrentFolder(MEFolderName+"/"+ AlgoNames[i]);
106  dEdxMEsVector.push_back(dEdxMEs() );
107 
108  histname = "MIP_dEdxPerTrack_";
109  dEdxMEsVector[i].ME_MipDeDx = dqmStore_->book1D(histname, histname, dEdxBin, dEdxMin, dEdxMax);
110  dEdxMEsVector[i].ME_MipDeDx->setAxisTitle("dEdx of each MIP Track (MeV/cm)");
111  dEdxMEsVector[i].ME_MipDeDx->setAxisTitle("Number of Tracks", 2);
112 
113  histname = "MIP_NumberOfdEdxHitsPerTrack_";
114  dEdxMEsVector[i].ME_MipDeDxNHits = dqmStore_->book1D(histname, histname, dEdxNHitBin, dEdxNHitMin, dEdxNHitMax);
115  dEdxMEsVector[i].ME_MipDeDxNHits->setAxisTitle("Number of dEdxHits of each MIP Track");
116  dEdxMEsVector[i].ME_MipDeDxNHits->setAxisTitle("Number of Tracks", 2);
117 
118  histname = "MIP_FractionOfSaturateddEdxHitsPerTrack_";
119  dEdxMEsVector[i].ME_MipDeDxNSatHits = dqmStore_->book1D(histname, histname,2*dEdxNHitBin, 0, 1);
120  dEdxMEsVector[i].ME_MipDeDxNSatHits->setAxisTitle("Fraction of Saturated dEdxHits of each MIP Track");
121  dEdxMEsVector[i].ME_MipDeDxNSatHits->setAxisTitle("Number of Tracks", 2);
122 
123  histname = "MIP_MassPerTrack_";
124  dEdxMEsVector[i].ME_MipDeDxMass = dqmStore_->book1D(histname, histname, dEdxMIPmassBin, dEdxMIPmassMin, dEdxMIPmassMax);
125  dEdxMEsVector[i].ME_MipDeDxMass->setAxisTitle("dEdx Mass of each MIP Track (GeV/c^{2})");
126  dEdxMEsVector[i].ME_MipDeDxMass->setAxisTitle("Number of Tracks", 2);
127 
128  histname = "HIP_MassPerTrack_";
129  dEdxMEsVector[i].ME_HipDeDxMass = dqmStore_->book1D(histname, histname, dEdxHIPmassBin, dEdxHIPmassMin, dEdxHIPmassMax);
130  dEdxMEsVector[i].ME_HipDeDxMass->setAxisTitle("dEdx Mass of each HIP Track (GeV/c^{2})");
131  dEdxMEsVector[i].ME_HipDeDxMass->setAxisTitle("Number of Tracks", 2);
132 
133  }
134  }
135 }
136 
137 
138 double dEdxAnalyzer::mass(double P, double I){
139  if(I-dEdxC<0)return -1;
140  return sqrt((I-dEdxC)/dEdxK)*P;
141 }
142 
143 // -- Analyse
144 // ---------------------------------------------------------------------------------//
146 {
147 
148  // Filter out events if Trigger Filtering is requested
149  if (genTriggerEventFlag_->on()&& ! genTriggerEventFlag_->accept( iEvent, iSetup) ) return;
150 
151 
152  if ( doDeDxPlots_ || doAllPlots_ ){
153  edm::Handle<reco::TrackCollection> trackCollectionHandle;
154  iEvent.getByLabel(TrackName,trackCollectionHandle);
155  if(!trackCollectionHandle.isValid())return;
156 
157 
158  for(unsigned int i=0;i<AlgoNames.size();i++){
159  edm::Handle<reco::DeDxDataValueMap> dEdxObjectHandle;
160  iEvent.getByLabel(AlgoNames[i],dEdxObjectHandle);
161  if(!dEdxObjectHandle.isValid())continue;
162  const edm::ValueMap<reco::DeDxData> dEdxColl = *dEdxObjectHandle.product();
163 
164 
165  for(unsigned int t=0; t<trackCollectionHandle->size(); t++){
166  reco::TrackRef track = reco::TrackRef( trackCollectionHandle, t );
167 
168 
169  if(track->quality(reco::TrackBase::highPurity) ) {
170  //MIPs
171  if( track->pt() >= 5.0 && track->numberOfValidHits()>TrackHitMin){
172  dEdxMEsVector[i].ME_MipDeDx ->Fill(dEdxColl[track].dEdx());
173  dEdxMEsVector[i].ME_MipDeDxNHits ->Fill(dEdxColl[track].numberOfMeasurements());
174  if (dEdxColl[track].numberOfMeasurements()!=0)
175  dEdxMEsVector[i].ME_MipDeDxNSatHits->Fill((1.0*dEdxColl[track].numberOfSaturatedMeasurements())/dEdxColl[track].numberOfMeasurements());
176  dEdxMEsVector[i].ME_MipDeDxMass ->Fill(mass(track->p(), dEdxColl[track].dEdx()));
177 
178  //HighlyIonizing particles
179  }else if(track->pt()<2 && dEdxColl[track].dEdx()>HIPdEdxMin){
180  dEdxMEsVector[i].ME_HipDeDxMass ->Fill(mass(track->p(), dEdxColl[track].dEdx()));
181  }
182  }
183  }
184  }
185  }
186 }
187 
188 
189 
190 void
192 {
193 }
194 
195 // ------------ method called when ending the processing of a luminosity block ------------
196 void
198 {
199 }
200 
201 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
202 void
204  //The following says we do not know what parameters are allowed so do no validation
205  // Please change this to state exactly what you do use, even if it is no parameters
207  desc.setUnknown();
208  descriptions.addDefault(desc);
209 }
210 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
Definition: dEdxAnalyzer.cc:59
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
double dEdxC
Definition: dEdxAnalyzer.h:71
double TrackHitMin
Definition: dEdxAnalyzer.h:70
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2113
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
#define P
std::vector< std::string > AlgoNames
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:48
virtual void beginJob()
Definition: dEdxAnalyzer.cc:67
double dEdxK
Definition: dEdxAnalyzer.h:71
dEdxAnalyzer(const edm::ParameterSet &)
Definition: dEdxAnalyzer.cc:28
int iEvent
Definition: GenABIO.cc:243
void addDefault(ParameterSetDescription const &psetDescription)
T sqrt(T t)
Definition: SSEVec.h:46
bool accept(const edm::Event &event, const edm::EventSetup &setup)
To be called from analyze/filter() methods.
GenericTriggerEventFlag * genTriggerEventFlag_
Definition: dEdxAnalyzer.h:78
const std::complex< double > I
Definition: I.h:8
bool doAllPlots_
Definition: dEdxAnalyzer.h:50
bool isValid() const
Definition: HandleBase.h:76
bool doDeDxPlots_
Definition: dEdxAnalyzer.h:51
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
std::vector< dEdxMEs > dEdxMEsVector
Definition: dEdxAnalyzer.h:75
double mass(double P, double I)
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:14
virtual void endJob()
Definition: dEdxAnalyzer.cc:46
DQMStore * dqmStore_
Definition: dEdxAnalyzer.h:46
T const * product() const
Definition: Handle.h:74
double HIPdEdxMin
Definition: dEdxAnalyzer.h:70
virtual void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup)
std::string histname
Definition: dEdxAnalyzer.h:76
void showDirStructure(void) const
Definition: DQMStore.cc:2761
void initRun(const edm::Run &run, const edm::EventSetup &setup)
To be called from beginRun() methods.
std::string TrackName
Definition: dEdxAnalyzer.h:73
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: Run.h:33