CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Protected Member Functions | Private Attributes
MuonResiduals6DOFrphiFitter Class Reference

#include <MuonResiduals6DOFrphiFitter.h>

Inheritance diagram for MuonResiduals6DOFrphiFitter:
MuonResidualsFitter

Public Types

enum  {
  kAlignX = 0, kAlignY, kAlignZ, kAlignPhiX,
  kAlignPhiY, kAlignPhiZ, kResidSigma, kResSlopeSigma,
  kAlpha, kResidGamma, kResSlopeGamma, kNPar
}
 
enum  {
  kResid = 0, kResSlope, kPositionX, kPositionY,
  kAngleX, kAngleY, kRedChi2, kNData
}
 
- Public Types inherited from MuonResidualsFitter
enum  { kPureGaussian, kPowerLawTails, kROOTVoigt, kGaussPowerTails }
 
enum  {
  k1DOF, k5DOF, k6DOF, k6DOFrphi,
  kPositionFitter, kAngleFitter, kAngleBfieldFitter
}
 

Public Member Functions

bool fit (Alignable *ali)
 
 MuonResiduals6DOFrphiFitter (int residualsModel, int minHits, const CSCGeometry *cscGeometry, bool weightAlignment=true)
 
int ndata ()
 
int npar ()
 
double plot (std::string name, TFileDirectory *dir, Alignable *ali)
 
double sumofweights ()
 
int type () const
 
- Public Member Functions inherited from MuonResidualsFitter
double errorerror (int parNum)
 
void fill (double *residual)
 
void fix (int parNum, bool value=true)
 
bool fixed (int parNum)
 
double loglikelihood ()
 
 MuonResidualsFitter (int residualsModel, int minHits, bool weightAlignment=true)
 
long numResiduals () const
 
long numsegments ()
 
void plotsimple (std::string name, TFileDirectory *dir, int which, double multiplier)
 
void plotweighted (std::string name, TFileDirectory *dir, int which, int whichredchi2, double multiplier)
 
void read (FILE *file, int which=0)
 
std::vector< double * >
::const_iterator 
residuals_begin () const
 
std::vector< double * >
::const_iterator 
residuals_end () const
 
int residualsModel () const
 
void setPrintLevel (int printLevel)
 
void setStrategy (int strategy)
 
double value (int parNum)
 
void write (FILE *file, int which=0)
 
virtual ~MuonResidualsFitter ()
 

Protected Member Functions

void inform (TMinuit *tMinuit)
 
- Protected Member Functions inherited from MuonResidualsFitter
bool dofit (void(*fcn)(int &, double *, double &, double *, int), std::vector< int > &parNum, std::vector< std::string > &parName, std::vector< double > &start, std::vector< double > &step, std::vector< double > &low, std::vector< double > &high)
 
void initialize_table ()
 

Private Attributes

const CSCGeometrym_cscGeometry
 

Additional Inherited Members

- Protected Attributes inherited from MuonResidualsFitter
std::vector< double > m_error
 
std::vector< bool > m_fixed
 
double m_loglikelihood
 
int m_minHits
 
int m_printLevel
 
std::vector< double * > m_residuals
 
int m_residualsModel
 
int m_strategy
 
std::vector< double > m_value
 
bool m_weightAlignment
 

Detailed Description

$Date: Thu Apr 16 21:29:15 CDT 2009

Revision:
1.3
Author
J. Pivarski - Texas A&M University pivar.nosp@m.ski@.nosp@m.physi.nosp@m.cs.t.nosp@m.amu.e.nosp@m.du

Definition at line 13 of file MuonResiduals6DOFrphiFitter.h.

Member Enumeration Documentation

anonymous enum
anonymous enum

Constructor & Destructor Documentation

MuonResiduals6DOFrphiFitter::MuonResiduals6DOFrphiFitter ( int  residualsModel,
int  minHits,
const CSCGeometry cscGeometry,
bool  weightAlignment = true 
)
inline

Definition at line 41 of file MuonResiduals6DOFrphiFitter.h.

tuple weightAlignment
Definition: align_cfg.py:24
MuonResidualsFitter(int residualsModel, int minHits, bool weightAlignment=true)

Member Function Documentation

bool MuonResiduals6DOFrphiFitter::fit ( Alignable ali)
virtual

Implements MuonResidualsFitter.

Definition at line 126 of file MuonResiduals6DOFrphiFitter.cc.

References MuonResidualsFitter::dofit(), MuonResidualsFitter::fixed(), MuonResidualsFitter::initialize_table(), kAlignPhiX, kAlignPhiY, kAlignPhiZ, kAlignX, kAlignY, kAlignZ, kAlpha, MuonResidualsFitter::kGaussPowerTails, MuonResidualsFitter::kPureGaussian, kResidGamma, kResidSigma, kResSlopeGamma, kResSlopeSigma, MuonResiduals6DOFrphiFitter_FCN(), mergeVDriftHistosByStation::name, MuonResidualsFitter::residualsModel(), launcher::step, and sumofweights().

