CMS 3D CMS Logo

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