CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SiStripCalibLorentzAngle.cc
Go to the documentation of this file.
1 #include <memory>
2 #include <string>
3 #include <iostream>
4 #include <fstream>
9 #include "CLHEP/Random/RandGauss.h"
14 
16 
19  tTopoToken_(esConsumes<edm::Transition::BeginRun>()),
20  tkGeomToken_(esConsumes<edm::Transition::BeginRun>()),
21  magFieldToken_(esConsumes<edm::Transition::BeginRun>()),
22  lorentzAngleToken_(esConsumes<edm::Transition::BeginRun>()),
23  conf_(conf) {}
24 
28  const auto& magField = c.getData(magFieldToken_);
29  detid_la = c.getData(lorentzAngleToken_).getLorentzAngles();
30 
32 
33  std::string inputFile_ = conf_.getUntrackedParameter<std::string>("fileName", "LAProfiles.root");
34  std::string LAreport_ = conf_.getUntrackedParameter<std::string>("LA_Report", "LA_Report.txt");
35  std::string NoEntriesHisto_ = conf_.getUntrackedParameter<std::string>("NoEntriesHisto", "NoEntriesHisto.txt");
36  std::string Dir_Name_ = conf_.getUntrackedParameter<std::string>("Dir_Name", "SiStrip");
37 
38  LayerDB = conf_.getUntrackedParameter<bool>("LayerDB", false);
39 
40  CalibByMC = conf_.getUntrackedParameter<bool>("CalibByMC", false);
41 
42  dbe_->open(inputFile_);
43 
44  // use SistripHistoId for producing histogram id (and title)
46 
47  edm::LogInfo("SiStripCalibLorentzAngle") << "### DIR-NAME = " << Dir_Name_;
48  histolist = dbe_->getAllContents(Dir_Name_);
49  std::vector<MonitorElement*>::iterator histo;
50 
51  hFile = new TFile(conf_.getUntrackedParameter<std::string>("out_fileName").c_str(), "RECREATE");
52 
53  LorentzAngle_Plots = hFile->mkdir("LorentzAngle_Plots");
54  Rootple = LorentzAngle_Plots->mkdir("Rootple");
55  MuH = LorentzAngle_Plots->mkdir("MuH");
56  TIB_MuH = MuH->mkdir("TIB_MuH");
57  TOB_MuH = MuH->mkdir("TOB_MuH");
58  MuH_vs_Phi = LorentzAngle_Plots->mkdir("MuH_vs_Phi");
59  TIB_Phi = MuH_vs_Phi->mkdir("TIB_Phi");
60  TOB_Phi = MuH_vs_Phi->mkdir("TOB_Phi");
61  MuH_vs_Eta = LorentzAngle_Plots->mkdir("MuH_vs_Eta");
62  TIB_Eta = MuH_vs_Eta->mkdir("TIB_Eta");
63  TOB_Eta = MuH_vs_Eta->mkdir("TOB_Eta");
64  FirstIT_GoodFit_Histos = LorentzAngle_Plots->mkdir("1IT_GoodFit_Histos");
65  TIB_1IT_GoodFit = FirstIT_GoodFit_Histos->mkdir("TIB_1IT_GoodFit");
66  TOB_1IT_GoodFit = FirstIT_GoodFit_Histos->mkdir("TOB_1IT_GoodFit");
67  SecondIT_GoodFit_Histos = LorentzAngle_Plots->mkdir("2IT_GoodFit_Histos");
68  TIB_2IT_GoodFit = SecondIT_GoodFit_Histos->mkdir("TIB_2IT_GoodFit");
69  TOB_2IT_GoodFit = SecondIT_GoodFit_Histos->mkdir("TOB_2IT_GoodFit");
70  SecondIT_BadFit_Histos = LorentzAngle_Plots->mkdir("2IT_BadFit_Histos");
71  TIB_2IT_BadFit = SecondIT_BadFit_Histos->mkdir("TIB_2IT_BadFit");
72  TOB_2IT_BadFit = SecondIT_BadFit_Histos->mkdir("TOB_2IT_BadFit");
73 
74  TH1Ds["LA_TIB"] = new TH1D("TanLAPerTesla TIB", "TanLAPerTesla TIB", 1000, -0.5, 0.5);
75  TH1Ds["LA_TIB"]->SetDirectory(MuH);
76  TH1Ds["LA_TOB"] = new TH1D("TanLAPerTesla TOB", "TanLAPerTesla TOB", 1000, -0.5, 0.5);
77  TH1Ds["LA_TOB"]->SetDirectory(MuH);
78  TH1Ds["LA_err_TIB"] = new TH1D("TanLAPerTesla Error TIB", "TanLAPerTesla Error TIB", 1000, 0, 1);
79  TH1Ds["LA_err_TIB"]->SetDirectory(MuH);
80  TH1Ds["LA_err_TOB"] = new TH1D("TanLAPerTesla Error TOB", "TanLAPerTesla Error TOB", 1000, 0, 1);
81  TH1Ds["LA_err_TOB"]->SetDirectory(MuH);
82  TH1Ds["LA_chi2norm_TIB"] = new TH1D("TanLAPerTesla Chi2norm TIB", "TanLAPerTesla Chi2norm TIB", 2000, 0, 10);
83  TH1Ds["LA_chi2norm_TIB"]->SetDirectory(MuH);
84  TH1Ds["LA_chi2norm_TOB"] = new TH1D("TanLAPerTesla Chi2norm TOB", "TanLAPerTesla Chi2norm TOB", 2000, 0, 10);
85  TH1Ds["LA_chi2norm_TOB"]->SetDirectory(MuH);
86  TH1Ds["MagneticField"] = new TH1D("MagneticField", "MagneticField", 500, 0, 5);
87  TH1Ds["MagneticField"]->SetDirectory(MuH);
88 
89  TH2Ds["LA_TIB_graph"] = new TH2D("TanLAPerTesla TIB Layers", "TanLAPerTesla TIB Layers", 60, 0, 5, 1000, -0.3, 0.3);
90  TH2Ds["LA_TIB_graph"]->SetDirectory(MuH);
91  TH2Ds["LA_TIB_graph"]->SetNdivisions(6);
92  TH2Ds["LA_TOB_graph"] = new TH2D("TanLAPerTesla TOB Layers", "TanLAPerTesla TOB Layers", 80, 0, 7, 1000, -0.3, 0.3);
93  TH2Ds["LA_TOB_graph"]->SetDirectory(MuH);
94  TH2Ds["LA_TOB_graph"]->SetNdivisions(8);
95 
96  TH1Ds["LA_TIB_1"] = new TH1D("TanLAPerTesla TIB1", "TanLAPerTesla TIB1", 2000, -0.5, 0.5);
97  TH1Ds["LA_TIB_1"]->SetDirectory(TIB_MuH);
98  TH1Ds["LA_TIB_1_mono"] = new TH1D("TanLAPerTesla TIB1 MONO", "TanLAPerTesla TIB1 MONO", 2000, -0.5, 0.5);
99  TH1Ds["LA_TIB_1_mono"]->SetDirectory(TIB_MuH);
100  TH1Ds["LA_TIB_1_stereo"] = new TH1D("TanLAPerTesla TIB1 STEREO", "TanLAPerTesla TIB1 STEREO", 2000, -0.5, 0.5);
101  TH1Ds["LA_TIB_1_stereo"]->SetDirectory(TIB_MuH);
102  TH1Ds["LA_TIB_2"] = new TH1D("TanLAPerTesla TIB2", "TanLAPerTesla TIB2", 2000, -0.5, 0.5);
103  TH1Ds["LA_TIB_2"]->SetDirectory(TIB_MuH);
104  TH1Ds["LA_TIB_2_mono"] = new TH1D("TanLAPerTesla TIB2 MONO", "TanLAPerTesla TIB2 MONO", 2000, -0.5, 0.5);
105  TH1Ds["LA_TIB_2_mono"]->SetDirectory(TIB_MuH);
106  TH1Ds["LA_TIB_2_stereo"] = new TH1D("TanLAPerTesla TIB2 STEREO", "TanLAPerTesla TIB2 STEREO", 2000, -0.5, 0.5);
107  TH1Ds["LA_TIB_2_stereo"]->SetDirectory(TIB_MuH);
108  TH1Ds["LA_TIB_3"] = new TH1D("TanLAPerTesla_TIB 3", "TanLAPerTesla TIB3", 2000, -0.5, 0.5);
109  TH1Ds["LA_TIB_3"]->SetDirectory(TIB_MuH);
110  TH1Ds["LA_TIB_4"] = new TH1D("TanLAPerTesla_TIB 4", "TanLAPerTesla TIB4", 2000, -0.5, 0.5);
111  TH1Ds["LA_TIB_4"]->SetDirectory(TIB_MuH);
112 
113  TH1Ds["LA_TOB_1"] = new TH1D("TanLAPerTesla TOB1", "TanLAPerTesla TOB1", 2000, -0.5, 0.5);
114  TH1Ds["LA_TOB_1"]->SetDirectory(TOB_MuH);
115  TH1Ds["LA_TOB_1_mono"] = new TH1D("TanLAPerTesla TOB1 MONO", "TanLAPerTesla TOB1 MONO", 2000, -0.5, 0.5);
116  TH1Ds["LA_TOB_1_mono"]->SetDirectory(TOB_MuH);
117  TH1Ds["LA_TOB_1_stereo"] = new TH1D("TanLAPerTesla TOB1 STEREO", "TanLAPerTesla TOB1 STEREO", 2000, -0.5, 0.5);
118  TH1Ds["LA_TOB_1_stereo"]->SetDirectory(TOB_MuH);
119  TH1Ds["LA_TOB_2"] = new TH1D("TanLAPerTesla TOB2", "TanLAPerTesla TOB2", 2000, -0.5, 0.5);
120  TH1Ds["LA_TOB_2"]->SetDirectory(TOB_MuH);
121  TH1Ds["LA_TOB_2_mono"] = new TH1D("TanLAPerTesla TOB2 MONO", "TanLAPerTesla TOB2 MONO", 2000, -0.5, 0.5);
122  TH1Ds["LA_TOB_2_mono"]->SetDirectory(TOB_MuH);
123  TH1Ds["LA_TOB_2_stereo"] = new TH1D("TanLAPerTesla TOB2 STEREO", "TanLAPerTesla TOB2 STEREO", 2000, -0.5, 0.5);
124  TH1Ds["LA_TOB_2_stereo"]->SetDirectory(TOB_MuH);
125  TH1Ds["LA_TOB_3"] = new TH1D("TanLAPerTesla TOB3", "TanLAPerTesla TOB3", 2000, -0.5, 0.5);
126  TH1Ds["LA_TOB_3"]->SetDirectory(TOB_MuH);
127  TH1Ds["LA_TOB_4"] = new TH1D("TanLAPerTesla TOB4", "TanLAPerTesla TOB4", 2000, -0.5, 0.5);
128  TH1Ds["LA_TOB_4"]->SetDirectory(TOB_MuH);
129  TH1Ds["LA_TOB_5"] = new TH1D("TanLAPerTesla TOB5", "TanLAPerTesla TOB5", 2000, -0.5, 0.5);
130  TH1Ds["LA_TOB_5"]->SetDirectory(TOB_MuH);
131  TH1Ds["LA_TOB_6"] = new TH1D("TanLAPerTesla TOB6", "TanLAPerTesla TOB6", 2000, -0.5, 0.5);
132  TH1Ds["LA_TOB_6"]->SetDirectory(TOB_MuH);
133 
134  TH2Ds["LA_phi_TIB"] = new TH2D("TanLAPerTesla vs Phi TIB", "TanLAPerTesla vs Phi TIB", 800, -4, 4, 600, -0.3, 0.3);
135  TH2Ds["LA_phi_TIB"]->SetDirectory(MuH_vs_Phi);
136  TH2Ds["LA_phi_TOB"] = new TH2D("TanLAPerTesla vs Phi TOB", "TanLAPerTesla vs Phi TOB", 800, -4, 4, 600, -0.3, 0.3);
137  TH2Ds["LA_phi_TOB"]->SetDirectory(MuH_vs_Phi);
138 
139  TH2Ds["LA_phi_TIB1"] = new TH2D("TanLAPerTesla vs Phi TIB1", "TanLAPerTesla vs Phi TIB1", 800, -4, 4, 600, -0.3, 0.3);
140  TH2Ds["LA_phi_TIB1"]->SetDirectory(TIB_Phi);
141  TH2Ds["LA_phi_TIB1_mono"] =
142  new TH2D("TanLAPerTesla vs Phi TIB1 MONO", "TanLAPerTesla vs Phi TIB1 MONO", 800, -4, 4, 600, -0.3, 0.3);
143  TH2Ds["LA_phi_TIB1_mono"]->SetDirectory(TIB_Phi);
144  TH2Ds["LA_phi_TIB1_stereo"] =
145  new TH2D("TanLAPerTesla vs Phi TIB1 STEREO", "TanLAPerTesla vs Phi TIB1 STEREO", 800, -4, 4, 600, -0.3, 0.3);
146  TH2Ds["LA_phi_TIB1_stereo"]->SetDirectory(TIB_Phi);
147  TH2Ds["LA_phi_TIB2"] = new TH2D("TanLAPerTesla vs Phi TIB2", "TanLAPerTesla vs Phi TIB2", 800, -4, 4, 600, -0.3, 0.3);
148  TH2Ds["LA_phi_TIB2"]->SetDirectory(TIB_Phi);
149  TH2Ds["LA_phi_TIB2_mono"] =
150  new TH2D("TanLAPerTesla vs Phi TIB2 MONO", "TanLAPerTesla vs Phi TIB2 MONO", 800, -4, 4, 600, -0.3, 0.3);
151  TH2Ds["LA_phi_TIB2_mono"]->SetDirectory(TIB_Phi);
152  TH2Ds["LA_phi_TIB2_stereo"] =
153  new TH2D("TanLAPerTesla vs Phi TIB2 STEREO", "TanLAPerTesla vs Phi TIB2 STEREO", 800, -4, 4, 600, -0.3, 0.3);
154  TH2Ds["LA_phi_TIB2_stereo"]->SetDirectory(TIB_Phi);
155  TH2Ds["LA_phi_TIB3"] = new TH2D("TanLAPerTesla vs Phi TIB3", "TanLAPerTesla vs Phi TIB3", 800, -4, 4, 600, -0.3, 0.3);
156  TH2Ds["LA_phi_TIB3"]->SetDirectory(TIB_Phi);
157  TH2Ds["LA_phi_TIB4"] = new TH2D("TanLAPerTesla vs Phi TIB4", "TanLAPerTesla vs Phi TIB4", 800, -4, 4, 600, -0.3, 0.3);
158  TH2Ds["LA_phi_TIB4"]->SetDirectory(TIB_Phi);
159 
160  TH2Ds["LA_phi_TOB1"] = new TH2D("TanLAPerTesla vs Phi TOB1", "TanLAPerTesla vs Phi TOB1", 800, -4, 4, 600, -0.3, 0.3);
161  TH2Ds["LA_phi_TOB1"]->SetDirectory(TOB_Phi);
162  TH2Ds["LA_phi_TOB1_mono"] =
163  new TH2D("TanLAPerTesla vs Phi TOB1 MONO", "TanLAPerTesla vs Phi TOB1 MONO", 800, -4, 4, 600, -0.3, 0.3);
164  TH2Ds["LA_phi_TOB1_mono"]->SetDirectory(TOB_Phi);
165  TH2Ds["LA_phi_TOB1_stereo"] =
166  new TH2D("TanLAPerTesla vs Phi TOB1 STEREO", "TanLAPerTesla vs Phi TOB1 STEREO", 800, -4, 4, 600, -0.3, 0.3);
167  TH2Ds["LA_phi_TOB1_stereo"]->SetDirectory(TOB_Phi);
168  TH2Ds["LA_phi_TOB2"] = new TH2D("TanLAPerTesla vs Phi TOB2", "TanLAPerTesla vs Phi TOB2", 800, -4, 4, 600, -0.3, 0.3);
169  TH2Ds["LA_phi_TOB2"]->SetDirectory(TOB_Phi);
170  TH2Ds["LA_phi_TOB2_mono"] =
171  new TH2D("TanLAPerTesla vs Phi TOB2 MONO", "TanLAPerTesla vs Phi TOB2 MONO", 800, -4, 4, 600, -0.3, 0.3);
172  TH2Ds["LA_phi_TOB2_mono"]->SetDirectory(TOB_Phi);
173  TH2Ds["LA_phi_TOB2_stereo"] =
174  new TH2D("TanLAPerTesla vs Phi TOB2 STEREO", "TanLAPerTesla vs Phi TOB2 STEREO", 800, -4, 4, 600, -0.3, 0.3);
175  TH2Ds["LA_phi_TOB2_stereo"]->SetDirectory(TOB_Phi);
176  TH2Ds["LA_phi_TOB3"] = new TH2D("TanLAPerTesla vs Phi TOB3", "TanLAPerTesla vs Phi TOB3", 800, -4, 4, 600, -0.3, 0.3);
177  TH2Ds["LA_phi_TOB3"]->SetDirectory(TOB_Phi);
178  TH2Ds["LA_phi_TOB4"] = new TH2D("TanLAPerTesla vs Phi TOB4", "TanLAPerTesla vs Phi TOB4", 800, -4, 4, 600, -0.3, 0.3);
179  TH2Ds["LA_phi_TOB4"]->SetDirectory(TOB_Phi);
180  TH2Ds["LA_phi_TOB5"] = new TH2D("TanLAPerTesla vs Phi TOB5", "TanLAPerTesla vs Phi TOB5", 800, -4, 4, 600, -0.3, 0.3);
181  TH2Ds["LA_phi_TOB5"]->SetDirectory(TOB_Phi);
182  TH2Ds["LA_phi_TOB6"] = new TH2D("TanLAPerTesla vs Phi TOB6", "TanLAPerTesla vs Phi TOB6", 800, -4, 4, 600, -0.3, 0.3);
183  TH2Ds["LA_phi_TOB6"]->SetDirectory(TOB_Phi);
184 
185  TH2Ds["LA_eta_TIB"] =
186  new TH2D("TanLAPerTesla vs Eta TIB", "TanLAPerTesla vs Eta TIB", 800, -2.6, 2.6, 600, -0.3, 0.3);
187  TH2Ds["LA_eta_TIB"]->SetDirectory(MuH_vs_Eta);
188  TH2Ds["LA_eta_TOB"] =
189  new TH2D("TanLAPerTesla vs Eta TOB", "TanLAPerTesla vs Eta TOB", 800, -2.6, 2.6, 600, -0.3, 0.3);
190  TH2Ds["LA_eta_TOB"]->SetDirectory(MuH_vs_Eta);
191 
192  TH2Ds["LA_eta_TIB1"] =
193  new TH2D("TanLAPerTesla vs Eta TIB1", "TanLAPerTesla vs Eta TIB1", 800, -2.6, 2.6, 600, -0.3, 0.3);
194  TH2Ds["LA_eta_TIB1"]->SetDirectory(TIB_Eta);
195  TH2Ds["LA_eta_TIB1_mono"] =
196  new TH2D("TanLAPerTesla vs Eta TIB1 MONO", "TanLAPerTesla vs Eta TIB1 MONO", 800, -2.6, 2.6, 600, -0.3, 0.3);
197  TH2Ds["LA_eta_TIB1_mono"]->SetDirectory(TIB_Eta);
198  TH2Ds["LA_eta_TIB1_stereo"] =
199  new TH2D("TanLAPerTesla vs Eta TIB1 STEREO", "TanLAPerTesla vs Eta TIB1 STEREO", 800, -2.6, 2.6, 600, -0.3, 0.3);
200  TH2Ds["LA_eta_TIB1_stereo"]->SetDirectory(TIB_Eta);
201  TH2Ds["LA_eta_TIB2"] =
202  new TH2D("TanLAPerTesla vs Eta TIB2", "TanLAPerTesla vs Eta TIB2", 800, -2.6, 2.6, 600, -0.3, 0.3);
203  TH2Ds["LA_eta_TIB2"]->SetDirectory(TIB_Eta);
204  TH2Ds["LA_eta_TIB2_mono"] =
205  new TH2D("TanLAPerTesla vs Eta TIB2 MONO", "TanLAPerTesla vs Eta TIB2 MONO", 800, -2.6, 2.6, 600, -0.3, 0.3);
206  TH2Ds["LA_eta_TIB2_mono"]->SetDirectory(TIB_Eta);
207  TH2Ds["LA_eta_TIB2_stereo"] =
208  new TH2D("TanLAPerTesla vs Eta TIB2 STEREO", "TanLAPerTesla vs Eta TIB2 STEREO", 800, -2.6, 2.6, 600, -0.3, 0.3);
209  TH2Ds["LA_eta_TIB2_stereo"]->SetDirectory(TIB_Eta);
210  TH2Ds["LA_eta_TIB3"] =
211  new TH2D("TanLAPerTesla vs Eta TIB3", "TanLAPerTesla vs Eta TIB3", 800, -2.6, 2.6, 600, -0.3, 0.3);
212  TH2Ds["LA_eta_TIB3"]->SetDirectory(TIB_Eta);
213  TH2Ds["LA_eta_TIB4"] =
214  new TH2D("TanLAPerTesla vs Eta TIB4", "TanLAPerTesla vs Eta TIB4", 800, -2.6, 2.6, 600, -0.3, 0.3);
215  TH2Ds["LA_eta_TIB4"]->SetDirectory(TIB_Eta);
216 
217  TH2Ds["LA_eta_TOB1"] =
218  new TH2D("TanLAPerTesla vs Eta TOB1", "TanLAPerTesla vs Eta TOB1", 800, -2.6, 2.6, 600, -0.3, 0.3);
219  TH2Ds["LA_eta_TOB1"]->SetDirectory(TIB_Eta);
220  TH2Ds["LA_eta_TOB1_mono"] =
221  new TH2D("TanLAPerTesla vs Eta TOB1 MONO", "TanLAPerTesla vs Eta TOB1 MONO", 800, -2.6, 2.6, 600, -0.3, 0.3);
222  TH2Ds["LA_eta_TOB1_mono"]->SetDirectory(TIB_Eta);
223  TH2Ds["LA_eta_TOB1_stereo"] =
224  new TH2D("TanLAPerTesla vs Eta TOB1 STEREO", "TanLAPerTesla vs Eta TOB1 STEREO", 800, -2.6, 2.6, 600, -0.3, 0.3);
225  TH2Ds["LA_eta_TOB1_stereo"]->SetDirectory(TIB_Eta);
226  TH2Ds["LA_eta_TOB2"] =
227  new TH2D("TanLAPerTesla vs Eta TOB2", "TanLAPerTesla vs Eta TOB2", 800, -2.6, 2.6, 600, -0.3, 0.3);
228  TH2Ds["LA_eta_TOB2"]->SetDirectory(TIB_Eta);
229  TH2Ds["LA_eta_TOB2_mono"] =
230  new TH2D("TanLAPerTesla vs Eta TOB2 MONO", "TanLAPerTesla vs Eta TOB2 MONO", 800, -2.6, 2.6, 600, -0.3, 0.3);
231  TH2Ds["LA_eta_TOB2_mono"]->SetDirectory(TIB_Eta);
232  TH2Ds["LA_eta_TOB2_stereo"] =
233  new TH2D("TanLAPerTesla vs Eta TOB2 STEREO", "TanLAPerTesla vs Eta TOB2 STEREO", 800, -2.6, 2.6, 600, -0.3, 0.3);
234  TH2Ds["LA_eta_TOB2_stereo"]->SetDirectory(TIB_Eta);
235  TH2Ds["LA_eta_TOB3"] =
236  new TH2D("TanLAPerTesla vs Eta TOB3", "TanLAPerTesla vs Eta TOB3", 800, -2.6, 2.6, 600, -0.3, 0.3);
237  TH2Ds["LA_eta_TOB3"]->SetDirectory(TIB_Eta);
238  TH2Ds["LA_eta_TOB4"] =
239  new TH2D("TanLAPerTesla vs Eta TOB4", "TanLAPerTesla vs Eta TOB4", 800, -2.6, 2.6, 600, -0.3, 0.3);
240  TH2Ds["LA_eta_TOB4"]->SetDirectory(TIB_Eta);
241  TH2Ds["LA_eta_TOB5"] =
242  new TH2D("TanLAPerTesla vs Eta TOB5", "TanLAPerTesla vs Eta TOB5", 800, -2.6, 2.6, 600, -0.3, 0.3);
243  TH2Ds["LA_eta_TOB5"]->SetDirectory(TIB_Eta);
244  TH2Ds["LA_eta_TOB6"] =
245  new TH2D("TanLAPerTesla vs Eta TOB6", "TanLAPerTesla vs Eta TOB6", 800, -2.6, 2.6, 600, -0.3, 0.3);
246  TH2Ds["LA_eta_TOB6"]->SetDirectory(TIB_Eta);
247 
248  ModuleTree = new TTree("ModuleTree", "ModuleTree");
249  ModuleTree->Branch("histoEntries", &histoEntries, "histoEntries/F");
250  ModuleTree->Branch("globalX", &globalX, "globalX/F");
251  ModuleTree->Branch("globalY", &globalY, "globalY/F");
252  ModuleTree->Branch("globalZ", &globalZ, "globalZ/F");
253  ModuleTree->Branch("gphi", &gphi, "gphi/F");
254  ModuleTree->Branch("geta", &geta, "geta/F");
255  ModuleTree->Branch("gR", &gR, "gR/F");
256  ModuleTree->Branch("goodFit", &goodFit, "goodFit/I");
257  ModuleTree->Branch("goodFit1IT", &goodFit1IT, "goodFit1IT/I");
258  ModuleTree->Branch("badFit", &badFit, "badFit/I");
259  ModuleTree->Branch("TIB", &TIB, "TIB/I");
260  ModuleTree->Branch("TOB", &TOB, "TOB/I");
261  ModuleTree->Branch("Layer", &Layer, "Layer/I");
262  ModuleTree->Branch("MonoStereo", &MonoStereo, "MonoStereo/I");
263  ModuleTree->Branch("theBfield", &theBfield, "theBfield/F");
264  ModuleTree->Branch("muH", &muH, "muH/F");
265 
266  ModuleTree->SetDirectory(Rootple);
267 
268  int histocounter = 0;
269  int NotEnoughEntries = 0;
270  int ZeroEntries = 0;
271  int GoodFit = 0;
272  int FirstIT_goodfit = 0;
273  int FirstIT_badfit = 0;
274  int SecondIT_badfit = 0;
275  int SecondIT_goodfit = 0;
276  int no_mod_histo = 0;
277  float chi2norm = 0;
278  LocalPoint p = LocalPoint(0, 0, 0);
279 
280  double ModuleRangeMin = conf_.getParameter<double>("ModuleFitXMin");
281  double ModuleRangeMax = conf_.getParameter<double>("ModuleFitXMax");
282  double ModuleRangeMin2IT = conf_.getParameter<double>("ModuleFit2ITXMin");
283  double ModuleRangeMax2IT = conf_.getParameter<double>("ModuleFit2ITXMax");
284  double FitCuts_Entries = conf_.getParameter<double>("FitCuts_Entries");
285  double FitCuts_p0 = conf_.getParameter<double>("FitCuts_p0");
286  double FitCuts_p1 = conf_.getParameter<double>("FitCuts_p1");
287  double FitCuts_p2 = conf_.getParameter<double>("FitCuts_p2");
288  double FitCuts_chi2 = conf_.getParameter<double>("FitCuts_chi2");
289  double FitCuts_ParErr_p0 = conf_.getParameter<double>("FitCuts_ParErr_p0");
290  double p0_guess = conf_.getParameter<double>("p0_guess");
291  double p1_guess = conf_.getParameter<double>("p1_guess");
292  double p2_guess = conf_.getParameter<double>("p2_guess");
293 
294  double TIB1calib = 1.;
295  double TIB2calib = 1.;
296  double TIB3calib = 1.;
297  double TIB4calib = 1.;
298  double TOB1calib = 1.;
299  double TOB2calib = 1.;
300  double TOB3calib = 1.;
301  double TOB4calib = 1.;
302  double TOB5calib = 1.;
303  double TOB6calib = 1.;
304 
305  if (CalibByMC == true) {
306  //Calibration factors evaluated by using MC analysis
307  TIB1calib = conf_.getParameter<double>("TIB1calib");
308  TIB2calib = conf_.getParameter<double>("TIB2calib");
309  TIB3calib = conf_.getParameter<double>("TIB3calib");
310  TIB4calib = conf_.getParameter<double>("TIB4calib");
311  TOB1calib = conf_.getParameter<double>("TOB1calib");
312  TOB2calib = conf_.getParameter<double>("TOB2calib");
313  TOB3calib = conf_.getParameter<double>("TOB3calib");
314  TOB4calib = conf_.getParameter<double>("TOB4calib");
315  TOB5calib = conf_.getParameter<double>("TOB5calib");
316  TOB6calib = conf_.getParameter<double>("TOB6calib");
317  }
318 
319  auto fitfunc = std::make_unique<TF1>("fitfunc", "([4]/[3])*[1]*(TMath::Abs(x-[0]))+[2]", -1, 1);
320  auto fitfunc2IT = std::make_unique<TF1>("fitfunc2IT", "([4]/[3])*[1]*(TMath::Abs(x-[0]))+[2]", -1, 1);
321 
322  std::ofstream NoEntries;
323  NoEntries.open(NoEntriesHisto_.c_str());
324  std::ofstream Rep;
325  Rep.open(LAreport_.c_str());
326 
327  gStyle->SetOptStat(1110);
328 
329  for (histo = histolist.begin(); histo != histolist.end(); ++histo) {
330  FitFunction = nullptr;
331  FitFunction2IT = nullptr;
332  bool Good2ITFit = false;
333  bool ModuleHisto = true;
334 
335  histoEntries = -99;
336  gphi = -99;
337  geta = -99;
338  gz = -99;
339  gR = -1;
340  globalX = -99;
341  globalY = -99;
342  globalZ = -99;
343  goodFit = 0;
344  goodFit1IT = 0;
345  badFit = 0;
346  muH = -1;
347  TIB = 0;
348  TOB = 0;
349  MonoStereo = -1;
350 
351  uint32_t id = hidmanager.getComponentId((*histo)->getName());
352  DetId detid(id);
353  StripSubdetector subid(id);
354  const GeomDetUnit* stripdet;
355  MonoStereo = subid.stereo();
356 
357  if (!(stripdet = tkGeom_->idToDetUnit(subid))) {
358  no_mod_histo++;
359  ModuleHisto = false;
360  edm::LogInfo("SiStripCalibLorentzAngle") << "### NO MODULE HISTOGRAM";
361  }
362 
363  if (stripdet != nullptr && ModuleHisto == true) {
364  if (subid.subdetId() == int(StripSubdetector::TIB)) {
365  Layer = tTopo_->tibLayer(detid);
366  TIB = 1;
367  }
368  if (subid.subdetId() == int(StripSubdetector::TOB)) {
369  Layer = tTopo_->tobLayer(detid);
370  TOB = 1;
371  }
372 
373  //get module coordinates
374  const GlobalPoint gposition = (stripdet->surface()).toGlobal(p);
375  histoEntries = (*histo)->getEntries();
376  globalX = gposition.x();
377  globalY = gposition.y();
378  globalZ = gposition.z();
379  gphi = gposition.phi();
380  geta = gposition.eta();
381  gR = sqrt(pow(gposition.x(), 2) + pow(gposition.y(), 2));
382  gz = gposition.z();
383 
384  //get magnetic field
385  const StripGeomDetUnit* det = dynamic_cast<const StripGeomDetUnit*>(tkGeom_->idToDetUnit(detid));
386  if (det == nullptr) {
387  edm::LogError("SiStripCalibLorentzAngle") << "[SiStripCalibLorentzAngle::getNewObject] the detID " << id
388  << " doesn't seem to belong to Tracker" << std::endl;
389  continue;
390  }
391  LocalVector lbfield = (det->surface()).toLocal(magField.inTesla(det->surface().position()));
392  theBfield = lbfield.mag();
393  theBfield = (theBfield > 0) ? theBfield : 0.00001;
394  TH1Ds["MagneticField"]->Fill(theBfield);
395  }
396  if (stripdet == nullptr)
397  continue;
398 
399  if (((*histo)->getEntries() <= FitCuts_Entries) && ModuleHisto == true) {
400  if (((*histo)->getEntries() == 0) && ModuleHisto == true) {
401  NoEntries << "NO ENTRIES MODULE, ID = " << id << std::endl;
402  edm::LogInfo("SiStripCalibLorentzAngle") << "### HISTOGRAM WITH 0 ENTRIES => TYPE:" << subid.subdetId();
403  ZeroEntries++;
404  } else {
405  edm::LogInfo("SiStripCalibLorentzAngle")
406  << "### HISTOGRAM WITH NR. ENTRIES <= ENTRIES_CUT => TYPE:" << subid.subdetId();
407  NotEnoughEntries++;
408  }
409  }
410 
412  if (TIB == 1) {
413  name += "TIB";
414  } else {
415  name += "TOB";
416  }
417  std::stringstream LayerStream;
418  LayerStream << Layer;
419  name += LayerStream.str();
420  std::stringstream idnum;
421  idnum << id;
422  name += "_Id_";
423  name += idnum.str();
424 
425  gStyle->SetOptFit(111);
426 
427  //Extract TProfile from Monitor Element to ProfileMap
428  Profiles[name] = new TProfile;
429  TProfile* theProfile = ExtractTObject<TProfile>().extract(*histo);
430  theProfile->Copy(*Profiles[name]);
431  Profiles[name]->SetName(name.c_str());
432 
433  if (((*histo)->getEntries() > FitCuts_Entries) && ModuleHisto == true) {
434  histocounter++;
435  if (TIB == 1) {
436  edm::LogInfo("SiStripCalibLorentzAngle") << "TIB layer = " << Layer;
437  }
438  if (TOB == 1) {
439  edm::LogInfo("SiStripCalibLorentzAngle") << "TOB layer = " << Layer;
440  }
441  edm::LogInfo("SiStripCalibLorentzAngle") << "id: " << id;
442 
443  float thickness = stripdet->specificSurface().bounds().thickness();
444  const StripTopology& topol = (const StripTopology&)stripdet->topology();
445  float pitch = topol.localPitch(p);
446 
447  fitfunc->SetParameter(0, p0_guess);
448  fitfunc->SetParameter(1, p1_guess);
449  fitfunc->SetParameter(2, p2_guess);
450  fitfunc->FixParameter(3, pitch);
451  fitfunc->FixParameter(4, thickness);
452 
453  Profiles[name]->Fit(fitfunc.get(), "E", "", ModuleRangeMin, ModuleRangeMax);
454 
455  FitFunction = fitfunc.get();
456  chi2norm = FitFunction->GetChisquare() / FitFunction->GetNDF();
457 
458  if (FitFunction->GetParameter(0) > FitCuts_p0 || FitFunction->GetParameter(1) < FitCuts_p1 ||
459  FitFunction->GetParameter(2) < FitCuts_p2 || chi2norm > FitCuts_chi2 ||
460  FitFunction->GetParError(0) < FitCuts_ParErr_p0) {
461  FirstIT_badfit++;
462 
463  fitfunc2IT->SetParameter(0, p0_guess);
464  fitfunc2IT->SetParameter(1, p1_guess);
465  fitfunc2IT->SetParameter(2, p2_guess);
466  fitfunc2IT->FixParameter(3, pitch);
467  fitfunc2IT->FixParameter(4, thickness);
468 
469  //2nd Iteration
470  Profiles[name]->Fit(fitfunc2IT.get(), "E", "", ModuleRangeMin2IT, ModuleRangeMax2IT);
471 
472  FitFunction = fitfunc2IT.get();
473  chi2norm = FitFunction->GetChisquare() / FitFunction->GetNDF();
474 
475  //2nd Iteration failed
476 
477  if (FitFunction->GetParameter(0) > FitCuts_p0 || FitFunction->GetParameter(1) < FitCuts_p1 ||
478  FitFunction->GetParameter(2) < FitCuts_p2 || chi2norm > FitCuts_chi2 ||
479  FitFunction->GetParError(0) < FitCuts_ParErr_p0) {
480  if (subid.subdetId() == int(StripSubdetector::TIB)) {
481  Profiles[name]->SetDirectory(TIB_2IT_BadFit);
482  } else {
483  Profiles[name]->SetDirectory(TOB_2IT_BadFit);
484  }
485 
486  SecondIT_badfit++;
487  badFit = 1;
488  }
489 
490  //2nd Iteration ok
491 
492  if (FitFunction->GetParameter(0) < FitCuts_p0 && FitFunction->GetParameter(1) > FitCuts_p1 &&
493  FitFunction->GetParameter(2) > FitCuts_p2 && chi2norm < FitCuts_chi2 &&
494  FitFunction->GetParError(0) > FitCuts_ParErr_p0) {
495  if (subid.subdetId() == int(StripSubdetector::TIB)) {
496  Profiles[name]->SetDirectory(TIB_2IT_GoodFit);
497  } else {
498  Profiles[name]->SetDirectory(TOB_2IT_GoodFit);
499  }
500 
501  SecondIT_goodfit++;
502  Good2ITFit = true;
503  }
504  }
505 
506  if (FitFunction->GetParameter(0) < FitCuts_p0 && FitFunction->GetParameter(1) > FitCuts_p1 &&
507  FitFunction->GetParameter(2) > FitCuts_p2 && chi2norm < FitCuts_chi2 &&
508  FitFunction->GetParError(0) > FitCuts_ParErr_p0) {
509  if (Good2ITFit == false) {
510  FirstIT_goodfit++;
511  goodFit1IT = 1;
512 
513  if (subid.subdetId() == int(StripSubdetector::TIB)) {
514  Profiles[name]->SetDirectory(TIB_1IT_GoodFit);
515  } else {
516  Profiles[name]->SetDirectory(TOB_1IT_GoodFit);
517  }
518  }
519 
520  GoodFit++;
521  goodFit = 1;
522 
523  LorentzAngle_Plots->cd();
524 
525  edm::LogInfo("SiStripCalibLorentzAngle") << FitFunction->GetParameter(0);
526 
527  muH = -(FitFunction->GetParameter(0)) / theBfield;
528 
529  if (TIB == 1) {
530  if (Layer == 1)
531  muH = muH / TIB1calib;
532  if (Layer == 2)
533  muH = muH / TIB2calib;
534  if (Layer == 3)
535  muH = muH / TIB3calib;
536  if (Layer == 4)
537  muH = muH / TIB4calib;
538  }
539  if (TOB == 1) {
540  if (Layer == 1)
541  muH = muH / TOB1calib;
542  if (Layer == 2)
543  muH = muH / TOB2calib;
544  if (Layer == 3)
545  muH = muH / TOB3calib;
546  if (Layer == 4)
547  muH = muH / TOB4calib;
548  if (Layer == 5)
549  muH = muH / TOB5calib;
550  if (Layer == 6)
551  muH = muH / TOB6calib;
552  }
553 
554  detid_la[id] = muH;
555 
556  if (TIB == 1) {
557  TH1Ds["LA_TIB"]->Fill(muH);
558  TH1Ds["LA_err_TIB"]->Fill(FitFunction->GetParError(0) / theBfield);
559  TH1Ds["LA_chi2norm_TIB"]->Fill(chi2norm);
560  TH2Ds["LA_phi_TIB"]->Fill(gphi, muH);
561  TH2Ds["LA_eta_TIB"]->Fill(geta, muH);
562  TH2Ds["LA_TIB_graph"]->Fill(Layer, muH);
563 
564  if (Layer == 1) {
565  TH1Ds["LA_TIB_1"]->Fill(muH);
566  TH2Ds["LA_phi_TIB1"]->Fill(gphi, muH);
567  TH2Ds["LA_eta_TIB1"]->Fill(geta, muH);
568  if (MonoStereo == 0) {
569  TH1Ds["LA_TIB_1_mono"]->Fill(muH);
570  TH2Ds["LA_phi_TIB1_mono"]->Fill(gphi, muH);
571  TH2Ds["LA_eta_TIB1_mono"]->Fill(geta, muH);
572  }
573  if (MonoStereo == 1) {
574  TH1Ds["LA_TIB_1_stereo"]->Fill(muH);
575  TH2Ds["LA_phi_TIB1_stereo"]->Fill(gphi, muH);
576  TH2Ds["LA_eta_TIB1_stereo"]->Fill(geta, muH);
577  }
578  }
579 
580  if (Layer == 2) {
581  TH1Ds["LA_TIB_2"]->Fill(muH);
582  TH2Ds["LA_phi_TIB2"]->Fill(gphi, muH);
583  TH2Ds["LA_eta_TIB2"]->Fill(geta, muH);
584  if (MonoStereo == 0) {
585  TH1Ds["LA_TIB_2_mono"]->Fill(muH);
586  TH2Ds["LA_phi_TIB2_mono"]->Fill(gphi, muH);
587  TH2Ds["LA_eta_TIB2_mono"]->Fill(geta, muH);
588  }
589  if (MonoStereo == 1) {
590  TH1Ds["LA_TIB_2_stereo"]->Fill(muH);
591  TH2Ds["LA_phi_TIB2_stereo"]->Fill(gphi, muH);
592  TH2Ds["LA_eta_TIB2_stereo"]->Fill(geta, muH);
593  }
594  }
595 
596  if (Layer == 3) {
597  TH1Ds["LA_TIB_3"]->Fill(muH);
598  TH2Ds["LA_phi_TIB3"]->Fill(gphi, muH);
599  TH2Ds["LA_eta_TIB3"]->Fill(geta, muH);
600  }
601 
602  if (Layer == 4) {
603  TH1Ds["LA_TIB_4"]->Fill(muH);
604  TH2Ds["LA_phi_TIB4"]->Fill(gphi, muH);
605  TH2Ds["LA_eta_TIB4"]->Fill(geta, muH);
606  }
607  }
608 
609  if (TOB == 1) {
610  TH1Ds["LA_TOB"]->Fill(muH);
611  TH1Ds["LA_err_TOB"]->Fill(FitFunction->GetParError(0) / theBfield);
612  TH1Ds["LA_chi2norm_TOB"]->Fill(chi2norm);
613  TH2Ds["LA_phi_TOB"]->Fill(gphi, muH);
614  TH2Ds["LA_eta_TOB"]->Fill(geta, muH);
615  TH2Ds["LA_TOB_graph"]->Fill(Layer, muH);
616 
617  if (Layer == 1) {
618  TH1Ds["LA_TOB_1"]->Fill(muH);
619  TH2Ds["LA_phi_TOB1"]->Fill(gphi, muH);
620  TH2Ds["LA_eta_TOB1"]->Fill(geta, muH);
621  if (MonoStereo == 0) {
622  TH1Ds["LA_TOB_1_mono"]->Fill(muH);
623  TH2Ds["LA_phi_TOB1_mono"]->Fill(gphi, muH);
624  TH2Ds["LA_eta_TOB1_mono"]->Fill(geta, muH);
625  }
626  if (MonoStereo == 1) {
627  TH1Ds["LA_TOB_1_stereo"]->Fill(muH);
628  TH2Ds["LA_phi_TOB1_stereo"]->Fill(gphi, muH);
629  TH2Ds["LA_eta_TOB1_stereo"]->Fill(geta, muH);
630  }
631  }
632 
633  if (Layer == 2) {
634  TH1Ds["LA_TOB_2"]->Fill(muH);
635  TH2Ds["LA_phi_TOB2"]->Fill(gphi, muH);
636  TH2Ds["LA_eta_TOB2"]->Fill(geta, muH);
637  if (MonoStereo == 0) {
638  TH1Ds["LA_TOB_2_mono"]->Fill(muH);
639  TH2Ds["LA_phi_TOB2_mono"]->Fill(gphi, muH);
640  TH2Ds["LA_eta_TOB2_mono"]->Fill(geta, muH);
641  }
642  if (MonoStereo == 1) {
643  TH1Ds["LA_TOB_2_stereo"]->Fill(muH);
644  TH2Ds["LA_phi_TOB2_stereo"]->Fill(gphi, muH);
645  TH2Ds["LA_eta_TOB2_stereo"]->Fill(geta, muH);
646  }
647  }
648 
649  if (Layer == 3) {
650  TH1Ds["LA_TOB_3"]->Fill(muH);
651  TH2Ds["LA_phi_TOB3"]->Fill(gphi, muH);
652  TH2Ds["LA_eta_TOB3"]->Fill(geta, muH);
653  }
654 
655  if (Layer == 4) {
656  TH1Ds["LA_TOB_4"]->Fill(muH);
657  TH2Ds["LA_phi_TOB4"]->Fill(gphi, muH);
658  TH2Ds["LA_eta_TOB4"]->Fill(geta, muH);
659  }
660 
661  if (Layer == 5) {
662  TH1Ds["LA_TOB_5"]->Fill(muH);
663  TH2Ds["LA_phi_TOB5"]->Fill(gphi, muH);
664  TH2Ds["LA_eta_TOB5"]->Fill(geta, muH);
665  }
666 
667  if (Layer == 6) {
668  TH1Ds["LA_TOB_6"]->Fill(muH);
669  TH2Ds["LA_phi_TOB6"]->Fill(gphi, muH);
670  TH2Ds["LA_eta_TOB6"]->Fill(geta, muH);
671  }
672  }
673  }
674  }
675 
676  ModuleTree->Fill();
677  }
678 
679  double GaussFitRange = conf_.getParameter<double>("GaussFitRange");
680  auto gaus = std::make_unique<TF1>("gaus", "gaus");
681 
682  TH1Ds["LA_TIB_1"]->Fit(gaus.get(), "", "", -GaussFitRange, GaussFitRange);
683  mean_TIB1 = gaus->GetParameter(1);
684  float err_mean_TIB1 = gaus->GetParError(1);
685  float rms_TIB1 = gaus->GetParameter(2);
686  TH1Ds["LA_TIB_2"]->Fit(gaus.get(), "", "", -GaussFitRange, GaussFitRange);
687  mean_TIB2 = gaus->GetParameter(1);
688  float err_mean_TIB2 = gaus->GetParError(1);
689  float rms_TIB2 = gaus->GetParameter(2);
690  TH1Ds["LA_TIB_3"]->Fit(gaus.get(), "", "", -GaussFitRange, GaussFitRange);
691  mean_TIB3 = gaus->GetParameter(1);
692  float err_mean_TIB3 = gaus->GetParError(1);
693  float rms_TIB3 = gaus->GetParameter(2);
694  TH1Ds["LA_TIB_4"]->Fit(gaus.get(), "", "", -GaussFitRange, GaussFitRange);
695  mean_TIB4 = gaus->GetParameter(1);
696  float err_mean_TIB4 = gaus->GetParError(1);
697  float rms_TIB4 = gaus->GetParameter(2);
698 
699  TH1Ds["LA_TOB_1"]->Fit(gaus.get(), "", "", -GaussFitRange, GaussFitRange);
700  mean_TOB1 = gaus->GetParameter(1);
701  float err_mean_TOB1 = gaus->GetParError(1);
702  float rms_TOB1 = gaus->GetParameter(2);
703  TH1Ds["LA_TOB_2"]->Fit(gaus.get(), "", "", -GaussFitRange, GaussFitRange);
704  mean_TOB2 = gaus->GetParameter(1);
705  float err_mean_TOB2 = gaus->GetParError(1);
706  float rms_TOB2 = gaus->GetParameter(2);
707  TH1Ds["LA_TOB_3"]->Fit(gaus.get(), "", "", -GaussFitRange, GaussFitRange);
708  mean_TOB3 = gaus->GetParameter(1);
709  float err_mean_TOB3 = gaus->GetParError(1);
710  float rms_TOB3 = gaus->GetParameter(2);
711  TH1Ds["LA_TOB_4"]->Fit(gaus.get(), "", "", -GaussFitRange, GaussFitRange);
712  mean_TOB4 = gaus->GetParameter(1);
713  float err_mean_TOB4 = gaus->GetParError(1);
714  float rms_TOB4 = gaus->GetParameter(2);
715  TH1Ds["LA_TOB_5"]->Fit(gaus.get(), "", "", -GaussFitRange, GaussFitRange);
716  mean_TOB5 = gaus->GetParameter(1);
717  float err_mean_TOB5 = gaus->GetParError(1);
718  float rms_TOB5 = gaus->GetParameter(2);
719  TH1Ds["LA_TOB_6"]->Fit(gaus.get(), "", "", -GaussFitRange, GaussFitRange);
720  mean_TOB6 = gaus->GetParameter(1);
721  float err_mean_TOB6 = gaus->GetParError(1);
722  float rms_TOB6 = gaus->GetParameter(2);
723 
724  int nlayersTIB = 4;
725  float TIBx[4] = {1, 2, 3, 4};
726  float TIBex[4] = {0, 0, 0, 0};
727  float TIBy[4] = {mean_TIB1, mean_TIB2, mean_TIB3, mean_TIB4};
728  float TIBey[4] = {err_mean_TIB1, err_mean_TIB2, err_mean_TIB3, err_mean_TIB4};
729 
730  int nlayersTOB = 6;
731  float TOBx[6] = {1, 2, 3, 4, 5, 6};
732  float TOBex[6] = {0, 0, 0, 0, 0, 0};
733  float TOBy[6] = {mean_TOB1, mean_TOB2, mean_TOB3, mean_TOB4, mean_TOB5, mean_TOB6};
734  float TOBey[6] = {err_mean_TOB1, err_mean_TOB2, err_mean_TOB3, err_mean_TOB4, err_mean_TOB5, err_mean_TOB6};
735 
736  TIB_graph = new TGraphErrors(nlayersTIB, TIBx, TIBy, TIBex, TIBey);
737  TOB_graph = new TGraphErrors(nlayersTOB, TOBx, TOBy, TOBex, TOBey);
738 
739  //TF1 *fit_TIB= new TF1("fit_TIB","[0]",0,4);
740  //TF1 *fit_TOB= new TF1("fit_TOB","[0]",0,6);
741 
742  gStyle->SetOptFit(111);
743  gStyle->SetOptStat(111);
744 
745  TIB_graph->SetTitle("TIB Layers #mu_{H}");
746  TIB_graph->GetXaxis()->SetTitle("Layers");
747  TIB_graph->GetXaxis()->SetNdivisions(4);
748  TIB_graph->GetYaxis()->SetTitle("#mu_{H}");
749  TIB_graph->SetMarkerStyle(20);
750  TIB_graph->GetYaxis()->SetTitleOffset(1.3);
751  TIB_graph->Fit("fit_TIB", "E", "", 1, 4);
752  meanMobility_TIB = TIB_graph->GetFunction("fit_TIB")->GetParameter(0);
753 
754  TOB_graph->SetTitle("TOB Layers #mu_{H}");
755  TOB_graph->GetXaxis()->SetTitle("Layers");
756  TOB_graph->GetXaxis()->SetNdivisions(6);
757  TOB_graph->GetYaxis()->SetTitle("#mu_{H}");
758  TOB_graph->SetMarkerStyle(20);
759  TOB_graph->GetYaxis()->SetTitleOffset(1.3);
760  TOB_graph->Fit("fit_TOB", "E", "", 1, 6);
761  meanMobility_TOB = TOB_graph->GetFunction("fit_TOB")->GetParameter(0);
762 
763  TIB_graph->Write("TIB_graph");
764  TOB_graph->Write("TOB_graph");
765 
766  Rep << "- NR.OF TIB AND TOB MODULES = 7932" << std::endl << std::endl << std::endl;
767  Rep << "- NO MODULE HISTOS FOUND = " << no_mod_histo << std::endl << std::endl;
768  Rep << "- NR.OF HISTOS WITH ENTRIES > " << FitCuts_Entries << " = " << histocounter << std::endl << std::endl;
769  Rep << "- NR.OF HISTOS WITH ENTRIES <= " << FitCuts_Entries << " (!=0) = " << NotEnoughEntries << std::endl
770  << std::endl;
771  Rep << "- NR.OF HISTOS WITH 0 ENTRIES = " << ZeroEntries << std::endl << std::endl << std::endl;
772  Rep << "- NR.OF GOOD FIT (FIRST IT + SECOND IT GOOD FIT)= " << GoodFit << std::endl << std::endl;
773  Rep << "- NR.OF FIRST IT GOOD FIT = " << FirstIT_goodfit << std::endl << std::endl;
774  Rep << "- NR.OF SECOND IT GOOD FIT = " << SecondIT_goodfit << std::endl << std::endl;
775  Rep << "- NR.OF FIRST IT BAD FIT = " << FirstIT_badfit << std::endl << std::endl;
776  Rep << "- NR.OF SECOND IT BAD FIT = " << SecondIT_badfit << std::endl << std::endl << std::endl;
777 
778  Rep << "--------------- Mean MuH values per Layer -------------------" << std::endl << std::endl << std::endl;
779  Rep << "TIB1 = " << mean_TIB1 << " +- " << err_mean_TIB1 << " RMS = " << rms_TIB1 << std::endl;
780  Rep << "TIB2 = " << mean_TIB2 << " +- " << err_mean_TIB2 << " RMS = " << rms_TIB2 << std::endl;
781  Rep << "TIB3 = " << mean_TIB3 << " +- " << err_mean_TIB3 << " RMS = " << rms_TIB3 << std::endl;
782  Rep << "TIB4 = " << mean_TIB4 << " +- " << err_mean_TIB4 << " RMS = " << rms_TIB4 << std::endl;
783  Rep << "TOB1 = " << mean_TOB1 << " +- " << err_mean_TOB1 << " RMS = " << rms_TOB1 << std::endl;
784  Rep << "TOB2 = " << mean_TOB2 << " +- " << err_mean_TOB2 << " RMS = " << rms_TOB2 << std::endl;
785  Rep << "TOB3 = " << mean_TOB3 << " +- " << err_mean_TOB3 << " RMS = " << rms_TOB3 << std::endl;
786  Rep << "TOB4 = " << mean_TOB4 << " +- " << err_mean_TOB4 << " RMS = " << rms_TOB4 << std::endl;
787  Rep << "TOB5 = " << mean_TOB5 << " +- " << err_mean_TOB5 << " RMS = " << rms_TOB5 << std::endl;
788  Rep << "TOB6 = " << mean_TOB6 << " +- " << err_mean_TOB6 << " RMS = " << rms_TOB6 << std::endl << std::endl;
789  Rep << "Mean Hall Mobility TIB = " << meanMobility_TIB << " +- " << TIB_graph->GetFunction("fit_TIB")->GetParError(0)
790  << std::endl;
791  Rep << "Mean Hall Mobility TOB = " << meanMobility_TOB << " +- " << TOB_graph->GetFunction("fit_TOB")->GetParError(0)
792  << std::endl
793  << std::endl
794  << std::endl;
795 
796  Rep.close();
797  NoEntries.close();
798 
799  hFile->Write();
800  hFile->Close();
801 }
802 
803 // Virtual destructor needed.
804 
806 
807 // Analyzer: Functions that gets called by framework every event
808 
809 std::unique_ptr<SiStripLorentzAngle> SiStripCalibLorentzAngle::getNewObject() {
810  auto LorentzAngle = std::make_unique<SiStripLorentzAngle>();
811 
812  if (!LayerDB) {
813  for (std::map<uint32_t, float>::iterator it = detid_la.begin(); it != detid_la.end(); it++) {
814  float langle = it->second;
815  if (!LorentzAngle->putLorentzAngle(it->first, langle))
816  edm::LogError("SiStripCalibLorentzAngle")
817  << "[SiStripCalibLorentzAngle::analyze] detid already exists" << std::endl;
818  }
819  }
820 
821  else {
823  TrackerGeometry::DetIdContainer::const_iterator Iditer;
824 
825  for (Iditer = Id.begin(); Iditer != Id.end(); Iditer++) {
826  StripSubdetector subid(Iditer->rawId());
827 
828  hallMobility = 0.;
829 
830  if (subid.subdetId() == int(StripSubdetector::TIB)) {
831  uint32_t tibLayer = tTopo_->tibLayer(*Iditer);
832  if (tibLayer == 1) {
833  hallMobility = mean_TIB1;
834  }
835  if (tibLayer == 2) {
836  hallMobility = mean_TIB2;
837  }
838  if (tibLayer == 3) {
839  hallMobility = mean_TIB3;
840  }
841  if (tibLayer == 4) {
842  hallMobility = mean_TIB4;
843  }
844  if (!LorentzAngle->putLorentzAngle(Iditer->rawId(), hallMobility))
845  edm::LogError("SiStripLorentzAngleGenerator") << " detid already exists" << std::endl;
846  }
847 
848  if (subid.subdetId() == int(StripSubdetector::TOB)) {
849  uint32_t tobLayer = tTopo_->tobLayer(*Iditer);
850  if (tobLayer == 1) {
851  hallMobility = mean_TOB1;
852  }
853  if (tobLayer == 2) {
854  hallMobility = mean_TOB2;
855  }
856  if (tobLayer == 3) {
857  hallMobility = mean_TOB3;
858  }
859  if (tobLayer == 4) {
860  hallMobility = mean_TOB4;
861  }
862  if (tobLayer == 5) {
863  hallMobility = mean_TOB5;
864  }
865  if (tobLayer == 6) {
866  hallMobility = mean_TOB6;
867  }
868  if (!LorentzAngle->putLorentzAngle(Iditer->rawId(), hallMobility))
869  edm::LogError("SiStripLorentzAngleGenerator") << " detid already exists" << std::endl;
870  }
871 
872  if (subid.subdetId() == int(StripSubdetector::TID)) {
873  hallMobility = meanMobility_TIB;
874  if (!LorentzAngle->putLorentzAngle(Iditer->rawId(), hallMobility))
875  edm::LogError("SiStripLorentzAngleGenerator") << " detid already exists" << std::endl;
876  }
877 
878  if (subid.subdetId() == int(StripSubdetector::TEC)) {
879  if (tTopo_->tecRing(subid) < 5) {
880  hallMobility = meanMobility_TIB;
881  } else {
882  hallMobility = meanMobility_TOB;
883  }
884  if (!LorentzAngle->putLorentzAngle(Iditer->rawId(), hallMobility))
885  edm::LogError("SiStripLorentzAngleGenerator") << " detid already exists" << std::endl;
886  }
887  }
888  }
889 
890  return LorentzAngle;
891 }
static constexpr auto TEC
T getUntrackedParameter(std::string const &, T const &) const
const edm::EventSetup & c
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
unsigned int tibLayer(const DetId &id) const
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
uint16_t *__restrict__ id
double ModuleRangeMin
virtual const Topology & topology() const
Definition: GeomDet.cc:67
const DetIdContainer & detIds() const override
Returm a vector of all GeomDet DetIds (including those of GeomDetUnits)
const auto & magField
unsigned int tecRing(const DetId &id) const
ring id
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
T y() const
Definition: PV3DBase.h:60
SiStripCalibLorentzAngle(const edm::ParameterSet &conf)
const Bounds & bounds() const
Definition: Surface.h:87
Log< level::Error, false > LogError
TrackerGeometry::DetIdContainer::const_iterator Iditer
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
virtual std::vector< dqm::harvesting::MonitorElement * > getAllContents(std::string const &path) const
Definition: DQMStore.cc:609
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
uint32_t getComponentId(std::string histoid)
virtual float thickness() const =0
bool getData(T &iHolder) const
Definition: EventSetup.h:128
virtual float localPitch(const LocalPoint &) const =0
T mag() const
Definition: PV3DBase.h:64
std::vector< MonitorElement * > histolist
T sqrt(T t)
Definition: SSEVec.h:19
T z() const
Definition: PV3DBase.h:61
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
Transition
Definition: Transition.h:12
static constexpr auto TOB
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
int extract(std::vector< int > *output, const std::string &dati)
SiStripHistoId hidmanager
Log< level::Info, false > LogInfo
double ModuleRangeMax
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomToken_
Definition: DetId.h:17
unsigned int stereo() const
stereo
edm::ESGetToken< SiStripLorentzAngle, SiStripLorentzAngleRcd > lorentzAngleToken_
static constexpr auto TIB
const TrackerGeometry * tkGeom_
void algoBeginJob(const edm::EventSetup &) override
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< DetId > DetIdContainer
T eta() const
Definition: PV3DBase.h:73
T x() const
Definition: PV3DBase.h:59
std::unique_ptr< SiStripLorentzAngle > getNewObject() override
const PositionType & position() const
static constexpr auto TID
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
tTopoToken_
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
DQM_DEPRECATED bool open(std::string const &filename, bool overwrite=false, std::string const &path="", std::string const &prepend="", OpenRunDirs stripdirs=KeepRunDirs, bool fileMustExist=true)
Definition: DQMStore.cc:790
std::map< uint32_t, float > detid_la
const TrackerTopology * tTopo_
const Plane & specificSurface() const
Same as surface(), kept for backward compatibility.
Definition: GeomDet.h:40
unsigned int tobLayer(const DetId &id) const