126  {
127  initialize_table(); // if not already initialized
128  sumofweights();
129 
130  double resid_mean = 0;
131  double resslope_mean = 0;
132  double resid_stdev = 0.5;
133  double resslope_stdev = 0.005;
134  double alpha_estimate = 0;
135 
136  std::vector<int> num;
137  std::vector<std::string> name;
138  std::vector<double> start;
139  std::vector<double> step;
140  std::vector<double> low;
141  std::vector<double> high;
142 
143  if (fixed(kAlignX)) {
144  num.push_back(kAlignX); name.push_back(std::string("AlignX")); start.push_back(0.); step.push_back(0.1); low.push_back(0.); high.push_back(0.);
145  } else {
146  num.push_back(kAlignX); name.push_back(std::string("AlignX")); start.push_back(resid_mean); step.push_back(0.1); low.push_back(0.); high.push_back(0.);
147  }
148  num.push_back(kAlignY); name.push_back(std::string("AlignY")); start.push_back(0.); step.push_back(0.1); low.push_back(0.); high.push_back(0.);
149  num.push_back(kAlignZ); name.push_back(std::string("AlignZ")); start.push_back(0.); step.push_back(0.1); low.push_back(0.); high.push_back(0.);
150  num.push_back(kAlignPhiX); name.push_back(std::string("AlignPhiX")); start.push_back(0.); step.push_back(0.001); low.push_back(0.); high.push_back(0.);
151  if (fixed(kAlignPhiY)) {
152  num.push_back(kAlignPhiY); name.push_back(std::string("AlignPhiY")); start.push_back(0.); step.push_back(0.001); low.push_back(0.); high.push_back(0.);
153  } else {
154  num.push_back(kAlignPhiY); name.push_back(std::string("AlignPhiY")); start.push_back(resslope_mean); step.push_back(0.001); low.push_back(0.); high.push_back(0.);
155  }
156  num.push_back(kAlignPhiZ); name.push_back(std::string("AlignPhiZ")); start.push_back(0.); step.push_back(0.001); low.push_back(0.); high.push_back(0.);
157  num.push_back(kResidSigma); name.push_back(std::string("ResidSigma")); start.push_back(resid_stdev); step.push_back(0.01*resid_stdev); low.push_back(0.); high.push_back(0.);
158  num.push_back(kResSlopeSigma); name.push_back(std::string("ResSlopeSigma")); start.push_back(resslope_stdev); step.push_back(0.01*resslope_stdev); low.push_back(0.); high.push_back(0.);
159  num.push_back(kAlpha); name.push_back(std::string("Alpha")); start.push_back(alpha_estimate); step.push_back(0.01*resslope_stdev); low.push_back(0.); high.push_back(0.);
161  num.push_back(kResidGamma); name.push_back(std::string("ResidGamma")); start.push_back(0.1*resid_stdev); step.push_back(0.01*resid_stdev); low.push_back(0.); high.push_back(0.);
162  num.push_back(kResSlopeGamma); name.push_back(std::string("ResSlopeGamma")); start.push_back(0.1*resslope_stdev); step.push_back(0.01*resslope_stdev); low.push_back(0.); high.push_back(0.);
163  }
164 
165  return dofit(&MuonResiduals6DOFrphiFitter_FCN, num, name, start, step, low, high);
166 }
list step
Definition: launcher.py:15
bool dofit(void(*fcn)(int &, double *, double &, double *, int), std::vector< int > &parNum, std::vector< std::string > &parName, std::vector< double > &start, std::vector< double > &step, std::vector< double > &low, std::vector< double > &high)
bool fixed(int parNum)
void MuonResiduals6DOFrphiFitter_FCN(int &npar, double *gin, double &fval, double *par, int iflag)
long long int num
Definition: procUtils.cc:71
void MuonResiduals6DOFrphiFitter::inform ( TMinuit *  tMinuit)
protectedvirtual

Implements MuonResidualsFitter.

Definition at line 15 of file MuonResiduals6DOFrphiFitter.cc.

References MuonResiduals6DOFrphiFitter_TMinuit.

15  {
17 }
static TMinuit * MuonResiduals6DOFrphiFitter_TMinuit
int MuonResiduals6DOFrphiFitter::ndata ( )
inlinevirtual

Implements MuonResidualsFitter.

Definition at line 51 of file MuonResiduals6DOFrphiFitter.h.

References kNData.

int MuonResiduals6DOFrphiFitter::npar ( )
inlinevirtual
double MuonResiduals6DOFrphiFitter::plot ( std::string  name,
TFileDirectory dir,
Alignable ali 
)
virtual

Implements MuonResidualsFitter.

Definition at line 168 of file MuonResiduals6DOFrphiFitter.cc.

