CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/Alignment/CommonAlignmentMonitor/src/MuonSystemMapPlot1D.cc

Go to the documentation of this file.
00001 #include "Alignment/CommonAlignmentMonitor/interface/MuonSystemMapPlot1D.h"
00002 #include "Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorMuonSystemMap1D.h"
00003 #include "TMath.h"
00004 
00005 const double MuonSystemMapPlot1D_xrange = 30.;
00006 const double MuonSystemMapPlot1D_yrange = 50.;
00007 const double MuonSystemMapPlot1D_dxdzrange = 50.;
00008 const double MuonSystemMapPlot1D_dydzrange = 200.;
00009 
00010 MuonSystemMapPlot1D::MuonSystemMapPlot1D(std::string name, AlignmentMonitorMuonSystemMap1D *module, int bins, double low, double high, bool twodimensional)
00011    : m_name(name), m_bins(bins), m_twodimensional(twodimensional)
00012 {
00013   m_x_prof = m_y_prof = m_dxdz_prof = m_dydz_prof = m_x_profPos = m_y_profPos = m_dxdz_profPos = m_dydz_profPos = m_x_profNeg = m_y_profNeg = m_dxdz_profNeg = m_dydz_profNeg = NULL;
00014   m_x_2d = m_y_2d = m_dxdz_2d = m_dydz_2d = m_x_2dweight = m_y_2dweight = m_dxdz_2dweight = m_dydz_2dweight = NULL;
00015   m_x_hist = m_y_hist = m_dxdz_hist = m_dydz_hist = m_x_weights = m_y_weights = m_dxdz_weights = m_dydz_weights = m_x_valweights = m_y_valweights = m_dxdz_valweights = m_dydz_valweights = NULL;
00016 
00017   std::stringstream name_x_prof, name_y_prof, name_dxdz_prof, name_dydz_prof;
00018   std::stringstream name_x_profPos, name_y_profPos, name_dxdz_profPos, name_dydz_profPos;
00019   std::stringstream name_x_profNeg, name_y_profNeg, name_dxdz_profNeg, name_dydz_profNeg;
00020   std::stringstream name_x_2d, name_y_2d, name_dxdz_2d, name_dydz_2d;
00021   std::stringstream name_x_2dweight, name_y_2dweight, name_dxdz_2dweight, name_dydz_2dweight;
00022   std::stringstream name_x_hist, name_y_hist, name_dxdz_hist, name_dydz_hist;
00023   std::stringstream name_x_weights, name_y_weights, name_dxdz_weights, name_dydz_weights;
00024   std::stringstream name_x_valweights, name_y_valweights, name_dxdz_valweights, name_dydz_valweights;
00025 
00026   name_x_prof << m_name << "_x_prof";
00027   name_y_prof << m_name << "_y_prof";
00028   name_dxdz_prof << m_name << "_dxdz_prof";
00029   name_dydz_prof << m_name << "_dydz_prof";
00030   name_x_profPos << m_name << "_x_profPos";
00031   name_y_profPos << m_name << "_y_profPos";
00032   name_dxdz_profPos << m_name << "_dxdz_profPos";
00033   name_dydz_profPos << m_name << "_dydz_profPos";
00034   name_x_profNeg << m_name << "_x_profNeg";
00035   name_y_profNeg << m_name << "_y_profNeg";
00036   name_dxdz_profNeg << m_name << "_dxdz_profNeg";
00037   name_dydz_profNeg << m_name << "_dydz_profNeg";
00038   name_x_2d << m_name << "_x_2d";
00039   name_y_2d << m_name << "_y_2d";
00040   name_dxdz_2d << m_name << "_dxdz_2d";
00041   name_dydz_2d << m_name << "_dydz_2d";
00042   name_x_2dweight << m_name << "_x_2dweight";
00043   name_y_2dweight << m_name << "_y_2dweight";
00044   name_dxdz_2dweight << m_name << "_dxdz_2dweight";
00045   name_dydz_2dweight << m_name << "_dydz_2dweight";
00046   name_x_hist << m_name << "_x_hist";
00047   name_y_hist << m_name << "_y_hist";
00048   name_dxdz_hist << m_name << "_dxdz_hist";
00049   name_dydz_hist << m_name << "_dydz_hist";
00050   name_x_weights << m_name << "_x_weights";
00051   name_y_weights << m_name << "_y_weights";
00052   name_dxdz_weights << m_name << "_dxdz_weights";
00053   name_dydz_weights << m_name << "_dydz_weights";
00054   name_x_valweights << m_name << "_x_valweights";
00055   name_y_valweights << m_name << "_y_valweights";
00056   name_dxdz_valweights << m_name << "_dxdz_valweights";
00057   name_dydz_valweights << m_name << "_dydz_valweights";
00058 
00059   m_x_prof = module->bookProfile("/iterN/", name_x_prof.str().c_str(), "", m_bins, low, high);
00060   if (m_twodimensional) m_y_prof = module->bookProfile("/iterN/", name_y_prof.str().c_str(), "", m_bins, low, high);
00061   m_dxdz_prof = module->bookProfile("/iterN/", name_dxdz_prof.str().c_str(), "", m_bins, low, high);
00062   if (m_twodimensional) m_dydz_prof = module->bookProfile("/iterN/", name_dydz_prof.str().c_str(), "", m_bins, low, high);
00063   m_x_profPos = module->bookProfile("/iterN/", name_x_profPos.str().c_str(), "", m_bins, low, high);
00064   if (m_twodimensional) m_y_profPos = module->bookProfile("/iterN/", name_y_profPos.str().c_str(), "", m_bins, low, high);
00065   m_dxdz_profPos = module->bookProfile("/iterN/", name_dxdz_profPos.str().c_str(), "", m_bins, low, high);
00066   if (m_twodimensional) m_dydz_profPos = module->bookProfile("/iterN/", name_dydz_profPos.str().c_str(), "", m_bins, low, high);
00067   m_x_profNeg = module->bookProfile("/iterN/", name_x_profNeg.str().c_str(), "", m_bins, low, high);
00068   if (m_twodimensional) m_y_profNeg = module->bookProfile("/iterN/", name_y_profNeg.str().c_str(), "", m_bins, low, high);
00069   m_dxdz_profNeg = module->bookProfile("/iterN/", name_dxdz_profNeg.str().c_str(), "", m_bins, low, high);
00070   if (m_twodimensional) m_dydz_profNeg = module->bookProfile("/iterN/", name_dydz_profNeg.str().c_str(), "", m_bins, low, high);
00071   m_x_2d = module->book2D("/iterN/", name_x_2d.str().c_str(), "", m_bins, low, high, 80, -40., 40.);
00072   if (m_twodimensional) m_y_2d = module->book2D("/iterN/", name_y_2d.str().c_str(), "", m_bins, low, high, 80, -40., 40.);
00073   m_dxdz_2d = module->book2D("/iterN/", name_dxdz_2d.str().c_str(), "", m_bins, low, high, 80, -40., 40.);
00074   if (m_twodimensional) m_dydz_2d = module->book2D("/iterN/", name_dydz_2d.str().c_str(), "", m_bins, low, high, 80, -40., 40.);
00075   m_x_2dweight = module->book2D("/iterN/", name_x_2dweight.str().c_str(), "", m_bins, low, high, 80, -40., 40.);
00076   if (m_twodimensional) m_y_2dweight = module->book2D("/iterN/", name_y_2dweight.str().c_str(), "", m_bins, low, high, 80, -40., 40.);
00077   m_dxdz_2dweight = module->book2D("/iterN/", name_dxdz_2dweight.str().c_str(), "", m_bins, low, high, 80, -40., 40.);
00078   if (m_twodimensional) m_dydz_2dweight = module->book2D("/iterN/", name_dydz_2dweight.str().c_str(), "", m_bins, low, high, 80, -40., 40.);
00079   m_x_hist = module->book1D("/iterN/", name_x_hist.str().c_str(), "", m_bins, -MuonSystemMapPlot1D_xrange, MuonSystemMapPlot1D_xrange);
00080   if (m_twodimensional) m_y_hist = module->book1D("/iterN/", name_y_hist.str().c_str(), "", m_bins, -MuonSystemMapPlot1D_yrange, MuonSystemMapPlot1D_yrange);
00081   m_dxdz_hist = module->book1D("/iterN/", name_dxdz_hist.str().c_str(), "", m_bins, -MuonSystemMapPlot1D_dxdzrange, MuonSystemMapPlot1D_dxdzrange);
00082   if (m_twodimensional) m_dydz_hist = module->book1D("/iterN/", name_dydz_hist.str().c_str(), "", m_bins, -MuonSystemMapPlot1D_dydzrange, MuonSystemMapPlot1D_dydzrange);
00083   m_x_weights = module->book1D("/iterN/", name_x_weights.str().c_str(), "", m_bins, low, high);
00084   if (m_twodimensional) m_y_weights = module->book1D("/iterN/", name_y_weights.str().c_str(), "", m_bins, low, high);
00085   m_dxdz_weights = module->book1D("/iterN/", name_dxdz_weights.str().c_str(), "", m_bins, low, high);
00086   if (m_twodimensional) m_dydz_weights = module->book1D("/iterN/", name_dydz_weights.str().c_str(), "", m_bins, low, high);
00087   m_x_valweights = module->book1D("/iterN/", name_x_valweights.str().c_str(), "", m_bins, low, high);
00088   if (m_twodimensional) m_y_valweights = module->book1D("/iterN/", name_y_valweights.str().c_str(), "", m_bins, low, high);
00089   m_dxdz_valweights = module->book1D("/iterN/", name_dxdz_valweights.str().c_str(), "", m_bins, low, high);
00090   if (m_twodimensional) m_dydz_valweights = module->book1D("/iterN/", name_dydz_valweights.str().c_str(), "", m_bins, low, high);
00091 
00092   m_x_prof->SetAxisRange(-10., 10., "Y");
00093   if (m_twodimensional) m_y_prof->SetAxisRange(-10., 10., "Y");
00094   m_dxdz_prof->SetAxisRange(-10., 10., "Y");
00095   if (m_twodimensional) m_dydz_prof->SetAxisRange(-10., 10., "Y");
00096 
00097   m_x_profPos->SetAxisRange(-10., 10., "Y");
00098   if (m_twodimensional) m_y_profPos->SetAxisRange(-10., 10., "Y");
00099   m_dxdz_profPos->SetAxisRange(-10., 10., "Y");
00100   if (m_twodimensional) m_dydz_profPos->SetAxisRange(-10., 10., "Y");
00101 
00102   m_x_profNeg->SetAxisRange(-10., 10., "Y");
00103   if (m_twodimensional) m_y_profNeg->SetAxisRange(-10., 10., "Y");
00104   m_dxdz_profNeg->SetAxisRange(-10., 10., "Y");
00105   if (m_twodimensional) m_dydz_profNeg->SetAxisRange(-10., 10., "Y");
00106 }
00107 
00108 void MuonSystemMapPlot1D::fill_x(char charge, double abscissa, double residx, double chi2, int dof) {
00109    if (chi2 > 0.  &&  TMath::Prob(chi2, dof) < 0.95) {  // no spikes allowed
00110       double residual = residx * 10.;
00111       double weight = dof / chi2;
00112 
00113       if (fabs(residual) < MuonSystemMapPlot1D_xrange) {
00114          m_x_prof->Fill(abscissa, residual);
00115          if (charge > 0) m_x_profPos->Fill(abscissa, residual);
00116          else m_x_profNeg->Fill(abscissa, residual);
00117          int i = m_x_weights->FindBin(abscissa);
00118          m_x_weights->SetBinContent(i, m_x_weights->GetBinContent(i) + weight);
00119          m_x_valweights->SetBinContent(i, m_x_valweights->GetBinContent(i) + residual * weight);
00120       }
00121       m_x_2d->Fill(abscissa, residual);
00122       m_x_2dweight->Fill(abscissa, residual, weight);
00123       m_x_hist->Fill(residual, weight);
00124    }
00125 }
00126 
00127 void MuonSystemMapPlot1D::fill_y(char charge, double abscissa, double residy, double chi2, int dof) {
00128    if (m_twodimensional  &&  chi2 > 0.  &&  TMath::Prob(chi2, dof) < 0.95) {  // no spikes allowed
00129       double residual = residy * 10.;
00130       double weight = dof / chi2;
00131       
00132       if (fabs(residual) < MuonSystemMapPlot1D_yrange) {
00133          m_y_prof->Fill(abscissa, residual);
00134          if (charge > 0) m_y_profPos->Fill(abscissa, residual);
00135          else m_y_profNeg->Fill(abscissa, residual);
00136          int i = m_y_weights->FindBin(abscissa);
00137          m_y_weights->SetBinContent(i, m_y_weights->GetBinContent(i) + weight);
00138          m_y_valweights->SetBinContent(i, m_y_valweights->GetBinContent(i) + residual * weight);
00139       }
00140       m_y_2d->Fill(abscissa, residual);
00141       m_y_2dweight->Fill(abscissa, residual, weight);
00142       m_y_hist->Fill(residual, weight);
00143    }
00144 }
00145 
00146 void MuonSystemMapPlot1D::fill_dxdz(char charge, double abscissa, double slopex, double chi2, int dof) {
00147    if (chi2 > 0.  &&  TMath::Prob(chi2, dof) < 0.95) {  // no spikes allowed
00148       double residual = slopex * 1000.;
00149       double weight = dof / chi2;
00150       
00151       if (fabs(residual) < MuonSystemMapPlot1D_dxdzrange) {
00152          m_dxdz_prof->Fill(abscissa, residual);
00153          if (charge > 0) m_dxdz_profPos->Fill(abscissa, residual);
00154          else m_dxdz_profNeg->Fill(abscissa, residual);
00155          int i = m_dxdz_weights->FindBin(abscissa);
00156          m_dxdz_weights->SetBinContent(i, m_dxdz_weights->GetBinContent(i) + weight);
00157          m_dxdz_valweights->SetBinContent(i, m_dxdz_valweights->GetBinContent(i) + residual * weight);
00158       }
00159       m_dxdz_2d->Fill(abscissa, residual);
00160       m_dxdz_2dweight->Fill(abscissa, residual, weight);
00161       m_dxdz_hist->Fill(residual, weight);
00162    }
00163 }
00164 
00165 void MuonSystemMapPlot1D::fill_dydz(char charge, double abscissa, double slopey, double chi2, int dof) {
00166    if (m_twodimensional  &&  chi2 > 0.  &&  TMath::Prob(chi2, dof) < 0.95) {  // no spikes allowed
00167       double residual = slopey * 1000.;
00168       double weight = dof / chi2;
00169       
00170       if (fabs(residual) < MuonSystemMapPlot1D_dydzrange) {
00171          m_dydz_prof->Fill(abscissa, residual);
00172          if (charge > 0) m_dydz_profPos->Fill(abscissa, residual);
00173          else m_dydz_profNeg->Fill(abscissa, residual);
00174          int i = m_dydz_weights->FindBin(abscissa);
00175          m_dydz_weights->SetBinContent(i, m_dydz_weights->GetBinContent(i) + weight);
00176          m_dydz_valweights->SetBinContent(i, m_dydz_valweights->GetBinContent(i) + residual * weight);
00177       }
00178       m_dydz_2d->Fill(abscissa, residual);
00179       m_dydz_2dweight->Fill(abscissa, residual, weight);
00180       m_dydz_hist->Fill(residual, weight);
00181    }
00182 }