CMS 3D CMS Logo

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