Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:57:05

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