CMS 3D CMS Logo

TrackEfficiencyClient.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author Anne-Catherine Le Bihan
5  */
6 
8 
13 
16 
17 #include <iostream>
18 #include <iomanip>
19 #include <cstdio>
20 #include <string>
21 #include <sstream>
22 #include <cmath>
23 
24 //-----------------------------------------------------------------------------------
26 //-----------------------------------------------------------------------------------
27 {
28  edm::LogInfo( "TrackEfficiencyClient") << "TrackEfficiencyClient::Deleting TrackEfficiencyClient ";
29 
30  FolderName_ = iConfig.getParameter<std::string>("FolderName");
31  algoName_ = iConfig.getParameter<std::string>("AlgoName");
32  trackEfficiency_ = iConfig.getParameter<bool>("trackEfficiency");
33 
34  conf_ = iConfig;
35 }
36 
37 
38 //-----------------------------------------------------------------------------------
40 //-----------------------------------------------------------------------------------
41 {
42  edm::LogInfo("TrackEfficiencyClient") << "TrackEfficiencyClient::Deleting TrackEfficiencyClient ";
43 }
44 
45 
46 //-----------------------------------------------------------------------------------
48 //-----------------------------------------------------------------------------------
49 {
50 
51  edm::LogInfo("TrackEfficiencyClient") << "TrackEfficiencyClient::beginJob done";
52 }
53 
54 
55 //-----------------------------------------------------------------------------------
57 //-----------------------------------------------------------------------------------
58 {
59  edm::LogInfo ("TrackEfficiencyClient") <<"TrackEfficiencyClient:: Begining of Run";
60 }
61 
62 //-----------------------------------------------------------------------------------
64 //-----------------------------------------------------------------------------------
65 {
66 
67  ibooker_.setCurrentFolder(FolderName_);
68 
69  //
70  int effXBin = conf_.getParameter<int> ("effXBin");
71  double effXMin = conf_.getParameter<double>("effXMin");
72  double effXMax = conf_.getParameter<double>("effXMax");
73 
74  histName = "effX_";
75  effX = ibooker_.book1D(histName+algoName_, histName+algoName_, effXBin, effXMin, effXMax);
76  if (effX->getTH1F()) effX->getTH1F()->Sumw2();
77  effX->setAxisTitle("");
78 
79 
80  //
81  int effYBin = conf_.getParameter<int> ("effYBin");
82  double effYMin = conf_.getParameter<double>("effYMin");
83  double effYMax = conf_.getParameter<double>("effYMax");
84 
85  histName = "effY_";
86  effY = ibooker_.book1D(histName+algoName_, histName+algoName_, effYBin, effYMin, effYMax);
87  if (effY->getTH1F()) effY->getTH1F()->Sumw2();
88  effY->setAxisTitle("");
89 
90  //
91  int effZBin = conf_.getParameter<int> ("effZBin");
92  double effZMin = conf_.getParameter<double>("effZMin");
93  double effZMax = conf_.getParameter<double>("effZMax");
94 
95  histName = "effZ_";
96  effZ = ibooker_.book1D(histName+algoName_, histName+algoName_, effZBin, effZMin, effZMax);
97  if (effZ->getTH1F()) effZ->getTH1F()->Sumw2();
98  effZ->setAxisTitle("");
99 
100  //
101  int effEtaBin = conf_.getParameter<int> ("effEtaBin");
102  double effEtaMin = conf_.getParameter<double>("effEtaMin");
103  double effEtaMax = conf_.getParameter<double>("effEtaMax");
104 
105  histName = "effEta_";
106  effEta = ibooker_.book1D(histName+algoName_, histName+algoName_, effEtaBin, effEtaMin, effEtaMax);
107  if (effEta->getTH1F()) effEta->getTH1F()->Sumw2();
108  effEta->setAxisTitle("");
109 
110  //
111  int effPhiBin = conf_.getParameter<int> ("effPhiBin");
112  double effPhiMin = conf_.getParameter<double>("effPhiMin");
113  double effPhiMax = conf_.getParameter<double>("effPhiMax");
114 
115  histName = "effPhi_";
116  effPhi = ibooker_.book1D(histName+algoName_, histName+algoName_, effPhiBin, effPhiMin, effPhiMax);
117  if (effPhi->getTH1F()) effPhi->getTH1F()->Sumw2();
118  effPhi->setAxisTitle("");
119 
120  //
121  int effD0Bin = conf_.getParameter<int> ("effD0Bin");
122  double effD0Min = conf_.getParameter<double>("effD0Min");
123  double effD0Max = conf_.getParameter<double>("effD0Max");
124 
125  histName = "effD0_";
126  effD0 = ibooker_.book1D(histName+algoName_, histName+algoName_, effD0Bin, effD0Min, effD0Max);
127  if (effD0->getTH1F()) effD0->getTH1F()->Sumw2();
128  effD0->setAxisTitle("");
129 
130 
131  //
132  int effCompatibleLayersBin = conf_.getParameter<int> ("effCompatibleLayersBin");
133  double effCompatibleLayersMin = conf_.getParameter<double>("effCompatibleLayersMin");
134  double effCompatibleLayersMax = conf_.getParameter<double>("effCompatibleLayersMax");
135 
136  histName = "effCompatibleLayers_";
137  effCompatibleLayers = ibooker_.book1D(histName+algoName_, histName+algoName_, effCompatibleLayersBin, effCompatibleLayersMin, effCompatibleLayersMax);
140 
141  histName = "MuonEffPtPhi_LowPt";
142  effPtPhiLowPt = ibooker_.book2D(histName+algoName_, histName+algoName_, 20,-2.4,2.4,20,-3.25,3.25);
143  if (effPtPhiLowPt->getTH2F()) effPtPhiLowPt->getTH2F()->Sumw2();
145 
146  histName = "MuonEffPtPhi_HighPt";
147  effPtPhiHighPt = ibooker_.book2D(histName+algoName_, histName+algoName_, 20,-2.4,2.4,20,-3.25,3.25);
148  if (effPtPhiHighPt->getTH2F()) effPtPhiHighPt->getTH2F()->Sumw2();
150 }
151 
152 //-----------------------------------------------------------------------------------
154 //-----------------------------------------------------------------------------------
155 {
156  edm::LogInfo( "TrackEfficiencyClient") << "TrackEfficiencyClient::endLuminosityBlock";
157 
158  bookMEs(ibooker_);
159  FolderName_ = "Tracking/TrackParameters";
160  std::vector<std::string> s1 = igetter_.getSubdirs();
161 
162  igetter_.cd("Tracking");
163 
164 
165  histName = "/trackX_";
166  MonitorElement* trackX = igetter_.get(FolderName_+histName+algoName_);
167 
168  histName = "/muonX_";
169  MonitorElement* muonX = igetter_.get(FolderName_+histName+algoName_);
170 
171  histName = "/trackY_";
172  MonitorElement* trackY = igetter_.get(FolderName_+histName+algoName_);
173  histName = "/muonY_";
174  MonitorElement* muonY = igetter_.get(FolderName_+histName+algoName_);
175 
176  histName = "/trackZ_";
177  MonitorElement* trackZ = igetter_.get(FolderName_+histName+algoName_);
178  histName = "/muonZ_";
179  MonitorElement* muonZ = igetter_.get(FolderName_+histName+algoName_);
180 
181  histName = "/trackEta_";
183  histName = "/muonEta_";
185 
186  histName = "/trackPhi_";
188  histName = "/muonPhi_";
190 
191  histName = "/trackD0_";
192  MonitorElement* trackD0 = igetter_.get(FolderName_+histName+algoName_);
193  histName = "/muonD0_";
194  MonitorElement* muonD0 = igetter_.get(FolderName_+histName+algoName_);
195 
196  histName = "/trackCompatibleLayers_";
197  MonitorElement* trackCompatibleLayers = igetter_.get(FolderName_+histName+algoName_);
198  histName = "/muonCompatibleLayers_";
199  MonitorElement* muonCompatibleLayers = igetter_.get(FolderName_+histName+algoName_);
200 
201  histName = "/StandaloneMuonPtEtaPhi_LowPt_";
202  MonitorElement* StandAloneMuonPtEtaPhiLowPt = igetter_.get(FolderName_+histName+algoName_);
203  histName = "/GlobalMuonPtEtaPhi_LowPt_";
204  MonitorElement* GlobalMuonPtEtaPhiLowPt = igetter_.get(FolderName_+histName+algoName_);
205 
206  histName = "/StandaloneMuonPtEtaPhi_HighPt_";
207  MonitorElement* StandAloneMuonPtEtaPhiHighPt = igetter_.get(FolderName_+histName+algoName_);
208  histName = "/GlobalMuonPtEtaPhi_HighPt_";
209  MonitorElement* GlobalMuonPtEtaPhiHighPt = igetter_.get(FolderName_+histName+algoName_);
210 
211 
212  if (StandAloneMuonPtEtaPhiLowPt && GlobalMuonPtEtaPhiLowPt && effPtPhiLowPt){
213  if ( StandAloneMuonPtEtaPhiLowPt->getTH2F() && GlobalMuonPtEtaPhiLowPt->getTH2F() && effPtPhiLowPt->getTH2F() ){
214  effPtPhiLowPt->getTH2F()->Divide(GlobalMuonPtEtaPhiLowPt->getTH2F(),StandAloneMuonPtEtaPhiLowPt->getTH2F(), 1.,1.,"");
215  }
216  }
217  if (StandAloneMuonPtEtaPhiHighPt && GlobalMuonPtEtaPhiHighPt && effPtPhiHighPt){
218  if ( StandAloneMuonPtEtaPhiHighPt->getTH2F() && GlobalMuonPtEtaPhiHighPt->getTH2F() && effPtPhiHighPt->getTH2F() ){
219  effPtPhiHighPt->getTH2F()->Divide(GlobalMuonPtEtaPhiHighPt->getTH2F(),StandAloneMuonPtEtaPhiHighPt->getTH2F(), 1.,1.,"");
220  }
221  }
222  if(trackX && muonX && trackY && muonY && trackZ && muonZ && trackEta && muonEta && trackPhi && muonPhi && trackD0 && muonD0 && trackCompatibleLayers && muonCompatibleLayers){// && StandAloneMuonPtEtaPhi && GlobalMuonPtEtaPhi){
223 
224  if (trackEfficiency_)
225  {
226 
227 
228  if (effX ->getTH1F() && trackX ->getTH1F() && muonX ->getTH1F()) { effX -> getTH1F()->Divide(trackX->getTH1F(),muonX->getTH1F(),1.,1.,"");}
229  if (effY ->getTH1F() && trackY ->getTH1F() && muonY ->getTH1F()) { effY -> getTH1F()->Divide(trackY->getTH1F(),muonY->getTH1F(),1.,1.,"");}
230  if (effZ ->getTH1F() && trackZ ->getTH1F() && muonZ ->getTH1F()) { effZ -> getTH1F()->Divide(trackZ->getTH1F(),muonZ->getTH1F(),1.,1.,"");}
231  if (effEta->getTH1F() && trackEta->getTH1F() && muonEta->getTH1F()) { effEta -> getTH1F()->Divide(trackEta->getTH1F(),muonEta->getTH1F(),1.,1.,"");}
232  if (effPhi->getTH1F() && trackPhi->getTH1F() && muonPhi->getTH1F()) { effPhi -> getTH1F()->Divide(trackPhi->getTH1F(),muonPhi->getTH1F(),1.,1.,"");}
233  if (effD0 ->getTH1F() && trackD0 ->getTH1F() && muonD0 ->getTH1F()) { effD0 -> getTH1F()->Divide(trackD0->getTH1F(),muonD0->getTH1F(),1.,1.,"");}
234  if (effCompatibleLayers->getTH1F() && trackCompatibleLayers->getTH1F() && muonCompatibleLayers->getTH1F()) { effCompatibleLayers -> getTH1F()->Divide(trackCompatibleLayers->getTH1F(),muonCompatibleLayers->getTH1F(),1.,1.,"");}
235  }
236  else {
237  if (effX ->getTH1F() && trackX ->getTH1F() && muonX ->getTH1F()) { effX -> getTH1F()->Divide(muonX->getTH1F(),trackX->getTH1F(),1.,1.,"");}
238  if (effY ->getTH1F() && trackY ->getTH1F() && muonY ->getTH1F()) { effY -> getTH1F()->Divide(muonY->getTH1F(),trackY->getTH1F(),1.,1.,"");}
239  if (effZ ->getTH1F() && trackZ ->getTH1F() && muonZ ->getTH1F()) { effZ -> getTH1F()->Divide(muonZ->getTH1F(),trackZ->getTH1F(),1.,1.,"");}
240  if (effEta->getTH1F() && trackEta->getTH1F() && muonEta->getTH1F()) { effEta -> getTH1F()->Divide(muonEta->getTH1F(),trackEta->getTH1F(),1.,1.,"");}
241  if (effPhi->getTH1F() && trackPhi->getTH1F() && muonPhi->getTH1F()) { effPhi -> getTH1F()->Divide(muonPhi->getTH1F(),trackPhi->getTH1F(),1.,1.,"");}
242  if (effD0 ->getTH1F() && trackD0 ->getTH1F() && muonD0 ->getTH1F()) { effD0 -> getTH1F()->Divide(muonD0->getTH1F(),trackD0->getTH1F(),1.,1.,"");}
243  }
244  }
245 
246 }
247 
T getParameter(std::string const &) const
void bookMEs(DQMStore::IBooker &ibooker_)
book MEs
MonitorElement * effPtPhiHighPt
TH1F * getTH1F() const
MonitorElement * effCompatibleLayers
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
~TrackEfficiencyClient() override
Destructor.
TH2F * getTH2F() const
MonitorElement * get(std::string const &path)
Definition: DQMStore.cc:303
void beginJob(void) override
BeginJob.
void dqmEndJob(DQMStore::IBooker &ibooker_, DQMStore::IGetter &igetter_) override
EndJob.
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
std::vector< std::string > getSubdirs()
Definition: DQMStore.cc:325
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
TrackEfficiencyClient(const edm::ParameterSet &ps)
Constructor.
Definition: Run.h:45
void beginRun(edm::Run const &run, edm::EventSetup const &eSetup) override
BeginRun.
MonitorElement * effPtPhiLowPt