References CSCDetId, Alignable::geomDetId(), Alignable::globalPosition(), i, kAlignPhiX, kAlignPhiY, kAlignPhiZ, kAlignX, kAlignY, kAlignZ, kAlpha, kAngleX, kAngleY, MuonResidualsFitter::kGaussPowerTails, kPositionX, kPositionY, MuonResidualsFitter::kPowerLawTails, MuonResidualsFitter::kPureGaussian, kRedChi2, kResid, kResidGamma, kResidSigma, kResSlope, kResSlopeGamma, kResSlopeSigma, MuonResidualsFitter::kROOTVoigt, AlignableSurface::length(), m_cscGeometry, MuonResidualsFitter::m_weightAlignment, TFileDirectory::make(), MuonResiduals6DOFrphiFitter_effectiveR(), MuonResiduals6DOFrphiFitter_R, MuonResiduals6DOFrphiFitter_residual(), MuonResiduals6DOFrphiFitter_residual_trackdxdz_TF1(), MuonResiduals6DOFrphiFitter_residual_trackdydz_TF1(), MuonResiduals6DOFrphiFitter_residual_trackx_TF1(), MuonResiduals6DOFrphiFitter_residual_tracky_TF1(), MuonResiduals6DOFrphiFitter_resslope(), MuonResiduals6DOFrphiFitter_resslope_trackdxdz_TF1(), MuonResiduals6DOFrphiFitter_resslope_trackdydz_TF1(), MuonResiduals6DOFrphiFitter_resslope_trackx_TF1(), MuonResiduals6DOFrphiFitter_resslope_tracky_TF1(), MuonResiduals6DOFrphiFitter_sum_of_weights, MuonResidualsFitter_GaussPowerTails_TF1(), MuonResidualsFitter_powerLawTails_TF1(), MuonResidualsFitter_pureGaussian_TF1(), MuonResidualsFitter_ROOTVoigt_TF1(), npar(), NULL, funct::pow(), DetId::rawId(), MuonResidualsFitter::residuals_begin(), MuonResidualsFitter::residuals_end(), MuonResidualsFitter::residualsModel(), mathSSE::sqrt(), sumofweights(), Alignable::surface(), MuonResidualsFitter::value(), CommonMethods::weight(), AlignableSurface::width(), tablePrinter::width, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

