Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:45:51

0001 /** \class MuonAlignmentAnalyzer
0002  *  MuonAlignment offline Monitor Analyzer 
0003  *  Makes histograms of high level Muon objects/quantities
0004  *  for Alignment Scenarios/DB comparison
0005  *
0006  *  $Date: 2011/09/04 17:40:58 $
0007  *  $Revision: 1.13 $
0008  *  \author J. Fernandez - Univ. Oviedo <Javier.Fernandez@cern.ch>
0009  */
0010 
0011 #include "Alignment/OfflineValidation/plugins/MuonAlignmentAnalyzer.h"
0012 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
0013 
0014 // Collaborating Class Header
0015 #include "FWCore/Framework/interface/MakerMacros.h"
0016 #include "FWCore/Framework/interface/Event.h"
0017 
0018 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
0019 #include "DataFormats/DetId/interface/DetId.h"
0020 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
0021 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0022 #include "DataFormats/Math/interface/deltaR.h"
0023 
0024 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
0025 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0026 #include "DataFormats/TrackReco/interface/Track.h"
0027 
0028 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0029 
0030 #include "DataFormats/TrackingRecHit/interface/RecSegment.h"
0031 #include "DataFormats/DTRecHit/interface/DTRecSegment4D.h"
0032 #include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
0033 #include "DataFormats/CSCRecHit/interface/CSCSegment.h"
0034 #include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h"
0035 #include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixPropagator.h"
0036 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
0037 
0038 #include "DataFormats/GeometrySurface/interface/Cylinder.h"
0039 #include "DataFormats/GeometrySurface/interface/Plane.h"
0040 #include "DataFormats/GeometrySurface/interface/Cone.h"
0041 
0042 #include "TH2F.h"
0043 #include "TLorentzVector.h"
0044 
0045 /// Constructor
0046 MuonAlignmentAnalyzer::MuonAlignmentAnalyzer(const edm::ParameterSet &pset)
0047     : magFieldToken_(esConsumes()),
0048       trackingGeometryToken_(esConsumes()),
0049       hGBNmuons(nullptr),
0050       hSANmuons(nullptr),
0051       hSimNmuons(nullptr),
0052       hGBNmuons_Barrel(nullptr),
0053       hSANmuons_Barrel(nullptr),
0054       hSimNmuons_Barrel(nullptr),
0055       hGBNmuons_Endcap(nullptr),
0056       hSANmuons_Endcap(nullptr),
0057       hSimNmuons_Endcap(nullptr),
0058       hGBNhits(nullptr),
0059       hGBNhits_Barrel(nullptr),
0060       hGBNhits_Endcap(nullptr),
0061       hSANhits(nullptr),
0062       hSANhits_Barrel(nullptr),
0063       hSANhits_Endcap(nullptr),
0064       hGBChi2(nullptr),
0065       hSAChi2(nullptr),
0066       hGBChi2_Barrel(nullptr),
0067       hSAChi2_Barrel(nullptr),
0068       hGBChi2_Endcap(nullptr),
0069       hSAChi2_Endcap(nullptr),
0070       hGBInvM(nullptr),
0071       hSAInvM(nullptr),
0072       hSimInvM(nullptr),
0073       hGBInvM_Barrel(nullptr),
0074       hSAInvM_Barrel(nullptr),
0075       hSimInvM_Barrel(nullptr),
0076       hGBInvM_Endcap(nullptr),
0077       hSAInvM_Endcap(nullptr),
0078       hSimInvM_Endcap(nullptr),
0079       hGBInvM_Overlap(nullptr),
0080       hSAInvM_Overlap(nullptr),
0081       hSimInvM_Overlap(nullptr),
0082       hSAPTRec(nullptr),
0083       hGBPTRec(nullptr),
0084       hSimPT(nullptr),
0085       hSAPTRec_Barrel(nullptr),
0086       hGBPTRec_Barrel(nullptr),
0087       hSimPT_Barrel(nullptr),
0088       hSAPTRec_Endcap(nullptr),
0089       hGBPTRec_Endcap(nullptr),
0090       hSimPT_Endcap(nullptr),
0091       hGBPTvsEta(nullptr),
0092       hGBPTvsPhi(nullptr),
0093       hSAPTvsEta(nullptr),
0094       hSAPTvsPhi(nullptr),
0095       hSimPTvsEta(nullptr),
0096       hSimPTvsPhi(nullptr),
0097       hSimPhivsEta(nullptr),
0098       hSAPhivsEta(nullptr),
0099       hGBPhivsEta(nullptr),
0100       hSAPTres(nullptr),
0101       hSAinvPTres(nullptr),
0102       hGBPTres(nullptr),
0103       hGBinvPTres(nullptr),
0104       hSAPTres_Barrel(nullptr),
0105       hSAPTres_Endcap(nullptr),
0106       hGBPTres_Barrel(nullptr),
0107       hGBPTres_Endcap(nullptr),
0108       hSAPTDiff(nullptr),
0109       hGBPTDiff(nullptr),
0110       hSAPTDiffvsEta(nullptr),
0111       hSAPTDiffvsPhi(nullptr),
0112       hGBPTDiffvsEta(nullptr),
0113       hGBPTDiffvsPhi(nullptr),
0114       hGBinvPTvsEta(nullptr),
0115       hGBinvPTvsPhi(nullptr),
0116       hSAinvPTvsEta(nullptr),
0117       hSAinvPTvsPhi(nullptr),
0118       hSAinvPTvsNhits(nullptr),
0119       hGBinvPTvsNhits(nullptr),
0120       hResidualLocalXDT(nullptr),
0121       hResidualLocalPhiDT(nullptr),
0122       hResidualLocalThetaDT(nullptr),
0123       hResidualLocalYDT(nullptr),
0124       hResidualLocalXCSC(nullptr),
0125       hResidualLocalPhiCSC(nullptr),
0126       hResidualLocalThetaCSC(nullptr),
0127       hResidualLocalYCSC(nullptr),
0128 
0129       hResidualLocalXDT_W(5),
0130       hResidualLocalPhiDT_W(5),
0131       hResidualLocalThetaDT_W(5),
0132       hResidualLocalYDT_W(5),
0133       hResidualLocalXCSC_ME(18),
0134       hResidualLocalPhiCSC_ME(18),
0135       hResidualLocalThetaCSC_ME(18),
0136       hResidualLocalYCSC_ME(18),
0137       hResidualLocalXDT_MB(20),
0138       hResidualLocalPhiDT_MB(20),
0139       hResidualLocalThetaDT_MB(20),
0140       hResidualLocalYDT_MB(20),
0141 
0142       hResidualGlobalRPhiDT(nullptr),
0143       hResidualGlobalPhiDT(nullptr),
0144       hResidualGlobalThetaDT(nullptr),
0145       hResidualGlobalZDT(nullptr),
0146       hResidualGlobalRPhiCSC(nullptr),
0147       hResidualGlobalPhiCSC(nullptr),
0148       hResidualGlobalThetaCSC(nullptr),
0149       hResidualGlobalRCSC(nullptr),
0150 
0151       hResidualGlobalRPhiDT_W(5),
0152       hResidualGlobalPhiDT_W(5),
0153       hResidualGlobalThetaDT_W(5),
0154       hResidualGlobalZDT_W(5),
0155       hResidualGlobalRPhiCSC_ME(18),
0156       hResidualGlobalPhiCSC_ME(18),
0157       hResidualGlobalThetaCSC_ME(18),
0158       hResidualGlobalRCSC_ME(18),
0159       hResidualGlobalRPhiDT_MB(20),
0160       hResidualGlobalPhiDT_MB(20),
0161       hResidualGlobalThetaDT_MB(20),
0162       hResidualGlobalZDT_MB(20),
0163 
0164       hprofLocalPositionCSC(nullptr),
0165       hprofLocalAngleCSC(nullptr),
0166       hprofLocalPositionRmsCSC(nullptr),
0167       hprofLocalAngleRmsCSC(nullptr),
0168       hprofGlobalPositionCSC(nullptr),
0169       hprofGlobalAngleCSC(nullptr),
0170       hprofGlobalPositionRmsCSC(nullptr),
0171       hprofGlobalAngleRmsCSC(nullptr),
0172       hprofLocalPositionDT(nullptr),
0173       hprofLocalAngleDT(nullptr),
0174       hprofLocalPositionRmsDT(nullptr),
0175       hprofLocalAngleRmsDT(nullptr),
0176       hprofGlobalPositionDT(nullptr),
0177       hprofGlobalAngleDT(nullptr),
0178       hprofGlobalPositionRmsDT(nullptr),
0179       hprofGlobalAngleRmsDT(nullptr),
0180       hprofLocalXDT(nullptr),
0181       hprofLocalPhiDT(nullptr),
0182       hprofLocalThetaDT(nullptr),
0183       hprofLocalYDT(nullptr),
0184       hprofLocalXCSC(nullptr),
0185       hprofLocalPhiCSC(nullptr),
0186       hprofLocalThetaCSC(nullptr),
0187       hprofLocalYCSC(nullptr),
0188       hprofGlobalRPhiDT(nullptr),
0189       hprofGlobalPhiDT(nullptr),
0190       hprofGlobalThetaDT(nullptr),
0191       hprofGlobalZDT(nullptr),
0192       hprofGlobalRPhiCSC(nullptr),
0193       hprofGlobalPhiCSC(nullptr),
0194       hprofGlobalThetaCSC(nullptr),
0195       hprofGlobalRCSC(nullptr) {
0196   usesResource(TFileService::kSharedResource);
0197 
0198   theSTAMuonTag = pset.getParameter<edm::InputTag>("StandAloneTrackCollectionTag");
0199   theGLBMuonTag = pset.getParameter<edm::InputTag>("GlobalMuonTrackCollectionTag");
0200 
0201   theRecHits4DTagDT = pset.getParameter<edm::InputTag>("RecHits4DDTCollectionTag");
0202   theRecHits4DTagCSC = pset.getParameter<edm::InputTag>("RecHits4DCSCCollectionTag");
0203 
0204   theDataType = pset.getUntrackedParameter<std::string>("DataType");
0205   ptRangeMin = pset.getUntrackedParameter<double>("ptRangeMin");
0206   ptRangeMax = pset.getUntrackedParameter<double>("ptRangeMax");
0207   invMassRangeMin = pset.getUntrackedParameter<double>("invMassRangeMin");
0208   invMassRangeMax = pset.getUntrackedParameter<double>("invMassRangeMax");
0209 
0210   doSAplots = pset.getUntrackedParameter<bool>("doSAplots");
0211   doGBplots = pset.getUntrackedParameter<bool>("doGBplots");
0212   doResplots = pset.getUntrackedParameter<bool>("doResplots");
0213 
0214   resLocalXRangeStation1 = pset.getUntrackedParameter<double>("resLocalXRangeStation1");
0215   resLocalXRangeStation2 = pset.getUntrackedParameter<double>("resLocalXRangeStation2");
0216   resLocalXRangeStation3 = pset.getUntrackedParameter<double>("resLocalXRangeStation3");
0217   resLocalXRangeStation4 = pset.getUntrackedParameter<double>("resLocalXRangeStation4");
0218   resLocalYRangeStation1 = pset.getUntrackedParameter<double>("resLocalYRangeStation1");
0219   resLocalYRangeStation2 = pset.getUntrackedParameter<double>("resLocalYRangeStation2");
0220   resLocalYRangeStation3 = pset.getUntrackedParameter<double>("resLocalYRangeStation3");
0221   resLocalYRangeStation4 = pset.getUntrackedParameter<double>("resLocalYRangeStation4");
0222   resPhiRange = pset.getUntrackedParameter<double>("resPhiRange");
0223   resThetaRange = pset.getUntrackedParameter<double>("resThetaRange");
0224   nbins = pset.getUntrackedParameter<unsigned int>("nbins");
0225   min1DTrackRecHitSize = pset.getUntrackedParameter<unsigned int>("min1DTrackRecHitSize");
0226   min4DTrackSegmentSize = pset.getUntrackedParameter<unsigned int>("min4DTrackSegmentSize");
0227 
0228   if (theDataType != "RealData" && theDataType != "SimData")
0229     edm::LogError("MuonAlignmentAnalyzer") << "Error in Data Type!!" << std::endl;
0230 
0231   numberOfSimTracks = 0;
0232   numberOfSARecTracks = 0;
0233   numberOfGBRecTracks = 0;
0234   numberOfHits = 0;
0235 }
0236 
0237 /// Destructor
0238 MuonAlignmentAnalyzer::~MuonAlignmentAnalyzer() {}
0239 
0240 void MuonAlignmentAnalyzer::beginJob() {
0241   //  eventSetup.get<IdealMagneticFieldRecord>().get(theMGField);
0242 
0243   //Create the propagator
0244   //  if(doResplots)  thePropagator = new SteppingHelixPropagator(&*theMGField, alongMomentum);
0245 
0246   int nBinsPt = (int)fabs(ptRangeMax - ptRangeMin);
0247   int nBinsMass = (int)fabs(invMassRangeMax - invMassRangeMin);
0248 
0249   // Define and book histograms for SA and GB muon quantities/objects
0250 
0251   if (doGBplots) {
0252     hGBNmuons = fs->make<TH1F>("GBNmuons", "Nmuons", 10, 0, 10);
0253     hGBNmuons_Barrel = fs->make<TH1F>("GBNmuons_Barrel", "Nmuons", 10, 0, 10);
0254     hGBNmuons_Endcap = fs->make<TH1F>("GBNmuons_Endcap", "Nmuons", 10, 0, 10);
0255     hGBNhits = fs->make<TH1F>("GBNhits", "Nhits", 100, 0, 100);
0256     hGBNhits_Barrel = fs->make<TH1F>("GBNhits_Barrel", "Nhits", 100, 0, 100);
0257     hGBNhits_Endcap = fs->make<TH1F>("GBNhits_Endcap", "Nhits", 100, 0, 100);
0258     hGBPTRec = fs->make<TH1F>("GBpTRec", "p_{T}^{rec}", nBinsPt, ptRangeMin, ptRangeMax);
0259     hGBPTRec_Barrel = fs->make<TH1F>("GBpTRec_Barrel", "p_{T}^{rec}", nBinsPt, ptRangeMin, ptRangeMax);
0260     hGBPTRec_Endcap = fs->make<TH1F>("GBpTRec_Endcap", "p_{T}^{rec}", nBinsPt, ptRangeMin, ptRangeMax);
0261     hGBPTvsEta = fs->make<TH2F>("GBPTvsEta", "p_{T}^{rec} VS #eta", 100, -2.5, 2.5, nBinsPt, ptRangeMin, ptRangeMax);
0262     hGBPTvsPhi =
0263         fs->make<TH2F>("GBPTvsPhi", "p_{T}^{rec} VS #phi", 100, -3.1416, 3.1416, nBinsPt, ptRangeMin, ptRangeMax);
0264     hGBPhivsEta = fs->make<TH2F>("GBPhivsEta", "#phi VS #eta", 100, -2.5, 2.5, 100, -3.1416, 3.1416);
0265 
0266     if (theDataType == "SimData") {
0267       hGBPTDiff = fs->make<TH1F>("GBpTDiff", "p_{T}^{rec} - p_{T}^{gen} ", 250, -120, 120);
0268       hGBPTDiffvsEta =
0269           fs->make<TH2F>("GBPTDiffvsEta", "p_{T}^{rec} - p_{T}^{gen} VS #eta", 100, -2.5, 2.5, 250, -120, 120);
0270       hGBPTDiffvsPhi =
0271           fs->make<TH2F>("GBPTDiffvsPhi", "p_{T}^{rec} - p_{T}^{gen} VS #phi", 100, -3.1416, 3.1416, 250, -120, 120);
0272       hGBPTres = fs->make<TH1F>("GBpTRes", "pT Resolution", 100, -2, 2);
0273       hGBPTres_Barrel = fs->make<TH1F>("GBpTRes_Barrel", "pT Resolution", 100, -2, 2);
0274       hGBPTres_Endcap = fs->make<TH1F>("GBpTRes_Endcap", "pT Resolution", 100, -2, 2);
0275       hGBinvPTres = fs->make<TH1F>("GBinvPTRes", "#sigma (q/p_{T}) Resolution", 100, -2, 2);
0276       hGBinvPTvsEta = fs->make<TH2F>("GBinvPTvsEta", "#sigma (q/p_{T}) VS #eta", 100, -2.5, 2.5, 100, -2, 2);
0277       hGBinvPTvsPhi = fs->make<TH2F>("GBinvPTvsPhi", "#sigma (q/p_{T}) VS #phi", 100, -3.1416, 3.1416, 100, -2, 2);
0278       hGBinvPTvsNhits = fs->make<TH2F>("GBinvPTvsNhits", "#sigma (q/p_{T}) VS Nhits", 100, 0, 100, 100, -2, 2);
0279     }
0280 
0281     hGBChi2 = fs->make<TH1F>("GBChi2", "Chi2", 200, 0, 200);
0282     hGBChi2_Barrel = fs->make<TH1F>("GBChi2_Barrel", "Chi2", 200, 0, 200);
0283     hGBChi2_Endcap = fs->make<TH1F>("GBChi2_Endcap ", "Chi2", 200, 0, 200);
0284     hGBInvM = fs->make<TH1F>("GBInvM", "M_{inv}^{rec}", nBinsMass, invMassRangeMin, invMassRangeMax);
0285     hGBInvM_Barrel = fs->make<TH1F>("GBInvM_Barrel", "M_{inv}^{rec}", nBinsMass, invMassRangeMin, invMassRangeMax);
0286     hGBInvM_Endcap = fs->make<TH1F>("GBInvM_Endcap ", "M_{inv}^{rec}", nBinsMass, invMassRangeMin, invMassRangeMax);
0287     hGBInvM_Overlap = fs->make<TH1F>("GBInvM_Overlap", "M_{inv}^{rec}", nBinsMass, invMassRangeMin, invMassRangeMax);
0288   }
0289 
0290   if (doSAplots) {
0291     hSANmuons = fs->make<TH1F>("SANmuons", "Nmuons", 10, 0, 10);
0292     hSANmuons_Barrel = fs->make<TH1F>("SANmuons_Barrel", "Nmuons", 10, 0, 10);
0293     hSANmuons_Endcap = fs->make<TH1F>("SANmuons_Endcap", "Nmuons", 10, 0, 10);
0294     hSANhits = fs->make<TH1F>("SANhits", "Nhits", 100, 0, 100);
0295     hSANhits_Barrel = fs->make<TH1F>("SANhits_Barrel", "Nhits", 100, 0, 100);
0296     hSANhits_Endcap = fs->make<TH1F>("SANhits_Endcap", "Nhits", 100, 0, 100);
0297     hSAPTRec = fs->make<TH1F>("SApTRec", "p_{T}^{rec}", nBinsPt, ptRangeMin, ptRangeMax);
0298     hSAPTRec_Barrel = fs->make<TH1F>("SApTRec_Barrel", "p_{T}^{rec}", nBinsPt, ptRangeMin, ptRangeMax);
0299     hSAPTRec_Endcap = fs->make<TH1F>("SApTRec_Endcap", "p_{T}^{rec}", nBinsPt, ptRangeMin, ptRangeMax);
0300     hSAPTvsEta = fs->make<TH2F>("SAPTvsEta", "p_{T}^{rec} VS #eta", 100, -2.5, 2.5, nBinsPt, ptRangeMin, ptRangeMax);
0301     hSAPTvsPhi =
0302         fs->make<TH2F>("SAPTvsPhi", "p_{T}^{rec} VS #phi", 100, -3.1416, 3.1416, nBinsPt, ptRangeMin, ptRangeMax);
0303     hSAPhivsEta = fs->make<TH2F>("SAPhivsEta", "#phi VS #eta", 100, -2.5, 2.5, 100, -3.1416, 3.1416);
0304 
0305     if (theDataType == "SimData") {
0306       hSAPTDiff = fs->make<TH1F>("SApTDiff", "p_{T}^{rec} - p_{T}^{gen} ", 250, -120, 120);
0307       hSAPTDiffvsEta =
0308           fs->make<TH2F>("SAPTDiffvsEta", "p_{T}^{rec} - p_{T}^{gen} VS #eta", 100, -2.5, 2.5, 250, -120, 120);
0309       hSAPTDiffvsPhi =
0310           fs->make<TH2F>("SAPTDiffvsPhi", "p_{T}^{rec} - p_{T}^{gen} VS #phi", 100, -3.1416, 3.1416, 250, -120, 120);
0311       hSAPTres = fs->make<TH1F>("SApTRes", "pT Resolution", 100, -2, 2);
0312       hSAPTres_Barrel = fs->make<TH1F>("SApTRes_Barrel", "pT Resolution", 100, -2, 2);
0313       hSAPTres_Endcap = fs->make<TH1F>("SApTRes_Endcap", "pT Resolution", 100, -2, 2);
0314       hSAinvPTres = fs->make<TH1F>("SAinvPTRes", "1/pT Resolution", 100, -2, 2);
0315 
0316       hSAinvPTvsEta = fs->make<TH2F>("SAinvPTvsEta", "#sigma (q/p_{T}) VS #eta", 100, -2.5, 2.5, 100, -2, 2);
0317       hSAinvPTvsPhi = fs->make<TH2F>("SAinvPTvsPhi", "#sigma (q/p_{T}) VS #phi", 100, -3.1416, 3.1416, 100, -2, 2);
0318       hSAinvPTvsNhits = fs->make<TH2F>("SAinvPTvsNhits", "#sigma (q/p_{T}) VS Nhits", 100, 0, 100, 100, -2, 2);
0319     }
0320     hSAInvM = fs->make<TH1F>("SAInvM", "M_{inv}^{rec}", nBinsMass, invMassRangeMin, invMassRangeMax);
0321     hSAInvM_Barrel = fs->make<TH1F>("SAInvM_Barrel", "M_{inv}^{rec}", nBinsMass, invMassRangeMin, invMassRangeMax);
0322     hSAInvM_Endcap = fs->make<TH1F>("SAInvM_Endcap", "M_{inv}^{rec}", nBinsMass, invMassRangeMin, invMassRangeMax);
0323     hSAInvM_Overlap = fs->make<TH1F>("SAInvM_Overlap", "M_{inv}^{rec}", nBinsMass, invMassRangeMin, invMassRangeMax);
0324     hSAChi2 = fs->make<TH1F>("SAChi2", "Chi2", 200, 0, 200);
0325     hSAChi2_Barrel = fs->make<TH1F>("SAChi2_Barrel", "Chi2", 200, 0, 200);
0326     hSAChi2_Endcap = fs->make<TH1F>("SAChi2_Endcap", "Chi2", 200, 0, 200);
0327   }
0328 
0329   if (theDataType == "SimData") {
0330     hSimNmuons = fs->make<TH1F>("SimNmuons", "Nmuons", 10, 0, 10);
0331     hSimNmuons_Barrel = fs->make<TH1F>("SimNmuons_Barrel", "Nmuons", 10, 0, 10);
0332     hSimNmuons_Endcap = fs->make<TH1F>("SimNmuons_Endcap", "Nmuons", 10, 0, 10);
0333     hSimPT = fs->make<TH1F>("SimPT", "p_{T}^{gen} ", nBinsPt, ptRangeMin, ptRangeMax);
0334     hSimPT_Barrel = fs->make<TH1F>("SimPT_Barrel", "p_{T}^{gen} ", nBinsPt, ptRangeMin, ptRangeMax);
0335     hSimPT_Endcap = fs->make<TH1F>("SimPT_Endcap", "p_{T}^{gen} ", nBinsPt, ptRangeMin, ptRangeMax);
0336     hSimPTvsEta = fs->make<TH2F>("SimPTvsEta", "p_{T}^{gen} VS #eta", 100, -2.5, 2.5, nBinsPt, ptRangeMin, ptRangeMax);
0337     hSimPTvsPhi =
0338         fs->make<TH2F>("SimPTvsPhi", "p_{T}^{gen} VS #phi", 100, -3.1416, 3.1416, nBinsPt, ptRangeMin, ptRangeMax);
0339     hSimPhivsEta = fs->make<TH2F>("SimPhivsEta", "#phi VS #eta", 100, -2.5, 2.5, 100, -3.1416, 3.1416);
0340     hSimInvM = fs->make<TH1F>("SimInvM", "M_{inv}^{gen} ", nBinsMass, invMassRangeMin, invMassRangeMax);
0341     hSimInvM_Barrel = fs->make<TH1F>("SimInvM_Barrel", "M_{inv}^{rec}", nBinsMass, invMassRangeMin, invMassRangeMax);
0342     hSimInvM_Endcap = fs->make<TH1F>("SimInvM_Endcap", "M_{inv}^{gen} ", nBinsMass, invMassRangeMin, invMassRangeMax);
0343     hSimInvM_Overlap = fs->make<TH1F>("SimInvM_Overlap", "M_{inv}^{gen} ", nBinsMass, invMassRangeMin, invMassRangeMax);
0344   }
0345 
0346   if (doResplots) {
0347     // All DT and CSC chambers
0348     hResidualLocalXDT = fs->make<TH1F>("hResidualLocalXDT", "hResidualLocalXDT", 200, -10, 10);
0349     hResidualLocalPhiDT = fs->make<TH1F>("hResidualLocalPhiDT", "hResidualLocalPhiDT", 100, -1, 1);
0350     hResidualLocalThetaDT = fs->make<TH1F>("hResidualLocalThetaDT", "hResidualLocalThetaDT", 100, -1, 1);
0351     hResidualLocalYDT = fs->make<TH1F>("hResidualLocalYDT", "hResidualLocalYDT", 200, -10, 10);
0352     hResidualLocalXCSC = fs->make<TH1F>("hResidualLocalXCSC", "hResidualLocalXCSC", 200, -10, 10);
0353     hResidualLocalPhiCSC = fs->make<TH1F>("hResidualLocalPhiCSC", "hResidualLocalPhiCSC", 100, -1, 1);
0354     hResidualLocalThetaCSC = fs->make<TH1F>("hResidualLocalThetaCSC", "hResidualLocalThetaCSC", 100, -1, 1);
0355     hResidualLocalYCSC = fs->make<TH1F>("hResidualLocalYCSC", "hResidualLocalYCSC", 200, -10, 10);
0356     hResidualGlobalRPhiDT = fs->make<TH1F>("hResidualGlobalRPhiDT", "hResidualGlobalRPhiDT", 200, -10, 10);
0357     hResidualGlobalPhiDT = fs->make<TH1F>("hResidualGlobalPhiDT", "hResidualGlobalPhiDT", 100, -1, 1);
0358     hResidualGlobalThetaDT = fs->make<TH1F>("hResidualGlobalThetaDT", "hResidualGlobalThetaDT", 100, -1, 1);
0359     hResidualGlobalZDT = fs->make<TH1F>("hResidualGlobalZDT", "hResidualGlobalZDT", 200, -10, 10);
0360     hResidualGlobalRPhiCSC = fs->make<TH1F>("hResidualGlobalRPhiCSC", "hResidualGlobalRPhiCSC", 200, -10, 10);
0361     hResidualGlobalPhiCSC = fs->make<TH1F>("hResidualGlobalPhiCSC", "hResidualGlobalPhiCSC", 100, -1, 1);
0362     hResidualGlobalThetaCSC = fs->make<TH1F>("hResidualGlobalThetaCSC", "hResidualGlobalThetaCSC", 100, -1, 1);
0363     hResidualGlobalRCSC = fs->make<TH1F>("hResidualGlobalRCSC", "hResidualGlobalRCSC", 200, -10, 10);
0364 
0365     // DT Wheels
0366     hResidualLocalXDT_W[0] = fs->make<TH1F>("hResidualLocalXDT_W-2", "hResidualLocalXDT_W-2", 200, -10, 10);
0367     hResidualLocalPhiDT_W[0] = fs->make<TH1F>("hResidualLocalPhiDT_W-2", "hResidualLocalPhiDT_W-2", 200, -1, 1);
0368     hResidualLocalThetaDT_W[0] = fs->make<TH1F>("hResidualLocalThetaDT_W-2", "hResidualLocalThetaDT_W-2", 200, -1, 1);
0369     hResidualLocalYDT_W[0] = fs->make<TH1F>("hResidualLocalYDT_W-2", "hResidualLocalYDT_W-2", 200, -10, 10);
0370     hResidualLocalXDT_W[1] = fs->make<TH1F>("hResidualLocalXDT_W-1", "hResidualLocalXDT_W-1", 200, -10, 10);
0371     hResidualLocalPhiDT_W[1] = fs->make<TH1F>("hResidualLocalPhiDT_W-1", "hResidualLocalPhiDT_W-1", 200, -1, 1);
0372     hResidualLocalThetaDT_W[1] = fs->make<TH1F>("hResidualLocalThetaDT_W-1", "hResidualLocalThetaDT_W-1", 200, -1, 1);
0373     hResidualLocalYDT_W[1] = fs->make<TH1F>("hResidualLocalYDT_W-1", "hResidualLocalYDT_W-1", 200, -10, 10);
0374     hResidualLocalXDT_W[2] = fs->make<TH1F>("hResidualLocalXDT_W0", "hResidualLocalXDT_W0", 200, -10, 10);
0375     hResidualLocalPhiDT_W[2] = fs->make<TH1F>("hResidualLocalPhiDT_W0", "hResidualLocalPhiDT_W0", 200, -1, 1);
0376     hResidualLocalThetaDT_W[2] = fs->make<TH1F>("hResidualLocalThetaDT_W0", "hResidualLocalThetaDT_W0", 200, -1, 1);
0377     hResidualLocalYDT_W[2] = fs->make<TH1F>("hResidualLocalYDT_W0", "hResidualLocalYDT_W0", 200, -10, 10);
0378     hResidualLocalXDT_W[3] = fs->make<TH1F>("hResidualLocalXDT_W1", "hResidualLocalXDT_W1", 200, -10, 10);
0379     hResidualLocalPhiDT_W[3] = fs->make<TH1F>("hResidualLocalPhiDT_W1", "hResidualLocalPhiDT_W1", 200, -1, 1);
0380     hResidualLocalThetaDT_W[3] = fs->make<TH1F>("hResidualLocalThetaDT_W1", "hResidualLocalThetaDT_W1", 200, -1, 1);
0381     hResidualLocalYDT_W[3] = fs->make<TH1F>("hResidualLocalYDT_W1", "hResidualLocalYDT_W1", 200, -10, 10);
0382     hResidualLocalXDT_W[4] = fs->make<TH1F>("hResidualLocalXDT_W2", "hResidualLocalXDT_W2", 200, -10, 10);
0383     hResidualLocalPhiDT_W[4] = fs->make<TH1F>("hResidualLocalPhiDT_W2", "hResidualLocalPhiDT_W2", 200, -1, 1);
0384     hResidualLocalThetaDT_W[4] = fs->make<TH1F>("hResidualLocalThetaDT_W2", "hResidualLocalThetaDT_W2", 200, -1, 1);
0385     hResidualLocalYDT_W[4] = fs->make<TH1F>("hResidualLocalYDT_W2", "hResidualLocalYDT_W2", 200, -10, 10);
0386     hResidualGlobalRPhiDT_W[0] = fs->make<TH1F>("hResidualGlobalRPhiDT_W-2", "hResidualGlobalRPhiDT_W-2", 200, -10, 10);
0387     hResidualGlobalPhiDT_W[0] = fs->make<TH1F>("hResidualGlobalPhiDT_W-2", "hResidualGlobalPhiDT_W-2", 200, -1, 1);
0388     hResidualGlobalThetaDT_W[0] =
0389         fs->make<TH1F>("hResidualGlobalThetaDT_W-2", "hResidualGlobalThetaDT_W-2", 200, -1, 1);
0390     hResidualGlobalZDT_W[0] = fs->make<TH1F>("hResidualGlobalZDT_W-2", "hResidualGlobalZDT_W-2", 200, -10, 10);
0391     hResidualGlobalRPhiDT_W[1] = fs->make<TH1F>("hResidualGlobalRPhiDT_W-1", "hResidualGlobalRPhiDT_W-1", 200, -10, 10);
0392     hResidualGlobalPhiDT_W[1] = fs->make<TH1F>("hResidualGlobalPhiDT_W-1", "hResidualGlobalPhiDT_W-1", 200, -1, 1);
0393     hResidualGlobalThetaDT_W[1] =
0394         fs->make<TH1F>("hResidualGlobalThetaDT_W-1", "hResidualGlobalThetaDT_W-1", 200, -1, 1);
0395     hResidualGlobalZDT_W[1] = fs->make<TH1F>("hResidualGlobalZDT_W-1", "hResidualGlobalZDT_W-1", 200, -10, 10);
0396     hResidualGlobalRPhiDT_W[2] = fs->make<TH1F>("hResidualGlobalRPhiDT_W0", "hResidualGlobalRPhiDT_W0", 200, -10, 10);
0397     hResidualGlobalPhiDT_W[2] = fs->make<TH1F>("hResidualGlobalPhiDT_W0", "hResidualGlobalPhiDT_W0", 200, -1, 1);
0398     hResidualGlobalThetaDT_W[2] = fs->make<TH1F>("hResidualGlobalThetaDT_W0", "hResidualGlobalThetaDT_W0", 200, -1, 1);
0399     hResidualGlobalZDT_W[2] = fs->make<TH1F>("hResidualGlobalZDT_W0", "hResidualGlobalZDT_W0", 200, -10, 10);
0400     hResidualGlobalRPhiDT_W[3] = fs->make<TH1F>("hResidualGlobalRPhiDT_W1", "hResidualGlobalRPhiDT_W1", 200, -10, 10);
0401     hResidualGlobalPhiDT_W[3] = fs->make<TH1F>("hResidualGlobalPhiDT_W1", "hResidualGlobalPhiDT_W1", 200, -1, 1);
0402     hResidualGlobalThetaDT_W[3] = fs->make<TH1F>("hResidualGlobalThetaDT_W1", "hResidualGlobalThetaDT_W1", 200, -1, 1);
0403     hResidualGlobalZDT_W[3] = fs->make<TH1F>("hResidualGlobalZDT_W1", "hResidualGlobalZDT_W1", 200, -10, 10);
0404     hResidualGlobalRPhiDT_W[4] = fs->make<TH1F>("hResidualGlobalRPhiDT_W2", "hResidualGlobalRPhiDT_W2", 200, -10, 10);
0405     hResidualGlobalPhiDT_W[4] = fs->make<TH1F>("hResidualGlobalPhiDT_W2", "hResidualGlobalPhiDT_W2", 200, -1, 1);
0406     hResidualGlobalThetaDT_W[4] = fs->make<TH1F>("hResidualGlobalThetaDT_W2", "hResidualGlobalThetaDT_W2", 200, -1, 1);
0407     hResidualGlobalZDT_W[4] = fs->make<TH1F>("hResidualGlobalZDT_W2", "hResidualGlobalZDT_W2", 200, -10, 10);
0408 
0409     // DT Stations
0410     hResidualLocalXDT_MB[0] = fs->make<TH1F>("hResidualLocalXDT_MB-2/1", "hResidualLocalXDT_MB-2/1", 200, -10, 10);
0411     hResidualLocalPhiDT_MB[0] = fs->make<TH1F>("hResidualLocalPhiDT_MB-2/1", "hResidualLocalPhiDT_MB-2/1", 200, -1, 1);
0412     hResidualLocalThetaDT_MB[0] =
0413         fs->make<TH1F>("hResidualLocalThetaDT_MB-2/1", "hResidualLocalThetaDT_MB-2/1", 200, -1, 1);
0414     hResidualLocalYDT_MB[0] = fs->make<TH1F>("hResidualLocalYDT_MB-2/1", "hResidualLocalYDT_MB-2/1", 200, -10, 10);
0415     hResidualLocalXDT_MB[1] = fs->make<TH1F>("hResidualLocalXDT_MB-2/2", "hResidualLocalXDT_MB-2/2", 200, -10, 10);
0416     hResidualLocalPhiDT_MB[1] = fs->make<TH1F>("hResidualLocalPhiDT_MB-2/2", "hResidualLocalPhiDT_MB-2/2", 200, -1, 1);
0417     hResidualLocalThetaDT_MB[1] =
0418         fs->make<TH1F>("hResidualLocalThetaDT_MB-2/2", "hResidualLocalThetaDT_MB-2/2", 200, -1, 1);
0419     hResidualLocalYDT_MB[1] = fs->make<TH1F>("hResidualLocalYDT_MB-2/2", "hResidualLocalYDT_MB-2/2", 200, -10, 10);
0420     hResidualLocalXDT_MB[2] = fs->make<TH1F>("hResidualLocalXDT_MB-2/3", "hResidualLocalXDT_MB-2/3", 200, -10, 10);
0421     hResidualLocalPhiDT_MB[2] = fs->make<TH1F>("hResidualLocalPhiDT_MB-2/3", "hResidualLocalPhiDT_MB-2/3", 200, -1, 1);
0422     hResidualLocalThetaDT_MB[2] =
0423         fs->make<TH1F>("hResidualLocalThetaDT_MB-2/3", "hResidualLocalThetaDT_MB-2/3", 200, -1, 1);
0424     hResidualLocalYDT_MB[2] = fs->make<TH1F>("hResidualLocalYDT_MB-2/3", "hResidualLocalYDT_MB-2/3", 200, -10, 10);
0425     hResidualLocalXDT_MB[3] = fs->make<TH1F>("hResidualLocalXDT_MB-2/4", "hResidualLocalXDT_MB-2/4", 200, -10, 10);
0426     hResidualLocalPhiDT_MB[3] = fs->make<TH1F>("hResidualLocalPhiDT_MB-2/4", "hResidualLocalPhiDT_MB-2/4", 200, -1, 1);
0427     hResidualLocalThetaDT_MB[3] =
0428         fs->make<TH1F>("hResidualLocalThetaDT_MB-2/4", "hResidualLocalThetaDT_MB-2/4", 200, -1, 1);
0429     hResidualLocalYDT_MB[3] = fs->make<TH1F>("hResidualLocalYDT_MB-2/4", "hResidualLocalYDT_MB-2/4", 200, -10, 10);
0430     hResidualLocalXDT_MB[4] = fs->make<TH1F>("hResidualLocalXDT_MB-1/1", "hResidualLocalXDT_MB-1/1", 200, -10, 10);
0431     hResidualLocalPhiDT_MB[4] = fs->make<TH1F>("hResidualLocalPhiDT_MB-1/1", "hResidualLocalPhiDT_MB-1/1", 200, -1, 1);
0432     hResidualLocalThetaDT_MB[4] =
0433         fs->make<TH1F>("hResidualLocalThetaDT_MB-1/1", "hResidualLocalThetaDT_MB-1/1", 200, -1, 1);
0434     hResidualLocalYDT_MB[4] = fs->make<TH1F>("hResidualLocalYDT_MB-1/1", "hResidualLocalYDT_MB-1/1", 200, -10, 10);
0435     hResidualLocalXDT_MB[5] = fs->make<TH1F>("hResidualLocalXDT_MB-1/2", "hResidualLocalXDT_MB-1/2", 200, -10, 10);
0436     hResidualLocalPhiDT_MB[5] = fs->make<TH1F>("hResidualLocalPhiDT_MB-1/2", "hResidualLocalPhiDT_MB-1/2", 200, -1, 1);
0437     hResidualLocalThetaDT_MB[5] =
0438         fs->make<TH1F>("hResidualLocalThetaDT_MB-1/2", "hResidualLocalThetaDT_MB-1/2", 200, -1, 1);
0439     hResidualLocalYDT_MB[5] = fs->make<TH1F>("hResidualLocalYDT_MB-1/2", "hResidualLocalYDT_MB-1/2", 200, -10, 10);
0440     hResidualLocalXDT_MB[6] = fs->make<TH1F>("hResidualLocalXDT_MB-1/3", "hResidualLocalXDT_MB-1/3", 200, -10, 10);
0441     hResidualLocalPhiDT_MB[6] = fs->make<TH1F>("hResidualLocalPhiDT_MB-1/3", "hResidualLocalPhiDT_MB-1/3", 200, -1, 1);
0442     hResidualLocalThetaDT_MB[6] =
0443         fs->make<TH1F>("hResidualLocalThetaDT_MB-1/3", "hResidualLocalThetaDT_MB-1/3", 200, -1, 1);
0444     hResidualLocalYDT_MB[6] = fs->make<TH1F>("hResidualLocalYDT_MB-1/3", "hResidualLocalYDT_MB-1/3", 200, -10, 10);
0445     hResidualLocalXDT_MB[7] = fs->make<TH1F>("hResidualLocalXDT_MB-1/4", "hResidualLocalXDT_MB-1/4", 200, -10, 10);
0446     hResidualLocalPhiDT_MB[7] = fs->make<TH1F>("hResidualLocalPhiDT_MB-1/4", "hResidualLocalPhiDT_MB-1/4", 200, -1, 1);
0447     hResidualLocalThetaDT_MB[7] =
0448         fs->make<TH1F>("hResidualLocalThetaDT_MB-1/4", "hResidualLocalThetaDT_MB-1/4", 200, -1, 1);
0449     hResidualLocalYDT_MB[7] = fs->make<TH1F>("hResidualLocalYDT_MB-1/4", "hResidualLocalYDT_MB-1/4", 200, -10, 10);
0450     hResidualLocalXDT_MB[8] = fs->make<TH1F>("hResidualLocalXDT_MB0/1", "hResidualLocalXDT_MB0/1", 200, -10, 10);
0451     hResidualLocalPhiDT_MB[8] = fs->make<TH1F>("hResidualLocalPhiDT_MB0/1", "hResidualLocalPhiDT_MB0/1", 200, -1, 1);
0452     hResidualLocalThetaDT_MB[8] =
0453         fs->make<TH1F>("hResidualLocalThetaDT_MB0/1", "hResidualLocalThetaDT_MB0/1", 200, -1, 1);
0454     hResidualLocalYDT_MB[8] = fs->make<TH1F>("hResidualLocalYDT_MB0/1", "hResidualLocalYDT_MB0/1", 200, -10, 10);
0455     hResidualLocalXDT_MB[9] = fs->make<TH1F>("hResidualLocalXDT_MB0/2", "hResidualLocalXDT_MB0/2", 200, -10, 10);
0456     hResidualLocalPhiDT_MB[9] = fs->make<TH1F>("hResidualLocalPhiDT_MB0/2", "hResidualLocalPhiDT_MB0/2", 200, -1, 1);
0457     hResidualLocalThetaDT_MB[9] =
0458         fs->make<TH1F>("hResidualLocalThetaDT_MB0/2", "hResidualLocalThetaDT_MB0/2", 200, -1, 1);
0459     hResidualLocalYDT_MB[9] = fs->make<TH1F>("hResidualLocalYDT_MB0/2", "hResidualLocalYDT_MB0/2", 200, -10, 10);
0460     hResidualLocalXDT_MB[10] = fs->make<TH1F>("hResidualLocalXDT_MB0/3", "hResidualLocalXDT_MB0/3", 200, -10, 10);
0461     hResidualLocalThetaDT_MB[10] =
0462         fs->make<TH1F>("hResidualLocalThetaDT_MB0/3", "hResidualLocalThetaDT_MB0/3", 200, -1, 1);
0463     hResidualLocalPhiDT_MB[10] = fs->make<TH1F>("hResidualLocalPhiDT_MB0/3", "hResidualLocalPhiDT_MB0/3", 200, -1, 1);
0464     hResidualLocalYDT_MB[10] = fs->make<TH1F>("hResidualLocalYDT_MB0/3", "hResidualLocalYDT_MB0/3", 200, -10, 10);
0465     hResidualLocalXDT_MB[11] = fs->make<TH1F>("hResidualLocalXDT_MB0/4", "hResidualLocalXDT_MB0/4", 200, -10, 10);
0466     hResidualLocalPhiDT_MB[11] = fs->make<TH1F>("hResidualLocalPhiDT_MB0/4", "hResidualLocalPhiDT_MB0/4", 200, -1, 1);
0467     hResidualLocalThetaDT_MB[11] =
0468         fs->make<TH1F>("hResidualLocalThetaDT_MB0/4", "hResidualLocalThetaDT_MB0/4", 200, -1, 1);
0469     hResidualLocalYDT_MB[11] = fs->make<TH1F>("hResidualLocalYDT_MB0/4", "hResidualLocalYDT_MB0/4", 200, -10, 10);
0470     hResidualLocalXDT_MB[12] = fs->make<TH1F>("hResidualLocalXDT_MB1/1", "hResidualLocalXDT_MB1/1", 200, -10, 10);
0471     hResidualLocalPhiDT_MB[12] = fs->make<TH1F>("hResidualLocalPhiDT_MB1/1", "hResidualLocalPhiDT_MB1/1", 200, -1, 1);
0472     hResidualLocalThetaDT_MB[12] =
0473         fs->make<TH1F>("hResidualLocalThetaDT_MB1/1", "hResidualLocalThetaDT_MB1/1", 200, -1, 1);
0474     hResidualLocalYDT_MB[12] = fs->make<TH1F>("hResidualLocalYDT_MB1/1", "hResidualLocalYDT_MB1/1", 200, -10, 10);
0475     hResidualLocalXDT_MB[13] = fs->make<TH1F>("hResidualLocalXDT_MB1/2", "hResidualLocalXDT_MB1/2", 200, -10, 10);
0476     hResidualLocalPhiDT_MB[13] = fs->make<TH1F>("hResidualLocalPhiDT_MB1/2", "hResidualLocalPhiDT_MB1/2", 200, -1, 1);
0477     hResidualLocalThetaDT_MB[13] =
0478         fs->make<TH1F>("hResidualLocalThetaDT_MB1/2", "hResidualLocalThetaDT_MB1/2", 200, -1, 1);
0479     hResidualLocalYDT_MB[13] = fs->make<TH1F>("hResidualLocalYDT_MB1/2", "hResidualLocalYDT_MB1/2", 200, -10, 10);
0480     hResidualLocalXDT_MB[14] = fs->make<TH1F>("hResidualLocalXDT_MB1/3", "hResidualLocalXDT_MB1/3", 200, -10, 10);
0481     hResidualLocalPhiDT_MB[14] = fs->make<TH1F>("hResidualLocalPhiDT_MB1/3", "hResidualLocalPhiDT_MB1/3", 200, -1, 1);
0482     hResidualLocalThetaDT_MB[14] =
0483         fs->make<TH1F>("hResidualLocalThetaDT_MB1/3", "hResidualLocalThetaDT_MB1/3", 200, -1, 1);
0484     hResidualLocalYDT_MB[14] = fs->make<TH1F>("hResidualLocalYDT_MB1/3", "hResidualLocalYDT_MB1/3", 200, -10, 10);
0485     hResidualLocalXDT_MB[15] = fs->make<TH1F>("hResidualLocalXDT_MB1/4", "hResidualLocalXDT_MB1/4", 200, -10, 10);
0486     hResidualLocalPhiDT_MB[15] = fs->make<TH1F>("hResidualLocalPhiDT_MB1/4", "hResidualLocalPhiDT_MB1/4", 200, -1, 1);
0487     hResidualLocalThetaDT_MB[15] =
0488         fs->make<TH1F>("hResidualLocalThetaDT_MB1/4", "hResidualLocalThetaDT_MB1/4", 200, -1, 1);
0489     hResidualLocalYDT_MB[15] = fs->make<TH1F>("hResidualLocalYDT_MB1/4", "hResidualLocalYDT_MB1/4", 200, -10, 10);
0490     hResidualLocalXDT_MB[16] = fs->make<TH1F>("hResidualLocalXDT_MB2/1", "hResidualLocalXDT_MB2/1", 200, -10, 10);
0491     hResidualLocalPhiDT_MB[16] = fs->make<TH1F>("hResidualLocalPhiDT_MB2/1", "hResidualLocalPhiDT_MB2/1", 200, -1, 1);
0492     hResidualLocalThetaDT_MB[16] =
0493         fs->make<TH1F>("hResidualLocalThetaDT_MB2/1", "hResidualLocalThetaDT_MB2/1", 200, -1, 1);
0494     hResidualLocalYDT_MB[16] = fs->make<TH1F>("hResidualLocalYDT_MB2/1", "hResidualLocalYDT_MB2/1", 200, -10, 10);
0495     hResidualLocalXDT_MB[17] = fs->make<TH1F>("hResidualLocalXDT_MB2/2", "hResidualLocalXDT_MB2/2", 200, -10, 10);
0496     hResidualLocalPhiDT_MB[17] = fs->make<TH1F>("hResidualLocalPhiDT_MB2/2", "hResidualLocalPhiDT_MB2/2", 200, -1, 1);
0497     hResidualLocalThetaDT_MB[17] =
0498         fs->make<TH1F>("hResidualLocalThetaDT_MB2/2", "hResidualLocalThetaDT_MB2/2", 200, -1, 1);
0499     hResidualLocalYDT_MB[17] = fs->make<TH1F>("hResidualLocalYDT_MB2/2", "hResidualLocalYDT_MB2/2", 200, -10, 10);
0500     hResidualLocalXDT_MB[18] = fs->make<TH1F>("hResidualLocalXDT_MB2/3", "hResidualLocalXDT_MB2/3", 200, -10, 10);
0501     hResidualLocalPhiDT_MB[18] = fs->make<TH1F>("hResidualLocalPhiDT_MB2/3", "hResidualLocalPhiDT_MB2/3", 200, -1, 1);
0502     hResidualLocalThetaDT_MB[18] =
0503         fs->make<TH1F>("hResidualLocalThetaDT_MB2/3", "hResidualLocalThetaDT_MB2/3", 200, -1, 1);
0504     hResidualLocalYDT_MB[18] = fs->make<TH1F>("hResidualLocalYDT_MB2/3", "hResidualLocalYDT_MB2/3", 200, -10, 10);
0505     hResidualLocalXDT_MB[19] = fs->make<TH1F>("hResidualLocalXDT_MB2/4", "hResidualLocalXDT_MB2/4", 200, -10, 10);
0506     hResidualLocalPhiDT_MB[19] = fs->make<TH1F>("hResidualLocalPhiDT_MB2/4", "hResidualLocalPhiDT_MB2/4", 200, -1, 1);
0507     hResidualLocalThetaDT_MB[19] =
0508         fs->make<TH1F>("hResidualLocalThetaDT_MB2/4", "hResidualLocalThetaDT_MB2/4", 200, -1, 1);
0509     hResidualLocalYDT_MB[19] = fs->make<TH1F>("hResidualLocalYDT_MB2/4", "hResidualLocalYDT_MB2/4", 200, -10, 10);
0510     hResidualGlobalRPhiDT_MB[0] =
0511         fs->make<TH1F>("hResidualGlobalRPhiDT_MB-2/1", "hResidualGlobalRPhiDT_MB-2/1", 200, -10, 10);
0512     hResidualGlobalPhiDT_MB[0] =
0513         fs->make<TH1F>("hResidualGlobalPhiDT_MB-2/1", "hResidualGlobalPhiDT_MB-2/1", 200, -1, 1);
0514     hResidualGlobalThetaDT_MB[0] =
0515         fs->make<TH1F>("hResidualGlobalThetaDT_MB-2/1", "hResidualGlobalThetaDT_MB-2/1", 200, -1, 1);
0516     hResidualGlobalZDT_MB[0] = fs->make<TH1F>("hResidualGlobalZDT_MB-2/1", "hResidualGlobalZDT_MB-2/1", 200, -10, 10);
0517     hResidualGlobalRPhiDT_MB[1] =
0518         fs->make<TH1F>("hResidualGlobalRPhiDT_MB-2/2", "hResidualGlobalRPhiDT_MB-2/2", 200, -10, 10);
0519     hResidualGlobalPhiDT_MB[1] =
0520         fs->make<TH1F>("hResidualGlobalPhiDT_MB-2/2", "hResidualGlobalPhiDT_MB-2/2", 200, -1, 1);
0521     hResidualGlobalThetaDT_MB[1] =
0522         fs->make<TH1F>("hResidualGlobalThetaDT_MB-2/2", "hResidualGlobalThetaDT_MB-2/2", 200, -1, 1);
0523     hResidualGlobalZDT_MB[1] = fs->make<TH1F>("hResidualGlobalZDT_MB-2/2", "hResidualGlobalZDT_MB-2/2", 200, -10, 10);
0524     hResidualGlobalRPhiDT_MB[2] =
0525         fs->make<TH1F>("hResidualGlobalRPhiDT_MB-2/3", "hResidualGlobalRPhiDT_MB-2/3", 200, -10, 10);
0526     hResidualGlobalPhiDT_MB[2] =
0527         fs->make<TH1F>("hResidualGlobalPhiDT_MB-2/3", "hResidualGlobalPhiDT_MB-2/3", 200, -1, 1);
0528     hResidualGlobalThetaDT_MB[2] =
0529         fs->make<TH1F>("hResidualGlobalThetaDT_MB-2/3", "hResidualGlobalThetaDT_MB-2/3", 200, -1, 1);
0530     hResidualGlobalZDT_MB[2] = fs->make<TH1F>("hResidualGlobalZDT_MB-2/3", "hResidualGlobalZDT_MB-2/3", 200, -10, 10);
0531     hResidualGlobalRPhiDT_MB[3] =
0532         fs->make<TH1F>("hResidualGlobalRPhiDT_MB-2/4", "hResidualGlobalRPhiDT_MB-2/4", 200, -10, 10);
0533     hResidualGlobalPhiDT_MB[3] =
0534         fs->make<TH1F>("hResidualGlobalPhiDT_MB-2/4", "hResidualGlobalPhiDT_MB-2/4", 200, -1, 1);
0535     hResidualGlobalThetaDT_MB[3] =
0536         fs->make<TH1F>("hResidualGlobalThetaDT_MB-2/4", "hResidualGlobalThetaDT_MB-2/4", 200, -1, 1);
0537     hResidualGlobalZDT_MB[3] = fs->make<TH1F>("hResidualGlobalZDT_MB-2/4", "hResidualGlobalZDT_MB-2/4", 200, -10, 10);
0538     hResidualGlobalRPhiDT_MB[4] =
0539         fs->make<TH1F>("hResidualGlobalRPhiDT_MB-1/1", "hResidualGlobalRPhiDT_MB-1/1", 200, -10, 10);
0540     hResidualGlobalPhiDT_MB[4] =
0541         fs->make<TH1F>("hResidualGlobalPhiDT_MB-1/1", "hResidualGlobalPhiDT_MB-1/1", 200, -1, 1);
0542     hResidualGlobalThetaDT_MB[4] =
0543         fs->make<TH1F>("hResidualGlobalThetaDT_MB-1/1", "hResidualGlobalThetaDT_MB-1/1", 200, -1, 1);
0544     hResidualGlobalZDT_MB[4] = fs->make<TH1F>("hResidualGlobalZDT_MB-1/1", "hResidualGlobalZDT_MB-1/1", 200, -10, 10);
0545     hResidualGlobalRPhiDT_MB[5] =
0546         fs->make<TH1F>("hResidualGlobalRPhiDT_MB-1/2", "hResidualGlobalRPhiDT_MB-1/2", 200, -10, 10);
0547     hResidualGlobalPhiDT_MB[5] =
0548         fs->make<TH1F>("hResidualGlobalPhiDT_MB-1/2", "hResidualGlobalPhiDT_MB-1/2", 200, -1, 1);
0549     hResidualGlobalThetaDT_MB[5] =
0550         fs->make<TH1F>("hResidualGlobalThetaDT_MB-1/2", "hResidualGlobalThetaDT_MB-1/2", 200, -1, 1);
0551     hResidualGlobalZDT_MB[5] = fs->make<TH1F>("hResidualGlobalZDT_MB-1/2", "hResidualGlobalZDT_MB-1/2", 200, -10, 10);
0552     hResidualGlobalRPhiDT_MB[6] =
0553         fs->make<TH1F>("hResidualGlobalRPhiDT_MB-1/3", "hResidualGlobalRPhiDT_MB-1/3", 200, -10, 10);
0554     hResidualGlobalPhiDT_MB[6] =
0555         fs->make<TH1F>("hResidualGlobalPhiDT_MB-1/3", "hResidualGlobalPhiDT_MB-1/3", 200, -1, 1);
0556     hResidualGlobalThetaDT_MB[6] =
0557         fs->make<TH1F>("hResidualGlobalThetaDT_MB-1/3", "hResidualGlobalThetaDT_MB-1/3", 200, -1, 1);
0558     hResidualGlobalZDT_MB[6] = fs->make<TH1F>("hResidualGlobalZDT_MB-1/3", "hResidualGlobalZDT_MB-1/3", 200, -10, 10);
0559     hResidualGlobalRPhiDT_MB[7] =
0560         fs->make<TH1F>("hResidualGlobalRPhiDT_MB-1/4", "hResidualGlobalRPhiDT_MB-1/4", 200, -10, 10);
0561     hResidualGlobalPhiDT_MB[7] =
0562         fs->make<TH1F>("hResidualGlobalPhiDT_MB-1/4", "hResidualGlobalPhiDT_MB-1/4", 200, -1, 1);
0563     hResidualGlobalThetaDT_MB[7] =
0564         fs->make<TH1F>("hResidualGlobalThetaDT_MB-1/4", "hResidualGlobalThetaDT_MB-1/4", 200, -1, 1);
0565     hResidualGlobalZDT_MB[7] = fs->make<TH1F>("hResidualGlobalZDT_MB-1/4", "hResidualGlobalZDT_MB-1/4", 200, -10, 10);
0566     hResidualGlobalRPhiDT_MB[8] =
0567         fs->make<TH1F>("hResidualGlobalRPhiDT_MB0/1", "hResidualGlobalRPhiDT_MB0/1", 200, -10, 10);
0568     hResidualGlobalPhiDT_MB[8] = fs->make<TH1F>("hResidualGlobalPhiDT_MB0/1", "hResidualGlobalPhiDT_MB0/1", 200, -1, 1);
0569     hResidualGlobalThetaDT_MB[8] =
0570         fs->make<TH1F>("hResidualGlobalThetaDT_MB0/1", "hResidualGlobalThetaDT_MB0/1", 200, -1, 1);
0571     hResidualGlobalZDT_MB[8] = fs->make<TH1F>("hResidualGlobalZDT_MB0/1", "hResidualGlobalZDT_MB0/1", 200, -10, 10);
0572     hResidualGlobalRPhiDT_MB[9] =
0573         fs->make<TH1F>("hResidualGlobalRPhiDT_MB0/2", "hResidualGlobalRPhiDT_MB0/2", 200, -10, 10);
0574     hResidualGlobalPhiDT_MB[9] = fs->make<TH1F>("hResidualGlobalPhiDT_MB0/2", "hResidualGlobalPhiDT_MB0/2", 200, -1, 1);
0575     hResidualGlobalThetaDT_MB[9] =
0576         fs->make<TH1F>("hResidualGlobalThetaDT_MB0/2", "hResidualGlobalThetaDT_MB0/2", 200, -1, 1);
0577     hResidualGlobalZDT_MB[9] = fs->make<TH1F>("hResidualGlobalZDT_MB0/2", "hResidualGlobalZDT_MB0/2", 200, -10, 10);
0578     hResidualGlobalRPhiDT_MB[10] =
0579         fs->make<TH1F>("hResidualGlobalRPhiDT_MB0/3", "hResidualGlobalRPhiDT_MB0/3", 200, -10, 10);
0580     hResidualGlobalThetaDT_MB[10] =
0581         fs->make<TH1F>("hResidualGlobalThetaDT_MB0/3", "hResidualGlobalThetaDT_MB0/3", 200, -1, 1);
0582     hResidualGlobalPhiDT_MB[10] =
0583         fs->make<TH1F>("hResidualGlobalPhiDT_MB0/3", "hResidualGlobalPhiDT_MB0/3", 200, -1, 1);
0584     hResidualGlobalZDT_MB[10] = fs->make<TH1F>("hResidualGlobalZDT_MB0/3", "hResidualGlobalZDT_MB0/3", 200, -10, 10);
0585     hResidualGlobalRPhiDT_MB[11] =
0586         fs->make<TH1F>("hResidualGlobalRPhiDT_MB0/4", "hResidualGlobalRPhiDT_MB0/4", 200, -10, 10);
0587     hResidualGlobalPhiDT_MB[11] =
0588         fs->make<TH1F>("hResidualGlobalPhiDT_MB0/4", "hResidualGlobalPhiDT_MB0/4", 200, -1, 1);
0589     hResidualGlobalThetaDT_MB[11] =
0590         fs->make<TH1F>("hResidualGlobalThetaDT_MB0/4", "hResidualGlobalThetaDT_MB0/4", 200, -1, 1);
0591     hResidualGlobalZDT_MB[11] = fs->make<TH1F>("hResidualGlobalZDT_MB0/4", "hResidualGlobalZDT_MB0/4", 200, -10, 10);
0592     hResidualGlobalRPhiDT_MB[12] =
0593         fs->make<TH1F>("hResidualGlobalRPhiDT_MB1/1", "hResidualGlobalRPhiDT_MB1/1", 200, -10, 10);
0594     hResidualGlobalPhiDT_MB[12] =
0595         fs->make<TH1F>("hResidualGlobalPhiDT_MB1/1", "hResidualGlobalPhiDT_MB1/1", 200, -1, 1);
0596     hResidualGlobalThetaDT_MB[12] =
0597         fs->make<TH1F>("hResidualGlobalThetaDT_MB1/1", "hResidualGlobalThetaDT_MB1/1", 200, -1, 1);
0598     hResidualGlobalZDT_MB[12] = fs->make<TH1F>("hResidualGlobalZDT_MB1/1", "hResidualGlobalZDT_MB1/1", 200, -10, 10);
0599     hResidualGlobalRPhiDT_MB[13] =
0600         fs->make<TH1F>("hResidualGlobalRPhiDT_MB1/2", "hResidualGlobalRPhiDT_MB1/2", 200, -10, 10);
0601     hResidualGlobalPhiDT_MB[13] =
0602         fs->make<TH1F>("hResidualGlobalPhiDT_MB1/2", "hResidualGlobalPhiDT_MB1/2", 200, -1, 1);
0603     hResidualGlobalThetaDT_MB[13] =
0604         fs->make<TH1F>("hResidualGlobalThetaDT_MB1/2", "hResidualGlobalThetaDT_MB1/2", 200, -1, 1);
0605     hResidualGlobalZDT_MB[13] = fs->make<TH1F>("hResidualGlobalZDT_MB1/2", "hResidualGlobalZDT_MB1/2", 200, -10, 10);
0606     hResidualGlobalRPhiDT_MB[14] =
0607         fs->make<TH1F>("hResidualGlobalRPhiDT_MB1/3", "hResidualGlobalRPhiDT_MB1/3", 200, -10, 10);
0608     hResidualGlobalPhiDT_MB[14] =
0609         fs->make<TH1F>("hResidualGlobalPhiDT_MB1/3", "hResidualGlobalPhiDT_MB1/3", 200, -1, 1);
0610     hResidualGlobalThetaDT_MB[14] =
0611         fs->make<TH1F>("hResidualGlobalThetaDT_MB1/3", "hResidualGlobalThetaDT_MB1/3", 200, -1, 1);
0612     hResidualGlobalZDT_MB[14] = fs->make<TH1F>("hResidualGlobalZDT_MB1/3", "hResidualGlobalZDT_MB1/3", 200, -10, 10);
0613     hResidualGlobalRPhiDT_MB[15] =
0614         fs->make<TH1F>("hResidualGlobalRPhiDT_MB1/4", "hResidualGlobalRPhiDT_MB1/4", 200, -10, 10);
0615     hResidualGlobalPhiDT_MB[15] =
0616         fs->make<TH1F>("hResidualGlobalPhiDT_MB1/4", "hResidualGlobalPhiDT_MB1/4", 200, -1, 1);
0617     hResidualGlobalThetaDT_MB[15] =
0618         fs->make<TH1F>("hResidualGlobalThetaDT_MB1/4", "hResidualGlobalThetaDT_MB1/4", 200, -1, 1);
0619     hResidualGlobalZDT_MB[15] = fs->make<TH1F>("hResidualGlobalZDT_MB1/4", "hResidualGlobalZDT_MB1/4", 200, -10, 10);
0620     hResidualGlobalRPhiDT_MB[16] =
0621         fs->make<TH1F>("hResidualGlobalRPhiDT_MB2/1", "hResidualGlobalRPhiDT_MB2/1", 200, -10, 10);
0622     hResidualGlobalPhiDT_MB[16] =
0623         fs->make<TH1F>("hResidualGlobalPhiDT_MB2/1", "hResidualGlobalPhiDT_MB2/1", 200, -1, 1);
0624     hResidualGlobalThetaDT_MB[16] =
0625         fs->make<TH1F>("hResidualGlobalThetaDT_MB2/1", "hResidualGlobalThetaDT_MB2/1", 200, -1, 1);
0626     hResidualGlobalZDT_MB[16] = fs->make<TH1F>("hResidualGlobalZDT_MB2/1", "hResidualGlobalZDT_MB2/1", 200, -10, 10);
0627     hResidualGlobalRPhiDT_MB[17] =
0628         fs->make<TH1F>("hResidualGlobalRPhiDT_MB2/2", "hResidualGlobalRPhiDT_MB2/2", 200, -10, 10);
0629     hResidualGlobalPhiDT_MB[17] =
0630         fs->make<TH1F>("hResidualGlobalPhiDT_MB2/2", "hResidualGlobalPhiDT_MB2/2", 200, -1, 1);
0631     hResidualGlobalThetaDT_MB[17] =
0632         fs->make<TH1F>("hResidualGlobalThetaDT_MB2/2", "hResidualGlobalThetaDT_MB2/2", 200, -1, 1);
0633     hResidualGlobalZDT_MB[17] = fs->make<TH1F>("hResidualGlobalZDT_MB2/2", "hResidualGlobalZDT_MB2/2", 200, -10, 10);
0634     hResidualGlobalRPhiDT_MB[18] =
0635         fs->make<TH1F>("hResidualGlobalRPhiDT_MB2/3", "hResidualGlobalRPhiDT_MB2/3", 200, -10, 10);
0636     hResidualGlobalPhiDT_MB[18] =
0637         fs->make<TH1F>("hResidualGlobalPhiDT_MB2/3", "hResidualGlobalPhiDT_MB2/3", 200, -1, 1);
0638     hResidualGlobalThetaDT_MB[18] =
0639         fs->make<TH1F>("hResidualGlobalThetaDT_MB2/3", "hResidualGlobalThetaDT_MB2/3", 200, -1, 1);
0640     hResidualGlobalZDT_MB[18] = fs->make<TH1F>("hResidualGlobalZDT_MB2/3", "hResidualGlobalZDT_MB2/3", 200, -10, 10);
0641     hResidualGlobalRPhiDT_MB[19] =
0642         fs->make<TH1F>("hResidualGlobalRPhiDT_MB2/4", "hResidualGlobalRPhiDT_MB2/4", 200, -10, 10);
0643     hResidualGlobalPhiDT_MB[19] =
0644         fs->make<TH1F>("hResidualGlobalPhiDT_MB2/4", "hResidualGlobalPhiDT_MB2/4", 200, -1, 1);
0645     hResidualGlobalThetaDT_MB[19] =
0646         fs->make<TH1F>("hResidualGlobalThetaDT_MB2/4", "hResidualGlobalThetaDT_MB2/4", 200, -1, 1);
0647     hResidualGlobalZDT_MB[19] = fs->make<TH1F>("hResidualGlobalZDT_MB2/4", "hResidualGlobalZDT_MB2/4", 200, -10, 10);
0648 
0649     // CSC Stations
0650     hResidualLocalXCSC_ME[0] = fs->make<TH1F>("hResidualLocalXCSC_ME-4/1", "hResidualLocalXCSC_ME-4/1", 200, -10, 10);
0651     hResidualLocalPhiCSC_ME[0] =
0652         fs->make<TH1F>("hResidualLocalPhiCSC_ME-4/1", "hResidualLocalPhiCSC_ME-4/1", 200, -1, 1);
0653     hResidualLocalThetaCSC_ME[0] =
0654         fs->make<TH1F>("hResidualLocalThetaCSC_ME-4/1", "hResidualLocalThetaCSC_ME-4/1", 200, -1, 1);
0655     hResidualLocalYCSC_ME[0] = fs->make<TH1F>("hResidualLocalYCSC_ME-4/1", "hResidualLocalYCSC_ME-4/1", 200, -10, 10);
0656     hResidualLocalXCSC_ME[1] = fs->make<TH1F>("hResidualLocalXCSC_ME-4/2", "hResidualLocalXCSC_ME-4/2", 200, -10, 10);
0657     hResidualLocalPhiCSC_ME[1] =
0658         fs->make<TH1F>("hResidualLocalPhiCSC_ME-4/2", "hResidualLocalPhiCSC_ME-4/2", 200, -1, 1);
0659     hResidualLocalThetaCSC_ME[1] =
0660         fs->make<TH1F>("hResidualLocalThetaCSC_ME-4/2", "hResidualLocalThetaCSC_ME-4/2", 200, -1, 1);
0661     hResidualLocalYCSC_ME[1] = fs->make<TH1F>("hResidualLocalYCSC_ME-4/2", "hResidualLocalYCSC_ME-4/2", 200, -10, 10);
0662     hResidualLocalXCSC_ME[2] = fs->make<TH1F>("hResidualLocalXCSC_ME-3/1", "hResidualLocalXCSC_ME-3/1", 200, -10, 10);
0663     hResidualLocalPhiCSC_ME[2] =
0664         fs->make<TH1F>("hResidualLocalPhiCSC_ME-3/1", "hResidualLocalPhiCSC_ME-3/1", 200, -1, 1);
0665     hResidualLocalThetaCSC_ME[2] =
0666         fs->make<TH1F>("hResidualLocalThetaCSC_ME-3/1", "hResidualLocalThetaCSC_ME-3/1", 200, -1, 1);
0667     hResidualLocalYCSC_ME[2] = fs->make<TH1F>("hResidualLocalYCSC_ME-3/1", "hResidualLocalYCSC_ME-3/1", 200, -10, 10);
0668     hResidualLocalXCSC_ME[3] = fs->make<TH1F>("hResidualLocalXCSC_ME-3/2", "hResidualLocalXCSC_ME-3/2", 200, -10, 10);
0669     hResidualLocalPhiCSC_ME[3] =
0670         fs->make<TH1F>("hResidualLocalPhiCSC_ME-3/2", "hResidualLocalPhiCSC_ME-3/2", 200, -1, 1);
0671     hResidualLocalThetaCSC_ME[3] =
0672         fs->make<TH1F>("hResidualLocalThetaCSC_ME-3/2", "hResidualLocalThetaCSC_ME-3/2", 200, -1, 1);
0673     hResidualLocalYCSC_ME[3] = fs->make<TH1F>("hResidualLocalYCSC_ME-3/2", "hResidualLocalYCSC_ME-3/2", 200, -10, 10);
0674     hResidualLocalXCSC_ME[4] = fs->make<TH1F>("hResidualLocalXCSC_ME-2/1", "hResidualLocalXCSC_ME-2/1", 200, -10, 10);
0675     hResidualLocalPhiCSC_ME[4] =
0676         fs->make<TH1F>("hResidualLocalPhiCSC_ME-2/1", "hResidualLocalPhiCSC_ME-2/1", 200, -1, 1);
0677     hResidualLocalThetaCSC_ME[4] =
0678         fs->make<TH1F>("hResidualLocalThetaCSC_ME-2/1", "hResidualLocalThetaCSC_ME-2/1", 200, -1, 1);
0679     hResidualLocalYCSC_ME[4] = fs->make<TH1F>("hResidualLocalYCSC_ME-2/1", "hResidualLocalYCSC_ME-2/1", 200, -10, 10);
0680     hResidualLocalXCSC_ME[5] = fs->make<TH1F>("hResidualLocalXCSC_ME-2/2", "hResidualLocalXCSC_ME-2/2", 200, -10, 10);
0681     hResidualLocalPhiCSC_ME[5] =
0682         fs->make<TH1F>("hResidualLocalPhiCSC_ME-2/2", "hResidualLocalPhiCSC_ME-2/2", 200, -1, 1);
0683     hResidualLocalThetaCSC_ME[5] =
0684         fs->make<TH1F>("hResidualLocalThetaCSC_ME-2/2", "hResidualLocalThetaCSC_ME-2/2", 200, -1, 1);
0685     hResidualLocalYCSC_ME[5] = fs->make<TH1F>("hResidualLocalYCSC_ME-2/2", "hResidualLocalYCSC_ME-2/2", 200, -10, 10);
0686     hResidualLocalXCSC_ME[6] = fs->make<TH1F>("hResidualLocalXCSC_ME-1/1", "hResidualLocalXCSC_ME-1/1", 200, -10, 10);
0687     hResidualLocalPhiCSC_ME[6] =
0688         fs->make<TH1F>("hResidualLocalPhiCSC_ME-1/1", "hResidualLocalPhiCSC_ME-1/1", 200, -1, 1);
0689     hResidualLocalThetaCSC_ME[6] =
0690         fs->make<TH1F>("hResidualLocalThetaCSC_ME-1/1", "hResidualLocalThetaCSC_ME-1/1", 200, -1, 1);
0691     hResidualLocalYCSC_ME[6] = fs->make<TH1F>("hResidualLocalYCSC_ME-1/1", "hResidualLocalYCSC_ME-1/1", 200, -10, 10);
0692     hResidualLocalXCSC_ME[7] = fs->make<TH1F>("hResidualLocalXCSC_ME-1/2", "hResidualLocalXCSC_ME-1/2", 200, -10, 10);
0693     hResidualLocalPhiCSC_ME[7] =
0694         fs->make<TH1F>("hResidualLocalPhiCSC_ME-1/2", "hResidualLocalPhiCSC_ME-1/2", 200, -1, 1);
0695     hResidualLocalThetaCSC_ME[7] =
0696         fs->make<TH1F>("hResidualLocalThetaCSC_ME-1/2", "hResidualLocalThetaCSC_ME-1/2", 200, -1, 1);
0697     hResidualLocalYCSC_ME[7] = fs->make<TH1F>("hResidualLocalYCSC_ME-1/2", "hResidualLocalYCSC_ME-1/2", 200, -10, 10);
0698     hResidualLocalXCSC_ME[8] = fs->make<TH1F>("hResidualLocalXCSC_ME-1/3", "hResidualLocalXCSC_ME-1/3", 200, -10, 10);
0699     hResidualLocalPhiCSC_ME[8] =
0700         fs->make<TH1F>("hResidualLocalPhiCSC_ME-1/3", "hResidualLocalPhiCSC_ME-1/3", 200, -1, 1);
0701     hResidualLocalThetaCSC_ME[8] =
0702         fs->make<TH1F>("hResidualLocalThetaCSC_ME-1/3", "hResidualLocalThetaCSC_ME-1/3", 200, -1, 1);
0703     hResidualLocalYCSC_ME[8] = fs->make<TH1F>("hResidualLocalYCSC_ME-1/3", "hResidualLocalYCSC_ME-1/3", 200, -10, 10);
0704     hResidualLocalXCSC_ME[9] = fs->make<TH1F>("hResidualLocalXCSC_ME1/1", "hResidualLocalXCSC_ME1/1", 200, -10, 10);
0705     hResidualLocalPhiCSC_ME[9] = fs->make<TH1F>("hResidualLocalPhiCSC_ME1/1", "hResidualLocalPhiCSC_ME1/1", 100, -1, 1);
0706     hResidualLocalThetaCSC_ME[9] =
0707         fs->make<TH1F>("hResidualLocalThetaCSC_ME1/1", "hResidualLocalThetaCSC_ME1/1", 200, -1, 1);
0708     hResidualLocalYCSC_ME[9] = fs->make<TH1F>("hResidualLocalYCSC_ME1/1", "hResidualLocalYCSC_ME1/1", 200, -10, 10);
0709     hResidualLocalXCSC_ME[10] = fs->make<TH1F>("hResidualLocalXCSC_ME1/2", "hResidualLocalXCSC_ME1/2", 200, -10, 10);
0710     hResidualLocalPhiCSC_ME[10] =
0711         fs->make<TH1F>("hResidualLocalPhiCSC_ME1/2", "hResidualLocalPhiCSC_ME1/2", 200, -1, 1);
0712     hResidualLocalThetaCSC_ME[10] =
0713         fs->make<TH1F>("hResidualLocalThetaCSC_ME1/2", "hResidualLocalThetaCSC_ME1/2", 200, -1, 1);
0714     hResidualLocalYCSC_ME[10] = fs->make<TH1F>("hResidualLocalYCSC_ME1/2", "hResidualLocalYCSC_ME1/2", 200, -10, 10);
0715     hResidualLocalXCSC_ME[11] = fs->make<TH1F>("hResidualLocalXCSC_ME1/3", "hResidualLocalXCSC_ME1/3", 200, -10, 10);
0716     hResidualLocalPhiCSC_ME[11] =
0717         fs->make<TH1F>("hResidualLocalPhiCSC_ME1/3", "hResidualLocalPhiCSC_ME1/3", 200, -1, 1);
0718     hResidualLocalThetaCSC_ME[11] =
0719         fs->make<TH1F>("hResidualLocalThetaCSC_ME1/3", "hResidualLocalThetaCSC_ME1/3", 200, -1, 1);
0720     hResidualLocalYCSC_ME[11] = fs->make<TH1F>("hResidualLocalYCSC_ME1/3", "hResidualLocalYCSC_ME1/3", 200, -10, 10);
0721     hResidualLocalXCSC_ME[12] = fs->make<TH1F>("hResidualLocalXCSC_ME2/1", "hResidualLocalXCSC_ME2/1", 200, -10, 10);
0722     hResidualLocalPhiCSC_ME[12] =
0723         fs->make<TH1F>("hResidualLocalPhiCSC_ME2/1", "hResidualLocalPhiCSC_ME2/1", 200, -1, 1);
0724     hResidualLocalThetaCSC_ME[12] =
0725         fs->make<TH1F>("hResidualLocalThetaCSC_ME2/1", "hResidualLocalThetaCSC_ME2/1", 200, -1, 1);
0726     hResidualLocalYCSC_ME[12] = fs->make<TH1F>("hResidualLocalYCSC_ME2/1", "hResidualLocalYCSC_ME2/1", 200, -10, 10);
0727     hResidualLocalXCSC_ME[13] = fs->make<TH1F>("hResidualLocalXCSC_ME2/2", "hResidualLocalXCSC_ME2/2", 200, -10, 10);
0728     hResidualLocalPhiCSC_ME[13] =
0729         fs->make<TH1F>("hResidualLocalPhiCSC_ME2/2", "hResidualLocalPhiCSC_ME2/2", 200, -1, 1);
0730     hResidualLocalThetaCSC_ME[13] =
0731         fs->make<TH1F>("hResidualLocalThetaCSC_ME2/2", "hResidualLocalThetaCSC_ME2/2", 200, -1, 1);
0732     hResidualLocalYCSC_ME[13] = fs->make<TH1F>("hResidualLocalYCSC_ME2/2", "hResidualLocalYCSC_ME2/2", 200, -10, 10);
0733     hResidualLocalXCSC_ME[14] = fs->make<TH1F>("hResidualLocalXCSC_ME3/1", "hResidualLocalXCSC_ME3/1", 200, -10, 10);
0734     hResidualLocalPhiCSC_ME[14] =
0735         fs->make<TH1F>("hResidualLocalPhiCSC_ME3/1", "hResidualLocalPhiCSC_ME3/1", 200, -1, 1);
0736     hResidualLocalThetaCSC_ME[14] =
0737         fs->make<TH1F>("hResidualLocalThetaCSC_ME3/1", "hResidualLocalThetaCSC_ME3/1", 200, -1, 1);
0738     hResidualLocalYCSC_ME[14] = fs->make<TH1F>("hResidualLocalYCSC_ME3/1", "hResidualLocalYCSC_ME3/1", 200, -10, 10);
0739     hResidualLocalXCSC_ME[15] = fs->make<TH1F>("hResidualLocalXCSC_ME3/2", "hResidualLocalXCSC_ME3/2", 200, -10, 10);
0740     hResidualLocalPhiCSC_ME[15] =
0741         fs->make<TH1F>("hResidualLocalPhiCSC_ME3/2", "hResidualLocalPhiCSC_ME3/2", 200, -1, 1);
0742     hResidualLocalThetaCSC_ME[15] =
0743         fs->make<TH1F>("hResidualLocalThetaCSC_ME3/2", "hResidualLocalThetaCSC_ME3/2", 200, -1, 1);
0744     hResidualLocalYCSC_ME[15] = fs->make<TH1F>("hResidualLocalYCSC_ME3/2", "hResidualLocalYCSC_ME3/2", 200, -10, 10);
0745     hResidualLocalXCSC_ME[16] = fs->make<TH1F>("hResidualLocalXCSC_ME4/1", "hResidualLocalXCSC_ME4/1", 200, -10, 10);
0746     hResidualLocalPhiCSC_ME[16] =
0747         fs->make<TH1F>("hResidualLocalPhiCSC_ME4/1", "hResidualLocalPhiCSC_ME4/1", 200, -1, 1);
0748     hResidualLocalThetaCSC_ME[16] =
0749         fs->make<TH1F>("hResidualLocalThetaCSC_ME4/1", "hResidualLocalThetaCSC_ME4/1", 200, -1, 1);
0750     hResidualLocalYCSC_ME[16] = fs->make<TH1F>("hResidualLocalYCSC_ME4/1", "hResidualLocalYCSC_ME4/1", 200, -10, 10);
0751     hResidualLocalXCSC_ME[17] = fs->make<TH1F>("hResidualLocalXCSC_ME4/2", "hResidualLocalXCSC_ME4/2", 200, -10, 10);
0752     hResidualLocalPhiCSC_ME[17] =
0753         fs->make<TH1F>("hResidualLocalPhiCSC_ME4/2", "hResidualLocalPhiCSC_ME4/2", 200, -1, 1);
0754     hResidualLocalThetaCSC_ME[17] =
0755         fs->make<TH1F>("hResidualLocalThetaCSC_ME4/2", "hResidualLocalThetaCSC_ME4/2", 200, -1, 1);
0756     hResidualLocalYCSC_ME[17] = fs->make<TH1F>("hResidualLocalYCSC_ME4/2", "hResidualLocalYCSC_ME4/2", 200, -10, 10);
0757     hResidualGlobalRPhiCSC_ME[0] =
0758         fs->make<TH1F>("hResidualGlobalRPhiCSC_ME-4/1", "hResidualGlobalRPhiCSC_ME-4/1", 200, -10, 10);
0759     hResidualGlobalPhiCSC_ME[0] =
0760         fs->make<TH1F>("hResidualGlobalPhiCSC_ME-4/1", "hResidualGlobalPhiCSC_ME-4/1", 200, -1, 1);
0761     hResidualGlobalThetaCSC_ME[0] =
0762         fs->make<TH1F>("hResidualGlobalThetaCSC_ME-4/1", "hResidualGlobalThetaCSC_ME-4/1", 200, -1, 1);
0763     hResidualGlobalRCSC_ME[0] =
0764         fs->make<TH1F>("hResidualGlobalRCSC_ME-4/1", "hResidualGlobalRCSC_ME-4/1", 200, -10, 10);
0765     hResidualGlobalRPhiCSC_ME[1] =
0766         fs->make<TH1F>("hResidualGlobalRPhiCSC_ME-4/2", "hResidualGlobalRPhiCSC_ME-4/2", 200, -10, 10);
0767     hResidualGlobalPhiCSC_ME[1] =
0768         fs->make<TH1F>("hResidualGlobalPhiCSC_ME-4/2", "hResidualGlobalPhiCSC_ME-4/2", 200, -1, 1);
0769     hResidualGlobalThetaCSC_ME[1] =
0770         fs->make<TH1F>("hResidualGlobalThetaCSC_ME-4/2", "hResidualGlobalThetaCSC_ME-4/2", 200, -1, 1);
0771     hResidualGlobalRCSC_ME[1] =
0772         fs->make<TH1F>("hResidualGlobalRCSC_ME-4/2", "hResidualGlobalRCSC_ME-4/2", 200, -10, 10);
0773     hResidualGlobalRPhiCSC_ME[2] =
0774         fs->make<TH1F>("hResidualGlobalRPhiCSC_ME-3/1", "hResidualGlobalRPhiCSC_ME-3/1", 200, -10, 10);
0775     hResidualGlobalPhiCSC_ME[2] =
0776         fs->make<TH1F>("hResidualGlobalPhiCSC_ME-3/1", "hResidualGlobalPhiCSC_ME-3/1", 200, -1, 1);
0777     hResidualGlobalThetaCSC_ME[2] =
0778         fs->make<TH1F>("hResidualGlobalThetaCSC_ME-3/1", "hResidualGlobalThetaCSC_ME-3/1", 200, -1, 1);
0779     hResidualGlobalRCSC_ME[2] =
0780         fs->make<TH1F>("hResidualGlobalRCSC_ME-3/1", "hResidualGlobalRCSC_ME-3/1", 200, -10, 10);
0781     hResidualGlobalRPhiCSC_ME[3] =
0782         fs->make<TH1F>("hResidualGlobalRPhiCSC_ME-3/2", "hResidualGlobalRPhiCSC_ME-3/2", 200, -10, 10);
0783     hResidualGlobalPhiCSC_ME[3] =
0784         fs->make<TH1F>("hResidualGlobalPhiCSC_ME-3/2", "hResidualGlobalPhiCSC_ME-3/2", 200, -1, 1);
0785     hResidualGlobalThetaCSC_ME[3] =
0786         fs->make<TH1F>("hResidualGlobalThetaCSC_ME-3/2", "hResidualGlobalThetaCSC_ME-3/2", 200, -1, 1);
0787     hResidualGlobalRCSC_ME[3] =
0788         fs->make<TH1F>("hResidualGlobalRCSC_ME-3/2", "hResidualGlobalRCSC_ME-3/2", 200, -10, 10);
0789     hResidualGlobalRPhiCSC_ME[4] =
0790         fs->make<TH1F>("hResidualGlobalRPhiCSC_ME-2/1", "hResidualGlobalRPhiCSC_ME-2/1", 200, -10, 10);
0791     hResidualGlobalPhiCSC_ME[4] =
0792         fs->make<TH1F>("hResidualGlobalPhiCSC_ME-2/1", "hResidualGlobalPhiCSC_ME-2/1", 200, -1, 1);
0793     hResidualGlobalThetaCSC_ME[4] =
0794         fs->make<TH1F>("hResidualGlobalThetaCSC_ME-2/1", "hResidualGlobalThetaCSC_ME-2/1", 200, -1, 1);
0795     hResidualGlobalRCSC_ME[4] =
0796         fs->make<TH1F>("hResidualGlobalRCSC_ME-2/1", "hResidualGlobalRCSC_ME-2/1", 200, -10, 10);
0797     hResidualGlobalRPhiCSC_ME[5] =
0798         fs->make<TH1F>("hResidualGlobalRPhiCSC_ME-2/2", "hResidualGlobalRPhiCSC_ME-2/2", 200, -10, 10);
0799     hResidualGlobalPhiCSC_ME[5] =
0800         fs->make<TH1F>("hResidualGlobalPhiCSC_ME-2/2", "hResidualGlobalPhiCSC_ME-2/2", 200, -1, 1);
0801     hResidualGlobalThetaCSC_ME[5] =
0802         fs->make<TH1F>("hResidualGlobalThetaCSC_ME-2/2", "hResidualGlobalThetaCSC_ME-2/2", 200, -1, 1);
0803     hResidualGlobalRCSC_ME[5] =
0804         fs->make<TH1F>("hResidualGlobalRCSC_ME-2/2", "hResidualGlobalRCSC_ME-2/2", 200, -10, 10);
0805     hResidualGlobalRPhiCSC_ME[6] =
0806         fs->make<TH1F>("hResidualGlobalRPhiCSC_ME-1/1", "hResidualGlobalRPhiCSC_ME-1/1", 200, -10, 10);
0807     hResidualGlobalPhiCSC_ME[6] =
0808         fs->make<TH1F>("hResidualGlobalPhiCSC_ME-1/1", "hResidualGlobalPhiCSC_ME-1/1", 200, -1, 1);
0809     hResidualGlobalThetaCSC_ME[6] =
0810         fs->make<TH1F>("hResidualGlobalThetaCSC_ME-1/1", "hResidualGlobalThetaCSC_ME-1/1", 200, -1, 1);
0811     hResidualGlobalRCSC_ME[6] =
0812         fs->make<TH1F>("hResidualGlobalRCSC_ME-1/1", "hResidualGlobalRCSC_ME-1/1", 200, -10, 10);
0813     hResidualGlobalRPhiCSC_ME[7] =
0814         fs->make<TH1F>("hResidualGlobalRPhiCSC_ME-1/2", "hResidualGlobalRPhiCSC_ME-1/2", 200, -10, 10);
0815     hResidualGlobalPhiCSC_ME[7] =
0816         fs->make<TH1F>("hResidualGlobalPhiCSC_ME-1/2", "hResidualGlobalPhiCSC_ME-1/2", 200, -1, 1);
0817     hResidualGlobalThetaCSC_ME[7] =
0818         fs->make<TH1F>("hResidualGlobalThetaCSC_ME-1/2", "hResidualGlobalThetaCSC_ME-1/2", 200, -1, 1);
0819     hResidualGlobalRCSC_ME[7] =
0820         fs->make<TH1F>("hResidualGlobalRCSC_ME-1/2", "hResidualGlobalRCSC_ME-1/2", 200, -10, 10);
0821     hResidualGlobalRPhiCSC_ME[8] =
0822         fs->make<TH1F>("hResidualGlobalRPhiCSC_ME-1/3", "hResidualGlobalRPhiCSC_ME-1/3", 200, -10, 10);
0823     hResidualGlobalPhiCSC_ME[8] =
0824         fs->make<TH1F>("hResidualGlobalPhiCSC_ME-1/3", "hResidualGlobalPhiCSC_ME-1/3", 200, -1, 1);
0825     hResidualGlobalThetaCSC_ME[8] =
0826         fs->make<TH1F>("hResidualGlobalThetaCSC_ME-1/3", "hResidualGlobalThetaCSC_ME-1/3", 200, -1, 1);
0827     hResidualGlobalRCSC_ME[8] =
0828         fs->make<TH1F>("hResidualGlobalRCSC_ME-1/3", "hResidualGlobalRCSC_ME-1/3", 200, -10, 10);
0829     hResidualGlobalRPhiCSC_ME[9] =
0830         fs->make<TH1F>("hResidualGlobalRPhiCSC_ME1/1", "hResidualGlobalRPhiCSC_ME1/1", 200, -10, 10);
0831     hResidualGlobalPhiCSC_ME[9] =
0832         fs->make<TH1F>("hResidualGlobalPhiCSC_ME1/1", "hResidualGlobalPhiCSC_ME1/1", 100, -1, 1);
0833     hResidualGlobalThetaCSC_ME[9] =
0834         fs->make<TH1F>("hResidualGlobalThetaCSC_ME1/1", "hResidualGlobalThetaCSC_ME1/1", 200, -1, 1);
0835     hResidualGlobalRCSC_ME[9] = fs->make<TH1F>("hResidualGlobalRCSC_ME1/1", "hResidualGlobalRCSC_ME1/1", 200, -10, 10);
0836     hResidualGlobalRPhiCSC_ME[10] =
0837         fs->make<TH1F>("hResidualGlobalRPhiCSC_ME1/2", "hResidualGlobalRPhiCSC_ME1/2", 200, -10, 10);
0838     hResidualGlobalPhiCSC_ME[10] =
0839         fs->make<TH1F>("hResidualGlobalPhiCSC_ME1/2", "hResidualGlobalPhiCSC_ME1/2", 200, -1, 1);
0840     hResidualGlobalThetaCSC_ME[10] =
0841         fs->make<TH1F>("hResidualGlobalThetaCSC_ME1/2", "hResidualGlobalThetaCSC_ME1/2", 200, -1, 1);
0842     hResidualGlobalRCSC_ME[10] = fs->make<TH1F>("hResidualGlobalRCSC_ME1/2", "hResidualGlobalRCSC_ME1/2", 200, -10, 10);
0843     hResidualGlobalRPhiCSC_ME[11] =
0844         fs->make<TH1F>("hResidualGlobalRPhiCSC_ME1/3", "hResidualGlobalRPhiCSC_ME1/3", 200, -10, 10);
0845     hResidualGlobalPhiCSC_ME[11] =
0846         fs->make<TH1F>("hResidualGlobalPhiCSC_ME1/3", "hResidualGlobalPhiCSC_ME1/3", 200, -1, 1);
0847     hResidualGlobalThetaCSC_ME[11] =
0848         fs->make<TH1F>("hResidualGlobalThetaCSC_ME1/3", "hResidualGlobalThetaCSC_ME1/3", 200, -1, 1);
0849     hResidualGlobalRCSC_ME[11] = fs->make<TH1F>("hResidualGlobalRCSC_ME1/3", "hResidualGlobalRCSC_ME1/3", 200, -10, 10);
0850     hResidualGlobalRPhiCSC_ME[12] =
0851         fs->make<TH1F>("hResidualGlobalRPhiCSC_ME2/1", "hResidualGlobalRPhiCSC_ME2/1", 200, -10, 10);
0852     hResidualGlobalPhiCSC_ME[12] =
0853         fs->make<TH1F>("hResidualGlobalPhiCSC_ME2/1", "hResidualGlobalPhiCSC_ME2/1", 200, -1, 1);
0854     hResidualGlobalThetaCSC_ME[12] =
0855         fs->make<TH1F>("hResidualGlobalThetaCSC_ME2/1", "hResidualGlobalThetaCSC_ME2/1", 200, -1, 1);
0856     hResidualGlobalRCSC_ME[12] = fs->make<TH1F>("hResidualGlobalRCSC_ME2/1", "hResidualGlobalRCSC_ME2/1", 200, -10, 10);
0857     hResidualGlobalRPhiCSC_ME[13] =
0858         fs->make<TH1F>("hResidualGlobalRPhiCSC_ME2/2", "hResidualGlobalRPhiCSC_ME2/2", 200, -10, 10);
0859     hResidualGlobalPhiCSC_ME[13] =
0860         fs->make<TH1F>("hResidualGlobalPhiCSC_ME2/2", "hResidualGlobalPhiCSC_ME2/2", 200, -1, 1);
0861     hResidualGlobalThetaCSC_ME[13] =
0862         fs->make<TH1F>("hResidualGlobalThetaCSC_ME2/2", "hResidualGlobalThetaCSC_ME2/2", 200, -1, 1);
0863     hResidualGlobalRCSC_ME[13] = fs->make<TH1F>("hResidualGlobalRCSC_ME2/2", "hResidualGlobalRCSC_ME2/2", 200, -10, 10);
0864     hResidualGlobalRPhiCSC_ME[14] =
0865         fs->make<TH1F>("hResidualGlobalRPhiCSC_ME3/1", "hResidualGlobalRPhiCSC_ME3/1", 200, -10, 10);
0866     hResidualGlobalPhiCSC_ME[14] =
0867         fs->make<TH1F>("hResidualGlobalPhiCSC_ME3/1", "hResidualGlobalPhiCSC_ME3/1", 200, -1, 1);
0868     hResidualGlobalThetaCSC_ME[14] =
0869         fs->make<TH1F>("hResidualGlobalThetaCSC_ME3/1", "hResidualGlobalThetaCSC_ME3/1", 200, -1, 1);
0870     hResidualGlobalRCSC_ME[14] = fs->make<TH1F>("hResidualGlobalRCSC_ME3/1", "hResidualGlobalRCSC_ME3/1", 200, -10, 10);
0871     hResidualGlobalRPhiCSC_ME[15] =
0872         fs->make<TH1F>("hResidualGlobalRPhiCSC_ME3/2", "hResidualGlobalRPhiCSC_ME3/2", 200, -10, 10);
0873     hResidualGlobalPhiCSC_ME[15] =
0874         fs->make<TH1F>("hResidualGlobalPhiCSC_ME3/2", "hResidualGlobalPhiCSC_ME3/2", 200, -1, 1);
0875     hResidualGlobalThetaCSC_ME[15] =
0876         fs->make<TH1F>("hResidualGlobalThetaCSC_ME3/2", "hResidualGlobalThetaCSC_ME3/2", 200, -1, 1);
0877     hResidualGlobalRCSC_ME[15] = fs->make<TH1F>("hResidualGlobalRCSC_ME3/2", "hResidualGlobalRCSC_ME3/2", 200, -10, 10);
0878     hResidualGlobalRPhiCSC_ME[16] =
0879         fs->make<TH1F>("hResidualGlobalRPhiCSC_ME4/1", "hResidualGlobalRPhiCSC_ME4/1", 200, -10, 10);
0880     hResidualGlobalPhiCSC_ME[16] =
0881         fs->make<TH1F>("hResidualGlobalPhiCSC_ME4/1", "hResidualGlobalPhiCSC_ME4/1", 200, -1, 1);
0882     hResidualGlobalThetaCSC_ME[16] =
0883         fs->make<TH1F>("hResidualGlobalThetaCSC_ME4/1", "hResidualGlobalThetaCSC_ME4/1", 200, -1, 1);
0884     hResidualGlobalRCSC_ME[16] = fs->make<TH1F>("hResidualGlobalRCSC_ME4/1", "hResidualGlobalRCSC_ME4/1", 200, -10, 10);
0885     hResidualGlobalRPhiCSC_ME[17] =
0886         fs->make<TH1F>("hResidualGlobalRPhiCSC_ME4/2", "hResidualGlobalRPhiCSC_ME4/2", 200, -10, 10);
0887     hResidualGlobalPhiCSC_ME[17] =
0888         fs->make<TH1F>("hResidualGlobalPhiCSC_ME4/2", "hResidualGlobalPhiCSC_ME4/2", 200, -1, 1);
0889     hResidualGlobalThetaCSC_ME[17] =
0890         fs->make<TH1F>("hResidualGlobalThetaCSC_ME4/2", "hResidualGlobalThetaCSC_ME4/2", 200, -1, 1);
0891     hResidualGlobalRCSC_ME[17] = fs->make<TH1F>("hResidualGlobalRCSC_ME4/2", "hResidualGlobalRCSC_ME4/2", 200, -10, 10);
0892 
0893     //DQM plots: mean residual with RMS as error
0894     hprofLocalXDT = fs->make<TH1F>("hprofLocalXDT", "Local X DT;;X (cm)", 280, 0, 280);
0895     hprofLocalPhiDT = fs->make<TH1F>("hprofLocalPhiDT", "Local Phi DT;;Phi (rad)", 280, 0, 280);
0896     hprofLocalThetaDT = fs->make<TH1F>("hprofLocalThetaDT", "Local Theta DT;;Theta (rad)", 280, 0, 280);
0897     hprofLocalYDT = fs->make<TH1F>("hprofLocalYDT", "Local Y DT;;Y (cm)", 280, 0, 280);
0898     hprofLocalXCSC = fs->make<TH1F>("hprofLocalXCSC", "Local X CSC;;X (cm)", 540, 0, 540);
0899     hprofLocalPhiCSC = fs->make<TH1F>("hprofLocalPhiCSC", "Local Phi CSC;;Phi (rad)", 540, 0, 540);
0900     hprofLocalThetaCSC = fs->make<TH1F>("hprofLocalThetaCSC", "Local Theta CSC;;Theta (rad)", 540, 0, 540);
0901     hprofLocalYCSC = fs->make<TH1F>("hprofLocalYCSC", "Local Y CSC;;Y (cm)", 540, 0, 540);
0902     hprofGlobalRPhiDT = fs->make<TH1F>("hprofGlobalRPhiDT", "Global RPhi DT;;RPhi (cm)", 280, 0, 280);
0903     hprofGlobalPhiDT = fs->make<TH1F>("hprofGlobalPhiDT", "Global Phi DT;;Phi (rad)", 280, 0, 280);
0904     hprofGlobalThetaDT = fs->make<TH1F>("hprofGlobalThetaDT", "Global Theta DT;;Theta (rad)", 280, 0, 280);
0905     hprofGlobalZDT = fs->make<TH1F>("hprofGlobalZDT", "Global Z DT;;Z (cm)", 280, 0, 280);
0906     hprofGlobalRPhiCSC = fs->make<TH1F>("hprofGlobalRPhiCSC", "Global RPhi CSC;;RPhi (cm)", 540, 0, 540);
0907     hprofGlobalPhiCSC = fs->make<TH1F>("hprofGlobalPhiCSC", "Global Phi CSC;;Phi (cm)", 540, 0, 540);
0908     hprofGlobalThetaCSC = fs->make<TH1F>("hprofGlobalThetaCSC", "Global Theta CSC;;Theta (rad)", 540, 0, 540);
0909     hprofGlobalRCSC = fs->make<TH1F>("hprofGlobalRCSC", "Global R CSC;;R (cm)", 540, 0, 540);
0910 
0911     // TH1F options
0912     hprofLocalXDT->GetXaxis()->SetLabelSize(0.025);
0913     hprofLocalPhiDT->GetXaxis()->SetLabelSize(0.025);
0914     hprofLocalThetaDT->GetXaxis()->SetLabelSize(0.025);
0915     hprofLocalYDT->GetXaxis()->SetLabelSize(0.025);
0916     hprofLocalXCSC->GetXaxis()->SetLabelSize(0.025);
0917     hprofLocalPhiCSC->GetXaxis()->SetLabelSize(0.025);
0918     hprofLocalThetaCSC->GetXaxis()->SetLabelSize(0.025);
0919     hprofLocalYCSC->GetXaxis()->SetLabelSize(0.025);
0920     hprofGlobalRPhiDT->GetXaxis()->SetLabelSize(0.025);
0921     hprofGlobalPhiDT->GetXaxis()->SetLabelSize(0.025);
0922     hprofGlobalThetaDT->GetXaxis()->SetLabelSize(0.025);
0923     hprofGlobalZDT->GetXaxis()->SetLabelSize(0.025);
0924     hprofGlobalRPhiCSC->GetXaxis()->SetLabelSize(0.025);
0925     hprofGlobalPhiCSC->GetXaxis()->SetLabelSize(0.025);
0926     hprofGlobalThetaCSC->GetXaxis()->SetLabelSize(0.025);
0927     hprofGlobalRCSC->GetXaxis()->SetLabelSize(0.025);
0928 
0929     // TH2F histos definition
0930     hprofGlobalPositionDT = fs->make<TH2F>(
0931         "hprofGlobalPositionDT", "Global DT position (cm) absolute MEAN residuals;Sector;;cm", 14, 0, 14, 40, 0, 40);
0932     hprofGlobalAngleDT = fs->make<TH2F>(
0933         "hprofGlobalAngleDT", "Global DT angle (rad) absolute MEAN residuals;Sector;;rad", 14, 0, 14, 40, 0, 40);
0934     hprofGlobalPositionRmsDT = fs->make<TH2F>(
0935         "hprofGlobalPositionRmsDT", "Global DT position (cm) RMS residuals;Sector;;rad", 14, 0, 14, 40, 0, 40);
0936     hprofGlobalAngleRmsDT = fs->make<TH2F>(
0937         "hprofGlobalAngleRmsDT", "Global DT angle (rad) RMS residuals;Sector;;rad", 14, 0, 14, 40, 0, 40);
0938     hprofLocalPositionDT = fs->make<TH2F>(
0939         "hprofLocalPositionDT", "Local DT position (cm) absolute MEAN residuals;Sector;;cm", 14, 0, 14, 40, 0, 40);
0940     hprofLocalAngleDT = fs->make<TH2F>(
0941         "hprofLocalAngleDT", "Local DT angle (rad) absolute MEAN residuals;Sector;;rad", 14, 0, 14, 40, 0, 40);
0942     hprofLocalPositionRmsDT = fs->make<TH2F>(
0943         "hprofLocalPositionRmsDT", "Local DT position (cm) RMS residuals;Sector;;rad", 14, 0, 14, 40, 0, 40);
0944     hprofLocalAngleRmsDT =
0945         fs->make<TH2F>("hprofLocalAngleRmsDT", "Local DT angle (rad) RMS residuals;Sector;;rad", 14, 0, 14, 40, 0, 40);
0946 
0947     hprofGlobalPositionCSC = fs->make<TH2F>(
0948         "hprofGlobalPositionCSC", "Global CSC position (cm) absolute MEAN residuals;Sector;;cm", 36, 0, 36, 36, 0, 36);
0949     hprofGlobalAngleCSC = fs->make<TH2F>(
0950         "hprofGlobalAngleCSC", "Global CSC angle (rad) absolute MEAN residuals;Sector;;rad", 36, 0, 36, 36, 0, 36);
0951     hprofGlobalPositionRmsCSC = fs->make<TH2F>(
0952         "hprofGlobalPositionRmsCSC", "Global CSC position (cm) RMS residuals;Sector;;rad", 36, 0, 36, 36, 0, 36);
0953     hprofGlobalAngleRmsCSC = fs->make<TH2F>(
0954         "hprofGlobalAngleRmsCSC", "Global CSC angle (rad) RMS residuals;Sector;;rad", 36, 0, 36, 36, 0, 36);
0955     hprofLocalPositionCSC = fs->make<TH2F>(
0956         "hprofLocalPositionCSC", "Local CSC position (cm) absolute MEAN residuals;Sector;;cm", 36, 0, 36, 36, 0, 36);
0957     hprofLocalAngleCSC = fs->make<TH2F>(
0958         "hprofLocalAngleCSC", "Local CSC angle (rad) absolute MEAN residuals;Sector;;rad", 36, 0, 36, 36, 0, 36);
0959     hprofLocalPositionRmsCSC = fs->make<TH2F>(
0960         "hprofLocalPositionRmsCSC", "Local CSC position (cm) RMS residuals;Sector;;rad", 36, 0, 36, 36, 0, 36);
0961     hprofLocalAngleRmsCSC = fs->make<TH2F>(
0962         "hprofLocalAngleRmsCSC", "Local CSC angle (rad) RMS residuals;Sector;;rad", 36, 0, 36, 36, 0, 36);
0963 
0964     // histos options
0965     Float_t labelSize = 0.025;
0966     hprofGlobalPositionDT->GetYaxis()->SetLabelSize(labelSize);
0967     hprofGlobalAngleDT->GetYaxis()->SetLabelSize(labelSize);
0968     hprofGlobalPositionRmsDT->GetYaxis()->SetLabelSize(labelSize);
0969     hprofGlobalAngleRmsDT->GetYaxis()->SetLabelSize(labelSize);
0970     hprofLocalPositionDT->GetYaxis()->SetLabelSize(labelSize);
0971     hprofLocalAngleDT->GetYaxis()->SetLabelSize(labelSize);
0972     hprofLocalPositionRmsDT->GetYaxis()->SetLabelSize(labelSize);
0973     hprofLocalAngleRmsDT->GetYaxis()->SetLabelSize(labelSize);
0974 
0975     hprofGlobalPositionCSC->GetYaxis()->SetLabelSize(labelSize);
0976     hprofGlobalAngleCSC->GetYaxis()->SetLabelSize(labelSize);
0977     hprofGlobalPositionRmsCSC->GetYaxis()->SetLabelSize(labelSize);
0978     hprofGlobalAngleRmsCSC->GetYaxis()->SetLabelSize(labelSize);
0979     hprofLocalPositionCSC->GetYaxis()->SetLabelSize(labelSize);
0980     hprofLocalAngleCSC->GetYaxis()->SetLabelSize(labelSize);
0981     hprofLocalPositionRmsCSC->GetYaxis()->SetLabelSize(labelSize);
0982     hprofLocalAngleRmsCSC->GetYaxis()->SetLabelSize(labelSize);
0983 
0984     char binLabel[32];
0985     for (int i = 1; i < 15; i++) {
0986       snprintf(binLabel, sizeof(binLabel), "Sec-%d", i);
0987       hprofGlobalPositionDT->GetXaxis()->SetBinLabel(i, binLabel);
0988       hprofGlobalAngleDT->GetXaxis()->SetBinLabel(i, binLabel);
0989       hprofGlobalPositionRmsDT->GetXaxis()->SetBinLabel(i, binLabel);
0990       hprofGlobalAngleRmsDT->GetXaxis()->SetBinLabel(i, binLabel);
0991       hprofLocalPositionDT->GetXaxis()->SetBinLabel(i, binLabel);
0992       hprofLocalAngleDT->GetXaxis()->SetBinLabel(i, binLabel);
0993       hprofLocalPositionRmsDT->GetXaxis()->SetBinLabel(i, binLabel);
0994       hprofLocalAngleRmsDT->GetXaxis()->SetBinLabel(i, binLabel);
0995     }
0996 
0997     for (int i = 1; i < 37; i++) {
0998       snprintf(binLabel, sizeof(binLabel), "Ch-%d", i);
0999       hprofGlobalPositionCSC->GetXaxis()->SetBinLabel(i, binLabel);
1000       hprofGlobalAngleCSC->GetXaxis()->SetBinLabel(i, binLabel);
1001       hprofGlobalPositionRmsCSC->GetXaxis()->SetBinLabel(i, binLabel);
1002       hprofGlobalAngleRmsCSC->GetXaxis()->SetBinLabel(i, binLabel);
1003       hprofLocalPositionCSC->GetXaxis()->SetBinLabel(i, binLabel);
1004       hprofLocalAngleCSC->GetXaxis()->SetBinLabel(i, binLabel);
1005       hprofLocalPositionRmsCSC->GetXaxis()->SetBinLabel(i, binLabel);
1006       hprofLocalAngleRmsCSC->GetXaxis()->SetBinLabel(i, binLabel);
1007     }
1008   }
1009 }
1010 
1011 void MuonAlignmentAnalyzer::endJob() {
1012   edm::LogInfo("MuonAlignmentAnalyzer") << "----------------- " << std::endl << std::endl;
1013 
1014   if (theDataType == "SimData")
1015     edm::LogInfo("MuonAlignmentAnalyzer") << "Number of Sim tracks: " << numberOfSimTracks << std::endl << std::endl;
1016 
1017   if (doSAplots)
1018     edm::LogInfo("MuonAlignmentAnalyzer") << "Number of SA Reco tracks: " << numberOfSARecTracks << std::endl
1019                                           << std::endl;
1020 
1021   if (doGBplots)
1022     edm::LogInfo("MuonAlignmentAnalyzer") << "Number of GB Reco tracks: " << numberOfGBRecTracks << std::endl
1023                                           << std::endl;
1024 
1025   if (doResplots) {
1026     //  delete thePropagator;
1027 
1028     edm::LogInfo("MuonAlignmentAnalyzer") << "Number of Hits considered for residuals: " << numberOfHits << std::endl
1029                                           << std::endl;
1030 
1031     char binLabel[40];
1032 
1033     for (unsigned int i = 0; i < unitsLocalX.size(); i++) {
1034       TString nameHistoLocalX = unitsLocalX[i]->GetName();
1035 
1036       TString nameHistoLocalPhi = unitsLocalPhi[i]->GetName();
1037 
1038       TString nameHistoLocalTheta = unitsLocalTheta[i]->GetName();
1039 
1040       TString nameHistoLocalY = unitsLocalY[i]->GetName();
1041 
1042       TString nameHistoGlobalRPhi = unitsGlobalRPhi[i]->GetName();
1043 
1044       TString nameHistoGlobalPhi = unitsGlobalPhi[i]->GetName();
1045 
1046       TString nameHistoGlobalTheta = unitsGlobalTheta[i]->GetName();
1047 
1048       TString nameHistoGlobalRZ = unitsGlobalRZ[i]->GetName();
1049 
1050       if (nameHistoLocalX.Contains("MB"))  // HistoLocalX DT
1051       {
1052         int wheel, station, sector;
1053 
1054         sscanf(nameHistoLocalX, "ResidualLocalX_W%dMB%1dS%d", &wheel, &station, &sector);
1055 
1056         Int_t nstation = station - 1;
1057         Int_t nwheel = wheel + 2;
1058 
1059         Double_t MeanRPhi = unitsLocalX[i]->GetMean();
1060         Double_t ErrorRPhi = unitsLocalX[i]->GetMeanError();
1061 
1062         Int_t xbin = sector + 14 * nstation + 14 * 4 * nwheel;
1063 
1064         snprintf(binLabel, sizeof(binLabel), "MB%d/%dS%d", wheel, station, sector);
1065 
1066         hprofLocalXDT->SetMarkerStyle(21);
1067         hprofLocalXDT->SetMarkerColor(kRed);
1068         hprofLocalXDT->SetBinContent(xbin, MeanRPhi);
1069         hprofLocalXDT->SetBinError(xbin, ErrorRPhi);
1070         hprofLocalXDT->GetXaxis()->SetBinLabel(xbin, binLabel);
1071 
1072         Int_t ybin = 1 + nwheel * 8 + nstation * 2;
1073         hprofLocalPositionDT->SetBinContent(sector, ybin, fabs(MeanRPhi));
1074         snprintf(binLabel, sizeof(binLabel), "MB%d/%d_LocalX", wheel, station);
1075         hprofLocalPositionDT->GetYaxis()->SetBinLabel(ybin, binLabel);
1076         hprofLocalPositionRmsDT->SetBinContent(sector, ybin, ErrorRPhi);
1077         hprofLocalPositionRmsDT->GetYaxis()->SetBinLabel(ybin, binLabel);
1078       }
1079 
1080       if (nameHistoLocalX.Contains("ME"))  // HistoLocalX CSC
1081       {
1082         int station, ring, chamber;
1083 
1084         sscanf(nameHistoLocalX, "ResidualLocalX_ME%dR%1dC%d", &station, &ring, &chamber);
1085 
1086         Double_t MeanRPhi = unitsLocalX[i]->GetMean();
1087         Double_t ErrorRPhi = unitsLocalX[i]->GetMeanError();
1088 
1089         Int_t xbin = abs(station) * 2 + ring;
1090         if (abs(station) == 1)
1091           xbin = ring;
1092         if (station > 0)
1093           xbin = xbin + 9;
1094         else
1095           xbin = 10 - xbin;
1096 
1097         // To avoid holes in xAxis, I can't imagine right now a simpler way...
1098         if (xbin < 5)
1099           xbin = 18 * (((Int_t)(xbin / 3)) * 2 + (Int_t)(xbin / 2)) + chamber;
1100         else if (xbin < 6)
1101           xbin = 108 + chamber;
1102         else if (xbin < 14)
1103           xbin = 126 + (xbin - 6) * 36 + chamber;
1104         else if (xbin < 18)
1105           xbin = 414 + 18 * (((Int_t)(xbin - 13) / 3) * 2 + ((Int_t)(xbin - 13) / 2)) + chamber;
1106         else
1107           xbin = 522 + chamber;
1108 
1109         snprintf(binLabel, sizeof(binLabel), "ME%d/%dC%d", station, ring, chamber);
1110 
1111         hprofLocalXCSC->SetMarkerStyle(21);
1112         hprofLocalXCSC->SetMarkerColor(kRed);
1113         hprofLocalXCSC->SetBinContent(xbin, MeanRPhi);
1114         hprofLocalXCSC->SetBinError(xbin, ErrorRPhi);
1115         hprofLocalXCSC->GetXaxis()->SetBinLabel(xbin, binLabel);
1116 
1117         Int_t ybin = abs(station) * 2 + ring;
1118         if (abs(station) == 1)
1119           ybin = ring;
1120         if (station > 0)
1121           ybin = ybin + 9;
1122         else
1123           ybin = 10 - ybin;
1124         ybin = 2 * ybin - 1;
1125         hprofLocalPositionCSC->SetBinContent(chamber, ybin, fabs(MeanRPhi));
1126         snprintf(binLabel, sizeof(binLabel), "ME%d/%d_LocalX", station, ring);
1127         hprofLocalPositionCSC->GetYaxis()->SetBinLabel(ybin, binLabel);
1128         hprofLocalPositionRmsCSC->SetBinContent(chamber, ybin, ErrorRPhi);
1129         hprofLocalPositionRmsCSC->GetYaxis()->SetBinLabel(ybin, binLabel);
1130       }
1131 
1132       if (nameHistoLocalTheta.Contains("MB"))  // HistoLocalTheta DT
1133       {
1134         int wheel, station, sector;
1135 
1136         sscanf(nameHistoLocalTheta, "ResidualLocalTheta_W%dMB%1dS%d", &wheel, &station, &sector);
1137 
1138         if (station != 4) {
1139           Int_t nstation = station - 1;
1140           Int_t nwheel = wheel + 2;
1141 
1142           Double_t MeanTheta = unitsLocalTheta[i]->GetMean();
1143           Double_t ErrorTheta = unitsLocalTheta[i]->GetMeanError();
1144 
1145           Int_t xbin = sector + 14 * nstation + 14 * 4 * nwheel;
1146 
1147           snprintf(binLabel, sizeof(binLabel), "MB%d/%dS%d", wheel, station, sector);
1148 
1149           hprofLocalThetaDT->SetBinContent(xbin, MeanTheta);
1150           hprofLocalThetaDT->SetBinError(xbin, ErrorTheta);
1151           hprofLocalThetaDT->SetMarkerStyle(21);
1152           hprofLocalThetaDT->SetMarkerColor(kRed);
1153           hprofLocalThetaDT->GetXaxis()->SetBinLabel(xbin, binLabel);
1154 
1155           Int_t ybin = 2 + nwheel * 8 + nstation * 2;
1156           hprofLocalAngleDT->SetBinContent(sector, ybin, fabs(MeanTheta));
1157           snprintf(binLabel, sizeof(binLabel), "MB%d/%d_LocalTheta", wheel, station);
1158           hprofLocalAngleDT->GetYaxis()->SetBinLabel(ybin, binLabel);
1159           hprofLocalAngleRmsDT->SetBinContent(sector, ybin, ErrorTheta);
1160           hprofLocalAngleRmsDT->GetYaxis()->SetBinLabel(ybin, binLabel);
1161         }
1162       }
1163 
1164       if (nameHistoLocalPhi.Contains("MB"))  // HistoLocalPhi DT
1165       {
1166         int wheel, station, sector;
1167 
1168         sscanf(nameHistoLocalPhi, "ResidualLocalPhi_W%dMB%1dS%d", &wheel, &station, &sector);
1169 
1170         Int_t nstation = station - 1;
1171         Int_t nwheel = wheel + 2;
1172 
1173         Double_t MeanPhi = unitsLocalPhi[i]->GetMean();
1174         Double_t ErrorPhi = unitsLocalPhi[i]->GetMeanError();
1175 
1176         Int_t xbin = sector + 14 * nstation + 14 * 4 * nwheel;
1177 
1178         snprintf(binLabel, sizeof(binLabel), "MB%d/%dS%d", wheel, station, sector);
1179 
1180         hprofLocalPhiDT->SetBinContent(xbin, MeanPhi);
1181         hprofLocalPhiDT->SetBinError(xbin, ErrorPhi);
1182         hprofLocalPhiDT->SetMarkerStyle(21);
1183         hprofLocalPhiDT->SetMarkerColor(kRed);
1184         hprofLocalPhiDT->GetXaxis()->SetBinLabel(xbin, binLabel);
1185 
1186         Int_t ybin = 1 + nwheel * 8 + nstation * 2;
1187         hprofLocalAngleDT->SetBinContent(sector, ybin, fabs(MeanPhi));
1188         snprintf(binLabel, sizeof(binLabel), "MB%d/%d_LocalPhi", wheel, station);
1189         hprofLocalAngleDT->GetYaxis()->SetBinLabel(ybin, binLabel);
1190         hprofLocalAngleRmsDT->SetBinContent(sector, ybin, ErrorPhi);
1191         hprofLocalAngleRmsDT->GetYaxis()->SetBinLabel(ybin, binLabel);
1192       }
1193 
1194       if (nameHistoLocalPhi.Contains("ME"))  // HistoLocalPhi CSC
1195       {
1196         int station, ring, chamber;
1197 
1198         sscanf(nameHistoLocalPhi, "ResidualLocalPhi_ME%dR%1dC%d", &station, &ring, &chamber);
1199 
1200         Double_t MeanPhi = unitsLocalPhi[i]->GetMean();
1201         Double_t ErrorPhi = unitsLocalPhi[i]->GetMeanError();
1202 
1203         Int_t xbin = abs(station) * 2 + ring;
1204         if (abs(station) == 1)
1205           xbin = ring;
1206         if (station > 0)
1207           xbin = xbin + 9;
1208         else
1209           xbin = 10 - xbin;
1210 
1211         // To avoid holes in xAxis, I can't imagine right now a simpler way...
1212         if (xbin < 5)
1213           xbin = 18 * (((Int_t)(xbin / 3)) * 2 + (Int_t)(xbin / 2)) + chamber;
1214         else if (xbin < 6)
1215           xbin = 108 + chamber;
1216         else if (xbin < 14)
1217           xbin = 126 + (xbin - 6) * 36 + chamber;
1218         else if (xbin < 18)
1219           xbin = 414 + 18 * (((Int_t)(xbin - 13) / 3) * 2 + ((Int_t)(xbin - 13) / 2)) + chamber;
1220         else
1221           xbin = 522 + chamber;
1222 
1223         snprintf(binLabel, sizeof(binLabel), "ME%d/%dC%d", station, ring, chamber);
1224 
1225         hprofLocalPhiCSC->SetMarkerStyle(21);
1226         hprofLocalPhiCSC->SetMarkerColor(kRed);
1227         hprofLocalPhiCSC->SetBinContent(xbin, MeanPhi);
1228         hprofLocalPhiCSC->SetBinError(xbin, ErrorPhi);
1229         hprofLocalPhiCSC->GetXaxis()->SetBinLabel(xbin, binLabel);
1230 
1231         Int_t ybin = abs(station) * 2 + ring;
1232         if (abs(station) == 1)
1233           ybin = ring;
1234         if (station > 0)
1235           ybin = ybin + 9;
1236         else
1237           ybin = 10 - ybin;
1238         ybin = 2 * ybin - 1;
1239         hprofLocalAngleCSC->SetBinContent(chamber, ybin, fabs(MeanPhi));
1240         snprintf(binLabel, sizeof(binLabel), "ME%d/%d_LocalPhi", station, ring);
1241         hprofLocalAngleCSC->GetYaxis()->SetBinLabel(ybin, binLabel);
1242         hprofLocalAngleRmsCSC->SetBinContent(chamber, ybin, ErrorPhi);
1243         hprofLocalAngleRmsCSC->GetYaxis()->SetBinLabel(ybin, binLabel);
1244       }
1245 
1246       if (nameHistoLocalTheta.Contains("ME"))  // HistoLocalTheta CSC
1247       {
1248         int station, ring, chamber;
1249 
1250         sscanf(nameHistoLocalTheta, "ResidualLocalTheta_ME%dR%1dC%d", &station, &ring, &chamber);
1251 
1252         Double_t MeanTheta = unitsLocalTheta[i]->GetMean();
1253         Double_t ErrorTheta = unitsLocalTheta[i]->GetMeanError();
1254 
1255         Int_t xbin = abs(station) * 2 + ring;
1256         if (abs(station) == 1)
1257           xbin = ring;
1258         if (station > 0)
1259           xbin = xbin + 9;
1260         else
1261           xbin = 10 - xbin;
1262 
1263         // To avoid holes in xAxis, I can't imagine right now a simpler way...
1264         if (xbin < 5)
1265           xbin = 18 * (((Int_t)(xbin / 3)) * 2 + (Int_t)(xbin / 2)) + chamber;
1266         else if (xbin < 6)
1267           xbin = 108 + chamber;
1268         else if (xbin < 14)
1269           xbin = 126 + (xbin - 6) * 36 + chamber;
1270         else if (xbin < 18)
1271           xbin = 414 + 18 * (((Int_t)(xbin - 13) / 3) * 2 + ((Int_t)(xbin - 13) / 2)) + chamber;
1272         else
1273           xbin = 522 + chamber;
1274 
1275         snprintf(binLabel, sizeof(binLabel), "ME%d/%dC%d", station, ring, chamber);
1276 
1277         hprofLocalThetaCSC->SetMarkerStyle(21);
1278         hprofLocalThetaCSC->SetMarkerColor(kRed);
1279         hprofLocalThetaCSC->SetBinContent(xbin, MeanTheta);
1280         hprofLocalThetaCSC->SetBinError(xbin, ErrorTheta);
1281         hprofLocalThetaCSC->GetXaxis()->SetBinLabel(xbin, binLabel);
1282 
1283         Int_t ybin = abs(station) * 2 + ring;
1284         if (abs(station) == 1)
1285           ybin = ring;
1286         if (station > 0)
1287           ybin = ybin + 9;
1288         else
1289           ybin = 10 - ybin;
1290         ybin = 2 * ybin;
1291         hprofLocalAngleCSC->SetBinContent(chamber, ybin, fabs(MeanTheta));
1292         snprintf(binLabel, sizeof(binLabel), "ME%d/%d_LocalTheta", station, ring);
1293         hprofLocalAngleCSC->GetYaxis()->SetBinLabel(ybin, binLabel);
1294         hprofLocalAngleRmsCSC->SetBinContent(chamber, ybin, ErrorTheta);
1295         hprofLocalAngleRmsCSC->GetYaxis()->SetBinLabel(ybin, binLabel);
1296       }
1297 
1298       if (nameHistoLocalY.Contains("MB"))  // HistoLocalY DT
1299       {
1300         int wheel, station, sector;
1301 
1302         sscanf(nameHistoLocalY, "ResidualLocalY_W%dMB%1dS%d", &wheel, &station, &sector);
1303 
1304         if (station != 4) {
1305           Int_t nstation = station - 1;
1306           Int_t nwheel = wheel + 2;
1307 
1308           Double_t MeanZ = unitsLocalY[i]->GetMean();
1309           Double_t ErrorZ = unitsLocalY[i]->GetMeanError();
1310 
1311           Int_t xbin = sector + 14 * nstation + 14 * 4 * nwheel;
1312 
1313           snprintf(binLabel, sizeof(binLabel), "MB%d/%dS%d", wheel, station, sector);
1314 
1315           hprofLocalYDT->SetMarkerStyle(21);
1316           hprofLocalYDT->SetMarkerColor(kRed);
1317           hprofLocalYDT->SetBinContent(xbin, MeanZ);
1318           hprofLocalYDT->SetBinError(xbin, ErrorZ);
1319           hprofLocalYDT->GetXaxis()->SetBinLabel(xbin, binLabel);
1320 
1321           Int_t ybin = 2 + nwheel * 8 + nstation * 2;
1322           hprofLocalPositionDT->SetBinContent(sector, ybin, fabs(MeanZ));
1323           snprintf(binLabel, sizeof(binLabel), "MB%d/%d_LocalY", wheel, station);
1324           hprofLocalPositionDT->GetYaxis()->SetBinLabel(ybin, binLabel);
1325           hprofLocalPositionRmsDT->SetBinContent(sector, ybin, ErrorZ);
1326           hprofLocalPositionRmsDT->GetYaxis()->SetBinLabel(ybin, binLabel);
1327         }
1328       }
1329 
1330       if (nameHistoLocalY.Contains("ME"))  // HistoLocalY CSC
1331       {
1332         int station, ring, chamber;
1333 
1334         sscanf(nameHistoLocalY, "ResidualLocalY_ME%dR%1dC%d", &station, &ring, &chamber);
1335 
1336         Double_t MeanR = unitsLocalY[i]->GetMean();
1337         Double_t ErrorR = unitsLocalY[i]->GetMeanError();
1338 
1339         Int_t xbin = abs(station) * 2 + ring;
1340         if (abs(station) == 1)
1341           xbin = ring;
1342         if (station > 0)
1343           xbin = xbin + 9;
1344         else
1345           xbin = 10 - xbin;
1346 
1347         // To avoid holes in xAxis, I can't imagine right now a simpler way...
1348         if (xbin < 5)
1349           xbin = 18 * (((Int_t)(xbin / 3)) * 2 + (Int_t)(xbin / 2)) + chamber;
1350         else if (xbin < 6)
1351           xbin = 108 + chamber;
1352         else if (xbin < 14)
1353           xbin = 126 + (xbin - 6) * 36 + chamber;
1354         else if (xbin < 18)
1355           xbin = 414 + 18 * (((Int_t)(xbin - 13) / 3) * 2 + ((Int_t)(xbin - 13) / 2)) + chamber;
1356         else
1357           xbin = 522 + chamber;
1358 
1359         snprintf(binLabel, sizeof(binLabel), "ME%d/%dC%d", station, ring, chamber);
1360 
1361         hprofLocalYCSC->SetMarkerStyle(21);
1362         hprofLocalYCSC->SetMarkerColor(kRed);
1363         hprofLocalYCSC->SetBinContent(xbin, MeanR);
1364         hprofLocalYCSC->SetBinError(xbin, ErrorR);
1365         hprofLocalYCSC->GetXaxis()->SetBinLabel(xbin, binLabel);
1366 
1367         Int_t ybin = abs(station) * 2 + ring;
1368         if (abs(station) == 1)
1369           ybin = ring;
1370         if (station > 0)
1371           ybin = ybin + 9;
1372         else
1373           ybin = 10 - ybin;
1374         ybin = 2 * ybin;
1375         hprofLocalPositionCSC->SetBinContent(chamber, ybin, fabs(MeanR));
1376         snprintf(binLabel, sizeof(binLabel), "ME%d/%d_LocalY", station, ring);
1377         hprofLocalPositionCSC->GetYaxis()->SetBinLabel(ybin, binLabel);
1378         hprofLocalPositionRmsCSC->SetBinContent(chamber, ybin, ErrorR);
1379         hprofLocalPositionRmsCSC->GetYaxis()->SetBinLabel(ybin, binLabel);
1380       }
1381 
1382       if (nameHistoGlobalRPhi.Contains("MB"))  // HistoGlobalRPhi DT
1383       {
1384         int wheel, station, sector;
1385 
1386         sscanf(nameHistoGlobalRPhi, "ResidualGlobalRPhi_W%dMB%1dS%d", &wheel, &station, &sector);
1387 
1388         Int_t nstation = station - 1;
1389         Int_t nwheel = wheel + 2;
1390 
1391         Double_t MeanRPhi = unitsGlobalRPhi[i]->GetMean();
1392         Double_t ErrorRPhi = unitsGlobalRPhi[i]->GetMeanError();
1393 
1394         Int_t xbin = sector + 14 * nstation + 14 * 4 * nwheel;
1395 
1396         snprintf(binLabel, sizeof(binLabel), "MB%d/%dS%d", wheel, station, sector);
1397 
1398         hprofGlobalRPhiDT->SetMarkerStyle(21);
1399         hprofGlobalRPhiDT->SetMarkerColor(kRed);
1400         hprofGlobalRPhiDT->SetBinContent(xbin, MeanRPhi);
1401         hprofGlobalRPhiDT->SetBinError(xbin, ErrorRPhi);
1402         hprofGlobalRPhiDT->GetXaxis()->SetBinLabel(xbin, binLabel);
1403 
1404         Int_t ybin = 1 + nwheel * 8 + nstation * 2;
1405         hprofGlobalPositionDT->SetBinContent(sector, ybin, fabs(MeanRPhi));
1406         snprintf(binLabel, sizeof(binLabel), "MB%d/%d_GlobalRPhi", wheel, station);
1407         hprofGlobalPositionDT->GetYaxis()->SetBinLabel(ybin, binLabel);
1408         hprofGlobalPositionRmsDT->SetBinContent(sector, ybin, ErrorRPhi);
1409         hprofGlobalPositionRmsDT->GetYaxis()->SetBinLabel(ybin, binLabel);
1410       }
1411 
1412       if (nameHistoGlobalRPhi.Contains("ME"))  // HistoGlobalRPhi CSC
1413       {
1414         int station, ring, chamber;
1415 
1416         sscanf(nameHistoGlobalRPhi, "ResidualGlobalRPhi_ME%dR%1dC%d", &station, &ring, &chamber);
1417 
1418         Double_t MeanRPhi = unitsGlobalRPhi[i]->GetMean();
1419         Double_t ErrorRPhi = unitsGlobalRPhi[i]->GetMeanError();
1420 
1421         Int_t xbin = abs(station) * 2 + ring;
1422         if (abs(station) == 1)
1423           xbin = ring;
1424         if (station > 0)
1425           xbin = xbin + 9;
1426         else
1427           xbin = 10 - xbin;
1428 
1429         // To avoid holes in xAxis, I can't imagine right now a simpler way...
1430         if (xbin < 5)
1431           xbin = 18 * (((Int_t)(xbin / 3)) * 2 + (Int_t)(xbin / 2)) + chamber;
1432         else if (xbin < 6)
1433           xbin = 108 + chamber;
1434         else if (xbin < 14)
1435           xbin = 126 + (xbin - 6) * 36 + chamber;
1436         else if (xbin < 18)
1437           xbin = 414 + 18 * (((Int_t)(xbin - 13) / 3) * 2 + ((Int_t)(xbin - 13) / 2)) + chamber;
1438         else
1439           xbin = 522 + chamber;
1440 
1441         snprintf(binLabel, sizeof(binLabel), "ME%d/%dC%d", station, ring, chamber);
1442 
1443         hprofGlobalRPhiCSC->SetMarkerStyle(21);
1444         hprofGlobalRPhiCSC->SetMarkerColor(kRed);
1445         hprofGlobalRPhiCSC->SetBinContent(xbin, MeanRPhi);
1446         hprofGlobalRPhiCSC->SetBinError(xbin, ErrorRPhi);
1447         hprofGlobalRPhiCSC->GetXaxis()->SetBinLabel(xbin, binLabel);
1448 
1449         Int_t ybin = abs(station) * 2 + ring;
1450         if (abs(station) == 1)
1451           ybin = ring;
1452         if (station > 0)
1453           ybin = ybin + 9;
1454         else
1455           ybin = 10 - ybin;
1456         ybin = 2 * ybin - 1;
1457         hprofGlobalPositionCSC->SetBinContent(chamber, ybin, fabs(MeanRPhi));
1458         snprintf(binLabel, sizeof(binLabel), "ME%d/%d_GlobalRPhi", station, ring);
1459         hprofGlobalPositionCSC->GetYaxis()->SetBinLabel(ybin, binLabel);
1460         hprofGlobalPositionRmsCSC->SetBinContent(chamber, ybin, ErrorRPhi);
1461         hprofGlobalPositionRmsCSC->GetYaxis()->SetBinLabel(ybin, binLabel);
1462       }
1463 
1464       if (nameHistoGlobalTheta.Contains("MB"))  // HistoGlobalRTheta DT
1465       {
1466         int wheel, station, sector;
1467 
1468         sscanf(nameHistoGlobalTheta, "ResidualGlobalTheta_W%dMB%1dS%d", &wheel, &station, &sector);
1469 
1470         if (station != 4) {
1471           Int_t nstation = station - 1;
1472           Int_t nwheel = wheel + 2;
1473 
1474           Double_t MeanTheta = unitsGlobalTheta[i]->GetMean();
1475           Double_t ErrorTheta = unitsGlobalTheta[i]->GetMeanError();
1476 
1477           Int_t xbin = sector + 14 * nstation + 14 * 4 * nwheel;
1478 
1479           snprintf(binLabel, sizeof(binLabel), "MB%d/%dS%d", wheel, station, sector);
1480 
1481           hprofGlobalThetaDT->SetBinContent(xbin, MeanTheta);
1482           hprofGlobalThetaDT->SetBinError(xbin, ErrorTheta);
1483           hprofGlobalThetaDT->SetMarkerStyle(21);
1484           hprofGlobalThetaDT->SetMarkerColor(kRed);
1485           hprofGlobalThetaDT->GetXaxis()->SetBinLabel(xbin, binLabel);
1486 
1487           Int_t ybin = 2 + nwheel * 8 + nstation * 2;
1488           hprofGlobalAngleDT->SetBinContent(sector, ybin, fabs(MeanTheta));
1489           snprintf(binLabel, sizeof(binLabel), "MB%d/%d_GlobalTheta", wheel, station);
1490           hprofGlobalAngleDT->GetYaxis()->SetBinLabel(ybin, binLabel);
1491           hprofGlobalAngleRmsDT->SetBinContent(sector, ybin, ErrorTheta);
1492           hprofGlobalAngleRmsDT->GetYaxis()->SetBinLabel(ybin, binLabel);
1493         }
1494       }
1495 
1496       if (nameHistoGlobalPhi.Contains("MB"))  // HistoGlobalPhi DT
1497       {
1498         int wheel, station, sector;
1499 
1500         sscanf(nameHistoGlobalPhi, "ResidualGlobalPhi_W%dMB%1dS%d", &wheel, &station, &sector);
1501 
1502         Int_t nstation = station - 1;
1503         Int_t nwheel = wheel + 2;
1504 
1505         Double_t MeanPhi = unitsGlobalPhi[i]->GetMean();
1506         Double_t ErrorPhi = unitsGlobalPhi[i]->GetMeanError();
1507 
1508         Int_t xbin = sector + 14 * nstation + 14 * 4 * nwheel;
1509 
1510         snprintf(binLabel, sizeof(binLabel), "MB%d/%dS%d", wheel, station, sector);
1511 
1512         hprofGlobalPhiDT->SetBinContent(xbin, MeanPhi);
1513         hprofGlobalPhiDT->SetBinError(xbin, ErrorPhi);
1514         hprofGlobalPhiDT->SetMarkerStyle(21);
1515         hprofGlobalPhiDT->SetMarkerColor(kRed);
1516         hprofGlobalPhiDT->GetXaxis()->SetBinLabel(xbin, binLabel);
1517 
1518         Int_t ybin = 1 + nwheel * 8 + nstation * 2;
1519         hprofGlobalAngleDT->SetBinContent(sector, ybin, fabs(MeanPhi));
1520         snprintf(binLabel, sizeof(binLabel), "MB%d/%d_GlobalPhi", wheel, station);
1521         hprofGlobalAngleDT->GetYaxis()->SetBinLabel(ybin, binLabel);
1522         hprofGlobalAngleRmsDT->SetBinContent(sector, ybin, ErrorPhi);
1523         hprofGlobalAngleRmsDT->GetYaxis()->SetBinLabel(ybin, binLabel);
1524       }
1525 
1526       if (nameHistoGlobalPhi.Contains("ME"))  // HistoGlobalPhi CSC
1527       {
1528         int station, ring, chamber;
1529 
1530         sscanf(nameHistoGlobalPhi, "ResidualGlobalPhi_ME%dR%1dC%d", &station, &ring, &chamber);
1531 
1532         Double_t MeanPhi = unitsGlobalPhi[i]->GetMean();
1533         Double_t ErrorPhi = unitsGlobalPhi[i]->GetMeanError();
1534 
1535         Int_t xbin = abs(station) * 2 + ring;
1536         if (abs(station) == 1)
1537           xbin = ring;
1538         if (station > 0)
1539           xbin = xbin + 9;
1540         else
1541           xbin = 10 - xbin;
1542 
1543         // To avoid holes in xAxis, I can't imagine right now a simpler way...
1544         if (xbin < 5)
1545           xbin = 18 * (((Int_t)(xbin / 3)) * 2 + (Int_t)(xbin / 2)) + chamber;
1546         else if (xbin < 6)
1547           xbin = 108 + chamber;
1548         else if (xbin < 14)
1549           xbin = 126 + (xbin - 6) * 36 + chamber;
1550         else if (xbin < 18)
1551           xbin = 414 + 18 * (((Int_t)(xbin - 13) / 3) * 2 + ((Int_t)(xbin - 13) / 2)) + chamber;
1552         else
1553           xbin = 522 + chamber;
1554 
1555         snprintf(binLabel, sizeof(binLabel), "ME%d/%dC%d", station, ring, chamber);
1556 
1557         hprofGlobalPhiCSC->SetMarkerStyle(21);
1558         hprofGlobalPhiCSC->SetMarkerColor(kRed);
1559         hprofGlobalPhiCSC->SetBinContent(xbin, MeanPhi);
1560         hprofGlobalPhiCSC->SetBinError(xbin, ErrorPhi);
1561         hprofGlobalPhiCSC->GetXaxis()->SetBinLabel(xbin, binLabel);
1562 
1563         Int_t ybin = abs(station) * 2 + ring;
1564         if (abs(station) == 1)
1565           ybin = ring;
1566         if (station > 0)
1567           ybin = ybin + 9;
1568         else
1569           ybin = 10 - ybin;
1570         ybin = 2 * ybin - 1;
1571         hprofGlobalAngleCSC->SetBinContent(chamber, ybin, fabs(MeanPhi));
1572         snprintf(binLabel, sizeof(binLabel), "ME%d/%d_GlobalPhi", station, ring);
1573         hprofGlobalAngleCSC->GetYaxis()->SetBinLabel(ybin, binLabel);
1574         hprofGlobalAngleRmsCSC->SetBinContent(chamber, ybin, ErrorPhi);
1575         hprofGlobalAngleRmsCSC->GetYaxis()->SetBinLabel(ybin, binLabel);
1576       }
1577 
1578       if (nameHistoGlobalTheta.Contains("ME"))  // HistoGlobalTheta CSC
1579       {
1580         int station, ring, chamber;
1581 
1582         sscanf(nameHistoGlobalTheta, "ResidualGlobalTheta_ME%dR%1dC%d", &station, &ring, &chamber);
1583 
1584         Double_t MeanTheta = unitsGlobalTheta[i]->GetMean();
1585         Double_t ErrorTheta = unitsGlobalTheta[i]->GetMeanError();
1586 
1587         Int_t xbin = abs(station) * 2 + ring;
1588         if (abs(station) == 1)
1589           xbin = ring;
1590         if (station > 0)
1591           xbin = xbin + 9;
1592         else
1593           xbin = 10 - xbin;
1594 
1595         // To avoid holes in xAxis, I can't imagine right now a simpler way...
1596         if (xbin < 5)
1597           xbin = 18 * (((Int_t)(xbin / 3)) * 2 + (Int_t)(xbin / 2)) + chamber;
1598         else if (xbin < 6)
1599           xbin = 108 + chamber;
1600         else if (xbin < 14)
1601           xbin = 126 + (xbin - 6) * 36 + chamber;
1602         else if (xbin < 18)
1603           xbin = 414 + 18 * (((Int_t)(xbin - 13) / 3) * 2 + ((Int_t)(xbin - 13) / 2)) + chamber;
1604         else
1605           xbin = 522 + chamber;
1606 
1607         snprintf(binLabel, sizeof(binLabel), "ME%d/%dC%d", station, ring, chamber);
1608 
1609         hprofGlobalThetaCSC->SetMarkerStyle(21);
1610         hprofGlobalThetaCSC->SetMarkerColor(kRed);
1611         hprofGlobalThetaCSC->SetBinContent(xbin, MeanTheta);
1612         hprofGlobalThetaCSC->SetBinError(xbin, ErrorTheta);
1613         hprofGlobalThetaCSC->GetXaxis()->SetBinLabel(xbin, binLabel);
1614 
1615         Int_t ybin = abs(station) * 2 + ring;
1616         if (abs(station) == 1)
1617           ybin = ring;
1618         if (station > 0)
1619           ybin = ybin + 9;
1620         else
1621           ybin = 10 - ybin;
1622         ybin = 2 * ybin;
1623         hprofGlobalAngleCSC->SetBinContent(chamber, ybin, fabs(MeanTheta));
1624         snprintf(binLabel, sizeof(binLabel), "ME%d/%d_GlobalTheta", station, ring);
1625         hprofGlobalAngleCSC->GetYaxis()->SetBinLabel(ybin, binLabel);
1626         hprofGlobalAngleRmsCSC->SetBinContent(chamber, ybin, ErrorTheta);
1627         hprofGlobalAngleRmsCSC->GetYaxis()->SetBinLabel(ybin, binLabel);
1628       }
1629 
1630       if (nameHistoGlobalRZ.Contains("MB"))  // HistoGlobalZ DT
1631       {
1632         int wheel, station, sector;
1633 
1634         sscanf(nameHistoGlobalRZ, "ResidualGlobalZ_W%dMB%1dS%d", &wheel, &station, &sector);
1635 
1636         if (station != 4) {
1637           Int_t nstation = station - 1;
1638           Int_t nwheel = wheel + 2;
1639 
1640           Double_t MeanZ = unitsGlobalRZ[i]->GetMean();
1641           Double_t ErrorZ = unitsGlobalRZ[i]->GetMeanError();
1642 
1643           Int_t xbin = sector + 14 * nstation + 14 * 4 * nwheel;
1644 
1645           snprintf(binLabel, sizeof(binLabel), "MB%d/%dS%d", wheel, station, sector);
1646 
1647           hprofGlobalZDT->SetMarkerStyle(21);
1648           hprofGlobalZDT->SetMarkerColor(kRed);
1649 
1650           hprofGlobalZDT->SetBinContent(xbin, MeanZ);
1651           hprofGlobalZDT->SetBinError(xbin, ErrorZ);
1652           hprofGlobalZDT->GetXaxis()->SetBinLabel(xbin, binLabel);
1653 
1654           Int_t ybin = 2 + nwheel * 8 + nstation * 2;
1655           hprofGlobalPositionDT->SetBinContent(sector, ybin, fabs(MeanZ));
1656           snprintf(binLabel, sizeof(binLabel), "MB%d/%d_GlobalZ", wheel, station);
1657           hprofGlobalPositionDT->GetYaxis()->SetBinLabel(ybin, binLabel);
1658           hprofGlobalPositionRmsDT->SetBinContent(sector, ybin, ErrorZ);
1659           hprofGlobalPositionRmsDT->GetYaxis()->SetBinLabel(ybin, binLabel);
1660         }
1661       }
1662 
1663       if (nameHistoGlobalRZ.Contains("ME"))  // HistoGlobalR CSC
1664       {
1665         int station, ring, chamber;
1666 
1667         sscanf(nameHistoGlobalRZ, "ResidualGlobalR_ME%dR%1dC%d", &station, &ring, &chamber);
1668 
1669         Double_t MeanR = unitsGlobalRZ[i]->GetMean();
1670         Double_t ErrorR = unitsGlobalRZ[i]->GetMeanError();
1671 
1672         Int_t xbin = abs(station) * 2 + ring;
1673         if (abs(station) == 1)
1674           xbin = ring;
1675         if (station > 0)
1676           xbin = xbin + 9;
1677         else
1678           xbin = 10 - xbin;
1679 
1680         // To avoid holes in xAxis, I can't imagine right now a simpler way...
1681         if (xbin < 5)
1682           xbin = 18 * (((Int_t)(xbin / 3)) * 2 + (Int_t)(xbin / 2)) + chamber;
1683         else if (xbin < 6)
1684           xbin = 108 + chamber;
1685         else if (xbin < 14)
1686           xbin = 126 + (xbin - 6) * 36 + chamber;
1687         else if (xbin < 18)
1688           xbin = 414 + 18 * (((Int_t)(xbin - 13) / 3) * 2 + ((Int_t)(xbin - 13) / 2)) + chamber;
1689         else
1690           xbin = 522 + chamber;
1691 
1692         snprintf(binLabel, sizeof(binLabel), "ME%d/%dC%d", station, ring, chamber);
1693 
1694         hprofGlobalRCSC->SetMarkerStyle(21);
1695         hprofGlobalRCSC->SetMarkerColor(kRed);
1696         hprofGlobalRCSC->SetBinContent(xbin, MeanR);
1697         hprofGlobalRCSC->SetBinError(xbin, ErrorR);
1698         hprofGlobalRCSC->GetXaxis()->SetBinLabel(xbin, binLabel);
1699 
1700         Int_t ybin = abs(station) * 2 + ring;
1701         if (abs(station) == 1)
1702           ybin = ring;
1703         if (station > 0)
1704           ybin = ybin + 9;
1705         else
1706           ybin = 10 - ybin;
1707         ybin = 2 * ybin;
1708         hprofGlobalPositionCSC->SetBinContent(chamber, ybin, fabs(MeanR));
1709         snprintf(binLabel, sizeof(binLabel), "ME%d/%d_GlobalR", station, ring);
1710         hprofGlobalPositionCSC->GetYaxis()->SetBinLabel(ybin, binLabel);
1711         hprofGlobalPositionRmsCSC->SetBinContent(chamber, ybin, ErrorR);
1712         hprofGlobalPositionRmsCSC->GetYaxis()->SetBinLabel(ybin, binLabel);
1713       }
1714 
1715     }  // for in histos
1716 
1717   }  // doResPlots
1718 }
1719 
1720 void MuonAlignmentAnalyzer::analyze(const edm::Event &event, const edm::EventSetup &eventSetup) {
1721   GlobalVector p1, p2;
1722   std::vector<double> simPar[4];  //pt,eta,phi,charge
1723 
1724   // ######### if data= MC, do Simulation Plots#####
1725   if (theDataType == "SimData") {
1726     double simEta = 0;
1727     double simPt = 0;
1728     double simPhi = 0;
1729     int i = 0, ie = 0, ib = 0;
1730 
1731     // Get the SimTrack collection from the event
1732     edm::Handle<edm::SimTrackContainer> simTracks;
1733     event.getByLabel("g4SimHits", simTracks);
1734 
1735     edm::SimTrackContainer::const_iterator simTrack;
1736 
1737     for (simTrack = simTracks->begin(); simTrack != simTracks->end(); ++simTrack) {
1738       if (abs((*simTrack).type()) == 13) {
1739         i++;
1740         simPt = (*simTrack).momentum().Pt();
1741         simEta = (*simTrack).momentum().eta();
1742         simPhi = (*simTrack).momentum().phi();
1743         numberOfSimTracks++;
1744         hSimPT->Fill(simPt);
1745         if (fabs(simEta) < 1.04) {
1746           hSimPT_Barrel->Fill(simPt);
1747           ib++;
1748         } else {
1749           hSimPT_Endcap->Fill(simPt);
1750           ie++;
1751         }
1752         hSimPTvsEta->Fill(simEta, simPt);
1753         hSimPTvsPhi->Fill(simPhi, simPt);
1754         hSimPhivsEta->Fill(simEta, simPhi);
1755 
1756         simPar[0].push_back(simPt);
1757         simPar[1].push_back(simEta);
1758         simPar[2].push_back(simPhi);
1759         simPar[3].push_back((*simTrack).charge());
1760 
1761         //  Save the muon pair
1762         if (i == 1)
1763           p1 = GlobalVector((*simTrack).momentum().x(), (*simTrack).momentum().y(), (*simTrack).momentum().z());
1764         if (i == 2)
1765           p2 = GlobalVector((*simTrack).momentum().x(), (*simTrack).momentum().y(), (*simTrack).momentum().z());
1766       }
1767     }
1768     hSimNmuons->Fill(i);
1769     hSimNmuons_Barrel->Fill(ib);
1770     hSimNmuons_Endcap->Fill(ie);
1771 
1772     if (i > 1) {  // Take 2 first muons :-(
1773       TLorentzVector mu1(p1.x(), p1.y(), p1.z(), p1.mag());
1774       TLorentzVector mu2(p2.x(), p2.y(), p2.z(), p2.mag());
1775       TLorentzVector pair = mu1 + mu2;
1776       double Minv = pair.M();
1777       hSimInvM->Fill(Minv);
1778       if (fabs(p1.eta()) < 1.04 && fabs(p2.eta()) < 1.04)
1779         hSimInvM_Barrel->Fill(Minv);
1780       else if (fabs(p1.eta()) >= 1.04 && fabs(p2.eta()) >= 1.04)
1781         hSimInvM_Endcap->Fill(Minv);
1782       else
1783         hSimInvM_Overlap->Fill(Minv);
1784     }
1785 
1786   }  //simData
1787 
1788   // ############ Stand Alone Muon plots ###############
1789   if (doSAplots) {
1790     double SArecPt = 0.;
1791     double SAeta = 0.;
1792     double SAphi = 0.;
1793     int i = 0, ie = 0, ib = 0;
1794     double ich = 0;
1795 
1796     // Get the RecTrack collection from the event
1797     edm::Handle<reco::TrackCollection> staTracks;
1798     event.getByLabel(theSTAMuonTag, staTracks);
1799     numberOfSARecTracks += staTracks->size();
1800 
1801     reco::TrackCollection::const_iterator staTrack;
1802 
1803     for (staTrack = staTracks->begin(); staTrack != staTracks->end(); ++staTrack) {
1804       i++;
1805 
1806       SArecPt = (*staTrack).pt();
1807       SAeta = (*staTrack).eta();
1808       SAphi = (*staTrack).phi();
1809       ich = (*staTrack).charge();
1810 
1811       hSAPTRec->Fill(SArecPt);
1812       hSAPhivsEta->Fill(SAeta, SAphi);
1813       hSAChi2->Fill((*staTrack).chi2());
1814       hSANhits->Fill((*staTrack).numberOfValidHits());
1815       if (fabs(SAeta) < 1.04) {
1816         hSAPTRec_Barrel->Fill(SArecPt);
1817         hSAChi2_Barrel->Fill((*staTrack).chi2());
1818         hSANhits_Barrel->Fill((*staTrack).numberOfValidHits());
1819         ib++;
1820       } else {
1821         hSAPTRec_Endcap->Fill(SArecPt);
1822         hSAChi2_Endcap->Fill((*staTrack).chi2());
1823         hSANhits_Endcap->Fill((*staTrack).numberOfValidHits());
1824         ie++;
1825       }
1826 
1827       // save the muon pair
1828       if (i == 1)
1829         p1 = GlobalVector((*staTrack).momentum().x(), (*staTrack).momentum().y(), (*staTrack).momentum().z());
1830       if (i == 2)
1831         p2 = GlobalVector((*staTrack).momentum().x(), (*staTrack).momentum().y(), (*staTrack).momentum().z());
1832 
1833       if (SArecPt && theDataType == "SimData") {
1834         double candDeltaR = -999.0, dR;
1835         int iCand = 0;
1836         if (!simPar[0].empty()) {
1837           for (unsigned int iSim = 0; iSim < simPar[0].size(); iSim++) {
1838             dR = deltaR(SAeta, SAphi, simPar[1][iSim], simPar[2][iSim]);
1839             if (candDeltaR < 0 || dR < candDeltaR) {
1840               candDeltaR = dR;
1841               iCand = iSim;
1842             }
1843           }
1844         }
1845 
1846         double simPt = simPar[0][iCand];
1847         hSAPTres->Fill((SArecPt - simPt) / simPt);
1848         if (fabs(SAeta) < 1.04)
1849           hSAPTres_Barrel->Fill((SArecPt - simPt) / simPt);
1850         else
1851           hSAPTres_Endcap->Fill((SArecPt - simPt) / simPt);
1852 
1853         hSAPTDiff->Fill(SArecPt - simPt);
1854 
1855         hSAPTDiffvsEta->Fill(SAeta, SArecPt - simPt);
1856         hSAPTDiffvsPhi->Fill(SAphi, SArecPt - simPt);
1857         double ptInvRes = (ich / SArecPt - simPar[3][iCand] / simPt) / (simPar[3][iCand] / simPt);
1858         hSAinvPTres->Fill(ptInvRes);
1859 
1860         hSAinvPTvsEta->Fill(SAeta, ptInvRes);
1861         hSAinvPTvsPhi->Fill(SAphi, ptInvRes);
1862         hSAinvPTvsNhits->Fill((*staTrack).numberOfValidHits(), ptInvRes);
1863       }
1864 
1865       hSAPTvsEta->Fill(SAeta, SArecPt);
1866       hSAPTvsPhi->Fill(SAphi, SArecPt);
1867     }
1868 
1869     hSANmuons->Fill(i);
1870     hSANmuons_Barrel->Fill(ib);
1871     hSANmuons_Endcap->Fill(ie);
1872 
1873     if (i > 1) {  // Take 2 first muons :-(
1874       TLorentzVector mu1(p1.x(), p1.y(), p1.z(), p1.mag());
1875       TLorentzVector mu2(p2.x(), p2.y(), p2.z(), p2.mag());
1876       TLorentzVector pair = mu1 + mu2;
1877       double Minv = pair.M();
1878       hSAInvM->Fill(Minv);
1879       if (fabs(p1.eta()) < 1.04 && fabs(p2.eta()) < 1.04)
1880         hSAInvM_Barrel->Fill(Minv);
1881       else if (fabs(p1.eta()) >= 1.04 && fabs(p2.eta()) >= 1.04)
1882         hSAInvM_Endcap->Fill(Minv);
1883       else
1884         hSAInvM_Overlap->Fill(Minv);
1885     }  // 2 first muons
1886 
1887   }  //end doSAplots
1888 
1889   // ############### Global Muons plots ##########
1890 
1891   if (doGBplots) {
1892     // Get the RecTrack collection from the event
1893     edm::Handle<reco::TrackCollection> glbTracks;
1894     event.getByLabel(theGLBMuonTag, glbTracks);
1895     numberOfGBRecTracks += glbTracks->size();
1896 
1897     double GBrecPt = 0;
1898     double GBeta = 0;
1899     double GBphi = 0;
1900     double ich = 0;
1901     int i = 0, ie = 0, ib = 0;
1902 
1903     reco::TrackCollection::const_iterator glbTrack;
1904 
1905     for (glbTrack = glbTracks->begin(); glbTrack != glbTracks->end(); ++glbTrack) {
1906       i++;
1907 
1908       GBrecPt = (*glbTrack).pt();
1909       GBeta = (*glbTrack).eta();
1910       GBphi = (*glbTrack).phi();
1911       ich = (*glbTrack).charge();
1912 
1913       hGBPTRec->Fill(GBrecPt);
1914       hGBPhivsEta->Fill(GBeta, GBphi);
1915       hGBChi2->Fill((*glbTrack).chi2());
1916       hGBNhits->Fill((*glbTrack).numberOfValidHits());
1917       if (fabs(GBeta) < 1.04) {
1918         hGBPTRec_Barrel->Fill(GBrecPt);
1919         hGBChi2_Barrel->Fill((*glbTrack).chi2());
1920         hGBNhits_Barrel->Fill((*glbTrack).numberOfValidHits());
1921         ib++;
1922       } else {
1923         hGBPTRec_Endcap->Fill(GBrecPt);
1924         hGBChi2_Endcap->Fill((*glbTrack).chi2());
1925         hGBNhits_Endcap->Fill((*glbTrack).numberOfValidHits());
1926         ie++;
1927       }
1928 
1929       // save the muon pair
1930       if (i == 1)
1931         p1 = GlobalVector((*glbTrack).momentum().x(), (*glbTrack).momentum().y(), (*glbTrack).momentum().z());
1932       if (i == 2)
1933         p2 = GlobalVector((*glbTrack).momentum().x(), (*glbTrack).momentum().y(), (*glbTrack).momentum().z());
1934 
1935       if (GBrecPt && theDataType == "SimData") {
1936         double candDeltaR = -999.0, dR;
1937         int iCand = 0;
1938         if (!simPar[0].empty()) {
1939           for (unsigned int iSim = 0; iSim < simPar[0].size(); iSim++) {
1940             dR = deltaR(GBeta, GBphi, simPar[1][iSim], simPar[2][iSim]);
1941             if (candDeltaR < 0 || dR < candDeltaR) {
1942               candDeltaR = dR;
1943               iCand = iSim;
1944             }
1945           }
1946         }
1947 
1948         double simPt = simPar[0][iCand];
1949 
1950         hGBPTres->Fill((GBrecPt - simPt) / simPt);
1951         if (fabs(GBeta) < 1.04)
1952           hGBPTres_Barrel->Fill((GBrecPt - simPt) / simPt);
1953         else
1954           hGBPTres_Endcap->Fill((GBrecPt - simPt) / simPt);
1955 
1956         hGBPTDiff->Fill(GBrecPt - simPt);
1957 
1958         hGBPTDiffvsEta->Fill(GBeta, GBrecPt - simPt);
1959         hGBPTDiffvsPhi->Fill(GBphi, GBrecPt - simPt);
1960 
1961         double ptInvRes = (ich / GBrecPt - simPar[3][iCand] / simPt) / (simPar[3][iCand] / simPt);
1962         hGBinvPTres->Fill(ptInvRes);
1963 
1964         hGBinvPTvsEta->Fill(GBeta, ptInvRes);
1965         hGBinvPTvsPhi->Fill(GBphi, ptInvRes);
1966         hGBinvPTvsNhits->Fill((*glbTrack).numberOfValidHits(), ptInvRes);
1967       }
1968 
1969       hGBPTvsEta->Fill(GBeta, GBrecPt);
1970       hGBPTvsPhi->Fill(GBphi, GBrecPt);
1971     }
1972 
1973     hGBNmuons->Fill(i);
1974     hGBNmuons_Barrel->Fill(ib);
1975     hGBNmuons_Endcap->Fill(ie);
1976 
1977     if (i > 1) {  // Take 2 first muons :-(
1978       TLorentzVector mu1(p1.x(), p1.y(), p1.z(), p1.mag());
1979       TLorentzVector mu2(p2.x(), p2.y(), p2.z(), p2.mag());
1980       TLorentzVector pair = mu1 + mu2;
1981       double Minv = pair.M();
1982       hGBInvM->Fill(Minv);
1983       if (fabs(p1.eta()) < 1.04 && fabs(p2.eta()) < 1.04)
1984         hGBInvM_Barrel->Fill(Minv);
1985       else if (fabs(p1.eta()) >= 1.04 && fabs(p2.eta()) >= 1.04)
1986         hGBInvM_Endcap->Fill(Minv);
1987       else
1988         hGBInvM_Overlap->Fill(Minv);
1989     }
1990 
1991   }  //end doGBplots
1992 
1993   // ############    Residual plots ###################
1994 
1995   if (doResplots) {
1996     const MagneticField *theMGField = &eventSetup.getData(magFieldToken_);
1997     edm::ESHandle<GlobalTrackingGeometry> theTrackingGeometry = eventSetup.getHandle(trackingGeometryToken_);
1998 
1999     // Get the RecTrack collection from the event
2000     edm::Handle<reco::TrackCollection> staTracks;
2001     event.getByLabel(theSTAMuonTag, staTracks);
2002 
2003     // Get the 4D DTSegments
2004     edm::Handle<DTRecSegment4DCollection> all4DSegmentsDT;
2005     event.getByLabel(theRecHits4DTagDT, all4DSegmentsDT);
2006     DTRecSegment4DCollection::const_iterator segmentDT;
2007 
2008     // Get the 4D CSCSegments
2009     edm::Handle<CSCSegmentCollection> all4DSegmentsCSC;
2010     event.getByLabel(theRecHits4DTagCSC, all4DSegmentsCSC);
2011     CSCSegmentCollection::const_iterator segmentCSC;
2012 
2013     //Vectors used to perform the matching between Segments and hits from Track
2014     intDVector indexCollectionDT;
2015     intDVector indexCollectionCSC;
2016 
2017     /*    std::cout << "<MuonAlignmentAnalyzer> List of DTSegments found in Local Reconstruction" << std::endl;
2018       std::cout << "Number: " << all4DSegmentsDT->size() << std::endl;
2019       for (segmentDT = all4DSegmentsDT->begin(); segmentDT != all4DSegmentsDT->end(); ++segmentDT){
2020       const GeomDet* geomDet = theTrackingGeometry->idToDet((*segmentDT).geographicalId());
2021       std::cout << "<MuonAlignmentAnalyzer> " << geomDet->toGlobal((*segmentDT).localPosition()) << std::endl;
2022       std::cout << "<MuonAlignmentAnalyzer> Local " << (*segmentDT).localPosition() << std::endl;
2023       }
2024       std::cout << "<MuonAlignmentAnalyzer> List of CSCSegments found in Local Reconstruction" << std::endl;
2025       for (segmentCSC = all4DSegmentsCSC->begin(); segmentCSC != all4DSegmentsCSC->end(); ++segmentCSC){
2026       const GeomDet* geomDet = theTrackingGeometry->idToDet((*segmentCSC).geographicalId());
2027       std::cout << "<MuonAlignmentAnalyzer>" << geomDet->toGlobal((*segmentCSC).localPosition()) << std::endl;
2028       }
2029 */
2030     thePropagator = new SteppingHelixPropagator(theMGField, alongMomentum);
2031 
2032     reco::TrackCollection::const_iterator staTrack;
2033     for (staTrack = staTracks->begin(); staTrack != staTracks->end(); ++staTrack) {
2034       int countPoints = 0;
2035 
2036       reco::TransientTrack track(*staTrack, theMGField, theTrackingGeometry);
2037 
2038       if (staTrack->numberOfValidHits() > (min1DTrackRecHitSize - 1)) {
2039         RecHitVector my4DTrack = this->doMatching(
2040             *staTrack, all4DSegmentsDT, all4DSegmentsCSC, &indexCollectionDT, &indexCollectionCSC, theTrackingGeometry);
2041 
2042         //cut in number of segments
2043 
2044         if (my4DTrack.size() > (min4DTrackSegmentSize - 1)) {
2045           // start propagation
2046           //    TrajectoryStateOnSurface innerTSOS = track.impactPointState();
2047           TrajectoryStateOnSurface innerTSOS = track.innermostMeasurementState();
2048 
2049           //If the state is valid
2050           if (innerTSOS.isValid()) {
2051             //Loop over Associated segments
2052             for (RecHitVector::iterator rechit = my4DTrack.begin(); rechit != my4DTrack.end(); ++rechit) {
2053               const GeomDet *geomDet = theTrackingGeometry->idToDet((*rechit)->geographicalId());
2054               //Otherwise the propagator could throw an exception
2055               const Plane *pDest = dynamic_cast<const Plane *>(&geomDet->surface());
2056               const Cylinder *cDest = dynamic_cast<const Cylinder *>(&geomDet->surface());
2057 
2058               if (pDest != nullptr || cDest != nullptr) {  //Donde antes iba el try
2059 
2060                 TrajectoryStateOnSurface destiny =
2061                     thePropagator->propagate(*(innerTSOS.freeState()), geomDet->surface());
2062 
2063                 if (!destiny.isValid() || !destiny.hasError())
2064                   continue;
2065 
2066                 /*      std::cout << "<MuonAlignmentAnalyzer> Segment: " << geomDet->toGlobal((*rechit)->localPosition()) << std::endl;
2067   std::cout << "<MuonAlignmentAnalyzer> Segment local: " << (*rechit)->localPosition() << std::endl;
2068   std::cout << "<MuonAlignmentAnalyzer> Predicted: " << destiny.freeState()->position() << std::endl;
2069   std::cout << "<MuonAlignmentAnalyzer> Predicted local: " << destiny.localPosition() << std::endl;
2070 */
2071                 const long rawId = (*rechit)->geographicalId().rawId();
2072                 int position = -1;
2073                 bool newDetector = true;
2074                 //Loop over the DetectorCollection to see if the detector is new and requires a new entry
2075                 for (std::vector<long>::iterator myIds = detectorCollection.begin(); myIds != detectorCollection.end();
2076                      myIds++) {
2077                   ++position;
2078                   //If matches newDetector = false
2079                   if (*myIds == rawId) {
2080                     newDetector = false;
2081                     break;
2082                   }
2083                 }
2084 
2085                 DetId myDet(rawId);
2086                 int det = myDet.subdetId();
2087                 int wheel = 0, station = 0, sector = 0;
2088                 int endcap = 0, ring = 0, chamber = 0;
2089 
2090                 double residualGlobalRPhi = 0, residualGlobalPhi = 0, residualGlobalR = 0, residualGlobalTheta = 0,
2091                        residualGlobalZ = 0;
2092                 double residualLocalX = 0, residualLocalPhi = 0, residualLocalY = 0, residualLocalTheta = 0;
2093 
2094                 // Fill generic histograms
2095                 //If it's a DT
2096                 if (det == 1) {
2097                   DTChamberId myChamber(rawId);
2098                   wheel = myChamber.wheel();
2099                   station = myChamber.station();
2100                   sector = myChamber.sector();
2101 
2102                   //global
2103                   residualGlobalRPhi =
2104                       geomDet->toGlobal((*rechit)->localPosition()).perp() *
2105                           geomDet->toGlobal((*rechit)->localPosition()).barePhi() -
2106                       destiny.freeState()->position().perp() * destiny.freeState()->position().barePhi();
2107 
2108                   //local
2109                   residualLocalX = (*rechit)->localPosition().x() - destiny.localPosition().x();
2110 
2111                   //global
2112                   residualGlobalPhi = geomDet->toGlobal(((RecSegment *)(*rechit))->localDirection()).barePhi() -
2113                                       destiny.globalDirection().barePhi();
2114 
2115                   //local
2116                   residualLocalPhi = atan2(((RecSegment *)(*rechit))->localDirection().z(),
2117                                            ((RecSegment *)(*rechit))->localDirection().x()) -
2118                                      atan2(destiny.localDirection().z(), destiny.localDirection().x());
2119 
2120                   hResidualGlobalRPhiDT->Fill(residualGlobalRPhi);
2121                   hResidualGlobalPhiDT->Fill(residualGlobalPhi);
2122                   hResidualLocalXDT->Fill(residualLocalX);
2123                   hResidualLocalPhiDT->Fill(residualLocalPhi);
2124 
2125                   if (station != 4) {
2126                     //global
2127                     residualGlobalZ =
2128                         geomDet->toGlobal((*rechit)->localPosition()).z() - destiny.freeState()->position().z();
2129 
2130                     //local
2131                     residualLocalY = (*rechit)->localPosition().y() - destiny.localPosition().y();
2132 
2133                     //global
2134                     residualGlobalTheta = geomDet->toGlobal(((RecSegment *)(*rechit))->localDirection()).bareTheta() -
2135                                           destiny.globalDirection().bareTheta();
2136 
2137                     //local
2138                     residualLocalTheta = atan2(((RecSegment *)(*rechit))->localDirection().z(),
2139                                                ((RecSegment *)(*rechit))->localDirection().y()) -
2140                                          atan2(destiny.localDirection().z(), destiny.localDirection().y());
2141 
2142                     hResidualGlobalThetaDT->Fill(residualGlobalTheta);
2143                     hResidualGlobalZDT->Fill(residualGlobalZ);
2144                     hResidualLocalThetaDT->Fill(residualLocalTheta);
2145                     hResidualLocalYDT->Fill(residualLocalY);
2146                   }
2147 
2148                   int index = wheel + 2;
2149                   hResidualGlobalRPhiDT_W[index]->Fill(residualGlobalRPhi);
2150                   hResidualGlobalPhiDT_W[index]->Fill(residualGlobalPhi);
2151                   hResidualLocalXDT_W[index]->Fill(residualLocalX);
2152                   hResidualLocalPhiDT_W[index]->Fill(residualLocalPhi);
2153                   if (station != 4) {
2154                     hResidualGlobalThetaDT_W[index]->Fill(residualGlobalTheta);
2155                     hResidualGlobalZDT_W[index]->Fill(residualGlobalZ);
2156                     hResidualLocalThetaDT_W[index]->Fill(residualLocalTheta);
2157                     hResidualLocalYDT_W[index]->Fill(residualLocalY);
2158                   }
2159 
2160                   index = wheel * 4 + station + 7;
2161                   hResidualGlobalRPhiDT_MB[index]->Fill(residualGlobalRPhi);
2162                   hResidualGlobalPhiDT_MB[index]->Fill(residualGlobalPhi);
2163                   hResidualLocalXDT_MB[index]->Fill(residualLocalX);
2164                   hResidualLocalPhiDT_MB[index]->Fill(residualLocalPhi);
2165 
2166                   if (station != 4) {
2167                     hResidualGlobalThetaDT_MB[index]->Fill(residualGlobalTheta);
2168                     hResidualGlobalZDT_MB[index]->Fill(residualGlobalZ);
2169                     hResidualLocalThetaDT_MB[index]->Fill(residualLocalTheta);
2170                     hResidualLocalYDT_MB[index]->Fill(residualLocalY);
2171                   }
2172                 } else if (det == 2) {
2173                   CSCDetId myChamber(rawId);
2174                   endcap = myChamber.endcap();
2175                   station = myChamber.station();
2176                   if (endcap == 2)
2177                     station = -station;
2178                   ring = myChamber.ring();
2179                   chamber = myChamber.chamber();
2180 
2181                   //global
2182                   residualGlobalRPhi =
2183                       geomDet->toGlobal((*rechit)->localPosition()).perp() *
2184                           geomDet->toGlobal((*rechit)->localPosition()).barePhi() -
2185                       destiny.freeState()->position().perp() * destiny.freeState()->position().barePhi();
2186 
2187                   //local
2188                   residualLocalX = (*rechit)->localPosition().x() - destiny.localPosition().x();
2189 
2190                   //global
2191                   residualGlobalR =
2192                       geomDet->toGlobal((*rechit)->localPosition()).perp() - destiny.freeState()->position().perp();
2193 
2194                   //local
2195                   residualLocalY = (*rechit)->localPosition().y() - destiny.localPosition().y();
2196 
2197                   //global
2198                   residualGlobalPhi = geomDet->toGlobal(((RecSegment *)(*rechit))->localDirection()).barePhi() -
2199                                       destiny.globalDirection().barePhi();
2200 
2201                   //local
2202                   residualLocalPhi = atan2(((RecSegment *)(*rechit))->localDirection().y(),
2203                                            ((RecSegment *)(*rechit))->localDirection().x()) -
2204                                      atan2(destiny.localDirection().y(), destiny.localDirection().x());
2205 
2206                   //global
2207                   residualGlobalTheta = geomDet->toGlobal(((RecSegment *)(*rechit))->localDirection()).bareTheta() -
2208                                         destiny.globalDirection().bareTheta();
2209 
2210                   //local
2211                   residualLocalTheta = atan2(((RecSegment *)(*rechit))->localDirection().y(),
2212                                              ((RecSegment *)(*rechit))->localDirection().z()) -
2213                                        atan2(destiny.localDirection().y(), destiny.localDirection().z());
2214 
2215                   hResidualGlobalRPhiCSC->Fill(residualGlobalRPhi);
2216                   hResidualGlobalPhiCSC->Fill(residualGlobalPhi);
2217                   hResidualGlobalThetaCSC->Fill(residualGlobalTheta);
2218                   hResidualGlobalRCSC->Fill(residualGlobalR);
2219                   hResidualLocalXCSC->Fill(residualLocalX);
2220                   hResidualLocalPhiCSC->Fill(residualLocalPhi);
2221                   hResidualLocalThetaCSC->Fill(residualLocalTheta);
2222                   hResidualLocalYCSC->Fill(residualLocalY);
2223 
2224                   int index = 2 * station + ring + 7;
2225                   if (station == -1) {
2226                     index = 5 + ring;
2227                     if (ring == 4)
2228                       index = 6;
2229                   }
2230                   if (station == 1) {
2231                     index = 8 + ring;
2232                     if (ring == 4)
2233                       index = 9;
2234                   }
2235                   hResidualGlobalRPhiCSC_ME[index]->Fill(residualGlobalRPhi);
2236                   hResidualGlobalPhiCSC_ME[index]->Fill(residualGlobalPhi);
2237                   hResidualGlobalThetaCSC_ME[index]->Fill(residualGlobalTheta);
2238                   hResidualGlobalRCSC_ME[index]->Fill(residualGlobalR);
2239                   hResidualLocalXCSC_ME[index]->Fill(residualLocalX);
2240                   hResidualLocalPhiCSC_ME[index]->Fill(residualLocalPhi);
2241                   hResidualLocalThetaCSC_ME[index]->Fill(residualLocalTheta);
2242                   hResidualLocalYCSC_ME[index]->Fill(residualLocalY);
2243 
2244                 } else {
2245                   residualGlobalRPhi = 0, residualGlobalPhi = 0, residualGlobalR = 0, residualGlobalTheta = 0,
2246                   residualGlobalZ = 0;
2247                   residualLocalX = 0, residualLocalPhi = 0, residualLocalY = 0, residualLocalTheta = 0;
2248                 }
2249                 // Fill individual chamber histograms
2250                 if (newDetector) {
2251                   //Create an RawIdDetector, fill it and push it into the collection
2252                   detectorCollection.push_back(rawId);
2253 
2254                   //This piece of code calculates the range of the residuals
2255                   double rangeX = 3.0, rangeY = 5.;
2256                   switch (abs(station)) {
2257                     case 1: {
2258                       rangeX = resLocalXRangeStation1;
2259                       rangeY = resLocalYRangeStation1;
2260                     } break;
2261                     case 2: {
2262                       rangeX = resLocalXRangeStation2;
2263                       rangeY = resLocalYRangeStation2;
2264                     } break;
2265                     case 3: {
2266                       rangeX = resLocalXRangeStation3;
2267                       rangeY = resLocalYRangeStation3;
2268                     } break;
2269                     case 4: {
2270                       rangeX = resLocalXRangeStation4;
2271                       rangeY = resLocalYRangeStation4;
2272                     } break;
2273                     default:
2274                       break;
2275                   }
2276 
2277                   //create new histograms
2278 
2279                   char nameOfHistoLocalX[50];
2280                   char nameOfHistoLocalTheta[50];
2281                   char nameOfHistoLocalY[50];
2282                   char nameOfHistoLocalPhi[50];
2283                   char nameOfHistoGlobalRPhi[50];
2284                   char nameOfHistoGlobalTheta[50];
2285                   char nameOfHistoGlobalR[50];
2286                   char nameOfHistoGlobalPhi[50];
2287                   char nameOfHistoGlobalZ[50];
2288 
2289                   if (det == 1) {  // DT
2290                     snprintf(nameOfHistoLocalX,
2291                              sizeof(nameOfHistoLocalX),
2292                              "ResidualLocalX_W%dMB%1dS%1d",
2293                              wheel,
2294                              station,
2295                              sector);
2296                     snprintf(nameOfHistoLocalPhi,
2297                              sizeof(nameOfHistoLocalPhi),
2298                              "ResidualLocalPhi_W%dMB%1dS%1d",
2299                              wheel,
2300                              station,
2301                              sector);
2302                     snprintf(nameOfHistoGlobalRPhi,
2303                              sizeof(nameOfHistoGlobalRPhi),
2304                              "ResidualGlobalRPhi_W%dMB%1dS%1d",
2305                              wheel,
2306                              station,
2307                              sector);
2308                     snprintf(nameOfHistoGlobalPhi,
2309                              sizeof(nameOfHistoGlobalPhi),
2310                              "ResidualGlobalPhi_W%dMB%1dS%1d",
2311                              wheel,
2312                              station,
2313                              sector);
2314                     snprintf(nameOfHistoLocalTheta,
2315                              sizeof(nameOfHistoLocalTheta),
2316                              "ResidualLocalTheta_W%dMB%1dS%1d",
2317                              wheel,
2318                              station,
2319                              sector);
2320                     snprintf(nameOfHistoLocalY,
2321                              sizeof(nameOfHistoLocalY),
2322                              "ResidualLocalY_W%dMB%1dS%1d",
2323                              wheel,
2324                              station,
2325                              sector);
2326                     TH1F *histoLocalY = fs->make<TH1F>(nameOfHistoLocalY, nameOfHistoLocalY, nbins, -rangeY, rangeY);
2327                     unitsLocalY.push_back(histoLocalY);
2328                     snprintf(nameOfHistoGlobalTheta,
2329                              sizeof(nameOfHistoGlobalTheta),
2330                              "ResidualGlobalTheta_W%dMB%1dS%1d",
2331                              wheel,
2332                              station,
2333                              sector);
2334                     snprintf(nameOfHistoGlobalZ,
2335                              sizeof(nameOfHistoGlobalZ),
2336                              "ResidualGlobalZ_W%dMB%1dS%1d",
2337                              wheel,
2338                              station,
2339                              sector);
2340                     TH1F *histoGlobalZ = fs->make<TH1F>(nameOfHistoGlobalZ, nameOfHistoGlobalZ, nbins, -rangeY, rangeY);
2341                     unitsGlobalRZ.push_back(histoGlobalZ);
2342 
2343                   } else if (det == 2) {  //CSC
2344                     snprintf(nameOfHistoLocalX,
2345                              sizeof(nameOfHistoLocalX),
2346                              "ResidualLocalX_ME%dR%1dC%1d",
2347                              station,
2348                              ring,
2349                              chamber);
2350                     snprintf(nameOfHistoLocalPhi,
2351                              sizeof(nameOfHistoLocalPhi),
2352                              "ResidualLocalPhi_ME%dR%1dC%1d",
2353                              station,
2354                              ring,
2355                              chamber);
2356                     snprintf(nameOfHistoLocalTheta,
2357                              sizeof(nameOfHistoLocalTheta),
2358                              "ResidualLocalTheta_ME%dR%1dC%1d",
2359                              station,
2360                              ring,
2361                              chamber);
2362                     snprintf(nameOfHistoLocalY,
2363                              sizeof(nameOfHistoLocalY),
2364                              "ResidualLocalY_ME%dR%1dC%1d",
2365                              station,
2366                              ring,
2367                              chamber);
2368                     TH1F *histoLocalY = fs->make<TH1F>(nameOfHistoLocalY, nameOfHistoLocalY, nbins, -rangeY, rangeY);
2369                     unitsLocalY.push_back(histoLocalY);
2370                     snprintf(nameOfHistoGlobalRPhi,
2371                              sizeof(nameOfHistoGlobalRPhi),
2372                              "ResidualGlobalRPhi_ME%dR%1dC%1d",
2373                              station,
2374                              ring,
2375                              chamber);
2376                     snprintf(nameOfHistoGlobalPhi,
2377                              sizeof(nameOfHistoGlobalPhi),
2378                              "ResidualGlobalPhi_ME%dR%1dC%1d",
2379                              station,
2380                              ring,
2381                              chamber);
2382                     snprintf(nameOfHistoGlobalTheta,
2383                              sizeof(nameOfHistoGlobalTheta),
2384                              "ResidualGlobalTheta_ME%dR%1dC%1d",
2385                              station,
2386                              ring,
2387                              chamber);
2388                     snprintf(nameOfHistoGlobalR,
2389                              sizeof(nameOfHistoGlobalR),
2390                              "ResidualGlobalR_ME%dR%1dC%1d",
2391                              station,
2392                              ring,
2393                              chamber);
2394                     TH1F *histoGlobalR = fs->make<TH1F>(nameOfHistoGlobalR, nameOfHistoGlobalR, nbins, -rangeY, rangeY);
2395                     unitsGlobalRZ.push_back(histoGlobalR);
2396                   }
2397 
2398                   // Common histos to DT and CSC
2399                   TH1F *histoLocalX = fs->make<TH1F>(nameOfHistoLocalX, nameOfHistoLocalX, nbins, -rangeX, rangeX);
2400                   TH1F *histoGlobalRPhi =
2401                       fs->make<TH1F>(nameOfHistoGlobalRPhi, nameOfHistoGlobalRPhi, nbins, -rangeX, rangeX);
2402                   TH1F *histoLocalPhi =
2403                       fs->make<TH1F>(nameOfHistoLocalPhi, nameOfHistoLocalPhi, nbins, -resPhiRange, resPhiRange);
2404                   TH1F *histoGlobalPhi =
2405                       fs->make<TH1F>(nameOfHistoGlobalPhi, nameOfHistoGlobalPhi, nbins, -resPhiRange, resPhiRange);
2406                   TH1F *histoGlobalTheta = fs->make<TH1F>(
2407                       nameOfHistoGlobalTheta, nameOfHistoGlobalTheta, nbins, -resThetaRange, resThetaRange);
2408                   TH1F *histoLocalTheta = fs->make<TH1F>(
2409                       nameOfHistoLocalTheta, nameOfHistoLocalTheta, nbins, -resThetaRange, resThetaRange);
2410 
2411                   histoLocalX->Fill(residualLocalX);
2412                   histoLocalPhi->Fill(residualLocalPhi);
2413                   histoLocalTheta->Fill(residualLocalTheta);
2414                   histoGlobalRPhi->Fill(residualGlobalRPhi);
2415                   histoGlobalPhi->Fill(residualGlobalPhi);
2416                   histoGlobalTheta->Fill(residualGlobalTheta);
2417                   //Push them into their respective vectors
2418                   unitsLocalX.push_back(histoLocalX);
2419                   unitsLocalPhi.push_back(histoLocalPhi);
2420                   unitsLocalTheta.push_back(histoLocalTheta);
2421                   unitsGlobalRPhi.push_back(histoGlobalRPhi);
2422                   unitsGlobalPhi.push_back(histoGlobalPhi);
2423                   unitsGlobalTheta.push_back(histoGlobalTheta);
2424 
2425                 }  // new detector
2426                 else {
2427                   //If the detector was not new, just fill the histogram
2428                   unitsLocalX.at(position)->Fill(residualLocalX);
2429                   unitsLocalPhi.at(position)->Fill(residualLocalPhi);
2430                   unitsLocalTheta.at(position)->Fill(residualLocalTheta);
2431                   unitsGlobalRPhi.at(position)->Fill(residualGlobalRPhi);
2432                   unitsGlobalPhi.at(position)->Fill(residualGlobalPhi);
2433                   unitsGlobalTheta.at(position)->Fill(residualGlobalTheta);
2434                   if (det == 1) {
2435                     unitsLocalY.at(position)->Fill(residualLocalY);
2436                     unitsGlobalRZ.at(position)->Fill(residualGlobalZ);
2437                   } else if (det == 2) {
2438                     unitsLocalY.at(position)->Fill(residualLocalY);
2439                     unitsGlobalRZ.at(position)->Fill(residualGlobalR);
2440                   }
2441                 }
2442 
2443                 countPoints++;
2444 
2445                 innerTSOS = destiny;
2446 
2447               } else {
2448                 edm::LogError("MuonAlignmentAnalyzer") << " Error!! Exception in propagator catched" << std::endl;
2449                 continue;
2450               }
2451 
2452             }  //loop over my4DTrack
2453           }    //TSOS was valid
2454 
2455         }  // cut in at least 4 segments
2456 
2457       }  //end cut in RecHitsSize>36
2458       numberOfHits = numberOfHits + countPoints;
2459     }  //loop over STAtracks
2460 
2461     delete thePropagator;
2462 
2463   }  //end doResplots
2464 }
2465 
2466 RecHitVector MuonAlignmentAnalyzer::doMatching(const reco::Track &staTrack,
2467                                                edm::Handle<DTRecSegment4DCollection> &all4DSegmentsDT,
2468                                                edm::Handle<CSCSegmentCollection> &all4DSegmentsCSC,
2469                                                intDVector *indexCollectionDT,
2470                                                intDVector *indexCollectionCSC,
2471                                                edm::ESHandle<GlobalTrackingGeometry> &theTrackingGeometry) {
2472   DTRecSegment4DCollection::const_iterator segmentDT;
2473   CSCSegmentCollection::const_iterator segmentCSC;
2474 
2475   std::vector<int> positionDT;
2476   std::vector<int> positionCSC;
2477   RecHitVector my4DTrack;
2478 
2479   //Loop over the hits of the track
2480   for (int counter = 0; counter != staTrack.numberOfValidHits() - 1; counter++) {
2481     TrackingRecHitRef myRef = staTrack.recHit(counter);
2482     const TrackingRecHit *rechit = myRef.get();
2483     const GeomDet *geomDet = theTrackingGeometry->idToDet(rechit->geographicalId());
2484 
2485     //It's a DT Hit
2486     if (geomDet->subDetector() == GeomDetEnumerators::DT) {
2487       //Take the layer associated to this hit
2488       DTLayerId myLayer(rechit->geographicalId().rawId());
2489 
2490       int NumberOfDTSegment = 0;
2491       //Loop over segments
2492       for (segmentDT = all4DSegmentsDT->begin(); segmentDT != all4DSegmentsDT->end(); ++segmentDT) {
2493         //By default the chamber associated to this Segment is new
2494         bool isNewChamber = true;
2495 
2496         //Loop over segments already included in the vector of segments in the actual track
2497         for (std::vector<int>::iterator positionIt = positionDT.begin(); positionIt != positionDT.end(); positionIt++) {
2498           //If this segment has been used before isNewChamber = false
2499           if (NumberOfDTSegment == *positionIt)
2500             isNewChamber = false;
2501         }
2502 
2503         //Loop over vectors of segments associated to previous tracks
2504         for (std::vector<std::vector<int> >::iterator collect = indexCollectionDT->begin();
2505              collect != indexCollectionDT->end();
2506              ++collect) {
2507           //Loop over segments associated to a track
2508           for (std::vector<int>::iterator positionIt = (*collect).begin(); positionIt != (*collect).end();
2509                positionIt++) {
2510             //If this segment was used in a previos track then isNewChamber = false
2511             if (NumberOfDTSegment == *positionIt)
2512               isNewChamber = false;
2513           }
2514         }
2515 
2516         //If the chamber is new
2517         if (isNewChamber) {
2518           DTChamberId myChamber((*segmentDT).geographicalId().rawId());
2519           //If the layer of the hit belongs to the chamber of the 4D Segment
2520           if (myLayer.wheel() == myChamber.wheel() && myLayer.station() == myChamber.station() &&
2521               myLayer.sector() == myChamber.sector()) {
2522             //push position of the segment and tracking rechit
2523             positionDT.push_back(NumberOfDTSegment);
2524             my4DTrack.push_back((TrackingRecHit *)&(*segmentDT));
2525           }
2526         }
2527         NumberOfDTSegment++;
2528       }
2529       //In case is a CSC
2530     } else if (geomDet->subDetector() == GeomDetEnumerators::CSC) {
2531       //Take the layer associated to this hit
2532       CSCDetId myLayer(rechit->geographicalId().rawId());
2533 
2534       int NumberOfCSCSegment = 0;
2535       //Loop over 4Dsegments
2536       for (segmentCSC = all4DSegmentsCSC->begin(); segmentCSC != all4DSegmentsCSC->end(); segmentCSC++) {
2537         //By default the chamber associated to the segment is new
2538         bool isNewChamber = true;
2539 
2540         //Loop over segments in the current track
2541         for (std::vector<int>::iterator positionIt = positionCSC.begin(); positionIt != positionCSC.end();
2542              positionIt++) {
2543           //If this segment has been used then newchamber = false
2544           if (NumberOfCSCSegment == *positionIt)
2545             isNewChamber = false;
2546         }
2547         //Loop over vectors of segments in previous tracks
2548         for (std::vector<std::vector<int> >::iterator collect = indexCollectionCSC->begin();
2549              collect != indexCollectionCSC->end();
2550              ++collect) {
2551           //Loop over segments in a track
2552           for (std::vector<int>::iterator positionIt = (*collect).begin(); positionIt != (*collect).end();
2553                positionIt++) {
2554             //If the segment was used in a previous track isNewChamber = false
2555             if (NumberOfCSCSegment == *positionIt)
2556               isNewChamber = false;
2557           }
2558         }
2559         //If the chamber is new
2560         if (isNewChamber) {
2561           CSCDetId myChamber((*segmentCSC).geographicalId().rawId());
2562           //If the chambers are the same
2563           if (myLayer.chamberId() == myChamber.chamberId()) {
2564             //push
2565             positionCSC.push_back(NumberOfCSCSegment);
2566             my4DTrack.push_back((TrackingRecHit *)&(*segmentCSC));
2567           }
2568         }
2569         NumberOfCSCSegment++;
2570       }
2571     }
2572   }
2573 
2574   indexCollectionDT->push_back(positionDT);
2575   indexCollectionCSC->push_back(positionCSC);
2576 
2577   return my4DTrack;
2578 }
2579 
2580 DEFINE_FWK_MODULE(MuonAlignmentAnalyzer);