CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/Alignment/MillePedeAlignmentAlgorithm/src/MillePedeMonitor.cc

Go to the documentation of this file.
00001 
00011 #include "DataFormats/GeometrySurface/interface/Surface.h" 
00012 #include "Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeMonitor.h"
00013 
00014 #include "DataFormats/TrackReco/interface/Track.h"
00015 
00016 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
00017 
00018 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00019 #include <Geometry/CommonDetUnit/interface/GeomDetUnit.h>
00020 #include <Geometry/CommonDetUnit/interface/GeomDetType.h>
00021 
00022 #include "Alignment/CommonAlignment/interface/Alignable.h"
00023 #include "Alignment/CommonAlignment/interface/AlignableBeamSpot.h"
00024 #include "Alignment/CommonAlignment/interface/AlignableDetOrUnitPtr.h"
00025 #include "Alignment/CommonAlignmentParametrization/interface/FrameToFrameDerivative.h"
00026 
00027 #include "DataFormats/DetId/interface/DetId.h"
00028 #include "DataFormats/SiStripDetId/interface/SiStripDetId.h"
00029 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00030 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
00031 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00032 const int kBPIX = PixelSubdetector::PixelBarrel;
00033 const int kFPIX = PixelSubdetector::PixelEndcap;
00034 
00035 #include <TProfile2D.h>
00036 #include <TFile.h>
00037 #include <TDirectory.h>
00038 #include <TMath.h>
00039 
00040 #include "Alignment/MillePedeAlignmentAlgorithm/interface/PedeLabelerBase.h"
00041 
00042 typedef TransientTrackingRecHit::ConstRecHitPointer   ConstRecHitPointer;
00043 
00044 //__________________________________________________________________
00045 MillePedeMonitor::MillePedeMonitor(const TrackerTopology* tTopo, const char *rootFileName)
00046   : myRootDir(0), myDeleteDir(false), trackerTopology(tTopo)
00047 {
00048   myRootDir = TFile::Open(rootFileName, "recreate");
00049   myDeleteDir = true;
00050 
00051   this->init(myRootDir);
00052 }
00053 
00054 //__________________________________________________________________
00055 MillePedeMonitor::MillePedeMonitor(TDirectory *rootDir, const TrackerTopology* tTopo) 
00056   : myRootDir(0), myDeleteDir(false), trackerTopology(tTopo)
00057 {
00058   //  cout << "MillePedeMonitor using input TDirectory" << endl;
00059 
00060   myRootDir = rootDir;
00061   myDeleteDir = false;
00062 
00063   this->init(myRootDir);
00064 }
00065 
00066 //__________________________________________________________________
00067 MillePedeMonitor::~MillePedeMonitor()
00068 {
00069 
00070   myRootDir->Write();
00071   if (myDeleteDir) delete myRootDir; //hists are deleted with their directory
00072 }
00073 
00074 //__________________________________________________________________
00075 bool MillePedeMonitor::init(TDirectory *directory)
00076 {
00077   if (!directory) return false;
00078   TDirectory *oldDir = gDirectory;
00079 
00080   const int kNumBins = 20;
00081   double binsPt[kNumBins+1] = {0.}; // fully initialised with 0.
00082   if (!this->equidistLogBins(binsPt, kNumBins, 0.8, 100.)) {
00083 //     cerr << "MillePedeMonitor::init: problem with log bins" << endl;
00084   }
00085   const int nHits = 35;
00086 
00087   myTrackHists1D.push_back(new TH1F("ptTrackLogBins",  "p_{t}(track);p_{t} [GeV]",
00088                                     kNumBins, binsPt));
00089 
00090   myTrackHists1D.push_back(new TH1F("ptTrack",  "p_{t}(track);p_{t} [GeV]",
00091                                     kNumBins, binsPt[0], binsPt[kNumBins]));
00092   myTrackHists1D.push_back(new TH1F("pTrack",  "p(track);p [GeV]",
00093                                     kNumBins, binsPt[0], 1.3*binsPt[kNumBins]));
00094   myTrackHists1D.push_back(new TH1F("etaTrack", "#eta(track);#eta", 26, -2.6, 2.6));
00095   myTrackHists1D.push_back(new TH1F("thetaTrack", "#theta(track);#theta", 100, 0., TMath::Pi()));
00096   myTrackHists1D.push_back(new TH1F("phiTrack", "#phi(track);#phi", 15, -TMath::Pi(), TMath::Pi()));
00097 
00098   myTrackHists1D.push_back(new TH1F("nHitTrack", "N_{hit}(track);N_{hit}", 40, 5., 45.));
00099   myTrackHists1D.push_back(new TH1F("nHitBPIXTrack", "N_{hit, BPIX}(track);N_{hit}", 45, 0., 45.));
00100   myTrackHists1D.push_back(new TH1F("nHitFPIXTrack", "N_{hit, FPIX}(track);N_{hit}", 45, 0., 45.));
00101   myTrackHists1D.push_back(new TH1F("nHitFPIXplusTrack", "N_{hit, BPIXplus}(track);N_{hit}", 45, 0., 45.));
00102   myTrackHists1D.push_back(new TH1F("nHitFPIXminusTrack", "N_{hit, BPIXminus}(track);N_{hit}", 45, 0., 45.));
00103   myTrackHists1D.push_back(new TH1F("nHitPIXELTrack", "N_{hit, PIXEL}(track);N_{hit}", 45, 0., 45.));
00104   myTrackHists1D.push_back(new TH1F("nHitTIBTrack", "N_{hit, TIB}(track);N_{hit}", 45, 0., 45.));
00105   myTrackHists1D.push_back(new TH1F("nHitTOBTrack", "N_{hit, TOB}(track);N_{hit}", 45, 0., 45.));
00106   myTrackHists1D.push_back(new TH1F("nHitTIDplusTrack", "N_{hit, TIDplus}(track);N_{hit}", 45, 0., 45.));
00107   myTrackHists1D.push_back(new TH1F("nHitTIDminusTrack", "N_{hit, TIDminus}(track);N_{hit}", 45, 0., 45.));
00108   myTrackHists1D.push_back(new TH1F("nHitTIDTrack", "N_{hit, TID}(track);N_{hit}", 45, 0., 45.));
00109   myTrackHists1D.push_back(new TH1F("nHitTECplusTrack", "N_{hit, TECplus}(track);N_{hit}", 45, 0., 45.));
00110   myTrackHists1D.push_back(new TH1F("nHitTECminusTrack", "N_{hit, TECminus}(track);N_{hit}", 45, 0., 45.));
00111   myTrackHists1D.push_back(new TH1F("nHitTECTrack", "N_{hit, TEC}(track);N_{hit}", 45, 0., 45.));
00112   myTrackHists1D.push_back(new TH1F("nHitENDCAPplusTrack", "N_{hit, ENDCAPplus}(track);N_{hit}", 45, 0., 45.));
00113   myTrackHists1D.push_back(new TH1F("nHitENDCAPminusTrack", "N_{hit, ENDCAPminus}(track);N_{hit}", 45, 0., 45.));
00114   myTrackHists1D.push_back(new TH1F("nHitENDCAPTrack", "N_{hit, ENDCAP}(track);N_{hit}", 45, 0., 45.));
00115   myTrackHists2D.push_back(new TH2F("nHitENDCAPTrackMinusVsPlus", "N_{hit, ENDCAP}(track);N_{hit, plus};N_{hit, minus}",
00116                                     45, 0., 45.,45, 0., 45.));
00117   myTrackHists1D.push_back(new TH1F("nHitInvalidTrack", "N_{hit, invalid}(track)", 5, 0., 5.));
00118   myTrackHists1D.push_back(new TH1F("r1Track", "r(1st hit);r [cm]", 20, 0., 20.));
00119   myTrackHists1D.push_back(new TH1F("phi1Track", "#phi(1st hit);#phi",
00120                                     30, -TMath::Pi(), TMath::Pi()));
00121   myTrackHists1D.push_back(new TH1F("y1Track", "y(1st hit);y [cm]", 40, -120., +120.));
00122   myTrackHists1D.push_back(new TH1F("z1Track", "z(1st hit);z [cm]", 20, -50, +50));
00123   myTrackHists1D.push_back(new TH1F("r1TrackSigned", "r(1st hit);r_{#pm} [cm]",
00124                                     40, -120., 120.));
00125   myTrackHists1D.push_back(new TH1F("z1TrackFull", "z(1st hit);z [cm]", 20, -300., +300.));
00126   myTrackHists1D.push_back(new TH1F("rLastTrack", "r(last hit);r [cm]", 20, 20., 120.));
00127   myTrackHists1D.push_back(new TH1F("phiLastTrack", "#phi(last hit);#phi",
00128                                     30, -TMath::Pi(), TMath::Pi()));
00129   myTrackHists1D.push_back(new TH1F("yLastTrack", "y(last hit);y [cm]", 40, -120., +120.));
00130   myTrackHists1D.push_back(new TH1F("zLastTrack", "z(last hit);z [cm]", 30, -300., +300.));
00131   myTrackHists1D.push_back(new TH1F("chi2PerNdf", "#chi^{2}/ndf;#chi^{2}/ndf", 500, 0., 50.));
00132   myTrackHists1D.push_back(new TH1F("impParZ", "impact parameter in z", 20, -20., 20.));
00133   myTrackHists1D.push_back(new TH1F("impParErrZ", "error of impact parameter in z",
00134                                     40, 0., 0.06));  
00135   myTrackHists1D.push_back(new TH1F("impParRphi", "impact parameter in r#phi", 51, -0.05, .05));
00136   myTrackHists1D.push_back(new TH1F("impParErrRphi", "error of impact parameter in r#phi",
00137                                     50, 0., 0.01));
00138 
00139   myTrackHists2D.push_back(new TH2F("rz1TrackFull", "rz(1st hit);z [cm]; r_{#pm} [cm]",
00140                                     40, -282., +282., 40, -115., +115.));
00141   myTrackHists2D.push_back(new TH2F("xy1Track", "xy(1st hit);x [cm]; y [cm]",
00142                                     40, -115., +115., 40, -115., +115.));
00143   
00144   TDirectory *dirTracks = directory->mkdir("trackHists", "input tracks");
00145   this->addToDirectory(myTrackHists1D, dirTracks);
00146   this->addToDirectory(myTrackHists2D, dirTracks);
00147 
00148 // used track 
00149   myUsedTrackHists1D = this->cloneHists(myTrackHists1D, "used", " (used tracks)");
00150   myUsedTrackHists2D = this->cloneHists(myTrackHists2D, "used", " (used tracks)");
00151   // must be after clone: index in vector!
00152   myUsedTrackHists1D.push_back(new TH1F("usedHitsX", "n(x-hits) transferred to pede;n(x-hits)", nHits, 0., nHits));
00153   myUsedTrackHists1D.push_back(new TH1F("usedHitsY", "n(y-hits) transferred to pede;n(y-hits)", 10, 0., 10));
00154 
00155   TDirectory *dirUsedTracks = directory->mkdir("usedTrackHists", "used tracks");
00156   this->addToDirectory(myUsedTrackHists1D, dirUsedTracks);
00157   this->addToDirectory(myUsedTrackHists2D, dirUsedTracks);
00158 
00159 // ReferenceTrajectory
00160   myTrajectoryHists1D.push_back(new TH1F("validRefTraj", "validity of ReferenceTrajectory",
00161                                          2, 0., 2.));
00162 
00163   myTrajectoryHists2D.push_back(new TProfile2D("profCorr",
00164                                                "mean of |#rho|, #rho#neq0;hit x/y;hit x/y;",
00165                                                2*nHits, 0., nHits, 2*nHits, 0., nHits));
00166   myTrajectoryHists2D.push_back
00167     (new TProfile2D("profCorrOffXy", "mean of |#rho|, #rho#neq0, no xy_{hit};hit x/y;hit x/y;",
00168                     2*nHits, 0., nHits, 2*nHits, 0., nHits));
00169 
00170   myTrajectoryHists2D.push_back(new TH2F("hitCorrOffBlock",
00171                                          "hit correlations: off-block-diagonals;N(hit);#rho",
00172                                          2*nHits, 0., nHits, 81, -.06, .06));
00173   TArrayD logBins(102);
00174   this->equidistLogBins(logBins.GetArray(), logBins.GetSize()-1, 1.E-11, .1);
00175   myTrajectoryHists2D.push_back(new TH2F("hitCorrOffBlockLog",
00176                                          "hit correlations: off-block-diagonals;N(hit);|#rho|",
00177                                          2*nHits, 0., nHits, logBins.GetSize()-1, logBins.GetArray()));
00178 
00179   myTrajectoryHists2D.push_back(new TH2F("hitCorrXy", "hit correlations: xy;N(hit);#rho",
00180                                          nHits, 0., nHits, 81, -.5, .5));
00181   myTrajectoryHists2D.push_back
00182     (new TH2F("hitCorrXyValid", "hit correlations: xy, 2D-det.;N(hit);#rho",
00183               nHits, 0., nHits, 81, -.02, .02));
00184   this->equidistLogBins(logBins.GetArray(), logBins.GetSize()-1, 1.E-10, .5);
00185   myTrajectoryHists2D.push_back(new TH2F("hitCorrXyLog", "hit correlations: xy;N(hit);|#rho|",
00186                                          nHits, 0., nHits, logBins.GetSize()-1, logBins.GetArray()));
00187   myTrajectoryHists2D.push_back
00188     (new TH2F("hitCorrXyLogValid", "hit correlations: xy, 2D-det.;N(hit);|#rho|",
00189               nHits, 0., nHits, logBins.GetSize()-1, logBins.GetArray()));
00190 
00191 
00192   myTrajectoryHists1D.push_back(new TH1F("measLocX", "local x measurements;x", 101, -6., 6.));
00193   myTrajectoryHists1D.push_back(new TH1F("measLocY", "local y measurements, 2D-det.;y",
00194                                          101, -10., 10.));
00195   myTrajectoryHists1D.push_back(new TH1F("trajLocX", "local x trajectory;x", 101, -6., 6.));
00196   myTrajectoryHists1D.push_back(new TH1F("trajLocY", "local y trajectory, 2D-det.;y",
00197                                          101, -10., 10.));
00198 
00199   myTrajectoryHists1D.push_back(new TH1F("residLocX", "local x residual;#Deltax", 101, -.75, .75));
00200   myTrajectoryHists1D.push_back(new TH1F("residLocY", "local y residual, 2D-det.;#Deltay",
00201                                          101, -2., 2.));
00202   myTrajectoryHists1D.push_back(new TH1F("reduResidLocX", "local x reduced residual;#Deltax/#sigma",
00203                                          101, -20., 20.));
00204   myTrajectoryHists1D.push_back
00205     (new TH1F("reduResidLocY", "local y reduced residual, 2D-det.;#Deltay/#sigma", 101, -20., 20.));
00206 
00207   // 2D vs. hit
00208   myTrajectoryHists2D.push_back(new TH2F("measLocXvsHit", "local x measurements;hit;x", 
00209                                          nHits, 0., nHits, 101, -6., 6.));
00210   myTrajectoryHists2D.push_back(new TH2F("measLocYvsHit", "local y measurements, 2D-det.;hit;y",
00211                                          nHits, 0., nHits, 101, -10., 10.));
00212   myTrajectoryHists2D.push_back(new TH2F("trajLocXvsHit", "local x trajectory;hit;x",
00213                                          nHits, 0., nHits, 101, -6., 6.));
00214   myTrajectoryHists2D.push_back(new TH2F("trajLocYvsHit", "local y trajectory, 2D-det.;hit;y",
00215                                          nHits, 0., nHits,  101, -10., 10.));
00216 
00217   myTrajectoryHists2D.push_back(new TH2F("residLocXvsHit", "local x residual;hit;#Deltax",
00218                                          nHits, 0., nHits, 101, -.75, .75));
00219   myTrajectoryHists2D.push_back(new TH2F("residLocYvsHit", "local y residual, 2D-det.;hit;#Deltay",
00220                                          nHits, 0., nHits, 101, -1., 1.));
00221   myTrajectoryHists2D.push_back
00222     (new TH2F("reduResidLocXvsHit", "local x reduced residual;hit;#Deltax/#sigma",
00223               nHits, 0., nHits, 101, -20., 20.));
00224   myTrajectoryHists2D.push_back
00225     (new TH2F("reduResidLocYvsHit", "local y reduced residual, 2D-det.;hit;#Deltay/#sigma",
00226               nHits, 0., nHits, 101, -20., 20.));
00227 
00228 
00229   myTrajectoryHists2D.push_back(new TProfile2D("profDerivatives",
00230                                                "mean derivatives;hit x/y;parameter;",
00231                                                2*nHits, 0., nHits, 10, 0., 10.));
00232 
00233   myTrajectoryHists2D.push_back
00234     (new TH2F("derivatives", "derivative;parameter;#partial(x/y)_{local}/#partial(param)",
00235               10, 0., 10., 101, -20., 20.));
00236   this->equidistLogBins(logBins.GetArray(), logBins.GetSize()-1, 1.E-12, 100.);
00237   myTrajectoryHists2D.push_back
00238     (new TH2F("derivativesLog", "|derivative|;parameter;|#partial(x/y)_{local}/#partial(param)|",
00239               10, 0., 10., logBins.GetSize()-1, logBins.GetArray()));
00240   myTrajectoryHists2D.push_back
00241     (new TH2F("derivativesVsPhi", 
00242               "derivatives vs. #phi;#phi(geomDet);#partial(x/y)_{local}/#partial(param)",
00243               50, -TMath::Pi(), TMath::Pi(), 101, -300., 300.));
00244   //  myTrajectoryHists2D.back()->SetBit(TH1::kCanRebin);
00245 
00246   TDirectory *dirTraject = directory->mkdir("refTrajectoryHists", "ReferenceTrajectory's");
00247   this->addToDirectory(myTrajectoryHists2D, dirTraject);
00248   this->addToDirectory(myTrajectoryHists1D, dirTraject);
00249 
00250 // derivatives hists
00251   myDerivHists2D.push_back
00252     (new TH2F("localDerivsPar","local derivatives vs. paramater;parameter;#partial/#partial(param)",
00253               6, 0., 6., 101, -200., 200.));
00254   myDerivHists2D.push_back
00255     (new TH2F("localDerivsPhi","local derivatives vs. #phi(det);#phi(det);#partial/#partial(param)",
00256               51, -TMath::Pi(), TMath::Pi(), 101, -150., 150.));
00257   this->equidistLogBins(logBins.GetArray(), logBins.GetSize()-1, 1.E-13, 150.);
00258   myDerivHists2D.push_back
00259     (new TH2F("localDerivsParLog",
00260               "local derivatives (#neq 0) vs. parameter;parameter;|#partial/#partial(param)|",
00261               6, 0., 6., logBins.GetSize()-1, logBins.GetArray()));
00262   myDerivHists2D.push_back
00263     (new TH2F("localDerivsPhiLog",
00264               "local derivatives (#neq 0) vs. #phi(det);#phi(det);|#partial/#partial(param)|",
00265               51, -TMath::Pi(), TMath::Pi(), logBins.GetSize()-1, logBins.GetArray()));
00266   const unsigned int maxParNum = PedeLabelerBase::theMaxNumParam;
00267   myDerivHists2D.push_back
00268     (new TH2F("globalDerivsPar",
00269               "global derivatives vs. paramater;parameter;#partial/#partial(param)",
00270               maxParNum, 0., maxParNum, 100, -200, 200));
00271   myDerivHists2D.push_back
00272     (new TH2F("globalDerivsPhi",
00273               "global derivatives vs. #phi(det);#phi(det);#partial/#partial(param)",
00274               51, -TMath::Pi(), TMath::Pi(), 102, -1.02, 1.02));
00275   this->equidistLogBins(logBins.GetArray(), logBins.GetSize()-1, 1.E-7, 5.e2);
00276   myDerivHists2D.push_back
00277     (new TH2F("globalDerivsParLog",
00278               "global derivatives (#neq 0) vs. parameter;parameter;|#partial/#partial(param)|",
00279               maxParNum, 0., maxParNum, logBins.GetSize()-1, logBins.GetArray()));
00280   myDerivHists2D.push_back
00281     (new TH2F("globalDerivsPhiLog",
00282               "global derivatives (#neq 0) vs. #phi(det);#phi(det);|#partial/#partial(param)|",
00283               51, -TMath::Pi(), TMath::Pi(), logBins.GetSize()-1, logBins.GetArray()));
00284 //   this->equidistLogBins(logBins.GetArray(), logBins.GetSize()-1, 1.e-40, 1.E-35);
00285 //   myDerivHists2D.push_back
00286 //     (new TH2F("globalDerivsPhiLog2",
00287 //               "global derivatives (#neq 0) vs. #phi(det);#phi(det);|#partial/#partial(param)|",
00288 //               51, -TMath::Pi(), TMath::Pi(), logBins.GetSize()-1, logBins.GetArray()));
00289 
00290   TDirectory *dirDerivs = directory->mkdir("derivatives", "derivatives etc.");
00291   this->addToDirectory(myDerivHists2D, dirDerivs);
00292 
00293 // residual hists
00294   myResidHists2D.push_back(new TH2F("residPhi","residuum vs. #phi(det);#phi(det);residuum[cm]",
00295                                     51, -TMath::Pi(), TMath::Pi(), 101, -.5, .5));
00296   myResidHists2D.push_back(new TH2F("sigmaPhi","#sigma vs. #phi(det);#phi(det);#sigma[cm]",
00297                                     51, -TMath::Pi(), TMath::Pi(), 101, .0, .1));
00298   myResidHists2D.push_back(new TH2F("reduResidPhi",
00299                                     "residuum/#sigma vs. #phi(det);#phi(det);residuum/#sigma",
00300                                     51, -TMath::Pi(), TMath::Pi(), 101, -14., 14.));
00301   
00302 //   myResidHists2D.push_back(new TProfile2D("residXProfXy",
00303 //                                        "mean |residuum| (u);x [cm];y [cm];#LT|residuum|#GT",
00304 //                                        25, -110., 110., 25, -110., 110.));
00305 //   myResidHists2D.push_back(new TProfile2D("residXProfZr",
00306 //                                        "mean |residuum| (u);z [cm];r_{#pm} [cm];#LT|residuum|#GT",
00307 //                                        25, -275., 275., 25, -110., 110.));
00308 //   myResidHists2D.push_back(new TProfile2D("residYProfXy",
00309 //                                        "mean |residuum| (v);x [cm];y [cm];#LT|residuum|#GT",
00310 //                                        25, -110., 110., 25, -110., 110.));
00311 //   myResidHists2D.push_back(new TProfile2D("residYProfZr",
00312 //                                        "mean |residuum| (v);z [cm];r_{#pm} [cm];#LT|residuum|#GT",
00313 //                                        25, -275., 275., 25, -110., 110.));
00314 //   myResidHists2D.push_back(new TProfile2D("reduResidXProfXy",
00315 //                                        "mean |residuum/#sigma| (u);x [cm];y [cm];#LT|res./#sigma|#GT",
00316 //                                        25, -110., 110., 25, -110., 110.));
00317 //   myResidHists2D.push_back(new TProfile2D("reduResidXProfZr",
00318 //                                        "mean |residuum/#sigma| (u);z [cm];r_{#pm} [cm];#LT|res./#sigma|#GT",
00319 //                                        25, -275., 275., 25, -110., 110.));
00320 //   myResidHists2D.push_back(new TProfile2D("reduResidYProfXy",
00321 //                                        "mean |residuum/#sigma| (v);x [cm];y [cm];#LT|res./#sigma|#GT",
00322 //                                        25, -110., 110., 25, -110., 110.));
00323 //   myResidHists2D.push_back(new TProfile2D("reduResidYProfZr",
00324 //                                        "mean |residuum/#sigma| (v);z [cm];r_{#pm} [cm];#LT|res./#sigma|#GT",
00325 //                                        25, -275., 275., 25, -110., 110.));
00326 //   myResidHists2D.push_back(new TProfile2D("sigmaXProfXy",
00327 //                                        "mean sigma (u);x [cm];y [cm];#LT#sigma#GT",
00328 //                                        25, -110., 110., 25, -110., 110.));
00329 //   myResidHists2D.push_back(new TProfile2D("sigmaXProfZr",
00330 //                                        "mean sigma (u);z [cm];r_{#pm} [cm];#LT#sigma#GT",
00331 //                                        25, -275., 275., 25, -110., 110.));
00332 //   myResidHists2D.push_back(new TProfile2D("sigmaYProfXy",
00333 //                                        "mean sigma (v);x [cm];y [cm];#LT#sigma#GT",
00334 //                                        25, -110., 110., 25, -110., 110.));
00335 //   myResidHists2D.push_back(new TProfile2D("sigmaYProfZr",
00336 //                                        "mean sigma (v);z [cm];r_{#pm} [cm];#LT#sigma#GT",
00337 //                                        25, -275., 275., 25, -110., 110.));
00338   
00339   TDirectory *dirResid = directory->mkdir("residuals", "hit residuals, sigma,...");
00340   this->addToDirectory(myResidHists2D, dirResid);
00341 
00342 // Residuum, hit sigma and res./sigma for all sensor/track angles and separated for large and
00343 // small angles with respect to the sensor normal in sensitive direction. 
00344   // Here for x-measurements:
00345   std::vector<TH1*> allResidHistsX;
00346   allResidHistsX.push_back(new TH1F("resid", "hit residuals;residuum [cm]", 101,-.5,.5));//51,-.05, .05));
00347   //allResidHistsX.back()->SetBit(TH1::kCanRebin);
00348   allResidHistsX.push_back(new TH1F("sigma", "hit uncertainties;#sigma [cm]", 100,0.,1.));//50, 0., .02));
00349   //allResidHistsX.back()->SetBit(TH1::kCanRebin);
00350   allResidHistsX.push_back(new TH1F("reduResid", "reduced hit residuals;res./#sigma",
00351                                     101, -10., 10.));//51, -3., 3.));
00352   //  allResidHistsX.back()->SetBit(TH1::kCanRebin);
00353   allResidHistsX.push_back(new TH1F("angle", "#phi_{tr} wrt normal (sens. plane);#phi_{n}^{sens}",
00354                                     50, 0., TMath::PiOver2()));
00355   allResidHistsX.push_back(new TH2F("residVsAngle",
00356                                     "residuum vs. #phi_{tr} wrt normal (sens. plane);#phi_{n}^{sens};residuum [cm]",
00357                                     50, 0., TMath::PiOver2(), 51, -1., 1.));
00358   this->equidistLogBins(logBins.GetArray(), logBins.GetSize()-1, 1.E-6, 100.);
00359   allResidHistsX.push_back(new TH2F("sigmaVsAngle",
00360                                     "#sigma vs. #phi_{tr} wrt normal (sens. plane);#phi_{n}^{sens};#sigma [cm]",
00361                                     50, 0., TMath::PiOver2(), logBins.GetSize()-1, logBins.GetArray()));
00362   allResidHistsX.push_back(new TH2F("reduResidVsAngle",
00363                                     "reduced residuum vs. #phi_{tr} wrt normal (sens. plane);#phi_{n}^{sens};res./#sigma",
00364                                     50, 0., TMath::PiOver2(), 51, -15., 15.));
00365 
00366   allResidHistsX.push_back(new TH1F("residGt45",
00367                                     "hit residuals (#phi_{n}^{sens}>45#circ);residuum [cm]",
00368                                     101, -.5, .5));//51, -.05, .05));
00369   // allResidHistsX.back()->SetBit(TH1::kCanRebin);
00370   allResidHistsX.push_back(new TH1F("sigmaGt45",
00371                                     "hit uncertainties(#phi_{n}^{sens}>45#circ);#sigma [cm]",
00372                                      100, 0., 1.));//50, 0., .02));
00373   // allResidHistsX.back()->SetBit(TH1::kCanRebin);
00374   allResidHistsX.push_back(new TH1F("reduResidGt45",
00375                                     "reduced hit residuals(#phi_{n}^{sens}>45#circ);res./#sigma",
00376                                     101, -10., 10.));//51,-3.,3.));
00377   // allResidHistsX.back()->SetBit(TH1::kCanRebin);
00378   allResidHistsX.push_back(new TH1F("residLt45",
00379                                     "hit residuals (#phi_{n}^{sens}<45#circ);residuum [cm]",
00380                                     101, -.5, .5));//51, -.15, .15));
00381   // allResidHistsX.back()->SetBit(TH1::kCanRebin);
00382   allResidHistsX.push_back(new TH1F("sigmaLt45",
00383                                     "hit uncertainties(#phi_{n}^{sens}<45#circ);#sigma [cm]",
00384                                     100, 0., 1.));//50, 0., .01));
00385   // allResidHistsX.back()->SetBit(TH1::kCanRebin);
00386   allResidHistsX.push_back(new TH1F("reduResidLt45",
00387                                     "reduced hit residuals(#phi_{n}^{sens}<45#circ);res./#sigma",
00388                                     101, -10., 10.));//51,-3.,3.));
00389   myResidHistsVec1DX.push_back(allResidHistsX); // at [0] for all subdets together...
00390   // ... then separately - indices/order like DetId.subdetId() in tracker:
00391   myResidHistsVec1DX.push_back(this->cloneHists(allResidHistsX, "TPB", " x-coord. in pixel barrel"));
00392   myResidHistsVec1DX.push_back(this->cloneHists(allResidHistsX, "TPE", " x-coord. in pixel discs"));
00393   myResidHistsVec1DX.push_back(this->cloneHists(allResidHistsX, "TIB", " x-coord. in TIB"));
00394   myResidHistsVec1DX.push_back(this->cloneHists(allResidHistsX, "TID", " x-coord. in TID"));
00395   myResidHistsVec1DX.push_back(this->cloneHists(allResidHistsX, "TOB", " x-coord. in TOB"));
00396   myResidHistsVec1DX.push_back(this->cloneHists(allResidHistsX, "TEC", " x-coord. in TEC"));
00397   // finally, differential in hit number (but subdet independent)
00398   for (unsigned int iHit = 0; iHit < 30; ++iHit) { // 4: for each hit fill only angle independent plots
00399     for (unsigned int iHist = 0; iHist < 4 && iHist < allResidHistsX.size(); ++iHist) {
00400       TH1 *h = allResidHistsX[iHist];
00401       myResidHitHists1DX.push_back(static_cast<TH1*>(h->Clone(Form("%s_%d", h->GetName(), iHit))));
00402       myResidHitHists1DX.back()->SetTitle(Form("%s, hit %d", h->GetTitle(), iHit));
00403     }
00404   }
00405 
00406   TDirectory *dirResidX =
00407     (dirResid ? dirResid : directory)->mkdir("X", "hit residuals etc. for x measurements");
00408   this->addToDirectory(myResidHitHists1DX, dirResidX);
00409   for (std::vector<std::vector<TH1*> >::iterator vecIter = myResidHistsVec1DX.begin(),
00410          vecIterEnd = myResidHistsVec1DX.end(); vecIter != vecIterEnd; ++vecIter) {
00411     this->addToDirectory(*vecIter, dirResidX);
00412   }
00413 
00414   // Now clone the same as above for y-ccordinate:
00415   myResidHistsVec1DY.push_back(this->cloneHists(allResidHistsX, "", " y-coord."));// all subdets
00416   std::vector<TH1*> &yHists1D = allResidHistsX;//myResidHistsVec1DY.back(); crashes? ROOT?
00417   myResidHistsVec1DY.push_back(this->cloneHists(yHists1D, "TPB", " y-coord. in pixel barrel"));
00418   myResidHistsVec1DY.push_back(this->cloneHists(yHists1D, "TPE", " y-coord. in pixel discs"));
00419   myResidHistsVec1DY.push_back(this->cloneHists(yHists1D, "TIB", " y-coord. in TIB"));
00420   myResidHistsVec1DY.push_back(this->cloneHists(yHists1D, "TID", " y-coord. in TID"));
00421   myResidHistsVec1DY.push_back(this->cloneHists(yHists1D, "TOB", " y-coord. in TOB"));
00422   myResidHistsVec1DY.push_back(this->cloneHists(yHists1D, "TEC", " y-coord. in TEC"));
00423   myResidHitHists1DY = this->cloneHists(myResidHitHists1DX, "", " y-coord.");// diff. in nHit
00424 
00425   TDirectory *dirResidY = 
00426     (dirResid ? dirResid : directory)->mkdir("Y", "hit residuals etc. for y measurements");
00427   this->addToDirectory(myResidHitHists1DY, dirResidY);
00428   for (std::vector<std::vector<TH1*> >::iterator vecIter = myResidHistsVec1DY.begin(),
00429          vecIterEnd = myResidHistsVec1DY.end(); vecIter != vecIterEnd; ++vecIter) {
00430     this->addToDirectory(*vecIter, dirResidY);
00431   }
00432 
00433   // farme-to-frame derivatives
00434   myFrame2FrameHists2D.push_back(new TProfile2D("frame2frame",
00435                                                 "mean frame to frame derivatives;col;row",
00436                                                 6, 0., 6., 6, 0., 6.));
00437   myFrame2FrameHists2D.push_back(new TProfile2D("frame2frameAbs",
00438                                                 "mean |frame to frame derivatives|, #neq0;col;row",
00439                                                 6, 0., 6., 6, 0., 6.));
00440 
00441   this->equidistLogBins(logBins.GetArray(), logBins.GetSize()-1, 1.E-36, 100.);
00442   for (unsigned int i = 0; i < 6; ++i) {
00443     for (unsigned int j = 0; j < 6; ++j) {
00444       myFrame2FrameHists2D.push_back
00445         (new TH2F(Form("frame2framePhi%d%d", i, j),
00446                   Form("frame to frame derivatives, %d%d;#phi(aliDet);deriv",i,j),
00447                   51, -TMath::Pi(), TMath::Pi(), 10, 0., 1.));
00448       myFrame2FrameHists2D.back()->SetBit(TH1::kCanRebin);
00449       myFrame2FrameHists2D.push_back
00450         (new TH2F(Form("frame2frameR%d%d", i, j),
00451                   Form("frame to frame derivatives, %d%d;r(aliDet);deriv",i,j),
00452                   51, 0., 110., 10, 0., 1.));
00453       myFrame2FrameHists2D.back()->SetBit(TH1::kCanRebin);
00454 
00455       myFrame2FrameHists2D.push_back
00456         (new TH2F(Form("frame2framePhiLog%d%d", i, j),
00457                   Form("frame to frame |derivatives|, %d%d, #neq0;#phi(aliDet);deriv",i,j),
00458                   51, -TMath::Pi(), TMath::Pi(), logBins.GetSize()-1, logBins.GetArray()));
00459       myFrame2FrameHists2D.push_back
00460         (new TH2F(Form("frame2frameRLog%d%d", i, j),
00461                   Form("frame to frame |derivatives|, %d%d, #neq0;r(aliDet);deriv",i,j),
00462                   51, 0., 110., logBins.GetSize()-1, logBins.GetArray()));
00463     }
00464   }
00465 
00466   TDirectory *dirF2f = directory->mkdir("frame2FrameHists", "derivatives etc.");
00467   this->addToDirectory(myFrame2FrameHists2D, dirF2f);
00468 
00469 
00470   myCorrHists.push_back(new TH1F("xyCorrTPB", "#rho_{xy} in pixel barrel", 50, -.5, .5));
00471   myCorrHists.push_back(new TH1F("xyCorrTPE", "#rho_{xy} in forward pixel", 50, -.5, .5));
00472   myCorrHists.push_back(new TH1F("xyCorrTIB", "#rho_{xy} in TIB", 50, -.5, .5));
00473   myCorrHists.push_back(new TH1F("xyCorrTID", "#rho_{xy} in TID", 50, -1., 1.));
00474   myCorrHists.push_back(new TH1F("xyCorrTOB", "#rho_{xy} in TOB", 50, -.5, .5));
00475   myCorrHists.push_back(new TH1F("xyCorrTEC", "#rho_{xy} in TEC", 50, -1., 1.));
00476   TDirectory *dirCorr = directory->mkdir("hitCorrelationHists", "correlations");
00477   this->addToDirectory( myCorrHists, dirCorr);
00478 
00479   // PXB Survey
00480   myPxbSurveyHists.push_back(new TH1F("PxbSurvChi2_lo", "#chi^{2} from PXB survey", 25, 0, 25));
00481   myPxbSurveyHists.push_back(new TH1F("PxbSurvChi2_md", "#chi^{2} from PXB survey", 25, 0, 500));
00482   myPxbSurveyHists.push_back(new TH1F("PxbSurvChi2_hi", "#chi^{2} from PXB survey", 25, 0, 50000));
00483   myPxbSurveyHists.push_back(new TH1F("PxbSurvChi2prob", "Math::Prob(#chi^{2},4) from PXB survey", 25, 0, 1));
00484   myPxbSurveyHists.push_back(new TH1F("PxbSurv_a0", "a_{0} from PXB survey", 100, -3000, 3000));
00485   myPxbSurveyHists.push_back(new TH1F("PxbSurv_a0_abs", "fabs(a_{0}) from PXB survey", 100, 0, 3000));
00486   myPxbSurveyHists.push_back(new TH1F("PxbSurv_a1", "a_{1} from PXB survey", 100, -6000, 6000));
00487   myPxbSurveyHists.push_back(new TH1F("PxbSurv_a1_abs", "fabs(a_{1}) from PXB survey", 100, 0, 6000));
00488   myPxbSurveyHists.push_back(new TH1F("PxbSurv_scale", "scale (#sqrt{a_{2}^{2}+a_{3}^{2}}) from PXB survey", 100, 0, 1500));
00489   myPxbSurveyHists.push_back(new TH1F("PxbSurv_phi", "angle(#atan{a_{3}/a_{4}}) from PXB survey", 100, -.05, .05));
00490   TDirectory *dirPxbSurvey = directory->mkdir("PxbSurveyHists", "PxbSurvey");
00491   this->addToDirectory( myPxbSurveyHists, dirPxbSurvey);
00492 
00493   oldDir->cd();
00494   return true;
00495 }
00496 
00497 
00498 //__________________________________________________________________
00499 bool MillePedeMonitor::equidistLogBins(double* bins, int nBins, 
00500                                         double first, double last) const
00501 {
00502   // Filling 'bins' with borders of 'nBins' bins between 'first' and 'last'
00503   // that are equidistant when viewed in log scale,
00504   // so 'bins' must have length nBins+1;
00505   // If 'first', 'last' or 'nBins' are not positive, failure is reported.
00506 
00507   if (nBins < 1 || first <= 0. || last <= 0.) return false;
00508 
00509   bins[0] = first;
00510   bins[nBins] = last;
00511   const double firstLog = TMath::Log10(bins[0]);
00512   const double lastLog  = TMath::Log10(bins[nBins]);
00513   for (int i = 1; i < nBins; ++i) {
00514     bins[i] = TMath::Power(10., firstLog + i*(lastLog-firstLog)/(nBins));
00515   }
00516 
00517   return true;
00518 }
00519 
00520 //__________________________________________________________________
00521 void MillePedeMonitor::fillTrack(const reco::Track *track)
00522 {
00523   this->fillTrack(track, myTrackHists1D, myTrackHists2D);
00524 }
00525 
00526 //__________________________________________________________________
00527 void MillePedeMonitor::fillUsedTrack(const reco::Track *track, unsigned int nHitX,
00528                                      unsigned int nHitY)
00529 {
00530   // these hist exist only for 'used track' hists:
00531   static const int iUsedX = this->GetIndex(myUsedTrackHists1D, "usedHitsX");
00532   myUsedTrackHists1D[iUsedX]->Fill(nHitX);
00533   static const int iUsedY = this->GetIndex(myUsedTrackHists1D, "usedHitsY");
00534   myUsedTrackHists1D[iUsedY]->Fill(nHitY);
00535 
00536   if (!track) return;
00537   this->fillTrack(track, myUsedTrackHists1D, myUsedTrackHists2D);
00538 }
00539 
00540 //__________________________________________________________________
00541 void MillePedeMonitor::fillTrack(const reco::Track *track, std::vector<TH1*> &trackHists1D,
00542                                  std::vector<TH2*> &trackHists2D)
00543 {
00544   if (!track) return;
00545 
00546   const reco::TrackBase::Vector p(track->momentum());
00547 
00548   static const int iPtLog = this->GetIndex(trackHists1D, "ptTrackLogBins");
00549   trackHists1D[iPtLog]->Fill(track->pt());
00550   static const int iPt = this->GetIndex(trackHists1D, "ptTrack");
00551   trackHists1D[iPt]->Fill(track->pt());
00552   static const int iP = this->GetIndex(trackHists1D, "pTrack");
00553   trackHists1D[iP]->Fill(p.R());
00554   static const int iEta = this->GetIndex(trackHists1D, "etaTrack");
00555   trackHists1D[iEta]->Fill(p.Eta());
00556   static const int iTheta = this->GetIndex(trackHists1D, "thetaTrack");
00557   trackHists1D[iTheta]->Fill(p.Theta());
00558   static const int iPhi = this->GetIndex(trackHists1D, "phiTrack");
00559   trackHists1D[iPhi]->Fill(p.Phi());
00560 
00561   static const int iNhit = this->GetIndex(trackHists1D, "nHitTrack");
00562   trackHists1D[iNhit]->Fill(track->numberOfValidHits());
00563   static const int iNhitInvalid = this->GetIndex(trackHists1D, "nHitInvalidTrack");
00564   trackHists1D[iNhitInvalid]->Fill(track->numberOfLostHits());
00565 
00566   int nhitinTIB = 0, nhitinTOB = 0, nhitinTID = 0;
00567   int nhitinTEC = 0, nhitinBPIX = 0, nhitinFPIX = 0, nhitinPIXEL=0;
00568   int nhitinENDCAP = 0, nhitinENDCAPplus = 0, nhitinENDCAPminus = 0;
00569   int nhitinTIDplus = 0, nhitinTIDminus = 0;
00570   int nhitinFPIXplus = 0, nhitinFPIXminus = 0;
00571   int nhitinTECplus = 0, nhitinTECminus = 0;
00572   unsigned int thishit = 0;
00573 
00574   for (trackingRecHit_iterator iHit = track->recHitsBegin(); iHit != track->recHitsEnd(); ++iHit) {
00575     thishit++;
00576     const DetId detId((*iHit)->geographicalId());
00577     const int subdetId = detId.subdetId(); 
00578 
00579     if (!(*iHit)->isValid()) continue; // only real hits count as in track->numberOfValidHits()
00580     if (detId.det() != DetId::Tracker) {
00581       edm::LogError("DetectorMismatch") << "@SUB=MillePedeMonitor::fillTrack"
00582                                         << "DetId.det() != DetId::Tracker (=" << DetId::Tracker
00583                                         << "), but " << detId.det() << ".";
00584     }
00585 
00586     if      (SiStripDetId::TIB == subdetId) ++nhitinTIB;
00587     else if (SiStripDetId::TOB == subdetId) ++nhitinTOB;
00588     else if (SiStripDetId::TID == subdetId) {
00589       ++nhitinTID;
00590       ++nhitinENDCAP;
00591       
00592       if (trackerTopology->tidIsZMinusSide(detId)) {
00593         ++nhitinTIDminus;
00594         ++nhitinENDCAPminus;
00595       }
00596       else if (trackerTopology->tidIsZPlusSide(detId)) {
00597         ++nhitinTIDplus;
00598         ++nhitinENDCAPplus;
00599       }
00600     }
00601     else if (SiStripDetId::TEC == subdetId) {
00602       ++nhitinTEC;
00603       ++nhitinENDCAP;
00604       
00605       if (trackerTopology->tecIsZMinusSide(detId)) {
00606         ++nhitinTECminus;
00607         ++nhitinENDCAPminus;
00608       }
00609       else if (trackerTopology->tecIsZPlusSide(detId)) {
00610         ++nhitinTECplus;
00611         ++nhitinENDCAPplus;
00612       }
00613     }
00614     else if (            kBPIX == subdetId) {++nhitinBPIX;++nhitinPIXEL;}
00615     else if (            kFPIX == subdetId) {
00616       ++nhitinFPIX;
00617       ++nhitinPIXEL;
00618       
00619       if (trackerTopology->pxfSide(detId)==1) ++nhitinFPIXminus;
00620       else if (trackerTopology->pxfSide(detId)==2) ++nhitinFPIXplus;
00621     }
00622 
00623   } // end loop on hits
00624 
00625   static const int iNhit01 = this->GetIndex(trackHists1D, "nHitBPIXTrack");
00626   trackHists1D[iNhit01]->Fill(nhitinBPIX);
00627   static const int iNhit02 = this->GetIndex(trackHists1D, "nHitFPIXplusTrack");
00628   trackHists1D[iNhit02]->Fill(nhitinFPIXplus);
00629   static const int iNhit03 = this->GetIndex(trackHists1D, "nHitFPIXminusTrack");
00630   trackHists1D[iNhit03]->Fill(nhitinFPIXminus);
00631   static const int iNhit04 = this->GetIndex(trackHists1D, "nHitFPIXTrack");
00632   trackHists1D[iNhit04]->Fill(nhitinFPIX);
00633   static const int iNhit05 = this->GetIndex(trackHists1D, "nHitPIXELTrack");
00634   trackHists1D[iNhit05]->Fill(nhitinPIXEL);
00635   static const int iNhit06 = this->GetIndex(trackHists1D, "nHitTIBTrack");
00636   trackHists1D[iNhit06]->Fill(nhitinTIB);
00637   static const int iNhit07 = this->GetIndex(trackHists1D, "nHitTOBTrack");
00638   trackHists1D[iNhit07]->Fill(nhitinTOB);
00639   static const int iNhit08 = this->GetIndex(trackHists1D, "nHitTIDplusTrack");
00640   trackHists1D[iNhit08]->Fill(nhitinTIDplus);
00641   static const int iNhit09 = this->GetIndex(trackHists1D, "nHitTIDminusTrack");
00642   trackHists1D[iNhit09]->Fill(nhitinTIDminus);
00643   static const int iNhit10 = this->GetIndex(trackHists1D, "nHitTIDTrack");
00644   trackHists1D[iNhit10]->Fill(nhitinTID);
00645   static const int iNhit11 = this->GetIndex(trackHists1D, "nHitTECplusTrack");
00646   trackHists1D[iNhit11]->Fill(nhitinTECplus);
00647   static const int iNhit12 = this->GetIndex(trackHists1D, "nHitTECminusTrack");
00648   trackHists1D[iNhit12]->Fill(nhitinTECminus);
00649   static const int iNhit13 = this->GetIndex(trackHists1D, "nHitTECTrack");
00650   trackHists1D[iNhit13]->Fill(nhitinTEC);
00651   static const int iNhit14 = this->GetIndex(trackHists1D, "nHitENDCAPplusTrack");
00652   trackHists1D[iNhit14]->Fill(nhitinENDCAPplus);
00653   static const int iNhit15 = this->GetIndex(trackHists1D, "nHitENDCAPminusTrack");
00654   trackHists1D[iNhit15]->Fill(nhitinENDCAPminus);
00655   static const int iNhit16 = this->GetIndex(trackHists1D, "nHitENDCAPTrack");
00656   trackHists1D[iNhit16]->Fill(nhitinENDCAP);
00657   static const int iNhit17 = this->GetIndex(trackHists2D, "nHitENDCAPTrackMinusVsPlus");
00658   trackHists2D[iNhit17]->Fill(nhitinENDCAPplus,nhitinENDCAPminus);
00659 
00660   if (track->innerOk()) {
00661     const reco::TrackBase::Point firstPoint(track->innerPosition());
00662     static const int iR1 = this->GetIndex(trackHists1D, "r1Track");
00663     trackHists1D[iR1]->Fill(firstPoint.Rho());
00664     const double rSigned1 = (firstPoint.y() > 0 ? firstPoint.Rho() : -firstPoint.Rho());
00665     static const int iR1Signed = this->GetIndex(trackHists1D, "r1TrackSigned");
00666     trackHists1D[iR1Signed]->Fill(rSigned1);
00667     static const int iZ1 = this->GetIndex(trackHists1D, "z1Track");
00668     trackHists1D[iZ1]->Fill(firstPoint.Z());
00669     static const int iZ1Full = this->GetIndex(trackHists1D, "z1TrackFull");
00670     trackHists1D[iZ1Full]->Fill(firstPoint.Z());
00671     static const int iY1 = this->GetIndex(trackHists1D, "y1Track");
00672     trackHists1D[iY1]->Fill(firstPoint.Y());
00673     static const int iPhi1 = this->GetIndex(trackHists1D, "phi1Track");
00674     trackHists1D[iPhi1]->Fill(firstPoint.phi());
00675     static const int iRz1Full = this->GetIndex(trackHists2D, "rz1TrackFull");
00676     trackHists2D[iRz1Full]->Fill(firstPoint.Z(), rSigned1);
00677     static const int iXy1 = this->GetIndex(trackHists2D, "xy1Track");
00678     trackHists2D[iXy1]->Fill(firstPoint.X(), firstPoint.Y());
00679   }
00680 
00681   if (track->outerOk()) {
00682     const reco::TrackBase::Point lastPoint(track->outerPosition());
00683     static const int iRlast = this->GetIndex(trackHists1D, "rLastTrack");
00684     trackHists1D[iRlast]->Fill(lastPoint.Rho());
00685     static const int iZlast = this->GetIndex(trackHists1D, "zLastTrack");
00686     trackHists1D[iZlast]->Fill(lastPoint.Z());
00687     static const int iYlast = this->GetIndex(trackHists1D, "yLastTrack");
00688     trackHists1D[iYlast]->Fill(lastPoint.Y());
00689     static const int iPhiLast = this->GetIndex(trackHists1D, "phiLastTrack");
00690     trackHists1D[iPhiLast]->Fill(lastPoint.phi());
00691   }
00692 
00693   static const int iChi2Ndf = this->GetIndex(trackHists1D, "chi2PerNdf");
00694   trackHists1D[iChi2Ndf]->Fill(track->normalizedChi2());
00695 
00696   static const int iImpZ = this->GetIndex(trackHists1D, "impParZ");
00697   trackHists1D[iImpZ]->Fill(track->dz());
00698   static const int iImpZerr = this->GetIndex(trackHists1D, "impParErrZ");
00699   trackHists1D[iImpZerr]->Fill(track->dzError());
00700 
00701 
00702   static const int iImpRphi = this->GetIndex(trackHists1D, "impParRphi");
00703   trackHists1D[iImpRphi]->Fill(track->d0());
00704   static const int iImpRphiErr = this->GetIndex(trackHists1D, "impParErrRphi");
00705   trackHists1D[iImpRphiErr]->Fill(track->d0Error());
00706 
00707 }
00708 
00709 //__________________________________________________________________
00710 void MillePedeMonitor::fillRefTrajectory(const ReferenceTrajectoryBase::ReferenceTrajectoryPtr &refTrajPtr)
00711 {
00712 
00713   static const int iValid = this->GetIndex(myTrajectoryHists1D, "validRefTraj");
00714   if (refTrajPtr->isValid()) {
00715     myTrajectoryHists1D[iValid]->Fill(1.);
00716   } else {
00717     myTrajectoryHists1D[iValid]->Fill(0.);
00718     return;
00719   }
00720 
00721   const AlgebraicSymMatrix &covMeasLoc = refTrajPtr->measurementErrors();
00722   const AlgebraicVector &measurementsLoc = refTrajPtr->measurements();
00723   const AlgebraicVector &trajectoryLoc = refTrajPtr->trajectoryPositions();
00724   const TransientTrackingRecHit::ConstRecHitContainer &recHits = refTrajPtr->recHits();
00725   const AlgebraicMatrix &derivatives = refTrajPtr->derivatives();
00726   
00727 // CHK
00728   const int nRow = refTrajPtr->numberOfHitMeas(); 
00729 
00730   for (int iRow = 0; iRow < nRow; ++iRow) {
00731     const double residuum = measurementsLoc[iRow] - trajectoryLoc[iRow];
00732     const double covMeasLocRow = covMeasLoc[iRow][iRow];
00733     const bool is2DhitRow = (!recHits[iRow/2]->detUnit() // FIXME: as in MillePedeAlignmentAlgorithm::is2D()
00734                              || recHits[iRow/2]->detUnit()->type().isTrackerPixel());
00735     //the GeomDetUnit* is zero for composite hits (matched hits in the tracker,...). 
00736     if (TMath::Even(iRow)) { // local x
00737       static const int iMeasLocX = this->GetIndex(myTrajectoryHists1D, "measLocX");
00738       myTrajectoryHists1D[iMeasLocX]->Fill(measurementsLoc[iRow]);
00739       static const int iTrajLocX = this->GetIndex(myTrajectoryHists1D, "trajLocX");
00740       myTrajectoryHists1D[iTrajLocX]->Fill(trajectoryLoc[iRow]);
00741       static const int iResidLocX = this->GetIndex(myTrajectoryHists1D, "residLocX");
00742       myTrajectoryHists1D[iResidLocX]->Fill(residuum);
00743 
00744       static const int iMeasLocXvsHit = this->GetIndex(myTrajectoryHists2D, "measLocXvsHit");
00745       myTrajectoryHists2D[iMeasLocXvsHit]->Fill(iRow/2, measurementsLoc[iRow]);
00746       static const int iTrajLocXvsHit = this->GetIndex(myTrajectoryHists2D, "trajLocXvsHit");
00747       myTrajectoryHists2D[iTrajLocXvsHit]->Fill(iRow/2, trajectoryLoc[iRow]);
00748       static const int iResidLocXvsHit = this->GetIndex(myTrajectoryHists2D, "residLocXvsHit");
00749       myTrajectoryHists2D[iResidLocXvsHit]->Fill(iRow/2, residuum);
00750 
00751       if (covMeasLocRow > 0.) { 
00752         static const int iReduResidLocX = this->GetIndex(myTrajectoryHists1D, "reduResidLocX");
00753         myTrajectoryHists1D[iReduResidLocX]->Fill(residuum / TMath::Sqrt(covMeasLocRow));
00754         static const int iReduResidLocXvsHit = 
00755           this->GetIndex(myTrajectoryHists2D, "reduResidLocXvsHit");
00756         myTrajectoryHists2D[iReduResidLocXvsHit]->Fill(iRow/2, residuum/TMath::Sqrt(covMeasLocRow));
00757       }
00758     } else if (is2DhitRow) { // local y, 2D detectors only
00759 
00760       static const int iMeasLocY = this->GetIndex(myTrajectoryHists1D, "measLocY");
00761       myTrajectoryHists1D[iMeasLocY]->Fill(measurementsLoc[iRow]);
00762       static const int iTrajLocY = this->GetIndex(myTrajectoryHists1D, "trajLocY");
00763       myTrajectoryHists1D[iTrajLocY]->Fill(trajectoryLoc[iRow]);
00764       static const int iResidLocY = this->GetIndex(myTrajectoryHists1D, "residLocY");
00765       myTrajectoryHists1D[iResidLocY]->Fill(residuum);
00766 
00767       static const int iMeasLocYvsHit = this->GetIndex(myTrajectoryHists2D, "measLocYvsHit");
00768       myTrajectoryHists2D[iMeasLocYvsHit]->Fill(iRow/2, measurementsLoc[iRow]);
00769       static const int iTrajLocYvsHit = this->GetIndex(myTrajectoryHists2D, "trajLocYvsHit");
00770       myTrajectoryHists2D[iTrajLocYvsHit]->Fill(iRow/2, trajectoryLoc[iRow]);
00771       static const int iResidLocYvsHit = this->GetIndex(myTrajectoryHists2D, "residLocYvsHit");
00772       myTrajectoryHists2D[iResidLocYvsHit]->Fill(iRow/2, residuum);
00773 
00774       if (covMeasLocRow > 0.) {
00775         static const int iReduResidLocY = this->GetIndex(myTrajectoryHists1D, "reduResidLocY");
00776         myTrajectoryHists1D[iReduResidLocY]->Fill(residuum / TMath::Sqrt(covMeasLocRow));
00777         static const int iReduResidLocYvsHit = this->GetIndex(myTrajectoryHists2D,
00778                                                               "reduResidLocYvsHit");
00779         myTrajectoryHists2D[iReduResidLocYvsHit]->Fill(iRow/2, residuum/TMath::Sqrt(covMeasLocRow));
00780       }
00781     }
00782 
00783     float nHitRow = iRow/2; // '/2' not '/2.'!
00784     if (TMath::Odd(iRow)) nHitRow += 0.5; // y-hit gets 0.5
00785     // correlations
00786     for (int iCol = iRow+1; iCol < nRow; ++iCol) {
00787       double rho = TMath::Sqrt(covMeasLocRow + covMeasLoc[iCol][iCol]);
00788       rho = (0. == rho ? -2 : covMeasLoc[iRow][iCol] / rho);
00789       float nHitCol = iCol/2; //cf. comment nHitRow
00790       if (TMath::Odd(iCol)) nHitCol += 0.5; // dito
00791       //      myProfileCorr->Fill(nHitRow, nHitCol, TMath::Abs(rho));
00792       if (0. == rho) continue;
00793       static const int iProfileCorr = this->GetIndex(myTrajectoryHists2D, "profCorr");
00794       myTrajectoryHists2D[iProfileCorr]->Fill(nHitRow, nHitCol, TMath::Abs(rho));
00795       if (iRow+1 == iCol && TMath::Even(iRow)) { // i.e. if iRow is x and iCol the same hit's y
00796 //      static const int iProfileCorrXy = this->GetIndex(myTrajectoryHists2D,"profCorrOffXy");
00797 //      myTrajectoryHists2D[iProfileCorrOffXy]->Fill(iRow/2, rho);
00798         static const int iHitCorrXy = this->GetIndex(myTrajectoryHists2D, "hitCorrXy");
00799         myTrajectoryHists2D[iHitCorrXy]->Fill(iRow/2, rho);
00800         static const int iHitCorrXyLog = this->GetIndex(myTrajectoryHists2D, "hitCorrXyLog");
00801         myTrajectoryHists2D[iHitCorrXyLog]->Fill(iRow/2, TMath::Abs(rho));
00802         if (is2DhitRow) {
00803           static const int iHitCorrXyValid = this->GetIndex(myTrajectoryHists2D, "hitCorrXyValid");
00804           myTrajectoryHists2D[iHitCorrXyValid]->Fill(iRow/2, rho); // nhitRow??
00805           static const int iHitCorrXyLogValid = this->GetIndex(myTrajectoryHists2D,
00806                                                                "hitCorrXyLogValid");
00807           myTrajectoryHists2D[iHitCorrXyLogValid]->Fill(iRow/2, TMath::Abs(rho)); // nhitRow??
00808         }
00809       } else {
00810         static const int iProfCorrOffXy = this->GetIndex(myTrajectoryHists2D, "profCorrOffXy");
00811         myTrajectoryHists2D[iProfCorrOffXy]->Fill(nHitRow, nHitCol, TMath::Abs(rho));
00812         static const int iHitCorrOffBlock = this->GetIndex(myTrajectoryHists2D, "hitCorrOffBlock");
00813         myTrajectoryHists2D[iHitCorrOffBlock]->Fill(nHitRow, rho);
00814         static const int iHitCorOffBlkLg = this->GetIndex(myTrajectoryHists2D,"hitCorrOffBlockLog");
00815         myTrajectoryHists2D[iHitCorOffBlkLg]->Fill(nHitRow, TMath::Abs(rho));
00816       }
00817     } // end loop on columns of covariance
00818     
00819     // derivatives
00820     for (int iCol = 0; iCol < derivatives.num_col(); ++iCol) {
00821       static const int iProfDerivatives = this->GetIndex(myTrajectoryHists2D, "profDerivatives");
00822       myTrajectoryHists2D[iProfDerivatives]->Fill(nHitRow, iCol, derivatives[iRow][iCol]);
00823       static const int iDerivatives = this->GetIndex(myTrajectoryHists2D, "derivatives");
00824       myTrajectoryHists2D[iDerivatives]->Fill(iCol, derivatives[iRow][iCol]);
00825       static const int iDerivativesLog = this->GetIndex(myTrajectoryHists2D, "derivativesLog");
00826       myTrajectoryHists2D[iDerivativesLog]->Fill(iCol, TMath::Abs(derivatives[iRow][iCol]));
00827       static const int iDerivativesPhi = this->GetIndex(myTrajectoryHists2D, "derivativesVsPhi");
00828       myTrajectoryHists2D[iDerivativesPhi]->Fill(recHits[iRow/2]->det()->position().phi(),
00829                                                  derivatives[iRow][iCol]);
00830     }
00831   } // end loop on rows of covarianvce
00832 
00833 }
00834 
00835 //____________________________________________________________________
00836 void MillePedeMonitor::fillDerivatives(const ConstRecHitPointer &recHit,
00837                                        const float *localDerivs, unsigned int nLocal,
00838                                        const float *globalDerivs, unsigned int nGlobal,
00839                                        const int *labels)
00840 {
00841   const double phi = recHit->det()->position().phi();
00842 
00843   static const int iLocPar = this->GetIndex(myDerivHists2D, "localDerivsPar");
00844   static const int iLocPhi = this->GetIndex(myDerivHists2D, "localDerivsPhi");
00845   static const int iLocParLog = this->GetIndex(myDerivHists2D, "localDerivsParLog");
00846   static const int iLocPhiLog = this->GetIndex(myDerivHists2D, "localDerivsPhiLog");
00847   for (unsigned int i = 0; i < nLocal; ++i) {
00848     myDerivHists2D[iLocPar]->Fill(i, localDerivs[i]);
00849     myDerivHists2D[iLocPhi]->Fill(phi, localDerivs[i]);
00850     if (localDerivs[i]) {
00851       myDerivHists2D[iLocParLog]->Fill(i, TMath::Abs(localDerivs[i]));
00852       myDerivHists2D[iLocPhiLog]->Fill(phi, TMath::Abs(localDerivs[i]));
00853     }
00854   }
00855 
00856   static const int iGlobPar = this->GetIndex(myDerivHists2D, "globalDerivsPar");
00857   static const int iGlobPhi = this->GetIndex(myDerivHists2D, "globalDerivsPhi");
00858   static const int iGlobParLog = this->GetIndex(myDerivHists2D, "globalDerivsParLog");
00859   static const int iGlobPhiLog = this->GetIndex(myDerivHists2D, "globalDerivsPhiLog");
00860 //   static const int iGlobPhiLog2 = this->GetIndex(myDerivHists2D, "globalDerivsPhiLog2");
00861   for (unsigned int i = 0; i < nGlobal; ++i) {
00862     const unsigned int parNum = (labels ? (labels[i]%PedeLabelerBase::theMaxNumParam)-1 : i);
00863     myDerivHists2D[iGlobPar]->Fill(parNum, globalDerivs[i]);
00864     myDerivHists2D[iGlobPhi]->Fill(phi, globalDerivs[i]);
00865     if (globalDerivs[i]) {
00866       myDerivHists2D[iGlobParLog]->Fill(parNum, TMath::Abs(globalDerivs[i]));
00867       myDerivHists2D[iGlobPhiLog]->Fill(phi, TMath::Abs(globalDerivs[i]));
00868 //       myDerivHists2D[iGlobPhiLog2]->Fill(phi, TMath::Abs(globalDerivs[i]));
00869     }
00870   }
00871 
00872 }
00873 
00874 
00875 //____________________________________________________________________
00876 void MillePedeMonitor::fillResiduals(const ConstRecHitPointer &recHit,
00877                                      const TrajectoryStateOnSurface &tsos,
00878                                      unsigned int nHit, float residuum, float sigma, bool isY)
00879 {
00880   // isY == false: x-measurements
00881   // isY == true:  y-measurements
00882   const GlobalPoint detPos(recHit->det()->position());
00883   const double phi = detPos.phi();
00884 //  const double rSigned = (detPos.y() > 0. ? detPos.perp() : -detPos.perp());
00885 
00886   static const int iResPhi = this->GetIndex(myResidHists2D, "residPhi");
00887   myResidHists2D[iResPhi]->Fill(phi, residuum);
00888   static const int iSigPhi = this->GetIndex(myResidHists2D, "sigmaPhi");
00889   myResidHists2D[iSigPhi]->Fill(phi, sigma);
00890   if (sigma) {
00891     static const int iReduResPhi = this->GetIndex(myResidHists2D, "reduResidPhi");
00892     myResidHists2D[iReduResPhi]->Fill(phi, residuum/sigma);
00893   }
00894 
00895 //   if (isY) {
00896 //     static const int iResYXy = this->GetIndex(myResidHists2D, "residYProfXy");
00897 //     myResidHists2D[iResYXy]->Fill(detPos.x(), detPos.y(), TMath::Abs(residuum));
00898 //     static const int iResYZr = this->GetIndex(myResidHists2D, "residYProfZr");
00899 //     myResidHists2D[iResYZr]->Fill(detPos.z(), rSigned, TMath::Abs(residuum));
00900 //     static const int iSigmaYXy = this->GetIndex(myResidHists2D, "sigmaYProfXy");
00901 //     myResidHists2D[iSigmaYXy]->Fill(detPos.x(), detPos.y(), sigma);
00902 //     static const int iSigmaYZr = this->GetIndex(myResidHists2D, "sigmaYProfZr");
00903 //     myResidHists2D[iSigmaYZr]->Fill(detPos.z(), rSigned, sigma);
00904 //     if (sigma) {
00905 //       static const int iReduResYXy = this->GetIndex(myResidHists2D, "reduResidYProfXy");
00906 //       myResidHists2D[iReduResYXy]->Fill(detPos.x(), detPos.y(), TMath::Abs(residuum/sigma));
00907 //       static const int iReduResYZr = this->GetIndex(myResidHists2D, "reduResidYProfZr");
00908 //       myResidHists2D[iReduResYZr]->Fill(detPos.z(), rSigned, TMath::Abs(residuum/sigma));
00909 //     }
00910 //   } else {
00911 //     static const int iResXXy = this->GetIndex(myResidHists2D, "residXProfXy");
00912 //     myResidHists2D[iResXXy]->Fill(detPos.x(), detPos.y(), TMath::Abs(residuum));
00913 //     static const int iResXZr = this->GetIndex(myResidHists2D, "residXProfZr");
00914 //     myResidHists2D[iResXZr]->Fill(detPos.z(), rSigned, TMath::Abs(residuum));
00915 //     static const int iSigmaXXy = this->GetIndex(myResidHists2D, "sigmaXProfXy");
00916 //     myResidHists2D[iSigmaXXy]->Fill(detPos.x(), detPos.y(), sigma);
00917 //     static const int iSigmaXZr = this->GetIndex(myResidHists2D, "sigmaXProfZr");
00918 //     myResidHists2D[iSigmaXZr]->Fill(detPos.z(), rSigned, sigma);
00919 //     if (sigma) {
00920 //       static const int iReduResXXy = this->GetIndex(myResidHists2D, "reduResidXProfXy");
00921 //       myResidHists2D[iReduResXXy]->Fill(detPos.x(), detPos.y(), TMath::Abs(residuum/sigma));
00922 //       static const int iReduResXZr = this->GetIndex(myResidHists2D, "reduResidXProfZr");
00923 //       myResidHists2D[iReduResXZr]->Fill(detPos.z(), rSigned, TMath::Abs(residuum/sigma));
00924 //     }
00925 //   }
00926 
00927   const LocalVector mom(tsos.localDirection()); // mom.z()==0. impossible for TSOS:
00928   const float phiSensToNorm = TMath::ATan(TMath::Abs((isY ? mom.y() : mom.x())/mom.z()));
00929 
00930   std::vector<std::vector<TH1*> > &histArrayVec = (isY ? myResidHistsVec1DY : myResidHistsVec1DX);
00931   std::vector<TH1*> &hitHists =                   (isY ? myResidHitHists1DY : myResidHitHists1DX);
00932 
00933   // call with histArrayVec[0] first: 'static' inside is referring to "subdet-less" names (X/Y irrelevant)
00934   this->fillResidualHists(histArrayVec[0], phiSensToNorm, residuum, sigma);
00935   this->fillResidualHitHists(hitHists, phiSensToNorm, residuum, sigma, nHit);
00936 
00937   const DetId detId(recHit->det()->geographicalId());
00938   if (detId.det() == DetId::Tracker) {
00939     //   const GeomDet::SubDetector subDetNum = recHit->det()->subDetector();
00940     unsigned int subDetNum = detId.subdetId();
00941     if (subDetNum < histArrayVec.size() && subDetNum > 0) {
00942       this->fillResidualHists(histArrayVec[subDetNum], phiSensToNorm, residuum, sigma);
00943     } else {
00944       if (detId!=AlignableBeamSpot::detId())
00945         edm::LogWarning("Alignment") << "@SUB=MillePedeMonitor::fillResiduals"
00946                                      << "Expect subDetNum from 1 to 6, got " << subDetNum;
00947     }
00948   }
00949 }
00950 
00951 //____________________________________________________________________
00952 void MillePedeMonitor::fillResidualHists(const std::vector<TH1*> &hists,
00953                                          float phiSensToNorm, float residuum, float sigma)
00954 {
00955   // Histogram indices are calculated at first call, so make sure the vector of hists at the first
00956   // call has the correct names (i.e. without subdet extension) and all later calls have the
00957   // same order of hists...
00958   
00959   static const int iRes = this->GetIndex(hists, "resid");
00960   hists[iRes]->Fill(residuum);
00961   static const int iSigma = this->GetIndex(hists, "sigma");
00962   hists[iSigma]->Fill(sigma);
00963   static const int iSigmaVsAngle = this->GetIndex(hists, "sigmaVsAngle");
00964   hists[iSigmaVsAngle]->Fill(phiSensToNorm, sigma);
00965   static const int iResidVsAngle = this->GetIndex(hists, "residVsAngle");
00966   hists[iResidVsAngle]->Fill(phiSensToNorm, residuum);
00967   static const int iReduRes = this->GetIndex(hists, "reduResid");
00968   static const int iReduResidVsAngle = this->GetIndex(hists, "reduResidVsAngle");
00969   if (sigma) {
00970     hists[iReduRes]->Fill(residuum/sigma);
00971     hists[iReduResidVsAngle]->Fill(phiSensToNorm, residuum/sigma);
00972   }
00973   static const int iAngle = this->GetIndex(hists, "angle");
00974   hists[iAngle]->Fill(phiSensToNorm);
00975   
00976   if (phiSensToNorm > TMath::DegToRad()*45.) {
00977     static const int iResGt45 = this->GetIndex(hists, "residGt45");
00978     hists[iResGt45]->Fill(residuum);
00979     static const int iSigmaGt45 = this->GetIndex(hists, "sigmaGt45");
00980     hists[iSigmaGt45]->Fill(sigma);
00981     static const int iReduResGt45 = this->GetIndex(hists, "reduResidGt45");
00982     if (sigma) hists[iReduResGt45]->Fill(residuum/sigma);
00983   } else {
00984     static const int iResLt45 = this->GetIndex(hists, "residLt45");
00985     hists[iResLt45]->Fill(residuum);
00986     static const int iSigmaLt45 = this->GetIndex(hists, "sigmaLt45");
00987     hists[iSigmaLt45]->Fill(sigma);
00988     static const int iReduResLt45 = this->GetIndex(hists, "reduResidLt45");
00989     if (sigma) hists[iReduResLt45]->Fill(residuum/sigma);
00990   }
00991 }
00992 
00993 //____________________________________________________________________
00994 void MillePedeMonitor::fillResidualHitHists(const std::vector<TH1*> &hists, float angle,
00995                                             float residuum, float sigma, unsigned int nHit)
00996 {
00997   // Histogram indices are calculated at first call, so make sure the vector of hists at the first
00998   // call has the correct names (i.e. without subdet extension) and all later calls have the
00999   // same order of hists...
01000   
01001   static const unsigned int maxNhit = 29;  // 0...29 foreseen in initialisation...
01002   static int iResHit[maxNhit+1] = {-1};
01003   static int iSigmaHit[maxNhit+1] = {-1};
01004   static int iReduResHit[maxNhit+1] = {-1};
01005   static int iAngleHit[maxNhit+1] = {-1};
01006   if (iResHit[0] == -1) { // first event only...
01007     for (unsigned int i = 0; i <= maxNhit; ++i) {
01008       iResHit[i] = this->GetIndex(hists, Form("resid_%d", i));
01009       iSigmaHit[i] = this->GetIndex(hists, Form("sigma_%d", i));
01010       iReduResHit[i] = this->GetIndex(hists, Form("reduResid_%d", i));
01011       iAngleHit[i] = this->GetIndex(hists, Form("angle_%d", i));
01012     }
01013   }
01014   if (nHit > maxNhit) nHit = maxNhit; // limit of hists
01015 
01016   hists[iResHit[nHit]]->Fill(residuum);
01017   hists[iSigmaHit[nHit]]->Fill(sigma);
01018   if (sigma) {
01019     hists[iReduResHit[nHit]]->Fill(residuum/sigma);
01020   }
01021   hists[iAngleHit[nHit]]->Fill(angle);
01022 }
01023 
01024 //____________________________________________________________________
01025 void MillePedeMonitor::fillFrameToFrame(const AlignableDetOrUnitPtr &aliDet, const Alignable *ali)
01026 {
01027   // get derivative of higher level structure w.r.t. det
01028   FrameToFrameDerivative ftfd;
01029   const AlgebraicMatrix frameDeriv = ftfd.frameToFrameDerivative(aliDet, ali);
01030   //const AlgebraicMatrix frameDeriv = ftfd.frameToFrameDerivativeAtOrgRot(aliDet, ali);
01031 
01032   static const int iF2f = this->GetIndex(myFrame2FrameHists2D, "frame2frame");
01033   static const int iF2fAbs = this->GetIndex(myFrame2FrameHists2D, "frame2frameAbs");
01034   static int iF2fIjPhi[6][6], iF2fIjPhiLog[6][6], iF2fIjR[6][6], iF2fIjRLog[6][6];
01035   static bool first = true;
01036   if (first) {
01037     for (unsigned int i = 0; i < 6; ++i) {
01038       for (unsigned int j = 0; j < 6; ++j) {
01039         iF2fIjPhi[i][j] = this->GetIndex(myFrame2FrameHists2D, Form("frame2framePhi%d%d", i, j));
01040         iF2fIjPhiLog[i][j]=this->GetIndex(myFrame2FrameHists2D, Form("frame2framePhiLog%d%d",i,j));
01041         iF2fIjR[i][j] = this->GetIndex(myFrame2FrameHists2D, Form("frame2frameR%d%d", i, j));
01042         iF2fIjRLog[i][j]=this->GetIndex(myFrame2FrameHists2D, Form("frame2frameRLog%d%d",i,j));
01043       }
01044     }
01045     first = false;
01046   }
01047   
01048   const double phi = aliDet->globalPosition().phi(); // after misalignment...
01049   const double r = aliDet->globalPosition().perp(); // after misalignment...
01050   for (unsigned int i = 0; i < 6; ++i) {
01051     for (unsigned int j = 0; j < 6; ++j) {
01052       myFrame2FrameHists2D[iF2f]->Fill(i, j, frameDeriv[i][j]);
01053       myFrame2FrameHists2D[iF2fIjPhi[i][j]]->Fill(phi, frameDeriv[i][j]);
01054       myFrame2FrameHists2D[iF2fIjR[i][j]]->Fill(r, frameDeriv[i][j]);
01055       if (frameDeriv[i][j]) {
01056         myFrame2FrameHists2D[iF2fAbs]->Fill(i, j, TMath::Abs(frameDeriv[i][j]));
01057         myFrame2FrameHists2D[iF2fIjPhiLog[i][j]]->Fill(phi, TMath::Abs(frameDeriv[i][j]));
01058         myFrame2FrameHists2D[iF2fIjRLog[i][j]]->Fill(r, TMath::Abs(frameDeriv[i][j]));
01059       }
01060     }
01061   }
01062 }
01063 
01064 //____________________________________________________________________
01065 void MillePedeMonitor::fillCorrelations2D(float corr, const ConstRecHitPointer &recHit)
01066 {
01067   const DetId detId(recHit->det()->geographicalId());
01068   if (detId.det() != DetId::Tracker) return;
01069 
01070   if ((detId.subdetId() < 1 || detId.subdetId() > 6) &&
01071       detId!=AlignableBeamSpot::detId()) {
01072     edm::LogWarning("Alignment") << "@SUB=MillePedeMonitor::fillCorrelations2D"
01073                                  << "Expect subdetId from 1 to 6, got " << detId.subdetId();
01074     return;
01075   }
01076 
01077   myCorrHists[detId.subdetId()-1]->Fill(corr);
01078 }
01079 
01080 //____________________________________________________________________
01081 void MillePedeMonitor::fillPxbSurveyHistsChi2(const float &chi2)
01082 {
01083   static const int iPxbSurvChi2_lo = this->GetIndex(myPxbSurveyHists,"PxbSurvChi2_lo");
01084   myPxbSurveyHists[iPxbSurvChi2_lo]->Fill(chi2);
01085   static const int iPxbSurvChi2_md = this->GetIndex(myPxbSurveyHists,"PxbSurvChi2_md");
01086   myPxbSurveyHists[iPxbSurvChi2_md]->Fill(chi2);
01087   static const int iPxbSurvChi2_hi = this->GetIndex(myPxbSurveyHists,"PxbSurvChi2_hi");
01088   myPxbSurveyHists[iPxbSurvChi2_hi]->Fill(chi2);
01089   static const int iPxbSurvChi2prob = this->GetIndex(myPxbSurveyHists,"PxbSurvChi2prob");
01090   myPxbSurveyHists[iPxbSurvChi2prob]->Fill(TMath::Prob(chi2,4));
01091 }
01092 
01093 //____________________________________________________________________
01094 void MillePedeMonitor::fillPxbSurveyHistsLocalPars(const float &a0, const float &a1, const float &S, const float &phi)
01095 {
01096   static const int iPxbSurv_a0 = this->GetIndex(myPxbSurveyHists,"PxbSurv_a0");
01097   myPxbSurveyHists[iPxbSurv_a0]->Fill(a0);
01098   static const int iPxbSurv_a0_abs = this->GetIndex(myPxbSurveyHists,"PxbSurv_a0_abs");
01099   myPxbSurveyHists[iPxbSurv_a0_abs]->Fill(fabs(a0));
01100   static const int iPxbSurv_a1 = this->GetIndex(myPxbSurveyHists,"PxbSurv_a1");
01101   myPxbSurveyHists[iPxbSurv_a1]->Fill(a1);
01102   static const int iPxbSurv_a1_abs = this->GetIndex(myPxbSurveyHists,"PxbSurv_a1_abs");
01103   myPxbSurveyHists[iPxbSurv_a1_abs]->Fill(fabs(a1));
01104   static const int iPxbSurv_scale = this->GetIndex(myPxbSurveyHists,"PxbSurv_scale");
01105   myPxbSurveyHists[iPxbSurv_scale]->Fill(S);
01106   static const int iPxbSurv_phi = this->GetIndex(myPxbSurveyHists,"PxbSurv_phi");
01107   myPxbSurveyHists[iPxbSurv_phi]->Fill(phi);
01108 }
01109 
01110