Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-03 01:57:37

0001 // -*- C++ -*-
0002 //
0003 // Package:     CommonAlignmentProducer
0004 // Class  :     AlignmentMonitorMuonResiduals
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Jim Pivarski
0010 //         Created:  Mon Nov 12 13:30:14 CST 2007
0011 //
0012 
0013 // system include files
0014 #include "Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorPluginFactory.h"
0015 #include "Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorBase.h"
0016 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0018 
0019 #include "TrackingTools/TrackFitters/interface/TrajectoryStateCombiner.h"
0020 #include "Alignment/MuonAlignment/interface/AlignableMuon.h"
0021 #include "DataFormats/MuonDetId/interface/MuonSubdetId.h"
0022 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
0023 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0024 #include "Geometry/CommonDetUnit/interface/TrackerGeomDet.h"
0025 #include "TH1F.h"
0026 #include "TTree.h"
0027 
0028 // user include files
0029 
0030 //
0031 // class definition
0032 //
0033 
0034 class AlignmentMonitorMuonResiduals : public AlignmentMonitorBase {
0035 public:
0036   AlignmentMonitorMuonResiduals(const edm::ParameterSet &cfg, edm::ConsumesCollector iC);
0037   ~AlignmentMonitorMuonResiduals() override{};
0038 
0039   void book() override;
0040   void event(const edm::Event &iEvent,
0041              const edm::EventSetup &iSetup,
0042              const ConstTrajTrackPairCollection &iTrajTracks) override;
0043   void afterAlignment() override;
0044 
0045 private:
0046   std::map<int, int> m_numx;
0047   std::map<int, double> m_x_w;
0048   std::map<int, double> m_x_ww;
0049   std::map<int, double> m_x_wx;
0050   std::map<int, double> m_x_wxx;
0051   std::map<int, int> m_numy;
0052   std::map<int, double> m_y_w;
0053   std::map<int, double> m_y_ww;
0054   std::map<int, double> m_y_wy;
0055   std::map<int, double> m_y_wyy;
0056 
0057   TH1F *m_sumnumx, *m_sumnumy, *m_xsummary, *m_ysummary;
0058 
0059   TH1F *m_xresid, *m_xresid_mb, *m_xresid_me, *m_xresid_mb1, *m_xresid_mb2, *m_xresid_mb3, *m_xresid_mb4,
0060       *m_xresid_minus2, *m_xresid_minus1, *m_xresid_zero, *m_xresid_plus1, *m_xresid_plus2, *m_xresid_mep11,
0061       *m_xresid_mep12, *m_xresid_mep13, *m_xresid_mep14, *m_xresid_mep21, *m_xresid_mep22, *m_xresid_mep31,
0062       *m_xresid_mep32, *m_xresid_mep41, *m_xresid_mem11, *m_xresid_mem12, *m_xresid_mem13, *m_xresid_mem14,
0063       *m_xresid_mem21, *m_xresid_mem22, *m_xresid_mem31, *m_xresid_mem32, *m_xresid_mem41, *m_xresid_me11,
0064       *m_xresid_me12, *m_xresid_me13, *m_xresid_me14, *m_xresid_me21, *m_xresid_me22, *m_xresid_me31, *m_xresid_me32,
0065       *m_xresid_me41;
0066 
0067   TH1F *m_xmean, *m_xmean_mb, *m_xmean_me, *m_xmean_mb1, *m_xmean_mb2, *m_xmean_mb3, *m_xmean_mb4, *m_xmean_minus2,
0068       *m_xmean_minus1, *m_xmean_zero, *m_xmean_plus1, *m_xmean_plus2, *m_xmean_mep11, *m_xmean_mep12, *m_xmean_mep13,
0069       *m_xmean_mep14, *m_xmean_mep21, *m_xmean_mep22, *m_xmean_mep31, *m_xmean_mep32, *m_xmean_mep41, *m_xmean_mem11,
0070       *m_xmean_mem12, *m_xmean_mem13, *m_xmean_mem14, *m_xmean_mem21, *m_xmean_mem22, *m_xmean_mem31, *m_xmean_mem32,
0071       *m_xmean_mem41, *m_xmean_me11, *m_xmean_me12, *m_xmean_me13, *m_xmean_me14, *m_xmean_me21, *m_xmean_me22,
0072       *m_xmean_me31, *m_xmean_me32, *m_xmean_me41;
0073 
0074   TH1F *m_xstdev, *m_xstdev_mb, *m_xstdev_me, *m_xstdev_mb1, *m_xstdev_mb2, *m_xstdev_mb3, *m_xstdev_mb4,
0075       *m_xstdev_minus2, *m_xstdev_minus1, *m_xstdev_zero, *m_xstdev_plus1, *m_xstdev_plus2, *m_xstdev_mep11,
0076       *m_xstdev_mep12, *m_xstdev_mep13, *m_xstdev_mep14, *m_xstdev_mep21, *m_xstdev_mep22, *m_xstdev_mep31,
0077       *m_xstdev_mep32, *m_xstdev_mep41, *m_xstdev_mem11, *m_xstdev_mem12, *m_xstdev_mem13, *m_xstdev_mem14,
0078       *m_xstdev_mem21, *m_xstdev_mem22, *m_xstdev_mem31, *m_xstdev_mem32, *m_xstdev_mem41, *m_xstdev_me11,
0079       *m_xstdev_me12, *m_xstdev_me13, *m_xstdev_me14, *m_xstdev_me21, *m_xstdev_me22, *m_xstdev_me31, *m_xstdev_me32,
0080       *m_xstdev_me41;
0081 
0082   TH1F *m_xerronmean, *m_xerronmean_mb, *m_xerronmean_me, *m_xerronmean_mb1, *m_xerronmean_mb2, *m_xerronmean_mb3,
0083       *m_xerronmean_mb4, *m_xerronmean_minus2, *m_xerronmean_minus1, *m_xerronmean_zero, *m_xerronmean_plus1,
0084       *m_xerronmean_plus2, *m_xerronmean_mep11, *m_xerronmean_mep12, *m_xerronmean_mep13, *m_xerronmean_mep14,
0085       *m_xerronmean_mep21, *m_xerronmean_mep22, *m_xerronmean_mep31, *m_xerronmean_mep32, *m_xerronmean_mep41,
0086       *m_xerronmean_mem11, *m_xerronmean_mem12, *m_xerronmean_mem13, *m_xerronmean_mem14, *m_xerronmean_mem21,
0087       *m_xerronmean_mem22, *m_xerronmean_mem31, *m_xerronmean_mem32, *m_xerronmean_mem41, *m_xerronmean_me11,
0088       *m_xerronmean_me12, *m_xerronmean_me13, *m_xerronmean_me14, *m_xerronmean_me21, *m_xerronmean_me22,
0089       *m_xerronmean_me31, *m_xerronmean_me32, *m_xerronmean_me41;
0090 
0091   TH1F *m_yresid, *m_yresid_mb, *m_yresid_me, *m_yresid_mb1, *m_yresid_mb2, *m_yresid_mb3, *m_yresid_mb4,
0092       *m_yresid_minus2, *m_yresid_minus1, *m_yresid_zero, *m_yresid_plus1, *m_yresid_plus2, *m_yresid_mep11,
0093       *m_yresid_mep12, *m_yresid_mep13, *m_yresid_mep14, *m_yresid_mep21, *m_yresid_mep22, *m_yresid_mep31,
0094       *m_yresid_mep32, *m_yresid_mep41, *m_yresid_mem11, *m_yresid_mem12, *m_yresid_mem13, *m_yresid_mem14,
0095       *m_yresid_mem21, *m_yresid_mem22, *m_yresid_mem31, *m_yresid_mem32, *m_yresid_mem41, *m_yresid_me11,
0096       *m_yresid_me12, *m_yresid_me13, *m_yresid_me14, *m_yresid_me21, *m_yresid_me22, *m_yresid_me31, *m_yresid_me32,
0097       *m_yresid_me41;
0098 
0099   TH1F *m_ymean, *m_ymean_mb, *m_ymean_me, *m_ymean_mb1, *m_ymean_mb2, *m_ymean_mb3, *m_ymean_mb4, *m_ymean_minus2,
0100       *m_ymean_minus1, *m_ymean_zero, *m_ymean_plus1, *m_ymean_plus2, *m_ymean_mep11, *m_ymean_mep12, *m_ymean_mep13,
0101       *m_ymean_mep14, *m_ymean_mep21, *m_ymean_mep22, *m_ymean_mep31, *m_ymean_mep32, *m_ymean_mep41, *m_ymean_mem11,
0102       *m_ymean_mem12, *m_ymean_mem13, *m_ymean_mem14, *m_ymean_mem21, *m_ymean_mem22, *m_ymean_mem31, *m_ymean_mem32,
0103       *m_ymean_mem41, *m_ymean_me11, *m_ymean_me12, *m_ymean_me13, *m_ymean_me14, *m_ymean_me21, *m_ymean_me22,
0104       *m_ymean_me31, *m_ymean_me32, *m_ymean_me41;
0105 
0106   TH1F *m_ystdev, *m_ystdev_mb, *m_ystdev_me, *m_ystdev_mb1, *m_ystdev_mb2, *m_ystdev_mb3, *m_ystdev_mb4,
0107       *m_ystdev_minus2, *m_ystdev_minus1, *m_ystdev_zero, *m_ystdev_plus1, *m_ystdev_plus2, *m_ystdev_mep11,
0108       *m_ystdev_mep12, *m_ystdev_mep13, *m_ystdev_mep14, *m_ystdev_mep21, *m_ystdev_mep22, *m_ystdev_mep31,
0109       *m_ystdev_mep32, *m_ystdev_mep41, *m_ystdev_mem11, *m_ystdev_mem12, *m_ystdev_mem13, *m_ystdev_mem14,
0110       *m_ystdev_mem21, *m_ystdev_mem22, *m_ystdev_mem31, *m_ystdev_mem32, *m_ystdev_mem41, *m_ystdev_me11,
0111       *m_ystdev_me12, *m_ystdev_me13, *m_ystdev_me14, *m_ystdev_me21, *m_ystdev_me22, *m_ystdev_me31, *m_ystdev_me32,
0112       *m_ystdev_me41;
0113 
0114   TH1F *m_yerronmean, *m_yerronmean_mb, *m_yerronmean_me, *m_yerronmean_mb1, *m_yerronmean_mb2, *m_yerronmean_mb3,
0115       *m_yerronmean_mb4, *m_yerronmean_minus2, *m_yerronmean_minus1, *m_yerronmean_zero, *m_yerronmean_plus1,
0116       *m_yerronmean_plus2, *m_yerronmean_mep11, *m_yerronmean_mep12, *m_yerronmean_mep13, *m_yerronmean_mep14,
0117       *m_yerronmean_mep21, *m_yerronmean_mep22, *m_yerronmean_mep31, *m_yerronmean_mep32, *m_yerronmean_mep41,
0118       *m_yerronmean_mem11, *m_yerronmean_mem12, *m_yerronmean_mem13, *m_yerronmean_mem14, *m_yerronmean_mem21,
0119       *m_yerronmean_mem22, *m_yerronmean_mem31, *m_yerronmean_mem32, *m_yerronmean_mem41, *m_yerronmean_me11,
0120       *m_yerronmean_me12, *m_yerronmean_me13, *m_yerronmean_me14, *m_yerronmean_me21, *m_yerronmean_me22,
0121       *m_yerronmean_me31, *m_yerronmean_me32, *m_yerronmean_me41;
0122 
0123   TTree *m_chambers;
0124   Int_t m_chambers_rawid, m_chambers_endcap, m_chambers_wheel, m_chambers_station, m_chambers_sector, m_chambers_ring,
0125       m_chambers_chamber;
0126   Int_t m_chambers_numx, m_chambers_numy;
0127   Float_t m_chambers_x_w, m_chambers_x_ww, m_chambers_x_wx, m_chambers_x_wxx;
0128   Float_t m_chambers_y_w, m_chambers_y_ww, m_chambers_y_wy, m_chambers_y_wyy;
0129 
0130   unsigned int xresid_bins, xmean_bins, xstdev_bins, xerronmean_bins, yresid_bins, ymean_bins, ystdev_bins,
0131       yerronmean_bins;
0132   double xresid_low, xresid_high, xmean_low, xmean_high, xstdev_low, xstdev_high, xerronmean_low, xerronmean_high,
0133       yresid_low, yresid_high, ymean_low, ymean_high, ystdev_low, ystdev_high, yerronmean_low, yerronmean_high;
0134 };
0135 
0136 //
0137 // constants, enums and typedefs
0138 //
0139 
0140 //
0141 // static data member definitions
0142 //
0143 
0144 //
0145 // member functions
0146 //
0147 
0148 AlignmentMonitorMuonResiduals::AlignmentMonitorMuonResiduals(const edm::ParameterSet &cfg, edm::ConsumesCollector iC)
0149     : AlignmentMonitorBase(cfg, iC, "AlignmentMonitorMuonResiduals") {
0150   xresid_bins = cfg.getParameter<unsigned int>("xresid_bins");
0151   xmean_bins = cfg.getParameter<unsigned int>("xmean_bins");
0152   xstdev_bins = cfg.getParameter<unsigned int>("xstdev_bins");
0153   xerronmean_bins = cfg.getParameter<unsigned int>("xerronmean_bins");
0154   yresid_bins = cfg.getParameter<unsigned int>("yresid_bins");
0155   ymean_bins = cfg.getParameter<unsigned int>("ymean_bins");
0156   ystdev_bins = cfg.getParameter<unsigned int>("ystdev_bins");
0157   yerronmean_bins = cfg.getParameter<unsigned int>("yerronmean_bins");
0158   xresid_low = cfg.getParameter<double>("xresid_low");
0159   xresid_high = cfg.getParameter<double>("xresid_high");
0160   xmean_low = cfg.getParameter<double>("xmean_low");
0161   xmean_high = cfg.getParameter<double>("xmean_high");
0162   xstdev_low = cfg.getParameter<double>("xstdev_low");
0163   xstdev_high = cfg.getParameter<double>("xstdev_high");
0164   xerronmean_low = cfg.getParameter<double>("xerronmean_low");
0165   xerronmean_high = cfg.getParameter<double>("xerronmean_high");
0166   yresid_low = cfg.getParameter<double>("yresid_low");
0167   yresid_high = cfg.getParameter<double>("yresid_high");
0168   ymean_low = cfg.getParameter<double>("ymean_low");
0169   ymean_high = cfg.getParameter<double>("ymean_high");
0170   ystdev_low = cfg.getParameter<double>("ystdev_low");
0171   ystdev_high = cfg.getParameter<double>("ystdev_high");
0172   yerronmean_low = cfg.getParameter<double>("yerronmean_low");
0173   yerronmean_high = cfg.getParameter<double>("yerronmean_high");
0174 }
0175 
0176 void AlignmentMonitorMuonResiduals::book() {
0177   m_numx.clear();
0178   m_x_w.clear();
0179   m_x_ww.clear();
0180   m_x_wx.clear();
0181   m_x_wxx.clear();
0182   m_numy.clear();
0183   m_y_w.clear();
0184   m_y_ww.clear();
0185   m_y_wy.clear();
0186   m_y_wyy.clear();
0187 
0188   align::Alignables chambers;
0189   for (const auto &iter : pMuon()->DTChambers())
0190     chambers.push_back(iter);
0191   for (const auto &iter : pMuon()->CSCChambers())
0192     chambers.push_back(iter);
0193 
0194   for (const auto &chamber : chambers) {
0195     int id = chamber->geomDetId().rawId();
0196     m_numx[id] = 0;
0197     m_x_w[id] = 0;
0198     m_x_ww[id] = 0;
0199     m_x_wx[id] = 0;
0200     m_x_wxx[id] = 0;
0201     m_numy[id] = 0;
0202     m_y_w[id] = 0;
0203     m_y_ww[id] = 0;
0204     m_y_wy[id] = 0;
0205     m_y_wyy[id] = 0;
0206   }
0207 
0208   m_sumnumx = book1D("/iterN/", "numx", "number of x hits", chambers.size(), 0.5, chambers.size() + 0.5);
0209   m_sumnumy = book1D("/iterN/", "numy", "number of y hits", chambers.size(), 0.5, chambers.size() + 0.5);
0210   m_xsummary = book1D("/iterN/",
0211                       "xsummary",
0212                       "summary of x means and errors (mm vertical axis)",
0213                       chambers.size(),
0214                       0.5,
0215                       chambers.size() + 0.5);
0216   m_ysummary = book1D("/iterN/",
0217                       "ysummary",
0218                       "summary of y means and errors (mm vertical axis)",
0219                       chambers.size(),
0220                       0.5,
0221                       chambers.size() + 0.5);
0222 
0223   m_xresid = book1D("/iterN/", "xresid", "x residual (mm)", xresid_bins, xresid_low, xresid_high);
0224   m_xresid_mb = book1D("/iterN/mb/", "xresid_mb", "barrel x residual (mm)", xresid_bins, xresid_low, xresid_high);
0225   m_xresid_me = book1D("/iterN/me/", "xresid_me", "endcap x residual (mm)", xresid_bins, xresid_low, xresid_high);
0226   m_xresid_mb1 =
0227       book1D("/iterN/mb1/", "xresid_mb1", "MB station 1 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0228   m_xresid_mb2 =
0229       book1D("/iterN/mb2/", "xresid_mb2", "MB station 2 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0230   m_xresid_mb3 =
0231       book1D("/iterN/mb3/", "xresid_mb3", "MB station 3 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0232   m_xresid_mb4 =
0233       book1D("/iterN/mb4/", "xresid_mb4", "MB station 4 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0234   m_xresid_minus2 =
0235       book1D("/iterN/minus2/", "xresid_minus2", "MB wheel -2 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0236   m_xresid_minus1 =
0237       book1D("/iterN/minus1/", "xresid_minus1", "MB wheel -1 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0238   m_xresid_zero =
0239       book1D("/iterN/zero/", "xresid_zero", "MB wheel 0 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0240   m_xresid_plus1 =
0241       book1D("/iterN/plus1/", "xresid_plus1", "MB wheel +1 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0242   m_xresid_plus2 =
0243       book1D("/iterN/plus2/", "xresid_plus2", "MB wheel +2 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0244   m_xresid_mep11 =
0245       book1D("/iterN/mep11/", "xresid_mep11", "ME+1/1 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0246   m_xresid_mep12 =
0247       book1D("/iterN/mep12/", "xresid_mep12", "ME+1/2 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0248   m_xresid_mep13 =
0249       book1D("/iterN/mep13/", "xresid_mep13", "ME+1/3 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0250   m_xresid_mep14 =
0251       book1D("/iterN/mep14/", "xresid_mep14", "ME+1/4 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0252   m_xresid_mep21 =
0253       book1D("/iterN/mep21/", "xresid_mep21", "ME+2/1 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0254   m_xresid_mep22 =
0255       book1D("/iterN/mep22/", "xresid_mep22", "ME+2/2 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0256   m_xresid_mep31 =
0257       book1D("/iterN/mep31/", "xresid_mep31", "ME+3/1 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0258   m_xresid_mep32 =
0259       book1D("/iterN/mep32/", "xresid_mep32", "ME+3/2 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0260   m_xresid_mep41 =
0261       book1D("/iterN/mep41/", "xresid_mep41", "ME+4/1 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0262   m_xresid_mem11 =
0263       book1D("/iterN/mem11/", "xresid_mem11", "ME-1/1 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0264   m_xresid_mem12 =
0265       book1D("/iterN/mem12/", "xresid_mem12", "ME-1/2 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0266   m_xresid_mem13 =
0267       book1D("/iterN/mem13/", "xresid_mem13", "ME-1/3 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0268   m_xresid_mem14 =
0269       book1D("/iterN/mem14/", "xresid_mem14", "ME-1/4 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0270   m_xresid_mem21 =
0271       book1D("/iterN/mem21/", "xresid_mem21", "ME-2/1 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0272   m_xresid_mem22 =
0273       book1D("/iterN/mem22/", "xresid_mem22", "ME-2/2 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0274   m_xresid_mem31 =
0275       book1D("/iterN/mem31/", "xresid_mem31", "ME-3/1 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0276   m_xresid_mem32 =
0277       book1D("/iterN/mem32/", "xresid_mem32", "ME-3/2 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0278   m_xresid_mem41 =
0279       book1D("/iterN/mem41/", "xresid_mem41", "ME-4/1 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0280   m_xresid_me11 = book1D("/iterN/me11/", "xresid_me11", "ME1/1 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0281   m_xresid_me12 = book1D("/iterN/me12/", "xresid_me12", "ME1/2 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0282   m_xresid_me13 = book1D("/iterN/me13/", "xresid_me13", "ME1/3 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0283   m_xresid_me14 = book1D("/iterN/me14/", "xresid_me14", "ME1/4 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0284   m_xresid_me21 = book1D("/iterN/me21/", "xresid_me21", "ME2/1 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0285   m_xresid_me22 = book1D("/iterN/me22/", "xresid_me22", "ME2/2 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0286   m_xresid_me31 = book1D("/iterN/me31/", "xresid_me31", "ME3/1 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0287   m_xresid_me32 = book1D("/iterN/me32/", "xresid_me32", "ME3/2 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0288   m_xresid_me41 = book1D("/iterN/me41/", "xresid_me41", "ME4/1 x residual (mm)", xresid_bins, xresid_low, xresid_high);
0289 
0290   m_xmean = book1D("/iterN/", "xmean", "weighted mean x residual per chamber (mm)", xmean_bins, xmean_low, xmean_high);
0291   m_xmean_mb = book1D(
0292       "/iterN/mb/", "xmean_mb", "barrel weighted mean x residual per chamber (mm)", xmean_bins, xmean_low, xmean_high);
0293   m_xmean_me = book1D(
0294       "/iterN/me/", "xmean_me", "endcap weighted mean x residual per chamber (mm)", xmean_bins, xmean_low, xmean_high);
0295   m_xmean_mb1 = book1D("/iterN/mb1/",
0296                        "xmean_mb1",
0297                        "MB station 1 weighted mean x residual per chamber (mm)",
0298                        xmean_bins,
0299                        xmean_low,
0300                        xmean_high);
0301   m_xmean_mb2 = book1D("/iterN/mb2/",
0302                        "xmean_mb2",
0303                        "MB station 2 weighted mean x residual per chamber (mm)",
0304                        xmean_bins,
0305                        xmean_low,
0306                        xmean_high);
0307   m_xmean_mb3 = book1D("/iterN/mb3/",
0308                        "xmean_mb3",
0309                        "MB station 3 weighted mean x residual per chamber (mm)",
0310                        xmean_bins,
0311                        xmean_low,
0312                        xmean_high);
0313   m_xmean_mb4 = book1D("/iterN/mb4/",
0314                        "xmean_mb4",
0315                        "MB station 4 weighted mean x residual per chamber (mm)",
0316                        xmean_bins,
0317                        xmean_low,
0318                        xmean_high);
0319   m_xmean_minus2 = book1D("/iterN/minus2/",
0320                           "xmean_minus2",
0321                           "MB wheel -2 weighted mean x residual per chamber (mm)",
0322                           xmean_bins,
0323                           xmean_low,
0324                           xmean_high);
0325   m_xmean_minus1 = book1D("/iterN/minus1/",
0326                           "xmean_minus1",
0327                           "MB wheel -1 weighted mean x residual per chamber (mm)",
0328                           xmean_bins,
0329                           xmean_low,
0330                           xmean_high);
0331   m_xmean_zero = book1D("/iterN/zero/",
0332                         "xmean_zero",
0333                         "MB wheel 0 weighted mean x residual per chamber (mm)",
0334                         xmean_bins,
0335                         xmean_low,
0336                         xmean_high);
0337   m_xmean_plus1 = book1D("/iterN/plus1/",
0338                          "xmean_plus1",
0339                          "MB wheel +1 weighted mean x residual per chamber (mm)",
0340                          xmean_bins,
0341                          xmean_low,
0342                          xmean_high);
0343   m_xmean_plus2 = book1D("/iterN/plus2/",
0344                          "xmean_plus2",
0345                          "MB wheel +2 weighted mean x residual per chamber (mm)",
0346                          xmean_bins,
0347                          xmean_low,
0348                          xmean_high);
0349   m_xmean_mep11 = book1D("/iterN/mep11/",
0350                          "xmean_mep11",
0351                          "ME+1/1 weighted mean x residual per chamber (mm)",
0352                          xmean_bins,
0353                          xmean_low,
0354                          xmean_high);
0355   m_xmean_mep12 = book1D("/iterN/mep12/",
0356                          "xmean_mep12",
0357                          "ME+1/2 weighted mean x residual per chamber (mm)",
0358                          xmean_bins,
0359                          xmean_low,
0360                          xmean_high);
0361   m_xmean_mep13 = book1D("/iterN/mep13/",
0362                          "xmean_mep13",
0363                          "ME+1/3 weighted mean x residual per chamber (mm)",
0364                          xmean_bins,
0365                          xmean_low,
0366                          xmean_high);
0367   m_xmean_mep14 = book1D("/iterN/mep14/",
0368                          "xmean_mep14",
0369                          "ME+1/4 weighted mean x residual per chamber (mm)",
0370                          xmean_bins,
0371                          xmean_low,
0372                          xmean_high);
0373   m_xmean_mep21 = book1D("/iterN/mep21/",
0374                          "xmean_mep21",
0375                          "ME+2/1 weighted mean x residual per chamber (mm)",
0376                          xmean_bins,
0377                          xmean_low,
0378                          xmean_high);
0379   m_xmean_mep22 = book1D("/iterN/mep22/",
0380                          "xmean_mep22",
0381                          "ME+2/2 weighted mean x residual per chamber (mm)",
0382                          xmean_bins,
0383                          xmean_low,
0384                          xmean_high);
0385   m_xmean_mep31 = book1D("/iterN/mep31/",
0386                          "xmean_mep31",
0387                          "ME+3/1 weighted mean x residual per chamber (mm)",
0388                          xmean_bins,
0389                          xmean_low,
0390                          xmean_high);
0391   m_xmean_mep32 = book1D("/iterN/mep32/",
0392                          "xmean_mep32",
0393                          "ME+3/2 weighted mean x residual per chamber (mm)",
0394                          xmean_bins,
0395                          xmean_low,
0396                          xmean_high);
0397   m_xmean_mep41 = book1D("/iterN/mep41/",
0398                          "xmean_mep41",
0399                          "ME+4/1 weighted mean x residual per chamber (mm)",
0400                          xmean_bins,
0401                          xmean_low,
0402                          xmean_high);
0403   m_xmean_mem11 = book1D("/iterN/mem11/",
0404                          "xmean_mem11",
0405                          "ME-1/1 weighted mean x residual per chamber (mm)",
0406                          xmean_bins,
0407                          xmean_low,
0408                          xmean_high);
0409   m_xmean_mem12 = book1D("/iterN/mem12/",
0410                          "xmean_mem12",
0411                          "ME-1/2 weighted mean x residual per chamber (mm)",
0412                          xmean_bins,
0413                          xmean_low,
0414                          xmean_high);
0415   m_xmean_mem13 = book1D("/iterN/mem13/",
0416                          "xmean_mem13",
0417                          "ME-1/3 weighted mean x residual per chamber (mm)",
0418                          xmean_bins,
0419                          xmean_low,
0420                          xmean_high);
0421   m_xmean_mem14 = book1D("/iterN/mem14/",
0422                          "xmean_mem14",
0423                          "ME-1/4 weighted mean x residual per chamber (mm)",
0424                          xmean_bins,
0425                          xmean_low,
0426                          xmean_high);
0427   m_xmean_mem21 = book1D("/iterN/mem21/",
0428                          "xmean_mem21",
0429                          "ME-2/1 weighted mean x residual per chamber (mm)",
0430                          xmean_bins,
0431                          xmean_low,
0432                          xmean_high);
0433   m_xmean_mem22 = book1D("/iterN/mem22/",
0434                          "xmean_mem22",
0435                          "ME-2/2 weighted mean x residual per chamber (mm)",
0436                          xmean_bins,
0437                          xmean_low,
0438                          xmean_high);
0439   m_xmean_mem31 = book1D("/iterN/mem31/",
0440                          "xmean_mem31",
0441                          "ME-3/1 weighted mean x residual per chamber (mm)",
0442                          xmean_bins,
0443                          xmean_low,
0444                          xmean_high);
0445   m_xmean_mem32 = book1D("/iterN/mem32/",
0446                          "xmean_mem32",
0447                          "ME-3/2 weighted mean x residual per chamber (mm)",
0448                          xmean_bins,
0449                          xmean_low,
0450                          xmean_high);
0451   m_xmean_mem41 = book1D("/iterN/mem41/",
0452                          "xmean_mem41",
0453                          "ME-4/1 weighted mean x residual per chamber (mm)",
0454                          xmean_bins,
0455                          xmean_low,
0456                          xmean_high);
0457   m_xmean_me11 = book1D("/iterN/me11/",
0458                         "xmean_me11",
0459                         "ME1/1 weighted mean x residual per chamber (mm)",
0460                         xmean_bins,
0461                         xmean_low,
0462                         xmean_high);
0463   m_xmean_me12 = book1D("/iterN/me12/",
0464                         "xmean_me12",
0465                         "ME1/2 weighted mean x residual per chamber (mm)",
0466                         xmean_bins,
0467                         xmean_low,
0468                         xmean_high);
0469   m_xmean_me13 = book1D("/iterN/me13/",
0470                         "xmean_me13",
0471                         "ME1/3 weighted mean x residual per chamber (mm)",
0472                         xmean_bins,
0473                         xmean_low,
0474                         xmean_high);
0475   m_xmean_me14 = book1D("/iterN/me14/",
0476                         "xmean_me14",
0477                         "ME1/4 weighted mean x residual per chamber (mm)",
0478                         xmean_bins,
0479                         xmean_low,
0480                         xmean_high);
0481   m_xmean_me21 = book1D("/iterN/me21/",
0482                         "xmean_me21",
0483                         "ME2/1 weighted mean x residual per chamber (mm)",
0484                         xmean_bins,
0485                         xmean_low,
0486                         xmean_high);
0487   m_xmean_me22 = book1D("/iterN/me22/",
0488                         "xmean_me22",
0489                         "ME2/2 weighted mean x residual per chamber (mm)",
0490                         xmean_bins,
0491                         xmean_low,
0492                         xmean_high);
0493   m_xmean_me31 = book1D("/iterN/me31/",
0494                         "xmean_me31",
0495                         "ME3/1 weighted mean x residual per chamber (mm)",
0496                         xmean_bins,
0497                         xmean_low,
0498                         xmean_high);
0499   m_xmean_me32 = book1D("/iterN/me32/",
0500                         "xmean_me32",
0501                         "ME3/2 weighted mean x residual per chamber (mm)",
0502                         xmean_bins,
0503                         xmean_low,
0504                         xmean_high);
0505   m_xmean_me41 = book1D("/iterN/me41/",
0506                         "xmean_me41",
0507                         "ME4/1 weighted mean x residual per chamber (mm)",
0508                         xmean_bins,
0509                         xmean_low,
0510                         xmean_high);
0511 
0512   m_xstdev =
0513       book1D("/iterN/", "xstdev", "weighted stdev x residual per chamber (mm)", xstdev_bins, xstdev_low, xstdev_high);
0514   m_xstdev_mb = book1D("/iterN/mb/",
0515                        "xstdev_mb",
0516                        "barrel weighted stdev x residual per chamber (mm)",
0517                        xstdev_bins,
0518                        xstdev_low,
0519                        xstdev_high);
0520   m_xstdev_me = book1D("/iterN/me/",
0521                        "xstdev_me",
0522                        "endcap weighted stdev x residual per chamber (mm)",
0523                        xstdev_bins,
0524                        xstdev_low,
0525                        xstdev_high);
0526   m_xstdev_mb1 = book1D("/iterN/mb1/",
0527                         "xstdev_mb1",
0528                         "MB station 1 weighted stdev x residual per chamber (mm)",
0529                         xstdev_bins,
0530                         xstdev_low,
0531                         xstdev_high);
0532   m_xstdev_mb2 = book1D("/iterN/mb2/",
0533                         "xstdev_mb2",
0534                         "MB station 2 weighted stdev x residual per chamber (mm)",
0535                         xstdev_bins,
0536                         xstdev_low,
0537                         xstdev_high);
0538   m_xstdev_mb3 = book1D("/iterN/mb3/",
0539                         "xstdev_mb3",
0540                         "MB station 3 weighted stdev x residual per chamber (mm)",
0541                         xstdev_bins,
0542                         xstdev_low,
0543                         xstdev_high);
0544   m_xstdev_mb4 = book1D("/iterN/mb4/",
0545                         "xstdev_mb4",
0546                         "MB station 4 weighted stdev x residual per chamber (mm)",
0547                         xstdev_bins,
0548                         xstdev_low,
0549                         xstdev_high);
0550   m_xstdev_minus2 = book1D("/iterN/minus2/",
0551                            "xstdev_minus2",
0552                            "MB wheel -2 weighted stdev x residual per chamber (mm)",
0553                            xstdev_bins,
0554                            xstdev_low,
0555                            xstdev_high);
0556   m_xstdev_minus1 = book1D("/iterN/minus1/",
0557                            "xstdev_minus1",
0558                            "MB wheel -1 weighted stdev x residual per chamber (mm)",
0559                            xstdev_bins,
0560                            xstdev_low,
0561                            xstdev_high);
0562   m_xstdev_zero = book1D("/iterN/zero/",
0563                          "xstdev_zero",
0564                          "MB wheel 0 weighted stdev x residual per chamber (mm)",
0565                          xstdev_bins,
0566                          xstdev_low,
0567                          xstdev_high);
0568   m_xstdev_plus1 = book1D("/iterN/plus1/",
0569                           "xstdev_plus1",
0570                           "MB wheel +1 weighted stdev x residual per chamber (mm)",
0571                           xstdev_bins,
0572                           xstdev_low,
0573                           xstdev_high);
0574   m_xstdev_plus2 = book1D("/iterN/plus2/",
0575                           "xstdev_plus2",
0576                           "MB wheel +2 weighted stdev x residual per chamber (mm)",
0577                           xstdev_bins,
0578                           xstdev_low,
0579                           xstdev_high);
0580   m_xstdev_mep11 = book1D("/iterN/mep11/",
0581                           "xstdev_mep11",
0582                           "ME+1/1 weighted stdev x residual per chamber (mm)",
0583                           xstdev_bins,
0584                           xstdev_low,
0585                           xstdev_high);
0586   m_xstdev_mep12 = book1D("/iterN/mep12/",
0587                           "xstdev_mep12",
0588                           "ME+1/2 weighted stdev x residual per chamber (mm)",
0589                           xstdev_bins,
0590                           xstdev_low,
0591                           xstdev_high);
0592   m_xstdev_mep13 = book1D("/iterN/mep13/",
0593                           "xstdev_mep13",
0594                           "ME+1/3 weighted stdev x residual per chamber (mm)",
0595                           xstdev_bins,
0596                           xstdev_low,
0597                           xstdev_high);
0598   m_xstdev_mep14 = book1D("/iterN/mep14/",
0599                           "xstdev_mep14",
0600                           "ME+1/4 weighted stdev x residual per chamber (mm)",
0601                           xstdev_bins,
0602                           xstdev_low,
0603                           xstdev_high);
0604   m_xstdev_mep21 = book1D("/iterN/mep21/",
0605                           "xstdev_mep21",
0606                           "ME+2/1 weighted stdev x residual per chamber (mm)",
0607                           xstdev_bins,
0608                           xstdev_low,
0609                           xstdev_high);
0610   m_xstdev_mep22 = book1D("/iterN/mep22/",
0611                           "xstdev_mep22",
0612                           "ME+2/2 weighted stdev x residual per chamber (mm)",
0613                           xstdev_bins,
0614                           xstdev_low,
0615                           xstdev_high);
0616   m_xstdev_mep31 = book1D("/iterN/mep31/",
0617                           "xstdev_mep31",
0618                           "ME+3/1 weighted stdev x residual per chamber (mm)",
0619                           xstdev_bins,
0620                           xstdev_low,
0621                           xstdev_high);
0622   m_xstdev_mep32 = book1D("/iterN/mep32/",
0623                           "xstdev_mep32",
0624                           "ME+3/2 weighted stdev x residual per chamber (mm)",
0625                           xstdev_bins,
0626                           xstdev_low,
0627                           xstdev_high);
0628   m_xstdev_mep41 = book1D("/iterN/mep41/",
0629                           "xstdev_mep41",
0630                           "ME+4/1 weighted stdev x residual per chamber (mm)",
0631                           xstdev_bins,
0632                           xstdev_low,
0633                           xstdev_high);
0634   m_xstdev_mem11 = book1D("/iterN/mem11/",
0635                           "xstdev_mem11",
0636                           "ME-1/1 weighted stdev x residual per chamber (mm)",
0637                           xstdev_bins,
0638                           xstdev_low,
0639                           xstdev_high);
0640   m_xstdev_mem12 = book1D("/iterN/mem12/",
0641                           "xstdev_mem12",
0642                           "ME-1/2 weighted stdev x residual per chamber (mm)",
0643                           xstdev_bins,
0644                           xstdev_low,
0645                           xstdev_high);
0646   m_xstdev_mem13 = book1D("/iterN/mem13/",
0647                           "xstdev_mem13",
0648                           "ME-1/3 weighted stdev x residual per chamber (mm)",
0649                           xstdev_bins,
0650                           xstdev_low,
0651                           xstdev_high);
0652   m_xstdev_mem14 = book1D("/iterN/mem14/",
0653                           "xstdev_mem14",
0654                           "ME-1/4 weighted stdev x residual per chamber (mm)",
0655                           xstdev_bins,
0656                           xstdev_low,
0657                           xstdev_high);
0658   m_xstdev_mem21 = book1D("/iterN/mem21/",
0659                           "xstdev_mem21",
0660                           "ME-2/1 weighted stdev x residual per chamber (mm)",
0661                           xstdev_bins,
0662                           xstdev_low,
0663                           xstdev_high);
0664   m_xstdev_mem22 = book1D("/iterN/mem22/",
0665                           "xstdev_mem22",
0666                           "ME-2/2 weighted stdev x residual per chamber (mm)",
0667                           xstdev_bins,
0668                           xstdev_low,
0669                           xstdev_high);
0670   m_xstdev_mem31 = book1D("/iterN/mem31/",
0671                           "xstdev_mem31",
0672                           "ME-3/1 weighted stdev x residual per chamber (mm)",
0673                           xstdev_bins,
0674                           xstdev_low,
0675                           xstdev_high);
0676   m_xstdev_mem32 = book1D("/iterN/mem32/",
0677                           "xstdev_mem32",
0678                           "ME-3/2 weighted stdev x residual per chamber (mm)",
0679                           xstdev_bins,
0680                           xstdev_low,
0681                           xstdev_high);
0682   m_xstdev_mem41 = book1D("/iterN/mem41/",
0683                           "xstdev_mem41",
0684                           "ME-4/1 weighted stdev x residual per chamber (mm)",
0685                           xstdev_bins,
0686                           xstdev_low,
0687                           xstdev_high);
0688   m_xstdev_me11 = book1D("/iterN/me11/",
0689                          "xstdev_me11",
0690                          "ME1/1 weighted stdev x residual per chamber (mm)",
0691                          xstdev_bins,
0692                          xstdev_low,
0693                          xstdev_high);
0694   m_xstdev_me12 = book1D("/iterN/me12/",
0695                          "xstdev_me12",
0696                          "ME1/2 weighted stdev x residual per chamber (mm)",
0697                          xstdev_bins,
0698                          xstdev_low,
0699                          xstdev_high);
0700   m_xstdev_me13 = book1D("/iterN/me13/",
0701                          "xstdev_me13",
0702                          "ME1/3 weighted stdev x residual per chamber (mm)",
0703                          xstdev_bins,
0704                          xstdev_low,
0705                          xstdev_high);
0706   m_xstdev_me14 = book1D("/iterN/me14/",
0707                          "xstdev_me14",
0708                          "ME1/4 weighted stdev x residual per chamber (mm)",
0709                          xstdev_bins,
0710                          xstdev_low,
0711                          xstdev_high);
0712   m_xstdev_me21 = book1D("/iterN/me21/",
0713                          "xstdev_me21",
0714                          "ME2/1 weighted stdev x residual per chamber (mm)",
0715                          xstdev_bins,
0716                          xstdev_low,
0717                          xstdev_high);
0718   m_xstdev_me22 = book1D("/iterN/me22/",
0719                          "xstdev_me22",
0720                          "ME2/2 weighted stdev x residual per chamber (mm)",
0721                          xstdev_bins,
0722                          xstdev_low,
0723                          xstdev_high);
0724   m_xstdev_me31 = book1D("/iterN/me31/",
0725                          "xstdev_me31",
0726                          "ME3/1 weighted stdev x residual per chamber (mm)",
0727                          xstdev_bins,
0728                          xstdev_low,
0729                          xstdev_high);
0730   m_xstdev_me32 = book1D("/iterN/me32/",
0731                          "xstdev_me32",
0732                          "ME3/2 weighted stdev x residual per chamber (mm)",
0733                          xstdev_bins,
0734                          xstdev_low,
0735                          xstdev_high);
0736   m_xstdev_me41 = book1D("/iterN/me41/",
0737                          "xstdev_me41",
0738                          "ME4/1 weighted stdev x residual per chamber (mm)",
0739                          xstdev_bins,
0740                          xstdev_low,
0741                          xstdev_high);
0742 
0743   m_xerronmean = book1D("/iterN/",
0744                         "xerronmean",
0745                         "error on x weighted mean residual per chamber (mm)",
0746                         xerronmean_bins,
0747                         xerronmean_low,
0748                         xerronmean_high);
0749   m_xerronmean_mb = book1D("/iterN/mb/",
0750                            "xerronmean_mb",
0751                            "barrel error on x weighted mean residual per chamber (mm)",
0752                            xerronmean_bins,
0753                            xerronmean_low,
0754                            xerronmean_high);
0755   m_xerronmean_me = book1D("/iterN/me/",
0756                            "xerronmean_me",
0757                            "endcap error on x weighted mean residual per chamber (mm)",
0758                            xerronmean_bins,
0759                            xerronmean_low,
0760                            xerronmean_high);
0761   m_xerronmean_mb1 = book1D("/iterN/mb1/",
0762                             "xerronmean_mb1",
0763                             "MB station 1 error on x weighted mean residual per chamber (mm)",
0764                             xerronmean_bins,
0765                             xerronmean_low,
0766                             xerronmean_high);
0767   m_xerronmean_mb2 = book1D("/iterN/mb2/",
0768                             "xerronmean_mb2",
0769                             "MB station 2 error on x weighted mean residual per chamber (mm)",
0770                             xerronmean_bins,
0771                             xerronmean_low,
0772                             xerronmean_high);
0773   m_xerronmean_mb3 = book1D("/iterN/mb3/",
0774                             "xerronmean_mb3",
0775                             "MB station 3 error on x weighted mean residual per chamber (mm)",
0776                             xerronmean_bins,
0777                             xerronmean_low,
0778                             xerronmean_high);
0779   m_xerronmean_mb4 = book1D("/iterN/mb4/",
0780                             "xerronmean_mb4",
0781                             "MB station 4 error on x weighted mean residual per chamber (mm)",
0782                             xerronmean_bins,
0783                             xerronmean_low,
0784                             xerronmean_high);
0785   m_xerronmean_minus2 = book1D("/iterN/minus2/",
0786                                "xerronmean_minus2",
0787                                "MB wheel -2 error on x weighted mean residual per chamber (mm)",
0788                                xerronmean_bins,
0789                                xerronmean_low,
0790                                xerronmean_high);
0791   m_xerronmean_minus1 = book1D("/iterN/minus1/",
0792                                "xerronmean_minus1",
0793                                "MB wheel -1 error on x weighted mean residual per chamber (mm)",
0794                                xerronmean_bins,
0795                                xerronmean_low,
0796                                xerronmean_high);
0797   m_xerronmean_zero = book1D("/iterN/zero/",
0798                              "xerronmean_zero",
0799                              "MB wheel 0 error on x weighted mean residual per chamber (mm)",
0800                              xerronmean_bins,
0801                              xerronmean_low,
0802                              xerronmean_high);
0803   m_xerronmean_plus1 = book1D("/iterN/plus1/",
0804                               "xerronmean_plus1",
0805                               "MB wheel +1 error on x weighted mean residual per chamber (mm)",
0806                               xerronmean_bins,
0807                               xerronmean_low,
0808                               xerronmean_high);
0809   m_xerronmean_plus2 = book1D("/iterN/plus2/",
0810                               "xerronmean_plus2",
0811                               "MB wheel +2 error on x weighted mean residual per chamber (mm)",
0812                               xerronmean_bins,
0813                               xerronmean_low,
0814                               xerronmean_high);
0815   m_xerronmean_mep11 = book1D("/iterN/mep11/",
0816                               "xerronmean_mep11",
0817                               "ME+1/1 error on x weighted mean residual per chamber (mm)",
0818                               xerronmean_bins,
0819                               xerronmean_low,
0820                               xerronmean_high);
0821   m_xerronmean_mep12 = book1D("/iterN/mep12/",
0822                               "xerronmean_mep12",
0823                               "ME+1/2 error on x weighted mean residual per chamber (mm)",
0824                               xerronmean_bins,
0825                               xerronmean_low,
0826                               xerronmean_high);
0827   m_xerronmean_mep13 = book1D("/iterN/mep13/",
0828                               "xerronmean_mep13",
0829                               "ME+1/3 error on x weighted mean residual per chamber (mm)",
0830                               xerronmean_bins,
0831                               xerronmean_low,
0832                               xerronmean_high);
0833   m_xerronmean_mep14 = book1D("/iterN/mep14/",
0834                               "xerronmean_mep14",
0835                               "ME+1/4 error on x weighted mean residual per chamber (mm)",
0836                               xerronmean_bins,
0837                               xerronmean_low,
0838                               xerronmean_high);
0839   m_xerronmean_mep21 = book1D("/iterN/mep21/",
0840                               "xerronmean_mep21",
0841                               "ME+2/1 error on x weighted mean residual per chamber (mm)",
0842                               xerronmean_bins,
0843                               xerronmean_low,
0844                               xerronmean_high);
0845   m_xerronmean_mep22 = book1D("/iterN/mep22/",
0846                               "xerronmean_mep22",
0847                               "ME+2/2 error on x weighted mean residual per chamber (mm)",
0848                               xerronmean_bins,
0849                               xerronmean_low,
0850                               xerronmean_high);
0851   m_xerronmean_mep31 = book1D("/iterN/mep31/",
0852                               "xerronmean_mep31",
0853                               "ME+3/1 error on x weighted mean residual per chamber (mm)",
0854                               xerronmean_bins,
0855                               xerronmean_low,
0856                               xerronmean_high);
0857   m_xerronmean_mep32 = book1D("/iterN/mep32/",
0858                               "xerronmean_mep32",
0859                               "ME+3/2 error on x weighted mean residual per chamber (mm)",
0860                               xerronmean_bins,
0861                               xerronmean_low,
0862                               xerronmean_high);
0863   m_xerronmean_mep41 = book1D("/iterN/mep41/",
0864                               "xerronmean_mep41",
0865                               "ME+4/1 error on x weighted mean residual per chamber (mm)",
0866                               xerronmean_bins,
0867                               xerronmean_low,
0868                               xerronmean_high);
0869   m_xerronmean_mem11 = book1D("/iterN/mem11/",
0870                               "xerronmean_mem11",
0871                               "ME-1/1 error on x weighted mean residual per chamber (mm)",
0872                               xerronmean_bins,
0873                               xerronmean_low,
0874                               xerronmean_high);
0875   m_xerronmean_mem12 = book1D("/iterN/mem12/",
0876                               "xerronmean_mem12",
0877                               "ME-1/2 error on x weighted mean residual per chamber (mm)",
0878                               xerronmean_bins,
0879                               xerronmean_low,
0880                               xerronmean_high);
0881   m_xerronmean_mem13 = book1D("/iterN/mem13/",
0882                               "xerronmean_mem13",
0883                               "ME-1/3 error on x weighted mean residual per chamber (mm)",
0884                               xerronmean_bins,
0885                               xerronmean_low,
0886                               xerronmean_high);
0887   m_xerronmean_mem14 = book1D("/iterN/mem14/",
0888                               "xerronmean_mem14",
0889                               "ME-1/4 error on x weighted mean residual per chamber (mm)",
0890                               xerronmean_bins,
0891                               xerronmean_low,
0892                               xerronmean_high);
0893   m_xerronmean_mem21 = book1D("/iterN/mem21/",
0894                               "xerronmean_mem21",
0895                               "ME-2/1 error on x weighted mean residual per chamber (mm)",
0896                               xerronmean_bins,
0897                               xerronmean_low,
0898                               xerronmean_high);
0899   m_xerronmean_mem22 = book1D("/iterN/mem22/",
0900                               "xerronmean_mem22",
0901                               "ME-2/2 error on x weighted mean residual per chamber (mm)",
0902                               xerronmean_bins,
0903                               xerronmean_low,
0904                               xerronmean_high);
0905   m_xerronmean_mem31 = book1D("/iterN/mem31/",
0906                               "xerronmean_mem31",
0907                               "ME-3/1 error on x weighted mean residual per chamber (mm)",
0908                               xerronmean_bins,
0909                               xerronmean_low,
0910                               xerronmean_high);
0911   m_xerronmean_mem32 = book1D("/iterN/mem32/",
0912                               "xerronmean_mem32",
0913                               "ME-3/2 error on x weighted mean residual per chamber (mm)",
0914                               xerronmean_bins,
0915                               xerronmean_low,
0916                               xerronmean_high);
0917   m_xerronmean_mem41 = book1D("/iterN/mem41/",
0918                               "xerronmean_mem41",
0919                               "ME-4/1 error on x weighted mean residual per chamber (mm)",
0920                               xerronmean_bins,
0921                               xerronmean_low,
0922                               xerronmean_high);
0923   m_xerronmean_me11 = book1D("/iterN/me11/",
0924                              "xerronmean_me11",
0925                              "ME1/1 error on x weighted mean residual per chamber (mm)",
0926                              xerronmean_bins,
0927                              xerronmean_low,
0928                              xerronmean_high);
0929   m_xerronmean_me12 = book1D("/iterN/me12/",
0930                              "xerronmean_me12",
0931                              "ME1/2 error on x weighted mean residual per chamber (mm)",
0932                              xerronmean_bins,
0933                              xerronmean_low,
0934                              xerronmean_high);
0935   m_xerronmean_me13 = book1D("/iterN/me13/",
0936                              "xerronmean_me13",
0937                              "ME1/3 error on x weighted mean residual per chamber (mm)",
0938                              xerronmean_bins,
0939                              xerronmean_low,
0940                              xerronmean_high);
0941   m_xerronmean_me14 = book1D("/iterN/me14/",
0942                              "xerronmean_me14",
0943                              "ME1/4 error on x weighted mean residual per chamber (mm)",
0944                              xerronmean_bins,
0945                              xerronmean_low,
0946                              xerronmean_high);
0947   m_xerronmean_me21 = book1D("/iterN/me21/",
0948                              "xerronmean_me21",
0949                              "ME2/1 error on x weighted mean residual per chamber (mm)",
0950                              xerronmean_bins,
0951                              xerronmean_low,
0952                              xerronmean_high);
0953   m_xerronmean_me22 = book1D("/iterN/me22/",
0954                              "xerronmean_me22",
0955                              "ME2/2 error on x weighted mean residual per chamber (mm)",
0956                              xerronmean_bins,
0957                              xerronmean_low,
0958                              xerronmean_high);
0959   m_xerronmean_me31 = book1D("/iterN/me31/",
0960                              "xerronmean_me31",
0961                              "ME3/1 error on x weighted mean residual per chamber (mm)",
0962                              xerronmean_bins,
0963                              xerronmean_low,
0964                              xerronmean_high);
0965   m_xerronmean_me32 = book1D("/iterN/me32/",
0966                              "xerronmean_me32",
0967                              "ME3/2 error on x weighted mean residual per chamber (mm)",
0968                              xerronmean_bins,
0969                              xerronmean_low,
0970                              xerronmean_high);
0971   m_xerronmean_me41 = book1D("/iterN/me41/",
0972                              "xerronmean_me41",
0973                              "ME4/1 error on x weighted mean residual per chamber (mm)",
0974                              xerronmean_bins,
0975                              xerronmean_low,
0976                              xerronmean_high);
0977 
0978   m_yresid = book1D("/iterN/", "yresid", "y residual (mm)", yresid_bins, yresid_low, yresid_high);
0979   m_yresid_mb = book1D("/iterN/mb/", "yresid_mb", "barrel y residual (mm)", yresid_bins, yresid_low, yresid_high);
0980   m_yresid_me = book1D("/iterN/me/", "yresid_me", "endcap y residual (mm)", yresid_bins, yresid_low, yresid_high);
0981   m_yresid_mb1 =
0982       book1D("/iterN/mb1/", "yresid_mb1", "MB station 1 y residual (mm)", yresid_bins, yresid_low, yresid_high);
0983   m_yresid_mb2 =
0984       book1D("/iterN/mb2/", "yresid_mb2", "MB station 2 y residual (mm)", yresid_bins, yresid_low, yresid_high);
0985   m_yresid_mb3 =
0986       book1D("/iterN/mb3/", "yresid_mb3", "MB station 3 y residual (mm)", yresid_bins, yresid_low, yresid_high);
0987   m_yresid_mb4 =
0988       book1D("/iterN/mb4/", "yresid_mb4", "MB station 4 y residual (mm)", yresid_bins, yresid_low, yresid_high);
0989   m_yresid_minus2 =
0990       book1D("/iterN/minus2/", "yresid_minus2", "MB wheel -2 y residual (mm)", yresid_bins, yresid_low, yresid_high);
0991   m_yresid_minus1 =
0992       book1D("/iterN/minus1/", "yresid_minus1", "MB wheel -1 y residual (mm)", yresid_bins, yresid_low, yresid_high);
0993   m_yresid_zero =
0994       book1D("/iterN/zero/", "yresid_zero", "MB wheel 0 y residual (mm)", yresid_bins, yresid_low, yresid_high);
0995   m_yresid_plus1 =
0996       book1D("/iterN/plus1/", "yresid_plus1", "MB wheel +1 y residual (mm)", yresid_bins, yresid_low, yresid_high);
0997   m_yresid_plus2 =
0998       book1D("/iterN/plus2/", "yresid_plus2", "MB wheel +2 y residual (mm)", yresid_bins, yresid_low, yresid_high);
0999   m_yresid_mep11 =
1000       book1D("/iterN/mep11/", "yresid_mep11", "ME+1/1 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1001   m_yresid_mep12 =
1002       book1D("/iterN/mep12/", "yresid_mep12", "ME+1/2 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1003   m_yresid_mep13 =
1004       book1D("/iterN/mep13/", "yresid_mep13", "ME+1/3 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1005   m_yresid_mep14 =
1006       book1D("/iterN/mep14/", "yresid_mep14", "ME+1/4 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1007   m_yresid_mep21 =
1008       book1D("/iterN/mep21/", "yresid_mep21", "ME+2/1 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1009   m_yresid_mep22 =
1010       book1D("/iterN/mep22/", "yresid_mep22", "ME+2/2 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1011   m_yresid_mep31 =
1012       book1D("/iterN/mep31/", "yresid_mep31", "ME+3/1 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1013   m_yresid_mep32 =
1014       book1D("/iterN/mep32/", "yresid_mep32", "ME+3/2 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1015   m_yresid_mep41 =
1016       book1D("/iterN/mep41/", "yresid_mep41", "ME+4/1 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1017   m_yresid_mem11 =
1018       book1D("/iterN/mem11/", "yresid_mem11", "ME-1/1 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1019   m_yresid_mem12 =
1020       book1D("/iterN/mem12/", "yresid_mem12", "ME-1/2 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1021   m_yresid_mem13 =
1022       book1D("/iterN/mem13/", "yresid_mem13", "ME-1/3 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1023   m_yresid_mem14 =
1024       book1D("/iterN/mem14/", "yresid_mem14", "ME-1/4 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1025   m_yresid_mem21 =
1026       book1D("/iterN/mem21/", "yresid_mem21", "ME-2/1 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1027   m_yresid_mem22 =
1028       book1D("/iterN/mem22/", "yresid_mem22", "ME-2/2 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1029   m_yresid_mem31 =
1030       book1D("/iterN/mem31/", "yresid_mem31", "ME-3/1 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1031   m_yresid_mem32 =
1032       book1D("/iterN/mem32/", "yresid_mem32", "ME-3/2 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1033   m_yresid_mem41 =
1034       book1D("/iterN/mem41/", "yresid_mem41", "ME-4/1 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1035   m_yresid_me11 = book1D("/iterN/me11/", "yresid_me11", "ME1/1 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1036   m_yresid_me12 = book1D("/iterN/me12/", "yresid_me12", "ME1/2 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1037   m_yresid_me13 = book1D("/iterN/me13/", "yresid_me13", "ME1/3 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1038   m_yresid_me14 = book1D("/iterN/me14/", "yresid_me14", "ME1/4 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1039   m_yresid_me21 = book1D("/iterN/me21/", "yresid_me21", "ME2/1 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1040   m_yresid_me22 = book1D("/iterN/me22/", "yresid_me22", "ME2/2 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1041   m_yresid_me31 = book1D("/iterN/me31/", "yresid_me31", "ME3/1 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1042   m_yresid_me32 = book1D("/iterN/me32/", "yresid_me32", "ME3/2 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1043   m_yresid_me41 = book1D("/iterN/me41/", "yresid_me41", "ME4/1 y residual (mm)", yresid_bins, yresid_low, yresid_high);
1044 
1045   m_ymean = book1D("/iterN/", "ymean", "weighted mean y residual per chamber (mm)", ymean_bins, ymean_low, ymean_high);
1046   m_ymean_mb = book1D(
1047       "/iterN/mb/", "ymean_mb", "barrel weighted mean y residual per chamber (mm)", ymean_bins, ymean_low, ymean_high);
1048   m_ymean_me = book1D(
1049       "/iterN/me/", "ymean_me", "endcap weighted mean y residual per chamber (mm)", ymean_bins, ymean_low, ymean_high);
1050   m_ymean_mb1 = book1D("/iterN/mb1/",
1051                        "ymean_mb1",
1052                        "MB station 1 weighted mean y residual per chamber (mm)",
1053                        ymean_bins,
1054                        ymean_low,
1055                        ymean_high);
1056   m_ymean_mb2 = book1D("/iterN/mb2/",
1057                        "ymean_mb2",
1058                        "MB station 2 weighted mean y residual per chamber (mm)",
1059                        ymean_bins,
1060                        ymean_low,
1061                        ymean_high);
1062   m_ymean_mb3 = book1D("/iterN/mb3/",
1063                        "ymean_mb3",
1064                        "MB station 3 weighted mean y residual per chamber (mm)",
1065                        ymean_bins,
1066                        ymean_low,
1067                        ymean_high);
1068   m_ymean_mb4 = book1D("/iterN/mb4/",
1069                        "ymean_mb4",
1070                        "MB station 4 weighted mean y residual per chamber (mm)",
1071                        ymean_bins,
1072                        ymean_low,
1073                        ymean_high);
1074   m_ymean_minus2 = book1D("/iterN/minus2/",
1075                           "ymean_minus2",
1076                           "MB wheel -2 weighted mean y residual per chamber (mm)",
1077                           ymean_bins,
1078                           ymean_low,
1079                           ymean_high);
1080   m_ymean_minus1 = book1D("/iterN/minus1/",
1081                           "ymean_minus1",
1082                           "MB wheel -1 weighted mean y residual per chamber (mm)",
1083                           ymean_bins,
1084                           ymean_low,
1085                           ymean_high);
1086   m_ymean_zero = book1D("/iterN/zero/",
1087                         "ymean_zero",
1088                         "MB wheel 0 weighted mean y residual per chamber (mm)",
1089                         ymean_bins,
1090                         ymean_low,
1091                         ymean_high);
1092   m_ymean_plus1 = book1D("/iterN/plus1/",
1093                          "ymean_plus1",
1094                          "MB wheel +1 weighted mean y residual per chamber (mm)",
1095                          ymean_bins,
1096                          ymean_low,
1097                          ymean_high);
1098   m_ymean_plus2 = book1D("/iterN/plus2/",
1099                          "ymean_plus2",
1100                          "MB wheel +2 weighted mean y residual per chamber (mm)",
1101                          ymean_bins,
1102                          ymean_low,
1103                          ymean_high);
1104   m_ymean_mep11 = book1D("/iterN/mep11/",
1105                          "ymean_mep11",
1106                          "ME+1/1 weighted mean y residual per chamber (mm)",
1107                          ymean_bins,
1108                          ymean_low,
1109                          ymean_high);
1110   m_ymean_mep12 = book1D("/iterN/mep12/",
1111                          "ymean_mep12",
1112                          "ME+1/2 weighted mean y residual per chamber (mm)",
1113                          ymean_bins,
1114                          ymean_low,
1115                          ymean_high);
1116   m_ymean_mep13 = book1D("/iterN/mep13/",
1117                          "ymean_mep13",
1118                          "ME+1/3 weighted mean y residual per chamber (mm)",
1119                          ymean_bins,
1120                          ymean_low,
1121                          ymean_high);
1122   m_ymean_mep14 = book1D("/iterN/mep14/",
1123                          "ymean_mep14",
1124                          "ME+1/4 weighted mean y residual per chamber (mm)",
1125                          ymean_bins,
1126                          ymean_low,
1127                          ymean_high);
1128   m_ymean_mep21 = book1D("/iterN/mep21/",
1129                          "ymean_mep21",
1130                          "ME+2/1 weighted mean y residual per chamber (mm)",
1131                          ymean_bins,
1132                          ymean_low,
1133                          ymean_high);
1134   m_ymean_mep22 = book1D("/iterN/mep22/",
1135                          "ymean_mep22",
1136                          "ME+2/2 weighted mean y residual per chamber (mm)",
1137                          ymean_bins,
1138                          ymean_low,
1139                          ymean_high);
1140   m_ymean_mep31 = book1D("/iterN/mep31/",
1141                          "ymean_mep31",
1142                          "ME+3/1 weighted mean y residual per chamber (mm)",
1143                          ymean_bins,
1144                          ymean_low,
1145                          ymean_high);
1146   m_ymean_mep32 = book1D("/iterN/mep32/",
1147                          "ymean_mep32",
1148                          "ME+3/2 weighted mean y residual per chamber (mm)",
1149                          ymean_bins,
1150                          ymean_low,
1151                          ymean_high);
1152   m_ymean_mep41 = book1D("/iterN/mep41/",
1153                          "ymean_mep41",
1154                          "ME+4/1 weighted mean y residual per chamber (mm)",
1155                          ymean_bins,
1156                          ymean_low,
1157                          ymean_high);
1158   m_ymean_mem11 = book1D("/iterN/mem11/",
1159                          "ymean_mem11",
1160                          "ME-1/1 weighted mean y residual per chamber (mm)",
1161                          ymean_bins,
1162                          ymean_low,
1163                          ymean_high);
1164   m_ymean_mem12 = book1D("/iterN/mem12/",
1165                          "ymean_mem12",
1166                          "ME-1/2 weighted mean y residual per chamber (mm)",
1167                          ymean_bins,
1168                          ymean_low,
1169                          ymean_high);
1170   m_ymean_mem13 = book1D("/iterN/mem13/",
1171                          "ymean_mem13",
1172                          "ME-1/3 weighted mean y residual per chamber (mm)",
1173                          ymean_bins,
1174                          ymean_low,
1175                          ymean_high);
1176   m_ymean_mem14 = book1D("/iterN/mem14/",
1177                          "ymean_mem14",
1178                          "ME-1/4 weighted mean y residual per chamber (mm)",
1179                          ymean_bins,
1180                          ymean_low,
1181                          ymean_high);
1182   m_ymean_mem21 = book1D("/iterN/mem21/",
1183                          "ymean_mem21",
1184                          "ME-2/1 weighted mean y residual per chamber (mm)",
1185                          ymean_bins,
1186                          ymean_low,
1187                          ymean_high);
1188   m_ymean_mem22 = book1D("/iterN/mem22/",
1189                          "ymean_mem22",
1190                          "ME-2/2 weighted mean y residual per chamber (mm)",
1191                          ymean_bins,
1192                          ymean_low,
1193                          ymean_high);
1194   m_ymean_mem31 = book1D("/iterN/mem31/",
1195                          "ymean_mem31",
1196                          "ME-3/1 weighted mean y residual per chamber (mm)",
1197                          ymean_bins,
1198                          ymean_low,
1199                          ymean_high);
1200   m_ymean_mem32 = book1D("/iterN/mem32/",
1201                          "ymean_mem32",
1202                          "ME-3/2 weighted mean y residual per chamber (mm)",
1203                          ymean_bins,
1204                          ymean_low,
1205                          ymean_high);
1206   m_ymean_mem41 = book1D("/iterN/mem41/",
1207                          "ymean_mem41",
1208                          "ME-4/1 weighted mean y residual per chamber (mm)",
1209                          ymean_bins,
1210                          ymean_low,
1211                          ymean_high);
1212   m_ymean_me11 = book1D("/iterN/me11/",
1213                         "ymean_me11",
1214                         "ME1/1 weighted mean y residual per chamber (mm)",
1215                         ymean_bins,
1216                         ymean_low,
1217                         ymean_high);
1218   m_ymean_me12 = book1D("/iterN/me12/",
1219                         "ymean_me12",
1220                         "ME1/2 weighted mean y residual per chamber (mm)",
1221                         ymean_bins,
1222                         ymean_low,
1223                         ymean_high);
1224   m_ymean_me13 = book1D("/iterN/me13/",
1225                         "ymean_me13",
1226                         "ME1/3 weighted mean y residual per chamber (mm)",
1227                         ymean_bins,
1228                         ymean_low,
1229                         ymean_high);
1230   m_ymean_me14 = book1D("/iterN/me14/",
1231                         "ymean_me14",
1232                         "ME1/4 weighted mean y residual per chamber (mm)",
1233                         ymean_bins,
1234                         ymean_low,
1235                         ymean_high);
1236   m_ymean_me21 = book1D("/iterN/me21/",
1237                         "ymean_me21",
1238                         "ME2/1 weighted mean y residual per chamber (mm)",
1239                         ymean_bins,
1240                         ymean_low,
1241                         ymean_high);
1242   m_ymean_me22 = book1D("/iterN/me22/",
1243                         "ymean_me22",
1244                         "ME2/2 weighted mean y residual per chamber (mm)",
1245                         ymean_bins,
1246                         ymean_low,
1247                         ymean_high);
1248   m_ymean_me31 = book1D("/iterN/me31/",
1249                         "ymean_me31",
1250                         "ME3/1 weighted mean y residual per chamber (mm)",
1251                         ymean_bins,
1252                         ymean_low,
1253                         ymean_high);
1254   m_ymean_me32 = book1D("/iterN/me32/",
1255                         "ymean_me32",
1256                         "ME3/2 weighted mean y residual per chamber (mm)",
1257                         ymean_bins,
1258                         ymean_low,
1259                         ymean_high);
1260   m_ymean_me41 = book1D("/iterN/me41/",
1261                         "ymean_me41",
1262                         "ME4/1 weighted mean y residual per chamber (mm)",
1263                         ymean_bins,
1264                         ymean_low,
1265                         ymean_high);
1266 
1267   m_ystdev =
1268       book1D("/iterN/", "ystdev", "weighted stdev y residual per chamber (mm)", ystdev_bins, ystdev_low, ystdev_high);
1269   m_ystdev_mb = book1D("/iterN/mb/",
1270                        "ystdev_mb",
1271                        "barrel weighted stdev y residual per chamber (mm)",
1272                        ystdev_bins,
1273                        ystdev_low,
1274                        ystdev_high);
1275   m_ystdev_me = book1D("/iterN/me/",
1276                        "ystdev_me",
1277                        "endcap weighted stdev y residual per chamber (mm)",
1278                        ystdev_bins,
1279                        ystdev_low,
1280                        ystdev_high);
1281   m_ystdev_mb1 = book1D("/iterN/mb1/",
1282                         "ystdev_mb1",
1283                         "MB station 1 weighted stdev y residual per chamber (mm)",
1284                         ystdev_bins,
1285                         ystdev_low,
1286                         ystdev_high);
1287   m_ystdev_mb2 = book1D("/iterN/mb2/",
1288                         "ystdev_mb2",
1289                         "MB station 2 weighted stdev y residual per chamber (mm)",
1290                         ystdev_bins,
1291                         ystdev_low,
1292                         ystdev_high);
1293   m_ystdev_mb3 = book1D("/iterN/mb3/",
1294                         "ystdev_mb3",
1295                         "MB station 3 weighted stdev y residual per chamber (mm)",
1296                         ystdev_bins,
1297                         ystdev_low,
1298                         ystdev_high);
1299   m_ystdev_mb4 = book1D("/iterN/mb4/",
1300                         "ystdev_mb4",
1301                         "MB station 4 weighted stdev y residual per chamber (mm)",
1302                         ystdev_bins,
1303                         ystdev_low,
1304                         ystdev_high);
1305   m_ystdev_minus2 = book1D("/iterN/minus2/",
1306                            "ystdev_minus2",
1307                            "MB wheel -2 weighted stdev y residual per chamber (mm)",
1308                            ystdev_bins,
1309                            ystdev_low,
1310                            ystdev_high);
1311   m_ystdev_minus1 = book1D("/iterN/minus1/",
1312                            "ystdev_minus1",
1313                            "MB wheel -1 weighted stdev y residual per chamber (mm)",
1314                            ystdev_bins,
1315                            ystdev_low,
1316                            ystdev_high);
1317   m_ystdev_zero = book1D("/iterN/zero/",
1318                          "ystdev_zero",
1319                          "MB wheel 0 weighted stdev y residual per chamber (mm)",
1320                          ystdev_bins,
1321                          ystdev_low,
1322                          ystdev_high);
1323   m_ystdev_plus1 = book1D("/iterN/plus1/",
1324                           "ystdev_plus1",
1325                           "MB wheel +1 weighted stdev y residual per chamber (mm)",
1326                           ystdev_bins,
1327                           ystdev_low,
1328                           ystdev_high);
1329   m_ystdev_plus2 = book1D("/iterN/plus2/",
1330                           "ystdev_plus2",
1331                           "MB wheel +2 weighted stdev y residual per chamber (mm)",
1332                           ystdev_bins,
1333                           ystdev_low,
1334                           ystdev_high);
1335   m_ystdev_mep11 = book1D("/iterN/mep11/",
1336                           "ystdev_mep11",
1337                           "ME+1/1 weighted stdev y residual per chamber (mm)",
1338                           ystdev_bins,
1339                           ystdev_low,
1340                           ystdev_high);
1341   m_ystdev_mep12 = book1D("/iterN/mep12/",
1342                           "ystdev_mep12",
1343                           "ME+1/2 weighted stdev y residual per chamber (mm)",
1344                           ystdev_bins,
1345                           ystdev_low,
1346                           ystdev_high);
1347   m_ystdev_mep13 = book1D("/iterN/mep13/",
1348                           "ystdev_mep13",
1349                           "ME+1/3 weighted stdev y residual per chamber (mm)",
1350                           ystdev_bins,
1351                           ystdev_low,
1352                           ystdev_high);
1353   m_ystdev_mep14 = book1D("/iterN/mep14/",
1354                           "ystdev_mep14",
1355                           "ME+1/4 weighted stdev y residual per chamber (mm)",
1356                           ystdev_bins,
1357                           ystdev_low,
1358                           ystdev_high);
1359   m_ystdev_mep21 = book1D("/iterN/mep21/",
1360                           "ystdev_mep21",
1361                           "ME+2/1 weighted stdev y residual per chamber (mm)",
1362                           ystdev_bins,
1363                           ystdev_low,
1364                           ystdev_high);
1365   m_ystdev_mep22 = book1D("/iterN/mep22/",
1366                           "ystdev_mep22",
1367                           "ME+2/2 weighted stdev y residual per chamber (mm)",
1368                           ystdev_bins,
1369                           ystdev_low,
1370                           ystdev_high);
1371   m_ystdev_mep31 = book1D("/iterN/mep31/",
1372                           "ystdev_mep31",
1373                           "ME+3/1 weighted stdev y residual per chamber (mm)",
1374                           ystdev_bins,
1375                           ystdev_low,
1376                           ystdev_high);
1377   m_ystdev_mep32 = book1D("/iterN/mep32/",
1378                           "ystdev_mep32",
1379                           "ME+3/2 weighted stdev y residual per chamber (mm)",
1380                           ystdev_bins,
1381                           ystdev_low,
1382                           ystdev_high);
1383   m_ystdev_mep41 = book1D("/iterN/mep41/",
1384                           "ystdev_mep41",
1385                           "ME+4/1 weighted stdev y residual per chamber (mm)",
1386                           ystdev_bins,
1387                           ystdev_low,
1388                           ystdev_high);
1389   m_ystdev_mem11 = book1D("/iterN/mem11/",
1390                           "ystdev_mem11",
1391                           "ME-1/1 weighted stdev y residual per chamber (mm)",
1392                           ystdev_bins,
1393                           ystdev_low,
1394                           ystdev_high);
1395   m_ystdev_mem12 = book1D("/iterN/mem12/",
1396                           "ystdev_mem12",
1397                           "ME-1/2 weighted stdev y residual per chamber (mm)",
1398                           ystdev_bins,
1399                           ystdev_low,
1400                           ystdev_high);
1401   m_ystdev_mem13 = book1D("/iterN/mem13/",
1402                           "ystdev_mem13",
1403                           "ME-1/3 weighted stdev y residual per chamber (mm)",
1404                           ystdev_bins,
1405                           ystdev_low,
1406                           ystdev_high);
1407   m_ystdev_mem14 = book1D("/iterN/mem14/",
1408                           "ystdev_mem14",
1409                           "ME-1/4 weighted stdev y residual per chamber (mm)",
1410                           ystdev_bins,
1411                           ystdev_low,
1412                           ystdev_high);
1413   m_ystdev_mem21 = book1D("/iterN/mem21/",
1414                           "ystdev_mem21",
1415                           "ME-2/1 weighted stdev y residual per chamber (mm)",
1416                           ystdev_bins,
1417                           ystdev_low,
1418                           ystdev_high);
1419   m_ystdev_mem22 = book1D("/iterN/mem22/",
1420                           "ystdev_mem22",
1421                           "ME-2/2 weighted stdev y residual per chamber (mm)",
1422                           ystdev_bins,
1423                           ystdev_low,
1424                           ystdev_high);
1425   m_ystdev_mem31 = book1D("/iterN/mem31/",
1426                           "ystdev_mem31",
1427                           "ME-3/1 weighted stdev y residual per chamber (mm)",
1428                           ystdev_bins,
1429                           ystdev_low,
1430                           ystdev_high);
1431   m_ystdev_mem32 = book1D("/iterN/mem32/",
1432                           "ystdev_mem32",
1433                           "ME-3/2 weighted stdev y residual per chamber (mm)",
1434                           ystdev_bins,
1435                           ystdev_low,
1436                           ystdev_high);
1437   m_ystdev_mem41 = book1D("/iterN/mem41/",
1438                           "ystdev_mem41",
1439                           "ME-4/1 weighted stdev y residual per chamber (mm)",
1440                           ystdev_bins,
1441                           ystdev_low,
1442                           ystdev_high);
1443   m_ystdev_me11 = book1D("/iterN/me11/",
1444                          "ystdev_me11",
1445                          "ME1/1 weighted stdev y residual per chamber (mm)",
1446                          ystdev_bins,
1447                          ystdev_low,
1448                          ystdev_high);
1449   m_ystdev_me12 = book1D("/iterN/me12/",
1450                          "ystdev_me12",
1451                          "ME1/2 weighted stdev y residual per chamber (mm)",
1452                          ystdev_bins,
1453                          ystdev_low,
1454                          ystdev_high);
1455   m_ystdev_me13 = book1D("/iterN/me13/",
1456                          "ystdev_me13",
1457                          "ME1/3 weighted stdev y residual per chamber (mm)",
1458                          ystdev_bins,
1459                          ystdev_low,
1460                          ystdev_high);
1461   m_ystdev_me14 = book1D("/iterN/me14/",
1462                          "ystdev_me14",
1463                          "ME1/4 weighted stdev y residual per chamber (mm)",
1464                          ystdev_bins,
1465                          ystdev_low,
1466                          ystdev_high);
1467   m_ystdev_me21 = book1D("/iterN/me21/",
1468                          "ystdev_me21",
1469                          "ME2/1 weighted stdev y residual per chamber (mm)",
1470                          ystdev_bins,
1471                          ystdev_low,
1472                          ystdev_high);
1473   m_ystdev_me22 = book1D("/iterN/me22/",
1474                          "ystdev_me22",
1475                          "ME2/2 weighted stdev y residual per chamber (mm)",
1476                          ystdev_bins,
1477                          ystdev_low,
1478                          ystdev_high);
1479   m_ystdev_me31 = book1D("/iterN/me31/",
1480                          "ystdev_me31",
1481                          "ME3/1 weighted stdev y residual per chamber (mm)",
1482                          ystdev_bins,
1483                          ystdev_low,
1484                          ystdev_high);
1485   m_ystdev_me32 = book1D("/iterN/me32/",
1486                          "ystdev_me32",
1487                          "ME3/2 weighted stdev y residual per chamber (mm)",
1488                          ystdev_bins,
1489                          ystdev_low,
1490                          ystdev_high);
1491   m_ystdev_me41 = book1D("/iterN/me41/",
1492                          "ystdev_me41",
1493                          "ME4/1 weighted stdev y residual per chamber (mm)",
1494                          ystdev_bins,
1495                          ystdev_low,
1496                          ystdev_high);
1497 
1498   m_yerronmean = book1D("/iterN/",
1499                         "yerronmean",
1500                         "error on y weighted mean residual per chamber (mm)",
1501                         yerronmean_bins,
1502                         yerronmean_low,
1503                         yerronmean_high);
1504   m_yerronmean_mb = book1D("/iterN/mb/",
1505                            "yerronmean_mb",
1506                            "barrel error on y weighted mean residual per chamber (mm)",
1507                            yerronmean_bins,
1508                            yerronmean_low,
1509                            yerronmean_high);
1510   m_yerronmean_me = book1D("/iterN/me/",
1511                            "yerronmean_me",
1512                            "endcap error on y weighted mean residual per chamber (mm)",
1513                            yerronmean_bins,
1514                            yerronmean_low,
1515                            yerronmean_high);
1516   m_yerronmean_mb1 = book1D("/iterN/mb1/",
1517                             "yerronmean_mb1",
1518                             "MB station 1 error on y weighted mean residual per chamber (mm)",
1519                             yerronmean_bins,
1520                             yerronmean_low,
1521                             yerronmean_high);
1522   m_yerronmean_mb2 = book1D("/iterN/mb2/",
1523                             "yerronmean_mb2",
1524                             "MB station 2 error on y weighted mean residual per chamber (mm)",
1525                             yerronmean_bins,
1526                             yerronmean_low,
1527                             yerronmean_high);
1528   m_yerronmean_mb3 = book1D("/iterN/mb3/",
1529                             "yerronmean_mb3",
1530                             "MB station 3 error on y weighted mean residual per chamber (mm)",
1531                             yerronmean_bins,
1532                             yerronmean_low,
1533                             yerronmean_high);
1534   m_yerronmean_mb4 = book1D("/iterN/mb4/",
1535                             "yerronmean_mb4",
1536                             "MB station 4 error on y weighted mean residual per chamber (mm)",
1537                             yerronmean_bins,
1538                             yerronmean_low,
1539                             yerronmean_high);
1540   m_yerronmean_minus2 = book1D("/iterN/minus2/",
1541                                "yerronmean_minus2",
1542                                "MB wheel -2 error on y weighted mean residual per chamber (mm)",
1543                                yerronmean_bins,
1544                                yerronmean_low,
1545                                yerronmean_high);
1546   m_yerronmean_minus1 = book1D("/iterN/minus1/",
1547                                "yerronmean_minus1",
1548                                "MB wheel -1 error on y weighted mean residual per chamber (mm)",
1549                                yerronmean_bins,
1550                                yerronmean_low,
1551                                yerronmean_high);
1552   m_yerronmean_zero = book1D("/iterN/zero/",
1553                              "yerronmean_zero",
1554                              "MB wheel 0 error on y weighted mean residual per chamber (mm)",
1555                              yerronmean_bins,
1556                              yerronmean_low,
1557                              yerronmean_high);
1558   m_yerronmean_plus1 = book1D("/iterN/plus1/",
1559                               "yerronmean_plus1",
1560                               "MB wheel +1 error on y weighted mean residual per chamber (mm)",
1561                               yerronmean_bins,
1562                               yerronmean_low,
1563                               yerronmean_high);
1564   m_yerronmean_plus2 = book1D("/iterN/plus2/",
1565                               "yerronmean_plus2",
1566                               "MB wheel +2 error on y weighted mean residual per chamber (mm)",
1567                               yerronmean_bins,
1568                               yerronmean_low,
1569                               yerronmean_high);
1570   m_yerronmean_mep11 = book1D("/iterN/mep11/",
1571                               "yerronmean_mep11",
1572                               "ME+1/1 error on y weighted mean residual per chamber (mm)",
1573                               yerronmean_bins,
1574                               yerronmean_low,
1575                               yerronmean_high);
1576   m_yerronmean_mep12 = book1D("/iterN/mep12/",
1577                               "yerronmean_mep12",
1578                               "ME+1/2 error on y weighted mean residual per chamber (mm)",
1579                               yerronmean_bins,
1580                               yerronmean_low,
1581                               yerronmean_high);
1582   m_yerronmean_mep13 = book1D("/iterN/mep13/",
1583                               "yerronmean_mep13",
1584                               "ME+1/3 error on y weighted mean residual per chamber (mm)",
1585                               yerronmean_bins,
1586                               yerronmean_low,
1587                               yerronmean_high);
1588   m_yerronmean_mep14 = book1D("/iterN/mep14/",
1589                               "yerronmean_mep14",
1590                               "ME+1/4 error on y weighted mean residual per chamber (mm)",
1591                               yerronmean_bins,
1592                               yerronmean_low,
1593                               yerronmean_high);
1594   m_yerronmean_mep21 = book1D("/iterN/mep21/",
1595                               "yerronmean_mep21",
1596                               "ME+2/1 error on y weighted mean residual per chamber (mm)",
1597                               yerronmean_bins,
1598                               yerronmean_low,
1599                               yerronmean_high);
1600   m_yerronmean_mep22 = book1D("/iterN/mep22/",
1601                               "yerronmean_mep22",
1602                               "ME+2/2 error on y weighted mean residual per chamber (mm)",
1603                               yerronmean_bins,
1604                               yerronmean_low,
1605                               yerronmean_high);
1606   m_yerronmean_mep31 = book1D("/iterN/mep31/",
1607                               "yerronmean_mep31",
1608                               "ME+3/1 error on y weighted mean residual per chamber (mm)",
1609                               yerronmean_bins,
1610                               yerronmean_low,
1611                               yerronmean_high);
1612   m_yerronmean_mep32 = book1D("/iterN/mep32/",
1613                               "yerronmean_mep32",
1614                               "ME+3/2 error on y weighted mean residual per chamber (mm)",
1615                               yerronmean_bins,
1616                               yerronmean_low,
1617                               yerronmean_high);
1618   m_yerronmean_mep41 = book1D("/iterN/mep41/",
1619                               "yerronmean_mep41",
1620                               "ME+4/1 error on y weighted mean residual per chamber (mm)",
1621                               yerronmean_bins,
1622                               yerronmean_low,
1623                               yerronmean_high);
1624   m_yerronmean_mem11 = book1D("/iterN/mem11/",
1625                               "yerronmean_mem11",
1626                               "ME-1/1 error on y weighted mean residual per chamber (mm)",
1627                               yerronmean_bins,
1628                               yerronmean_low,
1629                               yerronmean_high);
1630   m_yerronmean_mem12 = book1D("/iterN/mem12/",
1631                               "yerronmean_mem12",
1632                               "ME-1/2 error on y weighted mean residual per chamber (mm)",
1633                               yerronmean_bins,
1634                               yerronmean_low,
1635                               yerronmean_high);
1636   m_yerronmean_mem13 = book1D("/iterN/mem13/",
1637                               "yerronmean_mem13",
1638                               "ME-1/3 error on y weighted mean residual per chamber (mm)",
1639                               yerronmean_bins,
1640                               yerronmean_low,
1641                               yerronmean_high);
1642   m_yerronmean_mem14 = book1D("/iterN/mem14/",
1643                               "yerronmean_mem14",
1644                               "ME-1/4 error on y weighted mean residual per chamber (mm)",
1645                               yerronmean_bins,
1646                               yerronmean_low,
1647                               yerronmean_high);
1648   m_yerronmean_mem21 = book1D("/iterN/mem21/",
1649                               "yerronmean_mem21",
1650                               "ME-2/1 error on y weighted mean residual per chamber (mm)",
1651                               yerronmean_bins,
1652                               yerronmean_low,
1653                               yerronmean_high);
1654   m_yerronmean_mem22 = book1D("/iterN/mem22/",
1655                               "yerronmean_mem22",
1656                               "ME-2/2 error on y weighted mean residual per chamber (mm)",
1657                               yerronmean_bins,
1658                               yerronmean_low,
1659                               yerronmean_high);
1660   m_yerronmean_mem31 = book1D("/iterN/mem31/",
1661                               "yerronmean_mem31",
1662                               "ME-3/1 error on y weighted mean residual per chamber (mm)",
1663                               yerronmean_bins,
1664                               yerronmean_low,
1665                               yerronmean_high);
1666   m_yerronmean_mem32 = book1D("/iterN/mem32/",
1667                               "yerronmean_mem32",
1668                               "ME-3/2 error on y weighted mean residual per chamber (mm)",
1669                               yerronmean_bins,
1670                               yerronmean_low,
1671                               yerronmean_high);
1672   m_yerronmean_mem41 = book1D("/iterN/mem41/",
1673                               "yerronmean_mem41",
1674                               "ME-4/1 error on y weighted mean residual per chamber (mm)",
1675                               yerronmean_bins,
1676                               yerronmean_low,
1677                               yerronmean_high);
1678   m_yerronmean_me11 = book1D("/iterN/me11/",
1679                              "yerronmean_me11",
1680                              "ME1/1 error on y weighted mean residual per chamber (mm)",
1681                              yerronmean_bins,
1682                              yerronmean_low,
1683                              yerronmean_high);
1684   m_yerronmean_me12 = book1D("/iterN/me12/",
1685                              "yerronmean_me12",
1686                              "ME1/2 error on y weighted mean residual per chamber (mm)",
1687                              yerronmean_bins,
1688                              yerronmean_low,
1689                              yerronmean_high);
1690   m_yerronmean_me13 = book1D("/iterN/me13/",
1691                              "yerronmean_me13",
1692                              "ME1/3 error on y weighted mean residual per chamber (mm)",
1693                              yerronmean_bins,
1694                              yerronmean_low,
1695                              yerronmean_high);
1696   m_yerronmean_me14 = book1D("/iterN/me14/",
1697                              "yerronmean_me14",
1698                              "ME1/4 error on y weighted mean residual per chamber (mm)",
1699                              yerronmean_bins,
1700                              yerronmean_low,
1701                              yerronmean_high);
1702   m_yerronmean_me21 = book1D("/iterN/me21/",
1703                              "yerronmean_me21",
1704                              "ME2/1 error on y weighted mean residual per chamber (mm)",
1705                              yerronmean_bins,
1706                              yerronmean_low,
1707                              yerronmean_high);
1708   m_yerronmean_me22 = book1D("/iterN/me22/",
1709                              "yerronmean_me22",
1710                              "ME2/2 error on y weighted mean residual per chamber (mm)",
1711                              yerronmean_bins,
1712                              yerronmean_low,
1713                              yerronmean_high);
1714   m_yerronmean_me31 = book1D("/iterN/me31/",
1715                              "yerronmean_me31",
1716                              "ME3/1 error on y weighted mean residual per chamber (mm)",
1717                              yerronmean_bins,
1718                              yerronmean_low,
1719                              yerronmean_high);
1720   m_yerronmean_me32 = book1D("/iterN/me32/",
1721                              "yerronmean_me32",
1722                              "ME3/2 error on y weighted mean residual per chamber (mm)",
1723                              yerronmean_bins,
1724                              yerronmean_low,
1725                              yerronmean_high);
1726   m_yerronmean_me41 = book1D("/iterN/me41/",
1727                              "yerronmean_me41",
1728                              "ME4/1 error on y weighted mean residual per chamber (mm)",
1729                              yerronmean_bins,
1730                              yerronmean_low,
1731                              yerronmean_high);
1732 
1733   m_chambers = directory("/iterN/")->make<TTree>("chambers", "residual statistics for each chamber");
1734   m_chambers->Branch("rawid", &m_chambers_rawid, "rawid/I");
1735   m_chambers->Branch("endcap", &m_chambers_endcap, "endcap/I");
1736   m_chambers->Branch("wheel", &m_chambers_wheel, "wheel/I");
1737   m_chambers->Branch("station", &m_chambers_station, "station/I");
1738   m_chambers->Branch("sector", &m_chambers_sector, "sector/I");
1739   m_chambers->Branch("ring", &m_chambers_ring, "ring/I");
1740   m_chambers->Branch("chamber", &m_chambers_chamber, "chamber/I");
1741   m_chambers->Branch("numx", &m_chambers_numx, "numx/I");
1742   m_chambers->Branch("x_w", &m_chambers_x_w, "x_w/F");
1743   m_chambers->Branch("x_ww", &m_chambers_x_ww, "x_ww/F");
1744   m_chambers->Branch("x_wx", &m_chambers_x_wx, "x_wx/F");
1745   m_chambers->Branch("x_wxx", &m_chambers_x_wxx, "x_wxx/F");
1746   m_chambers->Branch("numy", &m_chambers_numy, "numy/I");
1747   m_chambers->Branch("y_w", &m_chambers_y_w, "y_w/F");
1748   m_chambers->Branch("y_ww", &m_chambers_y_ww, "y_ww/F");
1749   m_chambers->Branch("y_wy", &m_chambers_y_wy, "y_wy/F");
1750   m_chambers->Branch("y_wyy", &m_chambers_y_wyy, "y_wyy/F");
1751 }
1752 
1753 void AlignmentMonitorMuonResiduals::event(const edm::Event &iEvent,
1754                                           const edm::EventSetup &iSetup,
1755                                           const ConstTrajTrackPairCollection &tracks) {
1756   TrajectoryStateCombiner tsoscomb;
1757 
1758   for (ConstTrajTrackPairCollection::const_iterator it = tracks.begin(); it != tracks.end(); ++it) {
1759     const Trajectory *traj = it->first;
1760     //      const reco::Track *track = it->second;
1761 
1762     std::vector<TrajectoryMeasurement> measurements = traj->measurements();
1763 
1764     for (std::vector<TrajectoryMeasurement>::const_iterator im = measurements.begin(); im != measurements.end(); ++im) {
1765       const TrajectoryMeasurement meas = *im;
1766       const TransientTrackingRecHit *hit = &(*meas.recHit());
1767       const DetId id = hit->geographicalId();
1768 
1769       if (hit->isValid() && pNavigator()->detAndSubdetInMap(id)) {
1770         TrajectoryStateOnSurface tsosc = tsoscomb.combine(meas.forwardPredictedState(), meas.backwardPredictedState());
1771         align::LocalPoint trackPos = tsosc.localPosition();
1772         LocalError trackErr = tsosc.localError().positionError();
1773         align::LocalPoint hitPos = hit->localPosition();
1774         LocalError hitErr = hit->localPositionError();  // CPE+APE
1775 
1776         // subtract APEs from hitErr (if existing) from covariance matrix
1777         auto det = static_cast<const TrackerGeomDet *>(hit->det());
1778         const auto localAPE = det->localAlignmentError();
1779         if (localAPE.valid()) {
1780           hitErr = LocalError(hitErr.xx() - localAPE.xx(), hitErr.xy() - localAPE.xy(), hitErr.yy() - localAPE.yy());
1781         }
1782 
1783         double x_residual = 10. * (trackPos.x() - hitPos.x());
1784         double y_residual = 10. * (trackPos.y() - hitPos.y());
1785         double x_reserr2 = 100. * (trackErr.xx() + hitErr.xx());
1786         double y_reserr2 = 100. * (trackErr.yy() + hitErr.yy());
1787         //      double xpos = trackPos.x();
1788         //      double ypos = trackPos.y();
1789 
1790         if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::DT) {
1791           if (fabs(hit->surface()->toGlobal(align::LocalVector(0, 1, 0)).z()) < 0.1) {
1792             // local y != global z: it's a middle (y-measuring) superlayer
1793             y_residual = x_residual;
1794             y_reserr2 = x_reserr2;
1795 
1796             x_residual = 0.;
1797             x_reserr2 = 0.;
1798           } else {
1799             y_residual = 0.;
1800             y_reserr2 = 0.;
1801           }
1802 
1803           if (x_reserr2 > 0.) {
1804             m_xresid->Fill(x_residual, 1. / x_reserr2);
1805             m_xresid_mb->Fill(x_residual, 1. / x_reserr2);
1806           }
1807           if (y_reserr2 > 0.) {
1808             m_yresid->Fill(y_residual, 1. / y_reserr2);
1809             m_yresid_mb->Fill(y_residual, 1. / y_reserr2);
1810           }
1811 
1812           DTChamberId dtId(id.rawId());
1813           int rawId = dtId.rawId();
1814           if (x_reserr2 > 0.) {
1815             m_numx[rawId]++;
1816             m_x_w[rawId] += 1. / x_reserr2;
1817             m_x_ww[rawId] += 1. / x_reserr2 / x_reserr2;
1818             m_x_wx[rawId] += x_residual / x_reserr2;
1819             m_x_wxx[rawId] += x_residual * x_residual / x_reserr2;
1820           }
1821           if (y_reserr2 > 0.) {
1822             m_numy[rawId]++;
1823             m_y_w[rawId] += 1. / y_reserr2;
1824             m_y_ww[rawId] += 1. / y_reserr2 / y_reserr2;
1825             m_y_wy[rawId] += y_residual / y_reserr2;
1826             m_y_wyy[rawId] += y_residual * y_residual / y_reserr2;
1827           }
1828 
1829           if (dtId.station() == 1) {
1830             if (x_reserr2 > 0.) {
1831               m_xresid_mb1->Fill(x_residual, 1. / x_reserr2);
1832             }
1833             if (y_reserr2 > 0.) {
1834               m_yresid_mb1->Fill(y_residual, 1. / y_reserr2);
1835             }
1836           } else if (dtId.station() == 2) {
1837             if (x_reserr2 > 0.) {
1838               m_xresid_mb2->Fill(x_residual, 1. / x_reserr2);
1839             }
1840             if (y_reserr2 > 0.) {
1841               m_yresid_mb2->Fill(y_residual, 1. / y_reserr2);
1842             }
1843           } else if (dtId.station() == 3) {
1844             if (x_reserr2 > 0.) {
1845               m_xresid_mb3->Fill(x_residual, 1. / x_reserr2);
1846             }
1847             if (y_reserr2 > 0.) {
1848               m_yresid_mb3->Fill(y_residual, 1. / y_reserr2);
1849             }
1850           } else if (dtId.station() == 4) {
1851             if (x_reserr2 > 0.) {
1852               m_xresid_mb4->Fill(x_residual, 1. / x_reserr2);
1853             }
1854             if (y_reserr2 > 0.) {
1855               m_yresid_mb4->Fill(y_residual, 1. / y_reserr2);
1856             }
1857           }
1858 
1859           if (dtId.wheel() == -2) {
1860             if (x_reserr2 > 0.) {
1861               m_xresid_minus2->Fill(x_residual, 1. / x_reserr2);
1862             }
1863             if (y_reserr2 > 0.) {
1864               m_yresid_minus2->Fill(y_residual, 1. / y_reserr2);
1865             }
1866           } else if (dtId.wheel() == -1) {
1867             if (x_reserr2 > 0.) {
1868               m_xresid_minus1->Fill(x_residual, 1. / x_reserr2);
1869             }
1870             if (y_reserr2 > 0.) {
1871               m_yresid_minus1->Fill(y_residual, 1. / y_reserr2);
1872             }
1873           } else if (dtId.wheel() == 0) {
1874             if (x_reserr2 > 0.) {
1875               m_xresid_zero->Fill(x_residual, 1. / x_reserr2);
1876             }
1877             if (y_reserr2 > 0.) {
1878               m_yresid_zero->Fill(y_residual, 1. / y_reserr2);
1879             }
1880           } else if (dtId.wheel() == 1) {
1881             if (x_reserr2 > 0.) {
1882               m_xresid_plus1->Fill(x_residual, 1. / x_reserr2);
1883             }
1884             if (y_reserr2 > 0.) {
1885               m_yresid_plus1->Fill(y_residual, 1. / y_reserr2);
1886             }
1887           } else if (dtId.wheel() == 2) {
1888             if (x_reserr2 > 0.) {
1889               m_xresid_plus2->Fill(x_residual, 1. / x_reserr2);
1890             }
1891             if (y_reserr2 > 0.) {
1892               m_yresid_plus2->Fill(y_residual, 1. / y_reserr2);
1893             }
1894           }
1895         }  // end if DT
1896 
1897         else if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::CSC) {
1898           m_xresid->Fill(x_residual, 1. / x_reserr2);
1899           m_yresid->Fill(y_residual, 1. / y_reserr2);
1900 
1901           m_xresid_me->Fill(x_residual, 1. / x_reserr2);
1902           m_yresid_me->Fill(y_residual, 1. / y_reserr2);
1903 
1904           CSCDetId cscId(id.rawId());
1905           int rawId = cscId.chamberId().rawId();
1906           if (x_reserr2 > 0.) {
1907             m_numx[rawId]++;
1908             m_x_w[rawId] += 1. / x_reserr2;
1909             m_x_ww[rawId] += 1. / x_reserr2 / x_reserr2;
1910             m_x_wx[rawId] += x_residual / x_reserr2;
1911             m_x_wxx[rawId] += x_residual * x_residual / x_reserr2;
1912           }
1913           if (y_reserr2 > 0.) {
1914             m_numy[rawId]++;
1915             m_y_w[rawId] += 1. / y_reserr2;
1916             m_y_ww[rawId] += 1. / y_reserr2 / y_reserr2;
1917             m_y_wy[rawId] += y_residual / y_reserr2;
1918             m_y_wyy[rawId] += y_residual * y_residual / y_reserr2;
1919           }
1920 
1921           if ((cscId.endcap() == 1 ? 1 : -1) * cscId.station() == 1 && cscId.ring() == 1) {
1922             m_xresid_mep11->Fill(x_residual, 1. / x_reserr2);
1923             m_yresid_mep11->Fill(y_residual, 1. / y_reserr2);
1924             m_xresid_me11->Fill(x_residual, 1. / x_reserr2);
1925             m_yresid_me11->Fill(y_residual, 1. / y_reserr2);
1926           } else if ((cscId.endcap() == 1 ? 1 : -1) * cscId.station() == -1 && cscId.ring() == 1) {
1927             m_xresid_mem11->Fill(x_residual, 1. / x_reserr2);
1928             m_yresid_mem11->Fill(y_residual, 1. / y_reserr2);
1929             m_xresid_me11->Fill(x_residual, 1. / x_reserr2);
1930             m_yresid_me11->Fill(y_residual, 1. / y_reserr2);
1931           } else if ((cscId.endcap() == 1 ? 1 : -1) * cscId.station() == 1 && cscId.ring() == 2) {
1932             m_xresid_mep12->Fill(x_residual, 1. / x_reserr2);
1933             m_yresid_mep12->Fill(y_residual, 1. / y_reserr2);
1934             m_xresid_me12->Fill(x_residual, 1. / x_reserr2);
1935             m_yresid_me12->Fill(y_residual, 1. / y_reserr2);
1936           } else if ((cscId.endcap() == 1 ? 1 : -1) * cscId.station() == -1 && cscId.ring() == 2) {
1937             m_xresid_mem12->Fill(x_residual, 1. / x_reserr2);
1938             m_yresid_mem12->Fill(y_residual, 1. / y_reserr2);
1939             m_xresid_me12->Fill(x_residual, 1. / x_reserr2);
1940             m_yresid_me12->Fill(y_residual, 1. / y_reserr2);
1941           } else if ((cscId.endcap() == 1 ? 1 : -1) * cscId.station() == 1 && cscId.ring() == 3) {
1942             m_xresid_mep13->Fill(x_residual, 1. / x_reserr2);
1943             m_yresid_mep13->Fill(y_residual, 1. / y_reserr2);
1944             m_xresid_me13->Fill(x_residual, 1. / x_reserr2);
1945             m_yresid_me13->Fill(y_residual, 1. / y_reserr2);
1946           } else if ((cscId.endcap() == 1 ? 1 : -1) * cscId.station() == -1 && cscId.ring() == 3) {
1947             m_xresid_mem13->Fill(x_residual, 1. / x_reserr2);
1948             m_yresid_mem13->Fill(y_residual, 1. / y_reserr2);
1949             m_xresid_me13->Fill(x_residual, 1. / x_reserr2);
1950             m_yresid_me13->Fill(y_residual, 1. / y_reserr2);
1951           } else if ((cscId.endcap() == 1 ? 1 : -1) * cscId.station() == 1 && cscId.ring() == 4) {
1952             m_xresid_mep14->Fill(x_residual, 1. / x_reserr2);
1953             m_yresid_mep14->Fill(y_residual, 1. / y_reserr2);
1954             m_xresid_me14->Fill(x_residual, 1. / x_reserr2);
1955             m_yresid_me14->Fill(y_residual, 1. / y_reserr2);
1956           } else if ((cscId.endcap() == 1 ? 1 : -1) * cscId.station() == -1 && cscId.ring() == 4) {
1957             m_xresid_mem14->Fill(x_residual, 1. / x_reserr2);
1958             m_yresid_mem14->Fill(y_residual, 1. / y_reserr2);
1959             m_xresid_me14->Fill(x_residual, 1. / x_reserr2);
1960             m_yresid_me14->Fill(y_residual, 1. / y_reserr2);
1961           } else if ((cscId.endcap() == 1 ? 1 : -1) * cscId.station() == 2 && cscId.ring() == 1) {
1962             m_xresid_mep21->Fill(x_residual, 1. / x_reserr2);
1963             m_yresid_mep21->Fill(y_residual, 1. / y_reserr2);
1964             m_xresid_me21->Fill(x_residual, 1. / x_reserr2);
1965             m_yresid_me21->Fill(y_residual, 1. / y_reserr2);
1966           } else if ((cscId.endcap() == 1 ? 1 : -1) * cscId.station() == -2 && cscId.ring() == 1) {
1967             m_xresid_mem21->Fill(x_residual, 1. / x_reserr2);
1968             m_yresid_mem21->Fill(y_residual, 1. / y_reserr2);
1969             m_xresid_me21->Fill(x_residual, 1. / x_reserr2);
1970             m_yresid_me21->Fill(y_residual, 1. / y_reserr2);
1971           } else if ((cscId.endcap() == 1 ? 1 : -1) * cscId.station() == 2 && cscId.ring() == 2) {
1972             m_xresid_mep22->Fill(x_residual, 1. / x_reserr2);
1973             m_yresid_mep22->Fill(y_residual, 1. / y_reserr2);
1974             m_xresid_me22->Fill(x_residual, 1. / x_reserr2);
1975             m_yresid_me22->Fill(y_residual, 1. / y_reserr2);
1976           } else if ((cscId.endcap() == 1 ? 1 : -1) * cscId.station() == -2 && cscId.ring() == 2) {
1977             m_xresid_mem22->Fill(x_residual, 1. / x_reserr2);
1978             m_yresid_mem22->Fill(y_residual, 1. / y_reserr2);
1979             m_xresid_me22->Fill(x_residual, 1. / x_reserr2);
1980             m_yresid_me22->Fill(y_residual, 1. / y_reserr2);
1981           } else if ((cscId.endcap() == 1 ? 1 : -1) * cscId.station() == 3 && cscId.ring() == 1) {
1982             m_xresid_mep31->Fill(x_residual, 1. / x_reserr2);
1983             m_yresid_mep31->Fill(y_residual, 1. / y_reserr2);
1984             m_xresid_me31->Fill(x_residual, 1. / x_reserr2);
1985             m_yresid_me31->Fill(y_residual, 1. / y_reserr2);
1986           } else if ((cscId.endcap() == 1 ? 1 : -1) * cscId.station() == -3 && cscId.ring() == 1) {
1987             m_xresid_mem31->Fill(x_residual, 1. / x_reserr2);
1988             m_yresid_mem31->Fill(y_residual, 1. / y_reserr2);
1989             m_xresid_me31->Fill(x_residual, 1. / x_reserr2);
1990             m_yresid_me31->Fill(y_residual, 1. / y_reserr2);
1991           } else if ((cscId.endcap() == 1 ? 1 : -1) * cscId.station() == 3 && cscId.ring() == 2) {
1992             m_xresid_mep32->Fill(x_residual, 1. / x_reserr2);
1993             m_yresid_mep32->Fill(y_residual, 1. / y_reserr2);
1994             m_xresid_me32->Fill(x_residual, 1. / x_reserr2);
1995             m_yresid_me32->Fill(y_residual, 1. / y_reserr2);
1996           } else if ((cscId.endcap() == 1 ? 1 : -1) * cscId.station() == -3 && cscId.ring() == 2) {
1997             m_xresid_mem32->Fill(x_residual, 1. / x_reserr2);
1998             m_yresid_mem32->Fill(y_residual, 1. / y_reserr2);
1999             m_xresid_me32->Fill(x_residual, 1. / x_reserr2);
2000             m_yresid_me32->Fill(y_residual, 1. / y_reserr2);
2001           } else if ((cscId.endcap() == 1 ? 1 : -1) * cscId.station() == 4 && cscId.ring() == 1) {
2002             m_xresid_mep41->Fill(x_residual, 1. / x_reserr2);
2003             m_yresid_mep41->Fill(y_residual, 1. / y_reserr2);
2004             m_xresid_me41->Fill(x_residual, 1. / x_reserr2);
2005             m_yresid_me41->Fill(y_residual, 1. / y_reserr2);
2006           } else if ((cscId.endcap() == 1 ? 1 : -1) * cscId.station() == -4 && cscId.ring() == 1) {
2007             m_xresid_mem41->Fill(x_residual, 1. / x_reserr2);
2008             m_yresid_mem41->Fill(y_residual, 1. / y_reserr2);
2009             m_xresid_me41->Fill(x_residual, 1. / x_reserr2);
2010             m_yresid_me41->Fill(y_residual, 1. / y_reserr2);
2011           }
2012         }  // else if CSC
2013 
2014       }  // end if good hit
2015     }    // end loop over measurements
2016 
2017   }  // end loop over track-trajectories
2018 }
2019 
2020 void AlignmentMonitorMuonResiduals::afterAlignment() {
2021   align::Alignables chambers;
2022   for (const auto &iter : pMuon()->DTChambers())
2023     chambers.push_back(iter);
2024   for (const auto &iter : pMuon()->CSCChambers())
2025     chambers.push_back(iter);
2026 
2027   int index = 0;
2028   for (const auto &chamber : chambers) {
2029     const int id = chamber->geomDetId().rawId();
2030 
2031     m_chambers_rawid = id;
2032     m_chambers_numx = m_numx[id];
2033     m_chambers_x_w = m_x_w[id];
2034     m_chambers_x_ww = m_x_ww[id];
2035     m_chambers_x_wx = m_x_wx[id];
2036     m_chambers_x_wxx = m_x_wxx[id];
2037     m_chambers_numy = m_numy[id];
2038     m_chambers_y_w = m_y_w[id];
2039     m_chambers_y_ww = m_y_ww[id];
2040     m_chambers_y_wy = m_y_wy[id];
2041     m_chambers_y_wyy = m_y_wyy[id];
2042 
2043     index++;
2044     m_sumnumx->SetBinContent(index, m_numx[id]);
2045     m_sumnumy->SetBinContent(index, m_numy[id]);
2046 
2047     std::ostringstream name;
2048     if (chamber->geomDetId().subdetId() == MuonSubdetId::DT) {
2049       DTChamberId dtId(chamber->geomDetId());
2050       name << "MB" << dtId.wheel() << "/" << dtId.station() << " (" << dtId.sector() << ")";
2051       m_chambers_endcap = 0;
2052       m_chambers_wheel = dtId.wheel();
2053       m_chambers_station = dtId.station();
2054       m_chambers_sector = dtId.sector();
2055       m_chambers_ring = 0;
2056       m_chambers_chamber = 0;
2057     } else {
2058       CSCDetId cscId(chamber->geomDetId());
2059       name << "ME" << (cscId.endcap() == 1 ? "+" : "-") << cscId.station() << "/" << cscId.ring() << " ("
2060            << cscId.chamber() << ")";
2061       m_chambers_endcap = cscId.endcap();
2062       m_chambers_wheel = 0;
2063       m_chambers_station = cscId.station();
2064       m_chambers_sector = 0;
2065       m_chambers_ring = cscId.ring();
2066       m_chambers_chamber = cscId.chamber();
2067     }
2068     m_chambers->Fill();
2069 
2070     m_sumnumx->GetXaxis()->SetBinLabel(index, name.str().c_str());
2071     m_sumnumy->GetXaxis()->SetBinLabel(index, name.str().c_str());
2072     m_xsummary->GetXaxis()->SetBinLabel(index, name.str().c_str());
2073     m_ysummary->GetXaxis()->SetBinLabel(index, name.str().c_str());
2074 
2075     if (m_numx[id] > 0.) {
2076       double xmean = m_x_wx[id] / m_x_w[id];
2077       double xstdev =
2078           sqrt(((m_x_wxx[id] * m_x_w[id]) - (m_x_wx[id] * m_x_wx[id])) / ((m_x_w[id] * m_x_w[id]) - m_x_ww[id]));
2079       double xerronmean = xstdev / sqrt(m_numx[id]);
2080 
2081       m_xsummary->SetBinContent(index, xmean);
2082       m_xsummary->SetBinError(index, xerronmean);
2083 
2084       m_xmean->Fill(xmean);
2085       m_xstdev->Fill(xstdev);
2086       m_xerronmean->Fill(xerronmean);
2087       if (chamber->geomDetId().subdetId() == MuonSubdetId::DT) {
2088         m_xmean_mb->Fill(xmean);
2089         m_xstdev_mb->Fill(xstdev);
2090         m_xerronmean_mb->Fill(xerronmean);
2091         DTChamberId id(chamber->geomDetId().rawId());
2092         if (id.station() == 1) {
2093           m_xmean_mb1->Fill(xmean);
2094           m_xstdev_mb1->Fill(xstdev);
2095           m_xerronmean_mb1->Fill(xerronmean);
2096         } else if (id.station() == 2) {
2097           m_xmean_mb2->Fill(xmean);
2098           m_xstdev_mb2->Fill(xstdev);
2099           m_xerronmean_mb2->Fill(xerronmean);
2100         } else if (id.station() == 3) {
2101           m_xmean_mb3->Fill(xmean);
2102           m_xstdev_mb3->Fill(xstdev);
2103           m_xerronmean_mb3->Fill(xerronmean);
2104         } else if (id.station() == 4) {
2105           m_xmean_mb4->Fill(xmean);
2106           m_xstdev_mb4->Fill(xstdev);
2107           m_xerronmean_mb4->Fill(xerronmean);
2108         }
2109 
2110         if (id.wheel() == -2) {
2111           m_xmean_minus2->Fill(xmean);
2112           m_xstdev_minus2->Fill(xstdev);
2113           m_xerronmean_minus2->Fill(xerronmean);
2114         } else if (id.wheel() == -1) {
2115           m_xmean_minus1->Fill(xmean);
2116           m_xstdev_minus1->Fill(xstdev);
2117           m_xerronmean_minus1->Fill(xerronmean);
2118         } else if (id.wheel() == 0) {
2119           m_xmean_zero->Fill(xmean);
2120           m_xstdev_zero->Fill(xstdev);
2121           m_xerronmean_zero->Fill(xerronmean);
2122         } else if (id.wheel() == 1) {
2123           m_xmean_plus1->Fill(xmean);
2124           m_xstdev_plus1->Fill(xstdev);
2125           m_xerronmean_plus1->Fill(xerronmean);
2126         } else if (id.wheel() == 2) {
2127           m_xmean_plus2->Fill(xmean);
2128           m_xstdev_plus2->Fill(xstdev);
2129           m_xerronmean_plus2->Fill(xerronmean);
2130         }
2131       }  // end if DT
2132       else {
2133         m_xmean_me->Fill(xmean);
2134         m_xstdev_me->Fill(xstdev);
2135         m_xerronmean_me->Fill(xerronmean);
2136 
2137         CSCDetId id(chamber->geomDetId().rawId());
2138 
2139         if ((id.endcap() == 1 ? 1 : -1) * id.station() == 1 && id.ring() == 1) {
2140           m_xmean_mep11->Fill(xmean);
2141           m_xstdev_mep11->Fill(xstdev);
2142           m_xerronmean_mep11->Fill(xerronmean);
2143           m_xmean_me11->Fill(xmean);
2144           m_xstdev_me11->Fill(xstdev);
2145           m_xerronmean_me11->Fill(xerronmean);
2146         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == -1 && id.ring() == 1) {
2147           m_xmean_mem11->Fill(xmean);
2148           m_xstdev_mem11->Fill(xstdev);
2149           m_xerronmean_mem11->Fill(xerronmean);
2150           m_xmean_me11->Fill(xmean);
2151           m_xstdev_me11->Fill(xstdev);
2152           m_xerronmean_me11->Fill(xerronmean);
2153         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == 1 && id.ring() == 2) {
2154           m_xmean_mep12->Fill(xmean);
2155           m_xstdev_mep12->Fill(xstdev);
2156           m_xerronmean_mep12->Fill(xerronmean);
2157           m_xmean_me12->Fill(xmean);
2158           m_xstdev_me12->Fill(xstdev);
2159           m_xerronmean_me12->Fill(xerronmean);
2160         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == -1 && id.ring() == 2) {
2161           m_xmean_mem12->Fill(xmean);
2162           m_xstdev_mem12->Fill(xstdev);
2163           m_xerronmean_mem12->Fill(xerronmean);
2164           m_xmean_me12->Fill(xmean);
2165           m_xstdev_me12->Fill(xstdev);
2166           m_xerronmean_me12->Fill(xerronmean);
2167         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == 1 && id.ring() == 3) {
2168           m_xmean_mep13->Fill(xmean);
2169           m_xstdev_mep13->Fill(xstdev);
2170           m_xerronmean_mep13->Fill(xerronmean);
2171           m_xmean_me13->Fill(xmean);
2172           m_xstdev_me13->Fill(xstdev);
2173           m_xerronmean_me13->Fill(xerronmean);
2174         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == -1 && id.ring() == 3) {
2175           m_xmean_mem13->Fill(xmean);
2176           m_xstdev_mem13->Fill(xstdev);
2177           m_xerronmean_mem13->Fill(xerronmean);
2178           m_xmean_me13->Fill(xmean);
2179           m_xstdev_me13->Fill(xstdev);
2180           m_xerronmean_me13->Fill(xerronmean);
2181         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == 1 && id.ring() == 4) {
2182           m_xmean_mep14->Fill(xmean);
2183           m_xstdev_mep14->Fill(xstdev);
2184           m_xerronmean_mep14->Fill(xerronmean);
2185           m_xmean_me14->Fill(xmean);
2186           m_xstdev_me14->Fill(xstdev);
2187           m_xerronmean_me14->Fill(xerronmean);
2188         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == -1 && id.ring() == 4) {
2189           m_xmean_mem14->Fill(xmean);
2190           m_xstdev_mem14->Fill(xstdev);
2191           m_xerronmean_mem14->Fill(xerronmean);
2192           m_xmean_me14->Fill(xmean);
2193           m_xstdev_me14->Fill(xstdev);
2194           m_xerronmean_me14->Fill(xerronmean);
2195         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == 2 && id.ring() == 1) {
2196           m_xmean_mep21->Fill(xmean);
2197           m_xstdev_mep21->Fill(xstdev);
2198           m_xerronmean_mep21->Fill(xerronmean);
2199           m_xmean_me21->Fill(xmean);
2200           m_xstdev_me21->Fill(xstdev);
2201           m_xerronmean_me21->Fill(xerronmean);
2202         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == -2 && id.ring() == 1) {
2203           m_xmean_mem21->Fill(xmean);
2204           m_xstdev_mem21->Fill(xstdev);
2205           m_xerronmean_mem21->Fill(xerronmean);
2206           m_xmean_me21->Fill(xmean);
2207           m_xstdev_me21->Fill(xstdev);
2208           m_xerronmean_me21->Fill(xerronmean);
2209         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == 2 && id.ring() == 2) {
2210           m_xmean_mep22->Fill(xmean);
2211           m_xstdev_mep22->Fill(xstdev);
2212           m_xerronmean_mep22->Fill(xerronmean);
2213           m_xmean_me22->Fill(xmean);
2214           m_xstdev_me22->Fill(xstdev);
2215           m_xerronmean_me22->Fill(xerronmean);
2216         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == -2 && id.ring() == 2) {
2217           m_xmean_mem22->Fill(xmean);
2218           m_xstdev_mem22->Fill(xstdev);
2219           m_xerronmean_mem22->Fill(xerronmean);
2220           m_xmean_me22->Fill(xmean);
2221           m_xstdev_me22->Fill(xstdev);
2222           m_xerronmean_me22->Fill(xerronmean);
2223         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == 3 && id.ring() == 1) {
2224           m_xmean_mep31->Fill(xmean);
2225           m_xstdev_mep31->Fill(xstdev);
2226           m_xerronmean_mep31->Fill(xerronmean);
2227           m_xmean_me31->Fill(xmean);
2228           m_xstdev_me31->Fill(xstdev);
2229           m_xerronmean_me31->Fill(xerronmean);
2230         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == -3 && id.ring() == 1) {
2231           m_xmean_mem31->Fill(xmean);
2232           m_xstdev_mem31->Fill(xstdev);
2233           m_xerronmean_mem31->Fill(xerronmean);
2234           m_xmean_me31->Fill(xmean);
2235           m_xstdev_me31->Fill(xstdev);
2236           m_xerronmean_me31->Fill(xerronmean);
2237         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == 3 && id.ring() == 2) {
2238           m_xmean_mep32->Fill(xmean);
2239           m_xstdev_mep32->Fill(xstdev);
2240           m_xerronmean_mep32->Fill(xerronmean);
2241           m_xmean_me32->Fill(xmean);
2242           m_xstdev_me32->Fill(xstdev);
2243           m_xerronmean_me32->Fill(xerronmean);
2244         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == -3 && id.ring() == 2) {
2245           m_xmean_mem32->Fill(xmean);
2246           m_xstdev_mem32->Fill(xstdev);
2247           m_xerronmean_mem32->Fill(xerronmean);
2248           m_xmean_me32->Fill(xmean);
2249           m_xstdev_me32->Fill(xstdev);
2250           m_xerronmean_me32->Fill(xerronmean);
2251         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == 4 && id.ring() == 1) {
2252           m_xmean_mep41->Fill(xmean);
2253           m_xstdev_mep41->Fill(xstdev);
2254           m_xerronmean_mep41->Fill(xerronmean);
2255           m_xmean_me41->Fill(xmean);
2256           m_xstdev_me41->Fill(xstdev);
2257           m_xerronmean_me41->Fill(xerronmean);
2258         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == -4 && id.ring() == 1) {
2259           m_xmean_mem41->Fill(xmean);
2260           m_xstdev_mem41->Fill(xstdev);
2261           m_xerronmean_mem41->Fill(xerronmean);
2262           m_xmean_me41->Fill(xmean);
2263           m_xstdev_me41->Fill(xstdev);
2264           m_xerronmean_me41->Fill(xerronmean);
2265         }
2266       }  // else itis CSC
2267     }    // end if xmean, xstdev exist
2268 
2269     if (m_numy[id] > 0.) {
2270       double ymean = m_y_wy[id] / m_y_w[id];
2271       double ystdev =
2272           sqrt(((m_y_wyy[id] * m_y_w[id]) - (m_y_wy[id] * m_y_wy[id])) / ((m_y_w[id] * m_y_w[id]) - m_y_ww[id]));
2273       double yerronmean = ystdev / sqrt(m_numy[id]);
2274 
2275       m_ysummary->SetBinContent(index, ymean);
2276       m_ysummary->SetBinError(index, yerronmean);
2277 
2278       m_ymean->Fill(ymean);
2279       m_ystdev->Fill(ystdev);
2280       m_yerronmean->Fill(yerronmean);
2281       if (chamber->geomDetId().subdetId() == MuonSubdetId::DT) {
2282         m_ymean_mb->Fill(ymean);
2283         m_ystdev_mb->Fill(ystdev);
2284         m_yerronmean_mb->Fill(yerronmean);
2285         DTChamberId id(chamber->geomDetId().rawId());
2286         if (id.station() == 1) {
2287           m_ymean_mb1->Fill(ymean);
2288           m_ystdev_mb1->Fill(ystdev);
2289           m_yerronmean_mb1->Fill(yerronmean);
2290         } else if (id.station() == 2) {
2291           m_ymean_mb2->Fill(ymean);
2292           m_ystdev_mb2->Fill(ystdev);
2293           m_yerronmean_mb2->Fill(yerronmean);
2294         } else if (id.station() == 3) {
2295           m_ymean_mb3->Fill(ymean);
2296           m_ystdev_mb3->Fill(ystdev);
2297           m_yerronmean_mb3->Fill(yerronmean);
2298         } else if (id.station() == 4) {
2299           m_ymean_mb4->Fill(ymean);
2300           m_ystdev_mb4->Fill(ystdev);
2301           m_yerronmean_mb4->Fill(yerronmean);
2302         }
2303 
2304         if (id.wheel() == -2) {
2305           m_ymean_minus2->Fill(ymean);
2306           m_ystdev_minus2->Fill(ystdev);
2307           m_yerronmean_minus2->Fill(yerronmean);
2308         } else if (id.wheel() == -1) {
2309           m_ymean_minus1->Fill(ymean);
2310           m_ystdev_minus1->Fill(ystdev);
2311           m_yerronmean_minus1->Fill(yerronmean);
2312         } else if (id.wheel() == 0) {
2313           m_ymean_zero->Fill(ymean);
2314           m_ystdev_zero->Fill(ystdev);
2315           m_yerronmean_zero->Fill(yerronmean);
2316         } else if (id.wheel() == 1) {
2317           m_ymean_plus1->Fill(ymean);
2318           m_ystdev_plus1->Fill(ystdev);
2319           m_yerronmean_plus1->Fill(yerronmean);
2320         } else if (id.wheel() == 2) {
2321           m_ymean_plus2->Fill(ymean);
2322           m_ystdev_plus2->Fill(ystdev);
2323           m_yerronmean_plus2->Fill(yerronmean);
2324         }
2325       }  // end if DT
2326       else {
2327         m_ymean_me->Fill(ymean);
2328         m_ystdev_me->Fill(ystdev);
2329         m_yerronmean_me->Fill(yerronmean);
2330 
2331         CSCDetId id(chamber->geomDetId().rawId());
2332 
2333         if ((id.endcap() == 1 ? 1 : -1) * id.station() == 1 && id.ring() == 1) {
2334           m_ymean_mep11->Fill(ymean);
2335           m_ystdev_mep11->Fill(ystdev);
2336           m_yerronmean_mep11->Fill(yerronmean);
2337           m_ymean_me11->Fill(ymean);
2338           m_ystdev_me11->Fill(ystdev);
2339           m_yerronmean_me11->Fill(yerronmean);
2340         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == -1 && id.ring() == 1) {
2341           m_ymean_mem11->Fill(ymean);
2342           m_ystdev_mem11->Fill(ystdev);
2343           m_yerronmean_mem11->Fill(yerronmean);
2344           m_ymean_me11->Fill(ymean);
2345           m_ystdev_me11->Fill(ystdev);
2346           m_yerronmean_me11->Fill(yerronmean);
2347         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == 1 && id.ring() == 2) {
2348           m_ymean_mep12->Fill(ymean);
2349           m_ystdev_mep12->Fill(ystdev);
2350           m_yerronmean_mep12->Fill(yerronmean);
2351           m_ymean_me12->Fill(ymean);
2352           m_ystdev_me12->Fill(ystdev);
2353           m_yerronmean_me12->Fill(yerronmean);
2354         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == -1 && id.ring() == 2) {
2355           m_ymean_mem12->Fill(ymean);
2356           m_ystdev_mem12->Fill(ystdev);
2357           m_yerronmean_mem12->Fill(yerronmean);
2358           m_ymean_me12->Fill(ymean);
2359           m_ystdev_me12->Fill(ystdev);
2360           m_yerronmean_me12->Fill(yerronmean);
2361         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == 1 && id.ring() == 3) {
2362           m_ymean_mep13->Fill(ymean);
2363           m_ystdev_mep13->Fill(ystdev);
2364           m_yerronmean_mep13->Fill(yerronmean);
2365           m_ymean_me13->Fill(ymean);
2366           m_ystdev_me13->Fill(ystdev);
2367           m_yerronmean_me13->Fill(yerronmean);
2368         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == -1 && id.ring() == 3) {
2369           m_ymean_mem13->Fill(ymean);
2370           m_ystdev_mem13->Fill(ystdev);
2371           m_yerronmean_mem13->Fill(yerronmean);
2372           m_ymean_me13->Fill(ymean);
2373           m_ystdev_me13->Fill(ystdev);
2374           m_yerronmean_me13->Fill(yerronmean);
2375         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == 1 && id.ring() == 4) {
2376           m_ymean_mep14->Fill(ymean);
2377           m_ystdev_mep14->Fill(ystdev);
2378           m_yerronmean_mep14->Fill(yerronmean);
2379           m_ymean_me14->Fill(ymean);
2380           m_ystdev_me14->Fill(ystdev);
2381           m_yerronmean_me14->Fill(yerronmean);
2382         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == -1 && id.ring() == 4) {
2383           m_ymean_mem14->Fill(ymean);
2384           m_ystdev_mem14->Fill(ystdev);
2385           m_yerronmean_mem14->Fill(yerronmean);
2386           m_ymean_me14->Fill(ymean);
2387           m_ystdev_me14->Fill(ystdev);
2388           m_yerronmean_me14->Fill(yerronmean);
2389         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == 2 && id.ring() == 1) {
2390           m_ymean_mep21->Fill(ymean);
2391           m_ystdev_mep21->Fill(ystdev);
2392           m_yerronmean_mep21->Fill(yerronmean);
2393           m_ymean_me21->Fill(ymean);
2394           m_ystdev_me21->Fill(ystdev);
2395           m_yerronmean_me21->Fill(yerronmean);
2396         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == -2 && id.ring() == 1) {
2397           m_ymean_mem21->Fill(ymean);
2398           m_ystdev_mem21->Fill(ystdev);
2399           m_yerronmean_mem21->Fill(yerronmean);
2400           m_ymean_me21->Fill(ymean);
2401           m_ystdev_me21->Fill(ystdev);
2402           m_yerronmean_me21->Fill(yerronmean);
2403         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == 2 && id.ring() == 2) {
2404           m_ymean_mep22->Fill(ymean);
2405           m_ystdev_mep22->Fill(ystdev);
2406           m_yerronmean_mep22->Fill(yerronmean);
2407           m_ymean_me22->Fill(ymean);
2408           m_ystdev_me22->Fill(ystdev);
2409           m_yerronmean_me22->Fill(yerronmean);
2410         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == -2 && id.ring() == 2) {
2411           m_ymean_mem22->Fill(ymean);
2412           m_ystdev_mem22->Fill(ystdev);
2413           m_yerronmean_mem22->Fill(yerronmean);
2414           m_ymean_me22->Fill(ymean);
2415           m_ystdev_me22->Fill(ystdev);
2416           m_yerronmean_me22->Fill(yerronmean);
2417         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == 3 && id.ring() == 1) {
2418           m_ymean_mep31->Fill(ymean);
2419           m_ystdev_mep31->Fill(ystdev);
2420           m_yerronmean_mep31->Fill(yerronmean);
2421           m_ymean_me31->Fill(ymean);
2422           m_ystdev_me31->Fill(ystdev);
2423           m_yerronmean_me31->Fill(yerronmean);
2424         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == -3 && id.ring() == 1) {
2425           m_ymean_mem31->Fill(ymean);
2426           m_ystdev_mem31->Fill(ystdev);
2427           m_yerronmean_mem31->Fill(yerronmean);
2428           m_ymean_me31->Fill(ymean);
2429           m_ystdev_me31->Fill(ystdev);
2430           m_yerronmean_me31->Fill(yerronmean);
2431         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == 3 && id.ring() == 2) {
2432           m_ymean_mep32->Fill(ymean);
2433           m_ystdev_mep32->Fill(ystdev);
2434           m_yerronmean_mep32->Fill(yerronmean);
2435           m_ymean_me32->Fill(ymean);
2436           m_ystdev_me32->Fill(ystdev);
2437           m_yerronmean_me32->Fill(yerronmean);
2438         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == -3 && id.ring() == 2) {
2439           m_ymean_mem32->Fill(ymean);
2440           m_ystdev_mem32->Fill(ystdev);
2441           m_yerronmean_mem32->Fill(yerronmean);
2442           m_ymean_me32->Fill(ymean);
2443           m_ystdev_me32->Fill(ystdev);
2444           m_yerronmean_me32->Fill(yerronmean);
2445         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == 4 && id.ring() == 1) {
2446           m_ymean_mep41->Fill(ymean);
2447           m_ystdev_mep41->Fill(ystdev);
2448           m_yerronmean_mep41->Fill(yerronmean);
2449           m_ymean_me41->Fill(ymean);
2450           m_ystdev_me41->Fill(ystdev);
2451           m_yerronmean_me41->Fill(yerronmean);
2452         } else if ((id.endcap() == 1 ? 1 : -1) * id.station() == -4 && id.ring() == 1) {
2453           m_ymean_mem41->Fill(ymean);
2454           m_ystdev_mem41->Fill(ystdev);
2455           m_yerronmean_mem41->Fill(yerronmean);
2456           m_ymean_me41->Fill(ymean);
2457           m_ystdev_me41->Fill(ystdev);
2458           m_yerronmean_me41->Fill(yerronmean);
2459         }
2460       }  // else itis CSC
2461     }    // end if ymean, ystdev exist
2462 
2463   }  // end loop over chambers
2464 }
2465 
2466 //
2467 // constructors and destructor
2468 //
2469 
2470 // AlignmentMonitorMuonResiduals::AlignmentMonitorMuonResiduals(const AlignmentMonitorMuonResiduals& rhs)
2471 // {
2472 //    // do actual copying here;
2473 // }
2474 
2475 //
2476 // assignment operators
2477 //
2478 // const AlignmentMonitorMuonResiduals& AlignmentMonitorMuonResiduals::operator=(const AlignmentMonitorMuonResiduals& rhs)
2479 // {
2480 //   //An exception safe implementation is
2481 //   AlignmentMonitorMuonResiduals temp(rhs);
2482 //   swap(rhs);
2483 //
2484 //   return *this;
2485 // }
2486 
2487 //
2488 // const member functions
2489 //
2490 
2491 //
2492 // static member functions
2493 //
2494 
2495 //
2496 // SEAL definitions
2497 //
2498 
2499 DEFINE_EDM_PLUGIN(AlignmentMonitorPluginFactory, AlignmentMonitorMuonResiduals, "AlignmentMonitorMuonResiduals");