CMS 3D CMS Logo

Phase2ITRecHitHarvester.cc
Go to the documentation of this file.
12 public:
14  ~Phase2ITRecHitHarvester() override;
15  void dqmEndJob(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) override;
16 
17  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
18 
19 private:
20  void gausFitslices(MonitorElement* srcME, MonitorElement* meanME, MonitorElement* sigmaME);
21  void dofitsForLayer(const std::string& iFolder, DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter);
22 
23  // ----------member data ---------------------------
26  const unsigned int nbarrelLayers_;
27  const unsigned int ndisk1Rings_; //FOR IT epix//FOR OT TEDD1 rings
28  const unsigned int ndisk2Rings_; //FOR IT epix//FOR OT TEDD2 rings
29  const unsigned int fitThreshold_;
30  const std::string ecapdisk1Name_; //FOR IT Epix//FOR OT TEDD_1
31  const std::string ecapdisk2Name_; //FOR IT Fpix//FOR OT TEDD_2
37 };
38 
40  : config_(iConfig),
41  topFolder_(iConfig.getParameter<std::string>("TopFolder")),
42  nbarrelLayers_(iConfig.getParameter<uint32_t>("NbarrelLayers")),
43  ndisk1Rings_(iConfig.getParameter<uint32_t>("NDisk1Rings")),
44  ndisk2Rings_(iConfig.getParameter<uint32_t>("NDisk2Rings")),
45  fitThreshold_(iConfig.getParameter<uint32_t>("NFitThreshold")),
46  ecapdisk1Name_(iConfig.getParameter<std::string>("EcapDisk1Name")),
47  ecapdisk2Name_(iConfig.getParameter<std::string>("EcapDisk2Name")),
48  deltaXvsEtaname_(iConfig.getParameter<std::string>("ResidualXvsEta")),
49  deltaXvsPhiname_(iConfig.getParameter<std::string>("ResidualXvsPhi")),
50  deltaYvsEtaname_(iConfig.getParameter<std::string>("ResidualYvsEta")),
51  deltaYvsPhiname_(iConfig.getParameter<std::string>("ResidualYvsPhi")) {}
52 
54 
56  for (unsigned int i = 1; i <= nbarrelLayers_; i++) {
57  std::string iFolder = topFolder_ + "/Barrel/Layer" + std::to_string(i);
58  dofitsForLayer(iFolder, ibooker, igetter);
59  }
60  for (unsigned int iSide = 1; iSide <= 2; iSide++) {
61  const std::string ecapbasedisk1 =
62  topFolder_ + "/EndCap_Side" + std::to_string(iSide) + "/" + ecapdisk1Name_ + "/Ring";
63  const std::string ecapbasedisk2 =
64  topFolder_ + "/EndCap_Side" + std::to_string(iSide) + "/" + ecapdisk2Name_ + "/Ring";
65  //EPix or TEDD_1
66  for (unsigned int epixr = 1; epixr <= ndisk1Rings_; epixr++) {
67  std::string iFolder = ecapbasedisk1 + std::to_string(epixr);
68  dofitsForLayer(iFolder, ibooker, igetter);
69  }
70  //FPix or TEDD_2
71  for (unsigned int fpixr = 1; fpixr <= ndisk2Rings_; fpixr++) {
72  std::string iFolder = ecapbasedisk2 + std::to_string(fpixr);
73  dofitsForLayer(iFolder, ibooker, igetter);
74  }
75  }
76 }
77 //Function for Layer/Ring
79  DQMStore::IBooker& ibooker,
80  DQMStore::IGetter& igetter) {
81  MonitorElement* deltaX_eta = igetter.get(iFolder + "/" + deltaXvsEtaname_);
82  MonitorElement* deltaX_phi = igetter.get(iFolder + "/" + deltaXvsPhiname_);
83  MonitorElement* deltaY_eta = igetter.get(iFolder + "/" + deltaYvsEtaname_);
84  MonitorElement* deltaY_phi = igetter.get(iFolder + "/" + deltaYvsPhiname_);
85 
86  std::string resFolder = iFolder + "/ResolutionFromFit/";
87 
88  ibooker.cd();
89  ibooker.setCurrentFolder(resFolder);
90  MonitorElement* sigmaX_eta =
92  MonitorElement* meanX_eta =
94 
95  gausFitslices(deltaX_eta, meanX_eta, sigmaX_eta);
96 
97  MonitorElement* sigmaY_eta =
99  MonitorElement* meanY_eta =
101  gausFitslices(deltaY_eta, meanY_eta, sigmaY_eta);
102 
103  MonitorElement* sigmaX_phi =
105  MonitorElement* meanX_phi =
107  gausFitslices(deltaX_phi, meanX_phi, sigmaX_phi);
108 
109  MonitorElement* sigmaY_phi =
111  MonitorElement* meanY_phi =
113  gausFitslices(deltaY_phi, meanY_phi, sigmaY_phi);
114 }
116  TH2F* histo = srcME->getTH2F();
117 
118  // Fit slices projected along Y from bins in X
119  const unsigned int cont_min = fitThreshold_; //Minimum number of entries
120  for (int i = 1; i <= srcME->getNbinsX(); i++) {
121  TString iString(i);
122  TH1* histoY = histo->ProjectionY(" ", i, i);
123  const unsigned int cont = histoY->GetEntries();
124 
125  if (cont >= cont_min) {
126  float minfit = histoY->GetMean() - histoY->GetRMS();
127  float maxfit = histoY->GetMean() + histoY->GetRMS();
128 
129  std::unique_ptr<TF1> fitFcn{new TF1(TString("g") + histo->GetName() + iString, "gaus", minfit, maxfit)};
130  histoY->Fit(fitFcn.get(), "QR0 SERIAL", "", minfit, maxfit);
131 
132  double* par = fitFcn->GetParameters();
133  const double* err = fitFcn->GetParErrors();
134 
135  meanME->setBinContent(i, par[1]);
136  meanME->setBinError(i, err[1]);
137 
138  sigmaME->setBinContent(i, par[2]);
139  sigmaME->setBinError(i, err[2]);
140 
141  if (histoY)
142  delete histoY;
143  } else {
144  if (histoY)
145  delete histoY;
146  continue;
147  }
148  }
149 }
150 
154  // phase2ITrechitHarvester
156  desc.add<std::string>("TopFolder", "TrackerPhase2ITRecHitV");
157  desc.add<unsigned int>("NbarrelLayers", 4);
158  desc.add<unsigned int>("NDisk1Rings", 5);
159  desc.add<unsigned int>("NDisk2Rings", 4);
160  desc.add<std::string>("EcapDisk1Name", "EPix");
161  desc.add<std::string>("EcapDisk2Name", "FPix");
162  desc.add<std::string>("ResidualXvsEta", "Delta_X_vs_Eta");
163  desc.add<std::string>("ResidualXvsPhi", "Delta_X_vs_Phi");
164  desc.add<std::string>("ResidualYvsEta", "Delta_Y_vs_Eta");
165  desc.add<std::string>("ResidualYvsPhi", "Delta_Y_vs_Phi");
166 
168  psd0.add<std::string>("name", "resolutionXFitvseta");
169  psd0.add<std::string>("title", ";|#eta|; X-Resolution from fit [#mum]");
170  psd0.add<int>("NxBins", 41);
171  psd0.add<double>("xmax", 4.1);
172  psd0.add<double>("xmin", 0.);
173  psd0.add<bool>("switch", true);
174  desc.add<edm::ParameterSetDescription>("resXvseta", psd0);
175 
177  psd1.add<std::string>("name", "resolutionYFitvseta");
178  psd1.add<std::string>("title", ";|#eta|; Y-Resolution from fit [#mum]");
179  psd1.add<int>("NxBins", 41);
180  psd1.add<double>("xmax", 4.1);
181  psd1.add<double>("xmin", 0.);
182  psd1.add<bool>("switch", true);
183  desc.add<edm::ParameterSetDescription>("resYvseta", psd1);
184 
186  psd2.add<std::string>("name", "resolutionXFitvsphi");
187  psd2.add<std::string>("title", ";#phi; X-Resolution from fit [#mum]");
188  psd2.add<int>("NxBins", 36);
189  psd2.add<double>("xmax", M_PI);
190  psd2.add<double>("xmin", -M_PI);
191  psd2.add<bool>("switch", true);
192  desc.add<edm::ParameterSetDescription>("resXvsphi", psd2);
193 
195  psd3.add<std::string>("name", "resolutionYFitvsphi");
196  psd3.add<std::string>("title", ";#phi; Y-Resolution from fit [#mum]");
197  psd3.add<int>("NxBins", 36);
198  psd3.add<double>("xmax", M_PI);
199  psd3.add<double>("xmin", -M_PI);
200  psd3.add<bool>("switch", true);
201  desc.add<edm::ParameterSetDescription>("resYvsphi", psd3);
202 
204  psd4.add<std::string>("name", "meanXFitvseta");
205  psd4.add<std::string>("title", ";|#eta|; Mean residual X from fit [#mum]");
206  psd4.add<int>("NxBins", 41);
207  psd4.add<double>("xmax", 4.1);
208  psd4.add<double>("xmin", 0.);
209  psd4.add<bool>("switch", true);
210  desc.add<edm::ParameterSetDescription>("meanXvseta", psd4);
211 
213  psd5.add<std::string>("name", "meanYFitvseta");
214  psd5.add<std::string>("title", ";|#eta|; Mean residual Y from fit [#mum]");
215  psd5.add<int>("NxBins", 41);
216  psd5.add<double>("xmax", 4.1);
217  psd5.add<double>("xmin", 0.);
218  psd5.add<bool>("switch", true);
219  desc.add<edm::ParameterSetDescription>("meanYvseta", psd5);
220 
222  psd6.add<std::string>("name", "meanXFitvsphi");
223  psd6.add<std::string>("title", ";#phi; Mean residual X from fit [#mum]");
224  psd6.add<int>("NxBins", 36);
225  psd6.add<double>("xmax", M_PI);
226  psd6.add<double>("xmin", -M_PI);
227  psd6.add<bool>("switch", true);
228  desc.add<edm::ParameterSetDescription>("meanXvsphi", psd6);
229 
231  psd7.add<std::string>("name", "meanYFitvsphi");
232  psd7.add<std::string>("title", ";#phi; Mean residual Y from fit [#mum]");
233  psd7.add<int>("NxBins", 36);
234  psd7.add<double>("xmax", M_PI);
235  psd7.add<double>("xmin", -M_PI);
236  psd7.add<bool>("switch", true);
237  desc.add<edm::ParameterSetDescription>("meanYvsphi", psd7);
238 
239  desc.add<unsigned int>("NFitThreshold", 100);
240 
241  descriptions.add("Phase2ITRechitHarvester", desc);
242  // or use the following to generate the label from the module's C++ type
243  //descriptions.addWithDefaultLabel(desc);
244 }
245 
246 //define this as a plug-in
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
MonitorElement * book1DFromPSet(const edm::ParameterSet &hpars, DQMStore::IBooker &ibooker)
std::string to_string(const V &value)
Definition: OMSAccess.h:71
void gausFitslices(MonitorElement *srcME, MonitorElement *meanME, MonitorElement *sigmaME)
virtual TH2F * getTH2F() const
const edm::ParameterSet config_
void dqmEndJob(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ParameterDescriptionBase * add(U const &iLabel, T const &value)
#define M_PI
Phase2ITRecHitHarvester(const edm::ParameterSet &)
void dofitsForLayer(const std::string &iFolder, DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:712
virtual int getNbinsX() const
get # of bins in X-axis
virtual void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
cont
load Luminosity info ##
Definition: generateEDF.py:628