168  {
169  sumofweights();
170 
171  MuonResiduals6DOFrphiFitter_R = sqrt(pow(ali->globalPosition().x(), 2) + pow(ali->globalPosition().y(), 2));
174 
175  std::stringstream name_residual, name_resslope, name_residual_raw, name_resslope_raw, name_residual_cut, name_alpha;
176  std::stringstream name_residual_trackx, name_resslope_trackx;
177  std::stringstream name_residual_tracky, name_resslope_tracky;
178  std::stringstream name_residual_trackdxdz, name_resslope_trackdxdz;
179  std::stringstream name_residual_trackdydz, name_resslope_trackdydz;
180 
181  name_residual << name << "_residual";
182  name_resslope << name << "_resslope";
183  name_residual_raw << name << "_residual_raw";
184  name_resslope_raw << name << "_resslope_raw";
185  name_residual_cut << name << "_residual_cut";
186  name_alpha << name << "_alpha";
187  name_residual_trackx << name << "_residual_trackx";
188  name_resslope_trackx << name << "_resslope_trackx";
189  name_residual_tracky << name << "_residual_tracky";
190  name_resslope_tracky << name << "_resslope_tracky";
191  name_residual_trackdxdz << name << "_residual_trackdxdz";
192  name_resslope_trackdxdz << name << "_resslope_trackdxdz";
193  name_residual_trackdydz << name << "_residual_trackdydz";
194  name_resslope_trackdydz << name << "_resslope_trackdydz";
195 
196  double width = ali->surface().width();
197  double length = ali->surface().length();
198  double min_residual = -100.; double max_residual = 100.;
199  double min_resslope = -100.; double max_resslope = 100.;
200  double min_trackx = -width/2.; double max_trackx = width/2.;
201  double min_tracky = -length/2.; double max_tracky = length/2.;
202  double min_trackdxdz = -1.5; double max_trackdxdz = 1.5;
203  double min_trackdydz = -1.5; double max_trackdydz = 1.5;
204 
205  TH1F *hist_residual = dir->make<TH1F>(name_residual.str().c_str(), "", 100, min_residual, max_residual);
206  TH1F *hist_resslope = dir->make<TH1F>(name_resslope.str().c_str(), "", 100, min_resslope, max_resslope);
207  TH1F *hist_residual_raw = dir->make<TH1F>(name_residual_raw.str().c_str(), "", 100, min_residual, max_residual);
208  TH1F *hist_resslope_raw = dir->make<TH1F>(name_resslope_raw.str().c_str(), "", 100, min_resslope, max_resslope);
209  TH1F *hist_residual_cut = dir->make<TH1F>(name_residual_cut.str().c_str(), "", 100, min_residual, max_residual);
210  TH2F *hist_alpha = dir->make<TH2F>(name_alpha.str().c_str(),"", 40, min_resslope, max_resslope, 40, -20., 20.);
211  TProfile *hist_residual_trackx = dir->make<TProfile>(name_residual_trackx.str().c_str(), "", 100, min_trackx, max_trackx, min_residual, max_residual);
212  TProfile *hist_resslope_trackx = dir->make<TProfile>(name_resslope_trackx.str().c_str(), "", 100, min_trackx, max_trackx, min_resslope, max_resslope);
213  TProfile *hist_residual_tracky = dir->make<TProfile>(name_residual_tracky.str().c_str(), "", 100, min_tracky, max_tracky, min_residual, max_residual);
214  TProfile *hist_resslope_tracky = dir->make<TProfile>(name_resslope_tracky.str().c_str(), "", 100, min_tracky, max_tracky, min_resslope, max_resslope);
215  TProfile *hist_residual_trackdxdz = dir->make<TProfile>(name_residual_trackdxdz.str().c_str(), "", 500, min_trackdxdz, max_trackdxdz, min_residual, max_residual);
216  TProfile *hist_resslope_trackdxdz = dir->make<TProfile>(name_resslope_trackdxdz.str().c_str(), "", 500, min_trackdxdz, max_trackdxdz, min_resslope, max_resslope);
217  TProfile *hist_residual_trackdydz = dir->make<TProfile>(name_residual_trackdydz.str().c_str(), "", 500, min_trackdydz, max_trackdydz, min_residual, max_residual);
218  TProfile *hist_resslope_trackdydz = dir->make<TProfile>(name_resslope_trackdydz.str().c_str(), "", 500, min_trackdydz, max_trackdydz, min_resslope, max_resslope);
219 
220  hist_residual_trackx->SetAxisRange(-10., 10., "Y");
221  hist_resslope_trackx->SetAxisRange(-10., 10., "Y");
222  hist_residual_tracky->SetAxisRange(-10., 10., "Y");
223  hist_resslope_tracky->SetAxisRange(-10., 10., "Y");
224  hist_residual_trackdxdz->SetAxisRange(-10., 10., "Y");
225  hist_resslope_trackdxdz->SetAxisRange(-10., 10., "Y");
226  hist_residual_trackdydz->SetAxisRange(-10., 10., "Y");
227  hist_resslope_trackdydz->SetAxisRange(-10., 10., "Y");
228 
229  name_residual << "_fit";
230  name_resslope << "_fit";
231  name_alpha << "_fit";
232  name_residual_trackx << "_fit";
233  name_resslope_trackx << "_fit";
234  name_residual_tracky << "_fit";
235  name_resslope_tracky << "_fit";
236  name_residual_trackdxdz << "_fit";
237  name_resslope_trackdxdz << "_fit";
238  name_residual_trackdydz << "_fit";
239  name_resslope_trackdydz << "_fit";
240 
241  TF1 *fit_residual = NULL;
242  TF1 *fit_resslope = NULL;
243  if (residualsModel() == kPureGaussian) {
244  fit_residual = new TF1(name_residual.str().c_str(), MuonResidualsFitter_pureGaussian_TF1, min_residual, max_residual, 3);
245  fit_residual->SetParameters(MuonResiduals6DOFrphiFitter_sum_of_weights * (max_residual - min_residual)/100., 10.*value(kAlignX), 10.*value(kResidSigma));
246  fit_resslope = new TF1(name_resslope.str().c_str(), MuonResidualsFitter_pureGaussian_TF1, min_resslope, max_resslope, 3);
247  fit_resslope->SetParameters(MuonResiduals6DOFrphiFitter_sum_of_weights * (max_resslope - min_resslope)/100., 1000.*value(kAlignPhiY), 1000.*value(kResSlopeSigma));
248  }
249  else if (residualsModel() == kPowerLawTails) {
250  fit_residual = new TF1(name_residual.str().c_str(), MuonResidualsFitter_powerLawTails_TF1, min_residual, max_residual, 4);
251  fit_residual->SetParameters(MuonResiduals6DOFrphiFitter_sum_of_weights * (max_residual - min_residual)/100., 10.*value(kAlignX), 10.*value(kResidSigma), 10.*value(kResidGamma));
252  fit_resslope = new TF1(name_resslope.str().c_str(), MuonResidualsFitter_powerLawTails_TF1, min_resslope, max_resslope, 4);
253  fit_resslope->SetParameters(MuonResiduals6DOFrphiFitter_sum_of_weights * (max_resslope - min_resslope)/100., 1000.*value(kAlignPhiY), 1000.*value(kResSlopeSigma), 1000.*value(kResSlopeGamma));
254  }
255  else if (residualsModel() == kROOTVoigt) {
256  fit_residual = new TF1(name_residual.str().c_str(), MuonResidualsFitter_ROOTVoigt_TF1, min_residual, max_residual, 4);
257  fit_residual->SetParameters(MuonResiduals6DOFrphiFitter_sum_of_weights * (max_residual - min_residual)/100., 10.*value(kAlignX), 10.*value(kResidSigma), 10.*value(kResidGamma));
258  fit_resslope = new TF1(name_resslope.str().c_str(), MuonResidualsFitter_ROOTVoigt_TF1, min_resslope, max_resslope, 4);
259  fit_resslope->SetParameters(MuonResiduals6DOFrphiFitter_sum_of_weights * (max_resslope - min_resslope)/100., 1000.*value(kAlignPhiY), 1000.*value(kResSlopeSigma), 1000.*value(kResSlopeGamma));
260  }
261  else if (residualsModel() == kGaussPowerTails) {
262  fit_residual = new TF1(name_residual.str().c_str(), MuonResidualsFitter_GaussPowerTails_TF1, min_residual, max_residual, 3);
263  fit_residual->SetParameters(MuonResiduals6DOFrphiFitter_sum_of_weights * (max_residual - min_residual)/100., 10.*value(kAlignX), 10.*value(kResidSigma));
264  fit_resslope = new TF1(name_resslope.str().c_str(), MuonResidualsFitter_GaussPowerTails_TF1, min_resslope, max_resslope, 3);
265  fit_resslope->SetParameters(MuonResiduals6DOFrphiFitter_sum_of_weights * (max_resslope - min_resslope)/100., 1000.*value(kAlignPhiY), 1000.*value(kResSlopeSigma));
266  }
267  else { assert(false); }
268 
269  fit_residual->SetLineColor(2); fit_residual->SetLineWidth(2);
270  fit_resslope->SetLineColor(2); fit_resslope->SetLineWidth(2);
271  fit_residual->Write();
272  fit_resslope->Write();
273 
274  TF1 *fit_alpha = new TF1(name_alpha.str().c_str(), "[0] + x*[1]", min_resslope, max_resslope);
275  fit_alpha->SetParameters(10.*value(kAlignX), 10.*value(kAlpha)/1000.);
276  fit_alpha->SetLineColor(2); fit_alpha->SetLineWidth(2);
277  fit_alpha->Write();
278 
279  TProfile *fit_residual_trackx = dir->make<TProfile>(name_residual_trackx.str().c_str(), "", 100, min_trackx, max_trackx);
280  TProfile *fit_resslope_trackx = dir->make<TProfile>(name_resslope_trackx.str().c_str(), "", 100, min_trackx, max_trackx);
281  TProfile *fit_residual_tracky = dir->make<TProfile>(name_residual_tracky.str().c_str(), "", 100, min_tracky, max_tracky);
282  TProfile *fit_resslope_tracky = dir->make<TProfile>(name_resslope_tracky.str().c_str(), "", 100, min_tracky, max_tracky);
283  TProfile *fit_residual_trackdxdz = dir->make<TProfile>(name_residual_trackdxdz.str().c_str(), "", 500, min_trackdxdz, max_trackdxdz);
284  TProfile *fit_resslope_trackdxdz = dir->make<TProfile>(name_resslope_trackdxdz.str().c_str(), "", 500, min_trackdxdz, max_trackdxdz);
285  TProfile *fit_residual_trackdydz = dir->make<TProfile>(name_residual_trackdydz.str().c_str(), "", 500, min_trackdydz, max_trackdydz);
286  TProfile *fit_resslope_trackdydz = dir->make<TProfile>(name_resslope_trackdydz.str().c_str(), "", 500, min_trackdydz, max_trackdydz);
287 
288  fit_residual_trackx->SetLineColor(2); fit_residual_trackx->SetLineWidth(2);
289  fit_resslope_trackx->SetLineColor(2); fit_resslope_trackx->SetLineWidth(2);
290  fit_residual_tracky->SetLineColor(2); fit_residual_tracky->SetLineWidth(2);
291  fit_resslope_tracky->SetLineColor(2); fit_resslope_tracky->SetLineWidth(2);
292  fit_residual_trackdxdz->SetLineColor(2); fit_residual_trackdxdz->SetLineWidth(2);
293  fit_resslope_trackdxdz->SetLineColor(2); fit_resslope_trackdxdz->SetLineWidth(2);
294  fit_residual_trackdydz->SetLineColor(2); fit_residual_trackdydz->SetLineWidth(2);
295  fit_resslope_trackdydz->SetLineColor(2); fit_resslope_trackdydz->SetLineWidth(2);
296 
297  name_residual_trackx << "line";
298  name_resslope_trackx << "line";
299  name_residual_tracky << "line";
300  name_resslope_tracky << "line";
301  name_residual_trackdxdz << "line";
302  name_resslope_trackdxdz << "line";
303  name_residual_trackdydz << "line";
304  name_resslope_trackdydz << "line";
305 
306  TF1 *fitline_residual_trackx = new TF1(name_residual_trackx.str().c_str(), MuonResiduals6DOFrphiFitter_residual_trackx_TF1, min_trackx, max_trackx, 12);
307  TF1 *fitline_resslope_trackx = new TF1(name_resslope_trackx.str().c_str(), MuonResiduals6DOFrphiFitter_resslope_trackx_TF1, min_trackx, max_trackx, 12);
308  TF1 *fitline_residual_tracky = new TF1(name_residual_tracky.str().c_str(), MuonResiduals6DOFrphiFitter_residual_tracky_TF1, min_tracky, max_tracky, 12);
309  TF1 *fitline_resslope_tracky = new TF1(name_resslope_tracky.str().c_str(), MuonResiduals6DOFrphiFitter_resslope_tracky_TF1, min_tracky, max_tracky, 12);
310  TF1 *fitline_residual_trackdxdz = new TF1(name_residual_trackdxdz.str().c_str(), MuonResiduals6DOFrphiFitter_residual_trackdxdz_TF1, min_trackdxdz, max_trackdxdz, 12);
311  TF1 *fitline_resslope_trackdxdz = new TF1(name_resslope_trackdxdz.str().c_str(), MuonResiduals6DOFrphiFitter_resslope_trackdxdz_TF1, min_trackdxdz, max_trackdxdz, 12);
312  TF1 *fitline_residual_trackdydz = new TF1(name_residual_trackdydz.str().c_str(), MuonResiduals6DOFrphiFitter_residual_trackdydz_TF1, min_trackdydz, max_trackdydz, 12);
313  TF1 *fitline_resslope_trackdydz = new TF1(name_resslope_trackdydz.str().c_str(), MuonResiduals6DOFrphiFitter_resslope_trackdydz_TF1, min_trackdydz, max_trackdydz, 12);
314 
315  double sum_resslope = 0.;
316  double sum_trackx = 0.;
317  double sum_tracky = 0.;
318  double sum_trackdxdz = 0.;
319  double sum_trackdydz = 0.;
320  for (std::vector<double*>::const_iterator resiter = residuals_begin(); resiter != residuals_end(); ++resiter) {
321  const double resslope = (*resiter)[MuonResiduals6DOFrphiFitter::kResSlope];
322  const double positionX = (*resiter)[MuonResiduals6DOFrphiFitter::kPositionX];
323  const double positionY = (*resiter)[MuonResiduals6DOFrphiFitter::kPositionY];
324  const double angleX = (*resiter)[MuonResiduals6DOFrphiFitter::kAngleX];
325  const double angleY = (*resiter)[MuonResiduals6DOFrphiFitter::kAngleY];
326  const double redchi2 = (*resiter)[MuonResiduals6DOFrphiFitter::kRedChi2];
327  double weight = 1./redchi2;
328  if (!m_weightAlignment) weight = 1.;
329 
330  if (!m_weightAlignment || TMath::Prob(redchi2*6, 6) < 0.99) { // no spikes allowed
331  sum_resslope += weight * resslope;
332  sum_trackx += weight * positionX;
333  sum_tracky += weight * positionY;
334  sum_trackdxdz += weight * angleX;
335  sum_trackdydz += weight * angleY;
336  }
337  }
338  double mean_resslope = sum_resslope / MuonResiduals6DOFrphiFitter_sum_of_weights;
339  double mean_trackx = sum_trackx / MuonResiduals6DOFrphiFitter_sum_of_weights;
340  double mean_tracky = sum_tracky / MuonResiduals6DOFrphiFitter_sum_of_weights;
341  double mean_trackdxdz = sum_trackdxdz / MuonResiduals6DOFrphiFitter_sum_of_weights;
342  double mean_trackdydz = sum_trackdydz / MuonResiduals6DOFrphiFitter_sum_of_weights;
343 
344  double fitparameters[12];
345  fitparameters[0] = value(kAlignX);
346  fitparameters[1] = value(kAlignY);
347  fitparameters[2] = value(kAlignZ);
348  fitparameters[3] = value(kAlignPhiX);
349  fitparameters[4] = value(kAlignPhiY);
350  fitparameters[5] = value(kAlignPhiZ);
351  fitparameters[6] = mean_trackx;
352  fitparameters[7] = mean_tracky;
353  fitparameters[8] = mean_trackdxdz;
354  fitparameters[9] = mean_trackdydz;
355  fitparameters[10] = value(kAlpha);
356  fitparameters[11] = mean_resslope;
357 
358  fitline_residual_trackx->SetParameters(fitparameters);
359  fitline_resslope_trackx->SetParameters(fitparameters);
360  fitline_residual_tracky->SetParameters(fitparameters);
361  fitline_resslope_tracky->SetParameters(fitparameters);
362  fitline_residual_trackdxdz->SetParameters(fitparameters);
363  fitline_resslope_trackdxdz->SetParameters(fitparameters);
364  fitline_residual_trackdydz->SetParameters(fitparameters);
365  fitline_resslope_trackdydz->SetParameters(fitparameters);
366 
367  fitline_residual_trackx->SetLineColor(2); fitline_residual_trackx->SetLineWidth(2);
368  fitline_resslope_trackx->SetLineColor(2); fitline_resslope_trackx->SetLineWidth(2);
369  fitline_residual_tracky->SetLineColor(2); fitline_residual_tracky->SetLineWidth(2);
370  fitline_resslope_tracky->SetLineColor(2); fitline_resslope_tracky->SetLineWidth(2);
371  fitline_residual_trackdxdz->SetLineColor(2); fitline_residual_trackdxdz->SetLineWidth(2);
372  fitline_resslope_trackdxdz->SetLineColor(2); fitline_resslope_trackdxdz->SetLineWidth(2);
373  fitline_residual_trackdydz->SetLineColor(2); fitline_residual_trackdydz->SetLineWidth(2);
374  fitline_resslope_trackdydz->SetLineColor(2); fitline_resslope_trackdydz->SetLineWidth(2);
375 
376  fitline_residual_trackx->Write();
377  fitline_resslope_trackx->Write();
378  fitline_residual_tracky->Write();
379  fitline_resslope_tracky->Write();
380  fitline_residual_trackdxdz->Write();
381  fitline_resslope_trackdxdz->Write();
382  fitline_residual_trackdydz->Write();
383  fitline_resslope_trackdydz->Write();
384 
385  for (std::vector<double*>::const_iterator resiter = residuals_begin(); resiter != residuals_end(); ++resiter) {
386  const double resid = (*resiter)[MuonResiduals6DOFrphiFitter::kResid];
387  const double resslope = (*resiter)[MuonResiduals6DOFrphiFitter::kResSlope];
388  const double positionX = (*resiter)[MuonResiduals6DOFrphiFitter::kPositionX];
389  const double positionY = (*resiter)[MuonResiduals6DOFrphiFitter::kPositionY];
390  const double angleX = (*resiter)[MuonResiduals6DOFrphiFitter::kAngleX];
391  const double angleY = (*resiter)[MuonResiduals6DOFrphiFitter::kAngleY];
392  const double redchi2 = (*resiter)[MuonResiduals6DOFrphiFitter::kRedChi2];
393  double weight = 1./redchi2;
394  if (!m_weightAlignment) weight = 1.;
395 
396  if (!m_weightAlignment || TMath::Prob(redchi2*6, 6) < 0.99) { // no spikes allowed
397  hist_alpha->Fill(1000.*resslope, 10.*resid);
398 
399  double geom_resid = MuonResiduals6DOFrphiFitter_residual(value(kAlignX), value(kAlignY), value(kAlignZ), value(kAlignPhiX), value(kAlignPhiY), value(kAlignPhiZ), positionX, positionY, angleX, angleY, MuonResiduals6DOFrphiFitter_effectiveR(positionX, positionY), value(kAlpha), resslope);
400  hist_residual->Fill(10.*(resid - geom_resid + value(kAlignX)), weight);
401  hist_residual_trackx->Fill(positionX, 10.*resid, weight);
402  hist_residual_tracky->Fill(positionY, 10.*resid, weight);
403  hist_residual_trackdxdz->Fill(angleX, 10.*resid, weight);
404  hist_residual_trackdydz->Fill(angleY, 10.*resid, weight);
405  fit_residual_trackx->Fill(positionX, 10.*geom_resid, weight);
406  fit_residual_tracky->Fill(positionY, 10.*geom_resid, weight);
407  fit_residual_trackdxdz->Fill(angleX, 10.*geom_resid, weight);
408  fit_residual_trackdydz->Fill(angleY, 10.*geom_resid, weight);
409 
410  double geom_resslope = MuonResiduals6DOFrphiFitter_resslope(value(kAlignX), value(kAlignY), value(kAlignZ), value(kAlignPhiX), value(kAlignPhiY), value(kAlignPhiZ), positionX, positionY, angleX, angleY, MuonResiduals6DOFrphiFitter_effectiveR(positionX, positionY));
411  hist_resslope->Fill(1000.*(resslope - geom_resslope + value(kAlignPhiY)), weight);
412  hist_resslope_trackx->Fill(positionX, 1000.*resslope, weight);
413  hist_resslope_tracky->Fill(positionY, 1000.*resslope, weight);
414  hist_resslope_trackdxdz->Fill(angleX, 1000.*resslope, weight);
415  hist_resslope_trackdydz->Fill(angleY, 1000.*resslope, weight);
416  fit_resslope_trackx->Fill(positionX, 1000.*geom_resslope, weight);
417  fit_resslope_tracky->Fill(positionY, 1000.*geom_resslope, weight);
418  fit_resslope_trackdxdz->Fill(angleX, 1000.*geom_resslope, weight);
419  fit_resslope_trackdydz->Fill(angleY, 1000.*geom_resslope, weight);
420  }
421 
422  hist_residual_raw->Fill(10.*resid);
423  hist_resslope_raw->Fill(1000.*resslope);
424  if (fabs(resslope) < 0.005) hist_residual_cut->Fill(10.*resid);
425  }
426 
427  double chi2 = 0.;
428  double ndof = 0.;
429  for (int i = 1; i <= hist_residual->GetNbinsX(); i++) {
430  double xi = hist_residual->GetBinCenter(i);
431  double yi = hist_residual->GetBinContent(i);
432  double yerri = hist_residual->GetBinError(i);
433  double yth = fit_residual->Eval(xi);
434  if (yerri > 0.) {
435  chi2 += pow((yth - yi)/yerri, 2);
436  ndof += 1.;
437  }
438  }
439  for (int i = 1; i <= hist_resslope->GetNbinsX(); i++) {
440  double xi = hist_resslope->GetBinCenter(i);
441  double yi = hist_resslope->GetBinContent(i);
442  double yerri = hist_resslope->GetBinError(i);
443  double yth = fit_resslope->Eval(xi);
444  if (yerri > 0.) {
445  chi2 += pow((yth - yi)/yerri, 2);
446  ndof += 1.;
447  }
448  }
449  ndof -= npar();
450 
451  return (ndof > 0. ? chi2 / ndof : -1.);
452 }
align::Scalar width() const
int i
Definition: DBlmapReader.cc:9
Double_t MuonResiduals6DOFrphiFitter_resslope_trackdxdz_TF1(Double_t *xvec, Double_t *par)
static double MuonResiduals6DOFrphiFitter_R
Double_t MuonResidualsFitter_powerLawTails_TF1(Double_t *xvec, Double_t *par)
Double_t MuonResiduals6DOFrphiFitter_residual_trackdxdz_TF1(Double_t *xvec, Double_t *par)
T y() const
Definition: PV3DBase.h:57
Double_t MuonResiduals6DOFrphiFitter_residual_tracky_TF1(Double_t *xvec, Double_t *par)
#define NULL
Definition: scimark2.h:8
double value(int parNum)
double MuonResiduals6DOFrphiFitter_resslope(double delta_x, double delta_y, double delta_z, double delta_phix, double delta_phiy, double delta_phiz, double track_x, double track_y, double track_dxdz, double track_dydz, double R)
double MuonResiduals6DOFrphiFitter_effectiveR(double x, double y)
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
Double_t MuonResiduals6DOFrphiFitter_resslope_trackdydz_TF1(Double_t *xvec, Double_t *par)
T sqrt(T t)
Definition: SSEVec.h:28
double MuonResiduals6DOFrphiFitter_residual(double delta_x, double delta_y, double delta_z, double delta_phix, double delta_phiy, double delta_phiz, double track_x, double track_y, double track_dxdz, double track_dydz, double R, double alpha, double resslope)
Double_t MuonResidualsFitter_GaussPowerTails_TF1(Double_t *xvec, Double_t *par)
const AlignableSurface & surface() const
Return the Surface (global position and orientation) of the object.
Definition: Alignable.h:126
Double_t MuonResidualsFitter_pureGaussian_TF1(Double_t *xvec, Double_t *par)
align::Scalar length() const
static double MuonResiduals6DOFrphiFitter_sum_of_weights
std::vector< double * >::const_iterator residuals_end() const
Double_t MuonResiduals6DOFrphiFitter_resslope_trackx_TF1(Double_t *xvec, Double_t *par)
Double_t MuonResiduals6DOFrphiFitter_residual_trackdydz_TF1(Double_t *xvec, Double_t *par)
Double_t MuonResiduals6DOFrphiFitter_resslope_tracky_TF1(Double_t *xvec, Double_t *par)
T * make() const
make new ROOT object
const PositionType & globalPosition() const
Return the global position of the object.
Definition: Alignable.h:129
const CSCGeometry * MuonResiduals6DOFrphiFitter_cscGeometry
Double_t MuonResiduals6DOFrphiFitter_residual_trackx_TF1(Double_t *xvec, Double_t *par)
Double_t MuonResidualsFitter_ROOTVoigt_TF1(Double_t *xvec, Double_t *par)
std::vector< double * >::const_iterator residuals_begin() const
T x() const
Definition: PV3DBase.h:56
const DetId & geomDetId() const
Definition: Alignable.h:177
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
static CSCDetId MuonResiduals6DOFrphiFitter_cscDetId
double MuonResiduals6DOFrphiFitter::sumofweights ( )
virtual

