CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonSystemMapPlot1D.cc
Go to the documentation of this file.
3 #include "TMath.h"
4 
5 const double MuonSystemMapPlot1D_xrange = 30.;
6 const double MuonSystemMapPlot1D_yrange = 50.;
7 const double MuonSystemMapPlot1D_dxdzrange = 50.;
8 const double MuonSystemMapPlot1D_dydzrange = 200.;
9 
10 MuonSystemMapPlot1D::MuonSystemMapPlot1D(std::string name, AlignmentMonitorMuonSystemMap1D *module, int bins, double low, double high, bool twodimensional)
11  : m_name(name), m_bins(bins), m_twodimensional(twodimensional)
12 {
16 
17  std::stringstream name_x_prof, name_y_prof, name_dxdz_prof, name_dydz_prof;
18  std::stringstream name_x_profPos, name_y_profPos, name_dxdz_profPos, name_dydz_profPos;
19  std::stringstream name_x_profNeg, name_y_profNeg, name_dxdz_profNeg, name_dydz_profNeg;
20  std::stringstream name_x_2d, name_y_2d, name_dxdz_2d, name_dydz_2d;
21  std::stringstream name_x_2dweight, name_y_2dweight, name_dxdz_2dweight, name_dydz_2dweight;
22  std::stringstream name_x_hist, name_y_hist, name_dxdz_hist, name_dydz_hist;
23  std::stringstream name_x_weights, name_y_weights, name_dxdz_weights, name_dydz_weights;
24  std::stringstream name_x_valweights, name_y_valweights, name_dxdz_valweights, name_dydz_valweights;
25 
26  name_x_prof << m_name << "_x_prof";
27  name_y_prof << m_name << "_y_prof";
28  name_dxdz_prof << m_name << "_dxdz_prof";
29  name_dydz_prof << m_name << "_dydz_prof";
30  name_x_profPos << m_name << "_x_profPos";
31  name_y_profPos << m_name << "_y_profPos";
32  name_dxdz_profPos << m_name << "_dxdz_profPos";
33  name_dydz_profPos << m_name << "_dydz_profPos";
34  name_x_profNeg << m_name << "_x_profNeg";
35  name_y_profNeg << m_name << "_y_profNeg";
36  name_dxdz_profNeg << m_name << "_dxdz_profNeg";
37  name_dydz_profNeg << m_name << "_dydz_profNeg";
38  name_x_2d << m_name << "_x_2d";
39  name_y_2d << m_name << "_y_2d";
40  name_dxdz_2d << m_name << "_dxdz_2d";
41  name_dydz_2d << m_name << "_dydz_2d";
42  name_x_2dweight << m_name << "_x_2dweight";
43  name_y_2dweight << m_name << "_y_2dweight";
44  name_dxdz_2dweight << m_name << "_dxdz_2dweight";
45  name_dydz_2dweight << m_name << "_dydz_2dweight";
46  name_x_hist << m_name << "_x_hist";
47  name_y_hist << m_name << "_y_hist";
48  name_dxdz_hist << m_name << "_dxdz_hist";
49  name_dydz_hist << m_name << "_dydz_hist";
50  name_x_weights << m_name << "_x_weights";
51  name_y_weights << m_name << "_y_weights";
52  name_dxdz_weights << m_name << "_dxdz_weights";
53  name_dydz_weights << m_name << "_dydz_weights";
54  name_x_valweights << m_name << "_x_valweights";
55  name_y_valweights << m_name << "_y_valweights";
56  name_dxdz_valweights << m_name << "_dxdz_valweights";
57  name_dydz_valweights << m_name << "_dydz_valweights";
58 
59  m_x_prof = module->bookProfile("/iterN/", name_x_prof.str().c_str(), "", m_bins, low, high);
60  if (m_twodimensional) m_y_prof = module->bookProfile("/iterN/", name_y_prof.str().c_str(), "", m_bins, low, high);
61  m_dxdz_prof = module->bookProfile("/iterN/", name_dxdz_prof.str().c_str(), "", m_bins, low, high);
62  if (m_twodimensional) m_dydz_prof = module->bookProfile("/iterN/", name_dydz_prof.str().c_str(), "", m_bins, low, high);
63  m_x_profPos = module->bookProfile("/iterN/", name_x_profPos.str().c_str(), "", m_bins, low, high);
64  if (m_twodimensional) m_y_profPos = module->bookProfile("/iterN/", name_y_profPos.str().c_str(), "", m_bins, low, high);
65  m_dxdz_profPos = module->bookProfile("/iterN/", name_dxdz_profPos.str().c_str(), "", m_bins, low, high);
66  if (m_twodimensional) m_dydz_profPos = module->bookProfile("/iterN/", name_dydz_profPos.str().c_str(), "", m_bins, low, high);
67  m_x_profNeg = module->bookProfile("/iterN/", name_x_profNeg.str().c_str(), "", m_bins, low, high);
68  if (m_twodimensional) m_y_profNeg = module->bookProfile("/iterN/", name_y_profNeg.str().c_str(), "", m_bins, low, high);
69  m_dxdz_profNeg = module->bookProfile("/iterN/", name_dxdz_profNeg.str().c_str(), "", m_bins, low, high);
70  if (m_twodimensional) m_dydz_profNeg = module->bookProfile("/iterN/", name_dydz_profNeg.str().c_str(), "", m_bins, low, high);
71  m_x_2d = module->book2D("/iterN/", name_x_2d.str().c_str(), "", m_bins, low, high, 80, -40., 40.);
72  if (m_twodimensional) m_y_2d = module->book2D("/iterN/", name_y_2d.str().c_str(), "", m_bins, low, high, 80, -40., 40.);
73  m_dxdz_2d = module->book2D("/iterN/", name_dxdz_2d.str().c_str(), "", m_bins, low, high, 80, -40., 40.);
74  if (m_twodimensional) m_dydz_2d = module->book2D("/iterN/", name_dydz_2d.str().c_str(), "", m_bins, low, high, 80, -40., 40.);
75  m_x_2dweight = module->book2D("/iterN/", name_x_2dweight.str().c_str(), "", m_bins, low, high, 80, -40., 40.);
76  if (m_twodimensional) m_y_2dweight = module->book2D("/iterN/", name_y_2dweight.str().c_str(), "", m_bins, low, high, 80, -40., 40.);
77  m_dxdz_2dweight = module->book2D("/iterN/", name_dxdz_2dweight.str().c_str(), "", m_bins, low, high, 80, -40., 40.);
78  if (m_twodimensional) m_dydz_2dweight = module->book2D("/iterN/", name_dydz_2dweight.str().c_str(), "", m_bins, low, high, 80, -40., 40.);
79  m_x_hist = module->book1D("/iterN/", name_x_hist.str().c_str(), "", m_bins, -MuonSystemMapPlot1D_xrange, MuonSystemMapPlot1D_xrange);
80  if (m_twodimensional) m_y_hist = module->book1D("/iterN/", name_y_hist.str().c_str(), "", m_bins, -MuonSystemMapPlot1D_yrange, MuonSystemMapPlot1D_yrange);
81  m_dxdz_hist = module->book1D("/iterN/", name_dxdz_hist.str().c_str(), "", m_bins, -MuonSystemMapPlot1D_dxdzrange, MuonSystemMapPlot1D_dxdzrange);
82  if (m_twodimensional) m_dydz_hist = module->book1D("/iterN/", name_dydz_hist.str().c_str(), "", m_bins, -MuonSystemMapPlot1D_dydzrange, MuonSystemMapPlot1D_dydzrange);
83  m_x_weights = module->book1D("/iterN/", name_x_weights.str().c_str(), "", m_bins, low, high);
84  if (m_twodimensional) m_y_weights = module->book1D("/iterN/", name_y_weights.str().c_str(), "", m_bins, low, high);
85  m_dxdz_weights = module->book1D("/iterN/", name_dxdz_weights.str().c_str(), "", m_bins, low, high);
86  if (m_twodimensional) m_dydz_weights = module->book1D("/iterN/", name_dydz_weights.str().c_str(), "", m_bins, low, high);
87  m_x_valweights = module->book1D("/iterN/", name_x_valweights.str().c_str(), "", m_bins, low, high);
88  if (m_twodimensional) m_y_valweights = module->book1D("/iterN/", name_y_valweights.str().c_str(), "", m_bins, low, high);
89  m_dxdz_valweights = module->book1D("/iterN/", name_dxdz_valweights.str().c_str(), "", m_bins, low, high);
90  if (m_twodimensional) m_dydz_valweights = module->book1D("/iterN/", name_dydz_valweights.str().c_str(), "", m_bins, low, high);
91 
92  m_x_prof->SetAxisRange(-10., 10., "Y");
93  if (m_twodimensional) m_y_prof->SetAxisRange(-10., 10., "Y");
94  m_dxdz_prof->SetAxisRange(-10., 10., "Y");
95  if (m_twodimensional) m_dydz_prof->SetAxisRange(-10., 10., "Y");
96 
97  m_x_profPos->SetAxisRange(-10., 10., "Y");
98  if (m_twodimensional) m_y_profPos->SetAxisRange(-10., 10., "Y");
99  m_dxdz_profPos->SetAxisRange(-10., 10., "Y");
100  if (m_twodimensional) m_dydz_profPos->SetAxisRange(-10., 10., "Y");
101 
102  m_x_profNeg->SetAxisRange(-10., 10., "Y");
103  if (m_twodimensional) m_y_profNeg->SetAxisRange(-10., 10., "Y");
104  m_dxdz_profNeg->SetAxisRange(-10., 10., "Y");
105  if (m_twodimensional) m_dydz_profNeg->SetAxisRange(-10., 10., "Y");
106 }
107 
108 void MuonSystemMapPlot1D::fill_x(char charge, double abscissa, double residx, double chi2, int dof) {
109  if (chi2 > 0. && TMath::Prob(chi2, dof) < 0.95) { // no spikes allowed
110  double residual = residx * 10.;
111  double weight = dof / chi2;
112 
113  if (fabs(residual) < MuonSystemMapPlot1D_xrange) {
114  m_x_prof->Fill(abscissa, residual);
115  if (charge > 0) m_x_profPos->Fill(abscissa, residual);
116  else m_x_profNeg->Fill(abscissa, residual);
117  int i = m_x_weights->FindBin(abscissa);
118  m_x_weights->SetBinContent(i, m_x_weights->GetBinContent(i) + weight);
119  m_x_valweights->SetBinContent(i, m_x_valweights->GetBinContent(i) + residual * weight);
120  }
121  m_x_2d->Fill(abscissa, residual);
122  m_x_2dweight->Fill(abscissa, residual, weight);
123  m_x_hist->Fill(residual, weight);
124  }
125 }
126 
127 void MuonSystemMapPlot1D::fill_y(char charge, double abscissa, double residy, double chi2, int dof) {
128  if (m_twodimensional && chi2 > 0. && TMath::Prob(chi2, dof) < 0.95) { // no spikes allowed
129  double residual = residy * 10.;
130  double weight = dof / chi2;
131 
132  if (fabs(residual) < MuonSystemMapPlot1D_yrange) {
133  m_y_prof->Fill(abscissa, residual);
134  if (charge > 0) m_y_profPos->Fill(abscissa, residual);
135  else m_y_profNeg->Fill(abscissa, residual);
136  int i = m_y_weights->FindBin(abscissa);
137  m_y_weights->SetBinContent(i, m_y_weights->GetBinContent(i) + weight);
138  m_y_valweights->SetBinContent(i, m_y_valweights->GetBinContent(i) + residual * weight);
139  }
140  m_y_2d->Fill(abscissa, residual);
141  m_y_2dweight->Fill(abscissa, residual, weight);
142  m_y_hist->Fill(residual, weight);
143  }
144 }
145 
146 void MuonSystemMapPlot1D::fill_dxdz(char charge, double abscissa, double slopex, double chi2, int dof) {
147  if (chi2 > 0. && TMath::Prob(chi2, dof) < 0.95) { // no spikes allowed
148  double residual = slopex * 1000.;
149  double weight = dof / chi2;
150 
151  if (fabs(residual) < MuonSystemMapPlot1D_dxdzrange) {
152  m_dxdz_prof->Fill(abscissa, residual);
153  if (charge > 0) m_dxdz_profPos->Fill(abscissa, residual);
154  else m_dxdz_profNeg->Fill(abscissa, residual);
155  int i = m_dxdz_weights->FindBin(abscissa);
156  m_dxdz_weights->SetBinContent(i, m_dxdz_weights->GetBinContent(i) + weight);
157  m_dxdz_valweights->SetBinContent(i, m_dxdz_valweights->GetBinContent(i) + residual * weight);
158  }
159  m_dxdz_2d->Fill(abscissa, residual);
160  m_dxdz_2dweight->Fill(abscissa, residual, weight);
161  m_dxdz_hist->Fill(residual, weight);
162  }
163 }
164 
165 void MuonSystemMapPlot1D::fill_dydz(char charge, double abscissa, double slopey, double chi2, int dof) {
166  if (m_twodimensional && chi2 > 0. && TMath::Prob(chi2, dof) < 0.95) { // no spikes allowed
167  double residual = slopey * 1000.;
168  double weight = dof / chi2;
169 
170  if (fabs(residual) < MuonSystemMapPlot1D_dydzrange) {
171  m_dydz_prof->Fill(abscissa, residual);
172  if (charge > 0) m_dydz_profPos->Fill(abscissa, residual);
173  else m_dydz_profNeg->Fill(abscissa, residual);
174  int i = m_dydz_weights->FindBin(abscissa);
175  m_dydz_weights->SetBinContent(i, m_dydz_weights->GetBinContent(i) + weight);
176  m_dydz_valweights->SetBinContent(i, m_dydz_valweights->GetBinContent(i) + residual * weight);
177  }
178  m_dydz_2d->Fill(abscissa, residual);
179  m_dydz_2dweight->Fill(abscissa, residual, weight);
180  m_dydz_hist->Fill(residual, weight);
181  }
182 }
int i
Definition: DBlmapReader.cc:9
const double MuonSystemMapPlot1D_dydzrange
TH2F * book2D(std::string dir, std::string name, std::string title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
#define NULL
Definition: scimark2.h:8
void fill_y(char charge, double abscissa, double residy, double chi2, int dof)
TProfile * bookProfile(std::string dir, std::string name, std::string title, int nchX, double lowX, double highX, int nchY=1, double lowY=0., double highY=0., const char *option="s")
double charge(const std::vector< uint8_t > &Ampls)
void fill_x(char charge, double abscissa, double residx, double chi2, int dof)
const double MuonSystemMapPlot1D_xrange
TH1F * book1D(std::string dir, std::string name, std::string title, int nchX, double lowX, double highX)
const double MuonSystemMapPlot1D_yrange
void fill_dydz(char charge, double abscissa, double slopey, double chi2, int dof)
void fill_dxdz(char charge, double abscissa, double slopex, double chi2, int dof)
const double MuonSystemMapPlot1D_dxdzrange
Definition: vlib.h:209
MuonSystemMapPlot1D(std::string name, AlignmentMonitorMuonSystemMap1D *module, int bins, double low, double high, bool twodimensional)