Implements MuonResidualsFitter.

Definition at line 106 of file MuonResiduals6DOFrphiFitter.cc.

References kRedChi2, MuonResidualsFitter::m_weightAlignment, MuonResiduals6DOFrphiFitter_number_of_hits, MuonResiduals6DOFrphiFitter_sum_of_weights, MuonResiduals6DOFrphiFitter_weightAlignment, MuonResidualsFitter::residuals_begin(), and MuonResidualsFitter::residuals_end().

Referenced by fit(), and plot().

106  {
110  for (std::vector<double*>::const_iterator resiter = residuals_begin(); resiter != residuals_end(); ++resiter) {
111  if (m_weightAlignment) {
112  double redchi2 = (*resiter)[MuonResiduals6DOFrphiFitter::kRedChi2];
113  if (TMath::Prob(redchi2*6, 6) < 0.99) { // no spikes allowed
116  }
117  }
118  else {
121  }
122  }
124 }
static double MuonResiduals6DOFrphiFitter_number_of_hits
static bool MuonResiduals6DOFrphiFitter_weightAlignment
static double MuonResiduals6DOFrphiFitter_sum_of_weights
std::vector< double * >::const_iterator residuals_end() const
std::vector< double * >::const_iterator residuals_begin() const
int MuonResiduals6DOFrphiFitter::type ( ) const
inlinevirtual

Member Data Documentation

const CSCGeometry* MuonResiduals6DOFrphiFitter::m_cscGeometry
private

Definition at line 61 of file MuonResiduals6DOFrphiFitter.h.

Referenced by plot().