CMS 3D CMS Logo

MuonAlignmentAnalyzer.cc

Go to the documentation of this file.
00001 
00011 #include "Alignment/OfflineValidation/plugins/MuonAlignmentAnalyzer.h"
00012 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h" 
00013 
00014 // Collaborating Class Header
00015 #include "FWCore/Framework/interface/MakerMacros.h"
00016 #include "FWCore/Framework/interface/Event.h"
00017 
00018 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00019 #include "boost/mpl/vector.hpp" 
00020 #include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
00021 #include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
00022 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
00023 #include "DataFormats/DetId/interface/DetId.h"
00024 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
00025 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
00026 #include "DataFormats/Math/interface/deltaR.h"
00027 
00028 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
00029 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
00030 #include "DataFormats/TrackReco/interface/Track.h"
00031 
00032 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
00033 
00034 #include "DataFormats/TrackingRecHit/interface/RecSegment.h"
00035 #include "DataFormats/DTRecHit/interface/DTRecSegment4D.h"
00036 #include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
00037 #include "DataFormats/CSCRecHit/interface/CSCSegment.h"
00038 #include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h"
00039 #include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixPropagator.h"
00040 #include "DataFormats/GeometryVector/interface/GlobalVector.h" 
00041 
00042 #include "DataFormats/GeometrySurface/interface/Cylinder.h"
00043 #include "DataFormats/GeometrySurface/interface/Plane.h"
00044 #include "DataFormats/GeometrySurface/interface/Cone.h" 
00045 
00046 #include "TH2F.h"
00047 #include "TLorentzVector.h"
00048 
00049 using namespace std;
00050 using namespace edm;
00051 
00053 MuonAlignmentAnalyzer::MuonAlignmentAnalyzer(const ParameterSet& pset){
00054   theSTAMuonTag = pset.getParameter<edm::InputTag>("StandAloneTrackCollectionTag");
00055   theGLBMuonTag = pset.getParameter<edm::InputTag>("GlobalMuonTrackCollectionTag");
00056 
00057   theRecHits4DTagDT = pset.getParameter<edm::InputTag>("RecHits4DDTCollectionTag");
00058   theRecHits4DTagCSC = pset.getParameter<edm::InputTag>("RecHits4DCSCCollectionTag");
00059   
00060   theDataType = pset.getUntrackedParameter<string>("DataType");
00061   ptRangeMin = pset.getUntrackedParameter<double>("ptRangeMin");
00062   ptRangeMax = pset.getUntrackedParameter<double>("ptRangeMax");
00063   invMassRangeMin = pset.getUntrackedParameter<double>("invMassRangeMin");
00064   invMassRangeMax = pset.getUntrackedParameter<double>("invMassRangeMax");
00065 
00066   doSAplots = pset.getUntrackedParameter<bool>("doSAplots");
00067   doGBplots = pset.getUntrackedParameter<bool>("doGBplots");
00068   doResplots = pset.getUntrackedParameter<bool>("doResplots");
00069 
00070   resLocalXRangeStation1 = pset.getUntrackedParameter<double>("resLocalXRangeStation1");
00071   resLocalXRangeStation2 = pset.getUntrackedParameter<double>("resLocalXRangeStation2");
00072   resLocalXRangeStation3 = pset.getUntrackedParameter<double>("resLocalXRangeStation3");
00073   resLocalXRangeStation4 = pset.getUntrackedParameter<double>("resLocalXRangeStation4");
00074   resLocalYRangeStation1 = pset.getUntrackedParameter<double>("resLocalYRangeStation1");
00075   resLocalYRangeStation2 = pset.getUntrackedParameter<double>("resLocalYRangeStation2");
00076   resLocalYRangeStation3 = pset.getUntrackedParameter<double>("resLocalYRangeStation3");
00077   resLocalYRangeStation4 = pset.getUntrackedParameter<double>("resLocalYRangeStation4");
00078   resPhiRange = pset.getUntrackedParameter<double>("resPhiRange");
00079   resThetaRange = pset.getUntrackedParameter<double>("resThetaRange");
00080   nbins = pset.getUntrackedParameter<unsigned int>("nbins");
00081   min1DTrackRecHitSize = pset.getUntrackedParameter<unsigned int>("min1DTrackRecHitSize");
00082   min4DTrackSegmentSize = pset.getUntrackedParameter<unsigned int>("min4DTrackSegmentSize");
00083   
00084   if(theDataType != "RealData" && theDataType != "SimData")
00085     edm::LogError("MuonAlignmentAnalyzer")  << "Error in Data Type!!"<<endl;
00086 
00087   numberOfSimTracks=0;
00088   numberOfSARecTracks=0;
00089   numberOfGBRecTracks=0;
00090   numberOfHits=0;
00091 }
00092 
00094 MuonAlignmentAnalyzer::~MuonAlignmentAnalyzer(){
00095 }
00096 
00097 void MuonAlignmentAnalyzer::beginJob(const EventSetup& eventSetup){
00098 
00099 //  eventSetup.get<IdealMagneticFieldRecord>().get(theMGField);
00100   
00101   //Create the propagator
00102 //  if(doResplots)  thePropagator = new SteppingHelixPropagator(&*theMGField, alongMomentum);
00103 
00104    int nBinsPt= (int) fabs(ptRangeMax-ptRangeMin);
00105    int nBinsMass= (int) fabs(invMassRangeMax-invMassRangeMin);
00106 
00107 // Define and book histograms for SA and GB muon quantities/objects
00108 
00109   if(doGBplots) {
00110   hGBNmuons = fs->make<TH1F>("GBNmuons","Nmuons",10,0,10);
00111   hGBNmuons_Barrel = fs->make<TH1F>("GBNmuons_Barrel","Nmuons",10,0,10);
00112   hGBNmuons_Endcap = fs->make<TH1F>("GBNmuons_Endcap","Nmuons",10,0,10);
00113   hGBNhits = fs->make<TH1F>("GBNhits","Nhits",100,0,100);
00114   hGBNhits_Barrel = fs->make<TH1F>("GBNhits_Barrel","Nhits",100,0,100);
00115   hGBNhits_Endcap = fs->make<TH1F>("GBNhits_Endcap","Nhits",100,0,100);
00116   hGBPTRec = fs->make<TH1F>("GBpTRec","p_{T}^{rec}",nBinsPt,ptRangeMin,ptRangeMax);
00117   hGBPTRec_Barrel = fs->make<TH1F>("GBpTRec_Barrel","p_{T}^{rec}",nBinsPt,ptRangeMin,ptRangeMax);
00118   hGBPTRec_Endcap = fs->make<TH1F>("GBpTRec_Endcap","p_{T}^{rec}",nBinsPt,ptRangeMin,ptRangeMax);
00119   hGBPTvsEta = fs->make<TH2F> ("GBPTvsEta","p_{T}^{rec} VS #eta",100,-2.5,2.5,nBinsPt,ptRangeMin,ptRangeMax);
00120   hGBPTvsPhi = fs->make<TH2F> ("GBPTvsPhi","p_{T}^{rec} VS #phi",100,-3.1416,3.1416,nBinsPt,ptRangeMin,ptRangeMax);
00121   hGBPhivsEta = fs->make<TH2F> ("GBPhivsEta","#phi VS #eta",100,-2.5,2.5,100,-3.1416,3.1416);
00122 
00123   if(theDataType == "SimData"){
00124   hGBPTDiff = fs->make<TH1F>("GBpTDiff","p_{T}^{rec} - p_{T}^{gen} ",250,-120,120);
00125   hGBPTDiffvsEta = fs->make<TH2F> ("GBPTDiffvsEta","p_{T}^{rec} - p_{T}^{gen} VS #eta",100,-2.5,2.5,250,-120,120);
00126   hGBPTDiffvsPhi = fs->make<TH2F> ("GBPTDiffvsPhi","p_{T}^{rec} - p_{T}^{gen} VS #phi",100,-3.1416,3.1416,250,-120,120);
00127   hGBPTres = fs->make<TH1F>("GBpTRes","pT Resolution",100,-2,2);
00128   hGBPTres_Barrel = fs->make<TH1F>("GBpTRes_Barrel","pT Resolution",100,-2,2);
00129   hGBPTres_Endcap = fs->make<TH1F>("GBpTRes_Endcap","pT Resolution",100,-2,2);
00130   hGBinvPTres = fs->make<TH1F>("GBinvPTRes","#sigma (q/p_{T}) Resolution",100,-2,2);  
00131   hGBinvPTvsEta = fs->make<TH2F> ("GBinvPTvsEta","#sigma (q/p_{T}) VS #eta",100,-2.5,2.5,100,-2,2);
00132   hGBinvPTvsPhi = fs->make<TH2F> ("GBinvPTvsPhi","#sigma (q/p_{T}) VS #phi",100,-3.1416,3.1416,100,-2,2);
00133   hGBinvPTvsNhits = fs->make<TH2F> ("GBinvPTvsNhits","#sigma (q/p_{T}) VS Nhits",100,0,100,100,-2,2);
00134   }
00135   
00136   hGBChi2 = fs->make<TH1F>("GBChi2","Chi2",200,0,200);
00137   hGBChi2_Barrel = fs->make<TH1F>("GBChi2_Barrel","Chi2",200,0,200);
00138   hGBChi2_Endcap  = fs->make<TH1F>("GBChi2_Endcap ","Chi2",200,0,200);
00139   hGBInvM = fs->make<TH1F>("GBInvM","M_{inv}^{rec}",nBinsMass,invMassRangeMin,invMassRangeMax);
00140   hGBInvM_Barrel = fs->make<TH1F>("GBInvM_Barrel","M_{inv}^{rec}",nBinsMass,invMassRangeMin,invMassRangeMax);
00141   hGBInvM_Endcap  = fs->make<TH1F>("GBInvM_Endcap ","M_{inv}^{rec}",nBinsMass,invMassRangeMin,invMassRangeMax);
00142   hGBInvM_Overlap = fs->make<TH1F>("GBInvM_Overlap","M_{inv}^{rec}",nBinsMass,invMassRangeMin,invMassRangeMax);
00143   }
00144   
00145   
00146   if(doSAplots) {
00147   hSANmuons = fs->make<TH1F>("SANmuons","Nmuons",10,0,10);
00148   hSANmuons_Barrel = fs->make<TH1F>("SANmuons_Barrel","Nmuons",10,0,10);
00149   hSANmuons_Endcap = fs->make<TH1F>("SANmuons_Endcap","Nmuons",10,0,10);
00150   hSANhits = fs->make<TH1F>("SANhits","Nhits",100,0,100);
00151   hSANhits_Barrel = fs->make<TH1F>("SANhits_Barrel","Nhits",100,0,100);
00152   hSANhits_Endcap = fs->make<TH1F>("SANhits_Endcap","Nhits",100,0,100);
00153   hSAPTRec = fs->make<TH1F>("SApTRec","p_{T}^{rec}",nBinsPt,ptRangeMin,ptRangeMax);
00154   hSAPTRec_Barrel = fs->make<TH1F>("SApTRec_Barrel","p_{T}^{rec}",nBinsPt,ptRangeMin,ptRangeMax);
00155   hSAPTRec_Endcap = fs->make<TH1F>("SApTRec_Endcap","p_{T}^{rec}",nBinsPt,ptRangeMin,ptRangeMax);
00156   hSAPTvsEta = fs->make<TH2F> ("SAPTvsEta","p_{T}^{rec} VS #eta",100,-2.5,2.5,nBinsPt,ptRangeMin,ptRangeMax);
00157   hSAPTvsPhi = fs->make<TH2F> ("SAPTvsPhi","p_{T}^{rec} VS #phi",100,-3.1416,3.1416,nBinsPt,ptRangeMin,ptRangeMax);
00158   hSAPhivsEta = fs->make<TH2F> ("SAPhivsEta","#phi VS #eta",100,-2.5,2.5,100,-3.1416,3.1416);
00159 
00160   if(theDataType == "SimData"){
00161   hSAPTDiff = fs->make<TH1F>("SApTDiff","p_{T}^{rec} - p_{T}^{gen} ",250,-120,120);
00162   hSAPTDiffvsEta = fs->make<TH2F> ("SAPTDiffvsEta","p_{T}^{rec} - p_{T}^{gen} VS #eta",100,-2.5,2.5,250,-120,120);
00163   hSAPTDiffvsPhi = fs->make<TH2F> ("SAPTDiffvsPhi","p_{T}^{rec} - p_{T}^{gen} VS #phi",100,-3.1416,3.1416,250,-120,120);
00164   hSAPTres = fs->make<TH1F>("SApTRes","pT Resolution",100,-2,2);
00165   hSAPTres_Barrel = fs->make<TH1F>("SApTRes_Barrel","pT Resolution",100,-2,2);
00166   hSAPTres_Endcap = fs->make<TH1F>("SApTRes_Endcap","pT Resolution",100,-2,2);
00167   hSAinvPTres = fs->make<TH1F>("SAinvPTRes","1/pT Resolution",100,-2,2);
00168 
00169   hSAinvPTvsEta = fs->make<TH2F> ("SAinvPTvsEta","#sigma (q/p_{T}) VS #eta",100,-2.5,2.5,100,-2,2);
00170   hSAinvPTvsPhi = fs->make<TH2F> ("SAinvPTvsPhi","#sigma (q/p_{T}) VS #phi",100,-3.1416,3.1416,100,-2,2);
00171   hSAinvPTvsNhits = fs->make<TH2F> ("SAinvPTvsNhits","#sigma (q/p_{T}) VS Nhits",100,0,100,100,-2,2);
00172 }
00173   hSAInvM = fs->make<TH1F>("SAInvM","M_{inv}^{rec}",nBinsMass,invMassRangeMin,invMassRangeMax);
00174   hSAInvM_Barrel = fs->make<TH1F>("SAInvM_Barrel","M_{inv}^{rec}",nBinsMass,invMassRangeMin,invMassRangeMax);
00175   hSAInvM_Endcap = fs->make<TH1F>("SAInvM_Endcap","M_{inv}^{rec}",nBinsMass,invMassRangeMin,invMassRangeMax);
00176   hSAInvM_Overlap = fs->make<TH1F>("SAInvM_Overlap","M_{inv}^{rec}",nBinsMass,invMassRangeMin,invMassRangeMax);
00177   hSAChi2 = fs->make<TH1F>("SAChi2","Chi2",200,0,200);
00178   hSAChi2_Barrel = fs->make<TH1F>("SAChi2_Barrel","Chi2",200,0,200);
00179   hSAChi2_Endcap = fs->make<TH1F>("SAChi2_Endcap","Chi2",200,0,200);
00180   }
00181 
00182 
00183   if(theDataType == "SimData"){
00184   hSimNmuons = fs->make<TH1F>("SimNmuons","Nmuons",10,0,10);
00185   hSimNmuons_Barrel = fs->make<TH1F>("SimNmuons_Barrel","Nmuons",10,0,10);
00186   hSimNmuons_Endcap = fs->make<TH1F>("SimNmuons_Endcap","Nmuons",10,0,10);
00187   hSimPT = fs->make<TH1F>("SimPT","p_{T}^{gen} ",nBinsPt,ptRangeMin,ptRangeMax);
00188   hSimPT_Barrel = fs->make<TH1F>("SimPT_Barrel","p_{T}^{gen} ",nBinsPt,ptRangeMin,ptRangeMax);
00189   hSimPT_Endcap = fs->make<TH1F>("SimPT_Endcap","p_{T}^{gen} ",nBinsPt,ptRangeMin,ptRangeMax);
00190   hSimPTvsEta = fs->make<TH2F> ("SimPTvsEta","p_{T}^{gen} VS #eta",100,-2.5,2.5,nBinsPt,ptRangeMin,ptRangeMax);
00191   hSimPTvsPhi = fs->make<TH2F> ("SimPTvsPhi","p_{T}^{gen} VS #phi",100,-3.1416,3.1416,nBinsPt,ptRangeMin,ptRangeMax);
00192   hSimPhivsEta = fs->make<TH2F> ("SimPhivsEta","#phi VS #eta",100,-2.5,2.5,100,-3.1416,3.1416);
00193   hSimInvM = fs->make<TH1F>("SimInvM","M_{inv}^{gen} ",nBinsMass,invMassRangeMin,invMassRangeMax);
00194   hSimInvM_Barrel = fs->make<TH1F>("SimInvM_Barrel","M_{inv}^{rec}",nBinsMass,invMassRangeMin,invMassRangeMax);
00195   hSimInvM_Endcap = fs->make<TH1F>("SimInvM_Endcap","M_{inv}^{gen} ",nBinsMass,invMassRangeMin,invMassRangeMax);
00196   hSimInvM_Overlap = fs->make<TH1F>("SimInvM_Overlap","M_{inv}^{gen} ",nBinsMass,invMassRangeMin,invMassRangeMax);
00197   }
00198 
00199   if(doResplots){
00200 // All DT and CSC chambers 
00201   hResidualLocalXDT = fs->make<TH1F>("hResidualLocalXDT","hResidualLocalXDT",200,-10,10);
00202   hResidualLocalPhiDT = fs->make<TH1F>("hResidualLocalPhiDT","hResidualLocalPhiDT",100,-1,1);
00203   hResidualLocalThetaDT = fs->make<TH1F>("hResidualLocalThetaDT","hResidualLocalThetaDT",100,-1,1);
00204   hResidualLocalYDT = fs->make<TH1F>("hResidualLocalYDT","hResidualLocalYDT",200,-10,10);
00205   hResidualLocalXCSC = fs->make<TH1F>("hResidualLocalXCSC","hResidualLocalXCSC",200,-10,10);
00206   hResidualLocalPhiCSC = fs->make<TH1F>("hResidualLocalPhiCSC","hResidualLocalPhiCSC",100,-1,1);
00207   hResidualLocalThetaCSC = fs->make<TH1F>("hResidualLocalThetaCSC","hResidualLocalThetaCSC",100,-1,1);
00208   hResidualLocalYCSC = fs->make<TH1F>("hResidualLocalYCSC","hResidualLocalYCSC",200,-10,10);
00209   hResidualGlobalRPhiDT = fs->make<TH1F>("hResidualGlobalRPhiDT","hResidualGlobalRPhiDT",200,-10,10);
00210   hResidualGlobalPhiDT = fs->make<TH1F>("hResidualGlobalPhiDT","hResidualGlobalPhiDT",100,-1,1);
00211   hResidualGlobalThetaDT = fs->make<TH1F>("hResidualGlobalThetaDT","hResidualGlobalThetaDT",100,-1,1);
00212   hResidualGlobalZDT = fs->make<TH1F>("hResidualGlobalZDT","hResidualGlobalZDT",200,-10,10);
00213   hResidualGlobalRPhiCSC = fs->make<TH1F>("hResidualGlobalRPhiCSC","hResidualGlobalRPhiCSC",200,-10,10);
00214   hResidualGlobalPhiCSC = fs->make<TH1F>("hResidualGlobalPhiCSC","hResidualGlobalPhiCSC",100,-1,1);
00215   hResidualGlobalThetaCSC = fs->make<TH1F>("hResidualGlobalThetaCSC","hResidualGlobalThetaCSC",100,-1,1);
00216   hResidualGlobalRCSC = fs->make<TH1F>("hResidualGlobalRCSC","hResidualGlobalRCSC",200,-10,10);
00217 
00218 // DT Wheels
00219   hResidualLocalXDT_W[0]=fs->make<TH1F>("hResidualLocalXDT_W-2","hResidualLocalXDT_W-2",200,-10,10);
00220   hResidualLocalPhiDT_W[0]=fs->make<TH1F>("hResidualLocalPhiDT_W-2","hResidualLocalPhiDT_W-2",200,-1,1);
00221   hResidualLocalThetaDT_W[0]=fs->make<TH1F>("hResidualLocalThetaDT_W-2","hResidualLocalThetaDT_W-2",200,-1,1);
00222   hResidualLocalYDT_W[0] = fs->make<TH1F>("hResidualLocalYDT_W-2","hResidualLocalYDT_W-2",200,-10,10);
00223   hResidualLocalXDT_W[1]=fs->make<TH1F>("hResidualLocalXDT_W-1","hResidualLocalXDT_W-1",200,-10,10);
00224   hResidualLocalPhiDT_W[1]=fs->make<TH1F>("hResidualLocalPhiDT_W-1","hResidualLocalPhiDT_W-1",200,-1,1);
00225   hResidualLocalThetaDT_W[1]=fs->make<TH1F>("hResidualLocalThetaDT_W-1","hResidualLocalThetaDT_W-1",200,-1,1);
00226   hResidualLocalYDT_W[1] = fs->make<TH1F>("hResidualLocalYDT_W-1","hResidualLocalYDT_W-1",200,-10,10);
00227   hResidualLocalXDT_W[2]=fs->make<TH1F>("hResidualLocalXDT_W0","hResidualLocalXDT_W0",200,-10,10);
00228   hResidualLocalPhiDT_W[2]=fs->make<TH1F>("hResidualLocalPhiDT_W0","hResidualLocalPhiDT_W0",200,-1,1);
00229   hResidualLocalThetaDT_W[2]=fs->make<TH1F>("hResidualLocalThetaDT_W0","hResidualLocalThetaDT_W0",200,-1,1);
00230   hResidualLocalYDT_W[2] = fs->make<TH1F>("hResidualLocalYDT_W0","hResidualLocalYDT_W0",200,-10,10);
00231   hResidualLocalXDT_W[3]=fs->make<TH1F>("hResidualLocalXDT_W1","hResidualLocalXDT_W1",200,-10,10);
00232   hResidualLocalPhiDT_W[3]=fs->make<TH1F>("hResidualLocalPhiDT_W1","hResidualLocalPhiDT_W1",200,-1,1);
00233   hResidualLocalThetaDT_W[3]=fs->make<TH1F>("hResidualLocalThetaDT_W1","hResidualLocalThetaDT_W1",200,-1,1);
00234   hResidualLocalYDT_W[3] = fs->make<TH1F>("hResidualLocalYDT_W1","hResidualLocalYDT_W1",200,-10,10);
00235   hResidualLocalXDT_W[4]=fs->make<TH1F>("hResidualLocalXDT_W2","hResidualLocalXDT_W2",200,-10,10);
00236   hResidualLocalPhiDT_W[4]=fs->make<TH1F>("hResidualLocalPhiDT_W2","hResidualLocalPhiDT_W2",200,-1,1);
00237   hResidualLocalThetaDT_W[4]=fs->make<TH1F>("hResidualLocalThetaDT_W2","hResidualLocalThetaDT_W2",200,-1,1);
00238   hResidualLocalYDT_W[4] = fs->make<TH1F>("hResidualLocalYDT_W2","hResidualLocalYDT_W2",200,-10,10);
00239   hResidualGlobalRPhiDT_W[0]=fs->make<TH1F>("hResidualGlobalRPhiDT_W-2","hResidualGlobalRPhiDT_W-2",200,-10,10);
00240   hResidualGlobalPhiDT_W[0]=fs->make<TH1F>("hResidualGlobalPhiDT_W-2","hResidualGlobalPhiDT_W-2",200,-1,1);
00241   hResidualGlobalThetaDT_W[0]=fs->make<TH1F>("hResidualGlobalThetaDT_W-2","hResidualGlobalThetaDT_W-2",200,-1,1);
00242   hResidualGlobalZDT_W[0] = fs->make<TH1F>("hResidualGlobalZDT_W-2","hResidualGlobalZDT_W-2",200,-10,10);
00243   hResidualGlobalRPhiDT_W[1]=fs->make<TH1F>("hResidualGlobalRPhiDT_W-1","hResidualGlobalRPhiDT_W-1",200,-10,10);
00244   hResidualGlobalPhiDT_W[1]=fs->make<TH1F>("hResidualGlobalPhiDT_W-1","hResidualGlobalPhiDT_W-1",200,-1,1);
00245   hResidualGlobalThetaDT_W[1]=fs->make<TH1F>("hResidualGlobalThetaDT_W-1","hResidualGlobalThetaDT_W-1",200,-1,1);
00246   hResidualGlobalZDT_W[1] = fs->make<TH1F>("hResidualGlobalZDT_W-1","hResidualGlobalZDT_W-1",200,-10,10);
00247   hResidualGlobalRPhiDT_W[2]=fs->make<TH1F>("hResidualGlobalRPhiDT_W0","hResidualGlobalRPhiDT_W0",200,-10,10);
00248   hResidualGlobalPhiDT_W[2]=fs->make<TH1F>("hResidualGlobalPhiDT_W0","hResidualGlobalPhiDT_W0",200,-1,1);
00249   hResidualGlobalThetaDT_W[2]=fs->make<TH1F>("hResidualGlobalThetaDT_W0","hResidualGlobalThetaDT_W0",200,-1,1);
00250   hResidualGlobalZDT_W[2] = fs->make<TH1F>("hResidualGlobalZDT_W0","hResidualGlobalZDT_W0",200,-10,10);
00251   hResidualGlobalRPhiDT_W[3]=fs->make<TH1F>("hResidualGlobalRPhiDT_W1","hResidualGlobalRPhiDT_W1",200,-10,10);
00252   hResidualGlobalPhiDT_W[3]=fs->make<TH1F>("hResidualGlobalPhiDT_W1","hResidualGlobalPhiDT_W1",200,-1,1);
00253   hResidualGlobalThetaDT_W[3]=fs->make<TH1F>("hResidualGlobalThetaDT_W1","hResidualGlobalThetaDT_W1",200,-1,1);
00254   hResidualGlobalZDT_W[3] = fs->make<TH1F>("hResidualGlobalZDT_W1","hResidualGlobalZDT_W1",200,-10,10);
00255   hResidualGlobalRPhiDT_W[4]=fs->make<TH1F>("hResidualGlobalRPhiDT_W2","hResidualGlobalRPhiDT_W2",200,-10,10);
00256   hResidualGlobalPhiDT_W[4]=fs->make<TH1F>("hResidualGlobalPhiDT_W2","hResidualGlobalPhiDT_W2",200,-1,1);
00257   hResidualGlobalThetaDT_W[4]=fs->make<TH1F>("hResidualGlobalThetaDT_W2","hResidualGlobalThetaDT_W2",200,-1,1);
00258   hResidualGlobalZDT_W[4] = fs->make<TH1F>("hResidualGlobalZDT_W2","hResidualGlobalZDT_W2",200,-10,10);
00259 
00260 // DT Stations
00261   hResidualLocalXDT_MB[0]=fs->make<TH1F>("hResidualLocalXDT_MB-2/1","hResidualLocalXDT_MB-2/1",200,-10,10);
00262   hResidualLocalPhiDT_MB[0]=fs->make<TH1F>("hResidualLocalPhiDT_MB-2/1","hResidualLocalPhiDT_MB-2/1",200,-1,1);
00263   hResidualLocalThetaDT_MB[0]=fs->make<TH1F>("hResidualLocalThetaDT_MB-2/1","hResidualLocalThetaDT_MB-2/1",200,-1,1);
00264   hResidualLocalYDT_MB[0] = fs->make<TH1F>("hResidualLocalYDT_MB-2/1","hResidualLocalYDT_MB-2/1",200,-10,10);
00265   hResidualLocalXDT_MB[1]=fs->make<TH1F>("hResidualLocalXDT_MB-2/2","hResidualLocalXDT_MB-2/2",200,-10,10);
00266   hResidualLocalPhiDT_MB[1]=fs->make<TH1F>("hResidualLocalPhiDT_MB-2/2","hResidualLocalPhiDT_MB-2/2",200,-1,1);
00267   hResidualLocalThetaDT_MB[1]=fs->make<TH1F>("hResidualLocalThetaDT_MB-2/2","hResidualLocalThetaDT_MB-2/2",200,-1,1);
00268   hResidualLocalYDT_MB[1] = fs->make<TH1F>("hResidualLocalYDT_MB-2/2","hResidualLocalYDT_MB-2/2",200,-10,10);
00269   hResidualLocalXDT_MB[2]=fs->make<TH1F>("hResidualLocalXDT_MB-2/3","hResidualLocalXDT_MB-2/3",200,-10,10);
00270   hResidualLocalPhiDT_MB[2]=fs->make<TH1F>("hResidualLocalPhiDT_MB-2/3","hResidualLocalPhiDT_MB-2/3",200,-1,1);
00271   hResidualLocalThetaDT_MB[2]=fs->make<TH1F>("hResidualLocalThetaDT_MB-2/3","hResidualLocalThetaDT_MB-2/3",200,-1,1);
00272   hResidualLocalYDT_MB[2] = fs->make<TH1F>("hResidualLocalYDT_MB-2/3","hResidualLocalYDT_MB-2/3",200,-10,10);
00273   hResidualLocalXDT_MB[3]=fs->make<TH1F>("hResidualLocalXDT_MB-2/4","hResidualLocalXDT_MB-2/4",200,-10,10);
00274   hResidualLocalPhiDT_MB[3]=fs->make<TH1F>("hResidualLocalPhiDT_MB-2/4","hResidualLocalPhiDT_MB-2/4",200,-1,1);
00275   hResidualLocalThetaDT_MB[3]=fs->make<TH1F>("hResidualLocalThetaDT_MB-2/4","hResidualLocalThetaDT_MB-2/4",200,-1,1);
00276   hResidualLocalYDT_MB[3] = fs->make<TH1F>("hResidualLocalYDT_MB-2/4","hResidualLocalYDT_MB-2/4",200,-10,10);
00277   hResidualLocalXDT_MB[4]=fs->make<TH1F>("hResidualLocalXDT_MB-1/1","hResidualLocalXDT_MB-1/1",200,-10,10);
00278   hResidualLocalPhiDT_MB[4]=fs->make<TH1F>("hResidualLocalPhiDT_MB-1/1","hResidualLocalPhiDT_MB-1/1",200,-1,1);
00279   hResidualLocalThetaDT_MB[4]=fs->make<TH1F>("hResidualLocalThetaDT_MB-1/1","hResidualLocalThetaDT_MB-1/1",200,-1,1);
00280   hResidualLocalYDT_MB[4] = fs->make<TH1F>("hResidualLocalYDT_MB-1/1","hResidualLocalYDT_MB-1/1",200,-10,10);
00281   hResidualLocalXDT_MB[5]=fs->make<TH1F>("hResidualLocalXDT_MB-1/2","hResidualLocalXDT_MB-1/2",200,-10,10);
00282   hResidualLocalPhiDT_MB[5]=fs->make<TH1F>("hResidualLocalPhiDT_MB-1/2","hResidualLocalPhiDT_MB-1/2",200,-1,1);
00283   hResidualLocalThetaDT_MB[5]=fs->make<TH1F>("hResidualLocalThetaDT_MB-1/2","hResidualLocalThetaDT_MB-1/2",200,-1,1);
00284   hResidualLocalYDT_MB[5] = fs->make<TH1F>("hResidualLocalYDT_MB-1/2","hResidualLocalYDT_MB-1/2",200,-10,10);
00285   hResidualLocalXDT_MB[6]=fs->make<TH1F>("hResidualLocalXDT_MB-1/3","hResidualLocalXDT_MB-1/3",200,-10,10);
00286   hResidualLocalPhiDT_MB[6]=fs->make<TH1F>("hResidualLocalPhiDT_MB-1/3","hResidualLocalPhiDT_MB-1/3",200,-1,1);
00287   hResidualLocalThetaDT_MB[6]=fs->make<TH1F>("hResidualLocalThetaDT_MB-1/3","hResidualLocalThetaDT_MB-1/3",200,-1,1);
00288   hResidualLocalYDT_MB[6] = fs->make<TH1F>("hResidualLocalYDT_MB-1/3","hResidualLocalYDT_MB-1/3",200,-10,10);
00289   hResidualLocalXDT_MB[7]=fs->make<TH1F>("hResidualLocalXDT_MB-1/4","hResidualLocalXDT_MB-1/4",200,-10,10);
00290   hResidualLocalPhiDT_MB[7]=fs->make<TH1F>("hResidualLocalPhiDT_MB-1/4","hResidualLocalPhiDT_MB-1/4",200,-1,1);
00291   hResidualLocalThetaDT_MB[7]=fs->make<TH1F>("hResidualLocalThetaDT_MB-1/4","hResidualLocalThetaDT_MB-1/4",200,-1,1);
00292   hResidualLocalYDT_MB[7] = fs->make<TH1F>("hResidualLocalYDT_MB-1/4","hResidualLocalYDT_MB-1/4",200,-10,10);
00293   hResidualLocalXDT_MB[8]=fs->make<TH1F>("hResidualLocalXDT_MB0/1","hResidualLocalXDT_MB0/1",200,-10,10);
00294   hResidualLocalPhiDT_MB[8]=fs->make<TH1F>("hResidualLocalPhiDT_MB0/1","hResidualLocalPhiDT_MB0/1",200,-1,1);
00295   hResidualLocalThetaDT_MB[8]=fs->make<TH1F>("hResidualLocalThetaDT_MB0/1","hResidualLocalThetaDT_MB0/1",200,-1,1);
00296   hResidualLocalYDT_MB[8] = fs->make<TH1F>("hResidualLocalYDT_MB0/1","hResidualLocalYDT_MB0/1",200,-10,10);
00297   hResidualLocalXDT_MB[9]=fs->make<TH1F>("hResidualLocalXDT_MB0/2","hResidualLocalXDT_MB0/2",200,-10,10);
00298   hResidualLocalPhiDT_MB[9]=fs->make<TH1F>("hResidualLocalPhiDT_MB0/2","hResidualLocalPhiDT_MB0/2",200,-1,1);
00299   hResidualLocalThetaDT_MB[9]=fs->make<TH1F>("hResidualLocalThetaDT_MB0/2","hResidualLocalThetaDT_MB0/2",200,-1,1);
00300   hResidualLocalYDT_MB[9] = fs->make<TH1F>("hResidualLocalYDT_MB0/2","hResidualLocalYDT_MB0/2",200,-10,10);
00301   hResidualLocalXDT_MB[10]=fs->make<TH1F>("hResidualLocalXDT_MB0/3","hResidualLocalXDT_MB0/3",200,-10,10);
00302   hResidualLocalThetaDT_MB[10]=fs->make<TH1F>("hResidualLocalThetaDT_MB0/3","hResidualLocalThetaDT_MB0/3",200,-1,1);
00303   hResidualLocalPhiDT_MB[10]=fs->make<TH1F>("hResidualLocalPhiDT_MB0/3","hResidualLocalPhiDT_MB0/3",200,-1,1);
00304   hResidualLocalYDT_MB[10] = fs->make<TH1F>("hResidualLocalYDT_MB0/3","hResidualLocalYDT_MB0/3",200,-10,10);
00305   hResidualLocalXDT_MB[11]=fs->make<TH1F>("hResidualLocalXDT_MB0/4","hResidualLocalXDT_MB0/4",200,-10,10);
00306   hResidualLocalPhiDT_MB[11]=fs->make<TH1F>("hResidualLocalPhiDT_MB0/4","hResidualLocalPhiDT_MB0/4",200,-1,1);
00307   hResidualLocalThetaDT_MB[11]=fs->make<TH1F>("hResidualLocalThetaDT_MB0/4","hResidualLocalThetaDT_MB0/4",200,-1,1);
00308   hResidualLocalYDT_MB[11] = fs->make<TH1F>("hResidualLocalYDT_MB0/4","hResidualLocalYDT_MB0/4",200,-10,10);
00309   hResidualLocalXDT_MB[12]=fs->make<TH1F>("hResidualLocalXDT_MB1/1","hResidualLocalXDT_MB1/1",200,-10,10);
00310   hResidualLocalPhiDT_MB[12]=fs->make<TH1F>("hResidualLocalPhiDT_MB1/1","hResidualLocalPhiDT_MB1/1",200,-1,1);
00311   hResidualLocalThetaDT_MB[12]=fs->make<TH1F>("hResidualLocalThetaDT_MB1/1","hResidualLocalThetaDT_MB1/1",200,-1,1);
00312   hResidualLocalYDT_MB[12] = fs->make<TH1F>("hResidualLocalYDT_MB1/1","hResidualLocalYDT_MB1/1",200,-10,10);
00313   hResidualLocalXDT_MB[13]=fs->make<TH1F>("hResidualLocalXDT_MB1/2","hResidualLocalXDT_MB1/2",200,-10,10);
00314   hResidualLocalPhiDT_MB[13]=fs->make<TH1F>("hResidualLocalPhiDT_MB1/2","hResidualLocalPhiDT_MB1/2",200,-1,1);
00315   hResidualLocalThetaDT_MB[13]=fs->make<TH1F>("hResidualLocalThetaDT_MB1/2","hResidualLocalThetaDT_MB1/2",200,-1,1);
00316   hResidualLocalYDT_MB[13] = fs->make<TH1F>("hResidualLocalYDT_MB1/2","hResidualLocalYDT_MB1/2",200,-10,10);
00317   hResidualLocalXDT_MB[14]=fs->make<TH1F>("hResidualLocalXDT_MB1/3","hResidualLocalXDT_MB1/3",200,-10,10);
00318   hResidualLocalPhiDT_MB[14]=fs->make<TH1F>("hResidualLocalPhiDT_MB1/3","hResidualLocalPhiDT_MB1/3",200,-1,1);
00319   hResidualLocalThetaDT_MB[14]=fs->make<TH1F>("hResidualLocalThetaDT_MB1/3","hResidualLocalThetaDT_MB1/3",200,-1,1);
00320   hResidualLocalYDT_MB[14] = fs->make<TH1F>("hResidualLocalYDT_MB1/3","hResidualLocalYDT_MB1/3",200,-10,10);
00321   hResidualLocalXDT_MB[15]=fs->make<TH1F>("hResidualLocalXDT_MB1/4","hResidualLocalXDT_MB1/4",200,-10,10);
00322   hResidualLocalPhiDT_MB[15]=fs->make<TH1F>("hResidualLocalPhiDT_MB1/4","hResidualLocalPhiDT_MB1/4",200,-1,1);
00323   hResidualLocalThetaDT_MB[15]=fs->make<TH1F>("hResidualLocalThetaDT_MB1/4","hResidualLocalThetaDT_MB1/4",200,-1,1);
00324   hResidualLocalYDT_MB[15] = fs->make<TH1F>("hResidualLocalYDT_MB1/4","hResidualLocalYDT_MB1/4",200,-10,10);
00325   hResidualLocalXDT_MB[16]=fs->make<TH1F>("hResidualLocalXDT_MB2/1","hResidualLocalXDT_MB2/1",200,-10,10);
00326   hResidualLocalPhiDT_MB[16]=fs->make<TH1F>("hResidualLocalPhiDT_MB2/1","hResidualLocalPhiDT_MB2/1",200,-1,1);
00327   hResidualLocalThetaDT_MB[16]=fs->make<TH1F>("hResidualLocalThetaDT_MB2/1","hResidualLocalThetaDT_MB2/1",200,-1,1);
00328   hResidualLocalYDT_MB[16] = fs->make<TH1F>("hResidualLocalYDT_MB2/1","hResidualLocalYDT_MB2/1",200,-10,10);
00329   hResidualLocalXDT_MB[17]=fs->make<TH1F>("hResidualLocalXDT_MB2/2","hResidualLocalXDT_MB2/2",200,-10,10);
00330   hResidualLocalPhiDT_MB[17]=fs->make<TH1F>("hResidualLocalPhiDT_MB2/2","hResidualLocalPhiDT_MB2/2",200,-1,1);
00331   hResidualLocalThetaDT_MB[17]=fs->make<TH1F>("hResidualLocalThetaDT_MB2/2","hResidualLocalThetaDT_MB2/2",200,-1,1);
00332   hResidualLocalYDT_MB[17] = fs->make<TH1F>("hResidualLocalYDT_MB2/2","hResidualLocalYDT_MB2/2",200,-10,10);
00333   hResidualLocalXDT_MB[18]=fs->make<TH1F>("hResidualLocalXDT_MB2/3","hResidualLocalXDT_MB2/3",200,-10,10);
00334   hResidualLocalPhiDT_MB[18]=fs->make<TH1F>("hResidualLocalPhiDT_MB2/3","hResidualLocalPhiDT_MB2/3",200,-1,1);
00335   hResidualLocalThetaDT_MB[18]=fs->make<TH1F>("hResidualLocalThetaDT_MB2/3","hResidualLocalThetaDT_MB2/3",200,-1,1);
00336   hResidualLocalYDT_MB[18] = fs->make<TH1F>("hResidualLocalYDT_MB2/3","hResidualLocalYDT_MB2/3",200,-10,10);
00337   hResidualLocalXDT_MB[19]=fs->make<TH1F>("hResidualLocalXDT_MB2/4","hResidualLocalXDT_MB2/4",200,-10,10);
00338   hResidualLocalPhiDT_MB[19]=fs->make<TH1F>("hResidualLocalPhiDT_MB2/4","hResidualLocalPhiDT_MB2/4",200,-1,1);
00339   hResidualLocalThetaDT_MB[19]=fs->make<TH1F>("hResidualLocalThetaDT_MB2/4","hResidualLocalThetaDT_MB2/4",200,-1,1);
00340   hResidualLocalYDT_MB[19] = fs->make<TH1F>("hResidualLocalYDT_MB2/4","hResidualLocalYDT_MB2/4",200,-10,10);
00341   hResidualGlobalRPhiDT_MB[0]=fs->make<TH1F>("hResidualGlobalRPhiDT_MB-2/1","hResidualGlobalRPhiDT_MB-2/1",200,-10,10);
00342   hResidualGlobalPhiDT_MB[0]=fs->make<TH1F>("hResidualGlobalPhiDT_MB-2/1","hResidualGlobalPhiDT_MB-2/1",200,-1,1);
00343   hResidualGlobalThetaDT_MB[0]=fs->make<TH1F>("hResidualGlobalThetaDT_MB-2/1","hResidualGlobalThetaDT_MB-2/1",200,-1,1);
00344   hResidualGlobalZDT_MB[0] = fs->make<TH1F>("hResidualGlobalZDT_MB-2/1","hResidualGlobalZDT_MB-2/1",200,-10,10);
00345   hResidualGlobalRPhiDT_MB[1]=fs->make<TH1F>("hResidualGlobalRPhiDT_MB-2/2","hResidualGlobalRPhiDT_MB-2/2",200,-10,10);
00346   hResidualGlobalPhiDT_MB[1]=fs->make<TH1F>("hResidualGlobalPhiDT_MB-2/2","hResidualGlobalPhiDT_MB-2/2",200,-1,1);
00347   hResidualGlobalThetaDT_MB[1]=fs->make<TH1F>("hResidualGlobalThetaDT_MB-2/2","hResidualGlobalThetaDT_MB-2/2",200,-1,1);
00348   hResidualGlobalZDT_MB[1] = fs->make<TH1F>("hResidualGlobalZDT_MB-2/2","hResidualGlobalZDT_MB-2/2",200,-10,10);
00349   hResidualGlobalRPhiDT_MB[2]=fs->make<TH1F>("hResidualGlobalRPhiDT_MB-2/3","hResidualGlobalRPhiDT_MB-2/3",200,-10,10);
00350   hResidualGlobalPhiDT_MB[2]=fs->make<TH1F>("hResidualGlobalPhiDT_MB-2/3","hResidualGlobalPhiDT_MB-2/3",200,-1,1);
00351   hResidualGlobalThetaDT_MB[2]=fs->make<TH1F>("hResidualGlobalThetaDT_MB-2/3","hResidualGlobalThetaDT_MB-2/3",200,-1,1);
00352   hResidualGlobalZDT_MB[2] = fs->make<TH1F>("hResidualGlobalZDT_MB-2/3","hResidualGlobalZDT_MB-2/3",200,-10,10);
00353   hResidualGlobalRPhiDT_MB[3]=fs->make<TH1F>("hResidualGlobalRPhiDT_MB-2/4","hResidualGlobalRPhiDT_MB-2/4",200,-10,10);
00354   hResidualGlobalPhiDT_MB[3]=fs->make<TH1F>("hResidualGlobalPhiDT_MB-2/4","hResidualGlobalPhiDT_MB-2/4",200,-1,1);
00355   hResidualGlobalThetaDT_MB[3]=fs->make<TH1F>("hResidualGlobalThetaDT_MB-2/4","hResidualGlobalThetaDT_MB-2/4",200,-1,1);
00356   hResidualGlobalZDT_MB[3] = fs->make<TH1F>("hResidualGlobalZDT_MB-2/4","hResidualGlobalZDT_MB-2/4",200,-10,10);
00357   hResidualGlobalRPhiDT_MB[4]=fs->make<TH1F>("hResidualGlobalRPhiDT_MB-1/1","hResidualGlobalRPhiDT_MB-1/1",200,-10,10);
00358   hResidualGlobalPhiDT_MB[4]=fs->make<TH1F>("hResidualGlobalPhiDT_MB-1/1","hResidualGlobalPhiDT_MB-1/1",200,-1,1);
00359   hResidualGlobalThetaDT_MB[4]=fs->make<TH1F>("hResidualGlobalThetaDT_MB-1/1","hResidualGlobalThetaDT_MB-1/1",200,-1,1);
00360   hResidualGlobalZDT_MB[4] = fs->make<TH1F>("hResidualGlobalZDT_MB-1/1","hResidualGlobalZDT_MB-1/1",200,-10,10);
00361   hResidualGlobalRPhiDT_MB[5]=fs->make<TH1F>("hResidualGlobalRPhiDT_MB-1/2","hResidualGlobalRPhiDT_MB-1/2",200,-10,10);
00362   hResidualGlobalPhiDT_MB[5]=fs->make<TH1F>("hResidualGlobalPhiDT_MB-1/2","hResidualGlobalPhiDT_MB-1/2",200,-1,1);
00363   hResidualGlobalThetaDT_MB[5]=fs->make<TH1F>("hResidualGlobalThetaDT_MB-1/2","hResidualGlobalThetaDT_MB-1/2",200,-1,1);
00364   hResidualGlobalZDT_MB[5] = fs->make<TH1F>("hResidualGlobalZDT_MB-1/2","hResidualGlobalZDT_MB-1/2",200,-10,10);
00365   hResidualGlobalRPhiDT_MB[6]=fs->make<TH1F>("hResidualGlobalRPhiDT_MB-1/3","hResidualGlobalRPhiDT_MB-1/3",200,-10,10);
00366   hResidualGlobalPhiDT_MB[6]=fs->make<TH1F>("hResidualGlobalPhiDT_MB-1/3","hResidualGlobalPhiDT_MB-1/3",200,-1,1);
00367   hResidualGlobalThetaDT_MB[6]=fs->make<TH1F>("hResidualGlobalThetaDT_MB-1/3","hResidualGlobalThetaDT_MB-1/3",200,-1,1);
00368   hResidualGlobalZDT_MB[6] = fs->make<TH1F>("hResidualGlobalZDT_MB-1/3","hResidualGlobalZDT_MB-1/3",200,-10,10);
00369   hResidualGlobalRPhiDT_MB[7]=fs->make<TH1F>("hResidualGlobalRPhiDT_MB-1/4","hResidualGlobalRPhiDT_MB-1/4",200,-10,10);
00370   hResidualGlobalPhiDT_MB[7]=fs->make<TH1F>("hResidualGlobalPhiDT_MB-1/4","hResidualGlobalPhiDT_MB-1/4",200,-1,1);
00371   hResidualGlobalThetaDT_MB[7]=fs->make<TH1F>("hResidualGlobalThetaDT_MB-1/4","hResidualGlobalThetaDT_MB-1/4",200,-1,1);
00372   hResidualGlobalZDT_MB[7] = fs->make<TH1F>("hResidualGlobalZDT_MB-1/4","hResidualGlobalZDT_MB-1/4",200,-10,10);
00373   hResidualGlobalRPhiDT_MB[8]=fs->make<TH1F>("hResidualGlobalRPhiDT_MB0/1","hResidualGlobalRPhiDT_MB0/1",200,-10,10);
00374   hResidualGlobalPhiDT_MB[8]=fs->make<TH1F>("hResidualGlobalPhiDT_MB0/1","hResidualGlobalPhiDT_MB0/1",200,-1,1);
00375   hResidualGlobalThetaDT_MB[8]=fs->make<TH1F>("hResidualGlobalThetaDT_MB0/1","hResidualGlobalThetaDT_MB0/1",200,-1,1);
00376   hResidualGlobalZDT_MB[8] = fs->make<TH1F>("hResidualGlobalZDT_MB0/1","hResidualGlobalZDT_MB0/1",200,-10,10);
00377   hResidualGlobalRPhiDT_MB[9]=fs->make<TH1F>("hResidualGlobalRPhiDT_MB0/2","hResidualGlobalRPhiDT_MB0/2",200,-10,10);
00378   hResidualGlobalPhiDT_MB[9]=fs->make<TH1F>("hResidualGlobalPhiDT_MB0/2","hResidualGlobalPhiDT_MB0/2",200,-1,1);
00379   hResidualGlobalThetaDT_MB[9]=fs->make<TH1F>("hResidualGlobalThetaDT_MB0/2","hResidualGlobalThetaDT_MB0/2",200,-1,1);
00380   hResidualGlobalZDT_MB[9] = fs->make<TH1F>("hResidualGlobalZDT_MB0/2","hResidualGlobalZDT_MB0/2",200,-10,10);
00381   hResidualGlobalRPhiDT_MB[10]=fs->make<TH1F>("hResidualGlobalRPhiDT_MB0/3","hResidualGlobalRPhiDT_MB0/3",200,-10,10);
00382   hResidualGlobalThetaDT_MB[10]=fs->make<TH1F>("hResidualGlobalThetaDT_MB0/3","hResidualGlobalThetaDT_MB0/3",200,-1,1);
00383   hResidualGlobalPhiDT_MB[10]=fs->make<TH1F>("hResidualGlobalPhiDT_MB0/3","hResidualGlobalPhiDT_MB0/3",200,-1,1);
00384   hResidualGlobalZDT_MB[10] = fs->make<TH1F>("hResidualGlobalZDT_MB0/3","hResidualGlobalZDT_MB0/3",200,-10,10);
00385   hResidualGlobalRPhiDT_MB[11]=fs->make<TH1F>("hResidualGlobalRPhiDT_MB0/4","hResidualGlobalRPhiDT_MB0/4",200,-10,10);
00386   hResidualGlobalPhiDT_MB[11]=fs->make<TH1F>("hResidualGlobalPhiDT_MB0/4","hResidualGlobalPhiDT_MB0/4",200,-1,1);
00387   hResidualGlobalThetaDT_MB[11]=fs->make<TH1F>("hResidualGlobalThetaDT_MB0/4","hResidualGlobalThetaDT_MB0/4",200,-1,1);
00388   hResidualGlobalZDT_MB[11] = fs->make<TH1F>("hResidualGlobalZDT_MB0/4","hResidualGlobalZDT_MB0/4",200,-10,10);
00389   hResidualGlobalRPhiDT_MB[12]=fs->make<TH1F>("hResidualGlobalRPhiDT_MB1/1","hResidualGlobalRPhiDT_MB1/1",200,-10,10);
00390   hResidualGlobalPhiDT_MB[12]=fs->make<TH1F>("hResidualGlobalPhiDT_MB1/1","hResidualGlobalPhiDT_MB1/1",200,-1,1);
00391   hResidualGlobalThetaDT_MB[12]=fs->make<TH1F>("hResidualGlobalThetaDT_MB1/1","hResidualGlobalThetaDT_MB1/1",200,-1,1);
00392   hResidualGlobalZDT_MB[12] = fs->make<TH1F>("hResidualGlobalZDT_MB1/1","hResidualGlobalZDT_MB1/1",200,-10,10);
00393   hResidualGlobalRPhiDT_MB[13]=fs->make<TH1F>("hResidualGlobalRPhiDT_MB1/2","hResidualGlobalRPhiDT_MB1/2",200,-10,10);
00394   hResidualGlobalPhiDT_MB[13]=fs->make<TH1F>("hResidualGlobalPhiDT_MB1/2","hResidualGlobalPhiDT_MB1/2",200,-1,1);
00395   hResidualGlobalThetaDT_MB[13]=fs->make<TH1F>("hResidualGlobalThetaDT_MB1/2","hResidualGlobalThetaDT_MB1/2",200,-1,1);
00396   hResidualGlobalZDT_MB[13] = fs->make<TH1F>("hResidualGlobalZDT_MB1/2","hResidualGlobalZDT_MB1/2",200,-10,10);
00397   hResidualGlobalRPhiDT_MB[14]=fs->make<TH1F>("hResidualGlobalRPhiDT_MB1/3","hResidualGlobalRPhiDT_MB1/3",200,-10,10);
00398   hResidualGlobalPhiDT_MB[14]=fs->make<TH1F>("hResidualGlobalPhiDT_MB1/3","hResidualGlobalPhiDT_MB1/3",200,-1,1);
00399   hResidualGlobalThetaDT_MB[14]=fs->make<TH1F>("hResidualGlobalThetaDT_MB1/3","hResidualGlobalThetaDT_MB1/3",200,-1,1);
00400   hResidualGlobalZDT_MB[14] = fs->make<TH1F>("hResidualGlobalZDT_MB1/3","hResidualGlobalZDT_MB1/3",200,-10,10);
00401   hResidualGlobalRPhiDT_MB[15]=fs->make<TH1F>("hResidualGlobalRPhiDT_MB1/4","hResidualGlobalRPhiDT_MB1/4",200,-10,10);
00402   hResidualGlobalPhiDT_MB[15]=fs->make<TH1F>("hResidualGlobalPhiDT_MB1/4","hResidualGlobalPhiDT_MB1/4",200,-1,1);
00403   hResidualGlobalThetaDT_MB[15]=fs->make<TH1F>("hResidualGlobalThetaDT_MB1/4","hResidualGlobalThetaDT_MB1/4",200,-1,1);
00404   hResidualGlobalZDT_MB[15] = fs->make<TH1F>("hResidualGlobalZDT_MB1/4","hResidualGlobalZDT_MB1/4",200,-10,10);
00405   hResidualGlobalRPhiDT_MB[16]=fs->make<TH1F>("hResidualGlobalRPhiDT_MB2/1","hResidualGlobalRPhiDT_MB2/1",200,-10,10);
00406   hResidualGlobalPhiDT_MB[16]=fs->make<TH1F>("hResidualGlobalPhiDT_MB2/1","hResidualGlobalPhiDT_MB2/1",200,-1,1);
00407   hResidualGlobalThetaDT_MB[16]=fs->make<TH1F>("hResidualGlobalThetaDT_MB2/1","hResidualGlobalThetaDT_MB2/1",200,-1,1);
00408   hResidualGlobalZDT_MB[16] = fs->make<TH1F>("hResidualGlobalZDT_MB2/1","hResidualGlobalZDT_MB2/1",200,-10,10);
00409   hResidualGlobalRPhiDT_MB[17]=fs->make<TH1F>("hResidualGlobalRPhiDT_MB2/2","hResidualGlobalRPhiDT_MB2/2",200,-10,10);
00410   hResidualGlobalPhiDT_MB[17]=fs->make<TH1F>("hResidualGlobalPhiDT_MB2/2","hResidualGlobalPhiDT_MB2/2",200,-1,1);
00411   hResidualGlobalThetaDT_MB[17]=fs->make<TH1F>("hResidualGlobalThetaDT_MB2/2","hResidualGlobalThetaDT_MB2/2",200,-1,1);
00412   hResidualGlobalZDT_MB[17] = fs->make<TH1F>("hResidualGlobalZDT_MB2/2","hResidualGlobalZDT_MB2/2",200,-10,10);
00413   hResidualGlobalRPhiDT_MB[18]=fs->make<TH1F>("hResidualGlobalRPhiDT_MB2/3","hResidualGlobalRPhiDT_MB2/3",200,-10,10);
00414   hResidualGlobalPhiDT_MB[18]=fs->make<TH1F>("hResidualGlobalPhiDT_MB2/3","hResidualGlobalPhiDT_MB2/3",200,-1,1);
00415   hResidualGlobalThetaDT_MB[18]=fs->make<TH1F>("hResidualGlobalThetaDT_MB2/3","hResidualGlobalThetaDT_MB2/3",200,-1,1);
00416   hResidualGlobalZDT_MB[18] = fs->make<TH1F>("hResidualGlobalZDT_MB2/3","hResidualGlobalZDT_MB2/3",200,-10,10);
00417   hResidualGlobalRPhiDT_MB[19]=fs->make<TH1F>("hResidualGlobalRPhiDT_MB2/4","hResidualGlobalRPhiDT_MB2/4",200,-10,10);
00418   hResidualGlobalPhiDT_MB[19]=fs->make<TH1F>("hResidualGlobalPhiDT_MB2/4","hResidualGlobalPhiDT_MB2/4",200,-1,1);
00419   hResidualGlobalThetaDT_MB[19]=fs->make<TH1F>("hResidualGlobalThetaDT_MB2/4","hResidualGlobalThetaDT_MB2/4",200,-1,1);
00420   hResidualGlobalZDT_MB[19] = fs->make<TH1F>("hResidualGlobalZDT_MB2/4","hResidualGlobalZDT_MB2/4",200,-10,10);
00421 
00422 
00423 // CSC Stations
00424   hResidualLocalXCSC_ME[0]=fs->make<TH1F>("hResidualLocalXCSC_ME-4/1","hResidualLocalXCSC_ME-4/1",200,-10,10);
00425   hResidualLocalPhiCSC_ME[0]=fs->make<TH1F>("hResidualLocalPhiCSC_ME-4/1","hResidualLocalPhiCSC_ME-4/1",200,-1,1);
00426   hResidualLocalThetaCSC_ME[0]=fs->make<TH1F>("hResidualLocalThetaCSC_ME-4/1","hResidualLocalThetaCSC_ME-4/1",200,-1,1);
00427   hResidualLocalYCSC_ME[0] = fs->make<TH1F>("hResidualLocalYCSC_ME-4/1","hResidualLocalYCSC_ME-4/1",200,-10,10);
00428   hResidualLocalXCSC_ME[1]=fs->make<TH1F>("hResidualLocalXCSC_ME-4/2","hResidualLocalXCSC_ME-4/2",200,-10,10);
00429   hResidualLocalPhiCSC_ME[1]=fs->make<TH1F>("hResidualLocalPhiCSC_ME-4/2","hResidualLocalPhiCSC_ME-4/2",200,-1,1);
00430   hResidualLocalThetaCSC_ME[1]=fs->make<TH1F>("hResidualLocalThetaCSC_ME-4/2","hResidualLocalThetaCSC_ME-4/2",200,-1,1);
00431   hResidualLocalYCSC_ME[1] = fs->make<TH1F>("hResidualLocalYCSC_ME-4/2","hResidualLocalYCSC_ME-4/2",200,-10,10);
00432   hResidualLocalXCSC_ME[2]=fs->make<TH1F>("hResidualLocalXCSC_ME-3/1","hResidualLocalXCSC_ME-3/1",200,-10,10);
00433   hResidualLocalPhiCSC_ME[2]=fs->make<TH1F>("hResidualLocalPhiCSC_ME-3/1","hResidualLocalPhiCSC_ME-3/1",200,-1,1);
00434   hResidualLocalThetaCSC_ME[2]=fs->make<TH1F>("hResidualLocalThetaCSC_ME-3/1","hResidualLocalThetaCSC_ME-3/1",200,-1,1);
00435   hResidualLocalYCSC_ME[2] = fs->make<TH1F>("hResidualLocalYCSC_ME-3/1","hResidualLocalYCSC_ME-3/1",200,-10,10);
00436   hResidualLocalXCSC_ME[3]=fs->make<TH1F>("hResidualLocalXCSC_ME-3/2","hResidualLocalXCSC_ME-3/2",200,-10,10);
00437   hResidualLocalPhiCSC_ME[3]=fs->make<TH1F>("hResidualLocalPhiCSC_ME-3/2","hResidualLocalPhiCSC_ME-3/2",200,-1,1);
00438   hResidualLocalThetaCSC_ME[3]=fs->make<TH1F>("hResidualLocalThetaCSC_ME-3/2","hResidualLocalThetaCSC_ME-3/2",200,-1,1);
00439   hResidualLocalYCSC_ME[3] = fs->make<TH1F>("hResidualLocalYCSC_ME-3/2","hResidualLocalYCSC_ME-3/2",200,-10,10);
00440   hResidualLocalXCSC_ME[4]=fs->make<TH1F>("hResidualLocalXCSC_ME-2/1","hResidualLocalXCSC_ME-2/1",200,-10,10);
00441   hResidualLocalPhiCSC_ME[4]=fs->make<TH1F>("hResidualLocalPhiCSC_ME-2/1","hResidualLocalPhiCSC_ME-2/1",200,-1,1);
00442   hResidualLocalThetaCSC_ME[4]=fs->make<TH1F>("hResidualLocalThetaCSC_ME-2/1","hResidualLocalThetaCSC_ME-2/1",200,-1,1);
00443   hResidualLocalYCSC_ME[4] = fs->make<TH1F>("hResidualLocalYCSC_ME-2/1","hResidualLocalYCSC_ME-2/1",200,-10,10);
00444   hResidualLocalXCSC_ME[5]=fs->make<TH1F>("hResidualLocalXCSC_ME-2/2","hResidualLocalXCSC_ME-2/2",200,-10,10);
00445   hResidualLocalPhiCSC_ME[5]=fs->make<TH1F>("hResidualLocalPhiCSC_ME-2/2","hResidualLocalPhiCSC_ME-2/2",200,-1,1);
00446   hResidualLocalThetaCSC_ME[5]=fs->make<TH1F>("hResidualLocalThetaCSC_ME-2/2","hResidualLocalThetaCSC_ME-2/2",200,-1,1);
00447   hResidualLocalYCSC_ME[5] = fs->make<TH1F>("hResidualLocalYCSC_ME-2/2","hResidualLocalYCSC_ME-2/2",200,-10,10);
00448   hResidualLocalXCSC_ME[6]=fs->make<TH1F>("hResidualLocalXCSC_ME-1/1","hResidualLocalXCSC_ME-1/1",200,-10,10);
00449   hResidualLocalPhiCSC_ME[6]=fs->make<TH1F>("hResidualLocalPhiCSC_ME-1/1","hResidualLocalPhiCSC_ME-1/1",200,-1,1);
00450   hResidualLocalThetaCSC_ME[6]=fs->make<TH1F>("hResidualLocalThetaCSC_ME-1/1","hResidualLocalThetaCSC_ME-1/1",200,-1,1);
00451   hResidualLocalYCSC_ME[6] = fs->make<TH1F>("hResidualLocalYCSC_ME-1/1","hResidualLocalYCSC_ME-1/1",200,-10,10);
00452   hResidualLocalXCSC_ME[7]=fs->make<TH1F>("hResidualLocalXCSC_ME-1/2","hResidualLocalXCSC_ME-1/2",200,-10,10);
00453   hResidualLocalPhiCSC_ME[7]=fs->make<TH1F>("hResidualLocalPhiCSC_ME-1/2","hResidualLocalPhiCSC_ME-1/2",200,-1,1);
00454   hResidualLocalThetaCSC_ME[7]=fs->make<TH1F>("hResidualLocalThetaCSC_ME-1/2","hResidualLocalThetaCSC_ME-1/2",200,-1,1);
00455   hResidualLocalYCSC_ME[7] = fs->make<TH1F>("hResidualLocalYCSC_ME-1/2","hResidualLocalYCSC_ME-1/2",200,-10,10);
00456   hResidualLocalXCSC_ME[8]=fs->make<TH1F>("hResidualLocalXCSC_ME-1/3","hResidualLocalXCSC_ME-1/3",200,-10,10);
00457   hResidualLocalPhiCSC_ME[8]=fs->make<TH1F>("hResidualLocalPhiCSC_ME-1/3","hResidualLocalPhiCSC_ME-1/3",200,-1,1);
00458   hResidualLocalThetaCSC_ME[8]=fs->make<TH1F>("hResidualLocalThetaCSC_ME-1/3","hResidualLocalThetaCSC_ME-1/3",200,-1,1);
00459   hResidualLocalYCSC_ME[8] = fs->make<TH1F>("hResidualLocalYCSC_ME-1/3","hResidualLocalYCSC_ME-1/3",200,-10,10);
00460   hResidualLocalXCSC_ME[9]=fs->make<TH1F>("hResidualLocalXCSC_ME1/1","hResidualLocalXCSC_ME1/1",200,-10,10);
00461   hResidualLocalPhiCSC_ME[9]=fs->make<TH1F>("hResidualLocalPhiCSC_ME1/1","hResidualLocalPhiCSC_ME1/1",100,-1,1);
00462   hResidualLocalThetaCSC_ME[9]=fs->make<TH1F>("hResidualLocalThetaCSC_ME1/1","hResidualLocalThetaCSC_ME1/1",200,-1,1);
00463   hResidualLocalYCSC_ME[9] = fs->make<TH1F>("hResidualLocalYCSC_ME1/1","hResidualLocalYCSC_ME1/1",200,-10,10);
00464   hResidualLocalXCSC_ME[10]=fs->make<TH1F>("hResidualLocalXCSC_ME1/2","hResidualLocalXCSC_ME1/2",200,-10,10);
00465   hResidualLocalPhiCSC_ME[10]=fs->make<TH1F>("hResidualLocalPhiCSC_ME1/2","hResidualLocalPhiCSC_ME1/2",200,-1,1);
00466   hResidualLocalThetaCSC_ME[10]=fs->make<TH1F>("hResidualLocalThetaCSC_ME1/2","hResidualLocalThetaCSC_ME1/2",200,-1,1);
00467   hResidualLocalYCSC_ME[10] = fs->make<TH1F>("hResidualLocalYCSC_ME1/2","hResidualLocalYCSC_ME1/2",200,-10,10);
00468   hResidualLocalXCSC_ME[11]=fs->make<TH1F>("hResidualLocalXCSC_ME1/3","hResidualLocalXCSC_ME1/3",200,-10,10);
00469   hResidualLocalPhiCSC_ME[11]=fs->make<TH1F>("hResidualLocalPhiCSC_ME1/3","hResidualLocalPhiCSC_ME1/3",200,-1,1);
00470   hResidualLocalThetaCSC_ME[11]=fs->make<TH1F>("hResidualLocalThetaCSC_ME1/3","hResidualLocalThetaCSC_ME1/3",200,-1,1);
00471   hResidualLocalYCSC_ME[11] = fs->make<TH1F>("hResidualLocalYCSC_ME1/3","hResidualLocalYCSC_ME1/3",200,-10,10);
00472   hResidualLocalXCSC_ME[12]=fs->make<TH1F>("hResidualLocalXCSC_ME2/1","hResidualLocalXCSC_ME2/1",200,-10,10);
00473   hResidualLocalPhiCSC_ME[12]=fs->make<TH1F>("hResidualLocalPhiCSC_ME2/1","hResidualLocalPhiCSC_ME2/1",200,-1,1);
00474   hResidualLocalThetaCSC_ME[12]=fs->make<TH1F>("hResidualLocalThetaCSC_ME2/1","hResidualLocalThetaCSC_ME2/1",200,-1,1);
00475   hResidualLocalYCSC_ME[12] = fs->make<TH1F>("hResidualLocalYCSC_ME2/1","hResidualLocalYCSC_ME2/1",200,-10,10);
00476   hResidualLocalXCSC_ME[13]=fs->make<TH1F>("hResidualLocalXCSC_ME2/2","hResidualLocalXCSC_ME2/2",200,-10,10);
00477   hResidualLocalPhiCSC_ME[13]=fs->make<TH1F>("hResidualLocalPhiCSC_ME2/2","hResidualLocalPhiCSC_ME2/2",200,-1,1);
00478   hResidualLocalThetaCSC_ME[13]=fs->make<TH1F>("hResidualLocalThetaCSC_ME2/2","hResidualLocalThetaCSC_ME2/2",200,-1,1);
00479   hResidualLocalYCSC_ME[13] = fs->make<TH1F>("hResidualLocalYCSC_ME2/2","hResidualLocalYCSC_ME2/2",200,-10,10);
00480   hResidualLocalXCSC_ME[14]=fs->make<TH1F>("hResidualLocalXCSC_ME3/1","hResidualLocalXCSC_ME3/1",200,-10,10);
00481   hResidualLocalPhiCSC_ME[14]=fs->make<TH1F>("hResidualLocalPhiCSC_ME3/1","hResidualLocalPhiCSC_ME3/1",200,-1,1);
00482   hResidualLocalThetaCSC_ME[14]=fs->make<TH1F>("hResidualLocalThetaCSC_ME3/1","hResidualLocalThetaCSC_ME3/1",200,-1,1);
00483   hResidualLocalYCSC_ME[14] = fs->make<TH1F>("hResidualLocalYCSC_ME3/1","hResidualLocalYCSC_ME3/1",200,-10,10);
00484   hResidualLocalXCSC_ME[15]=fs->make<TH1F>("hResidualLocalXCSC_ME3/2","hResidualLocalXCSC_ME3/2",200,-10,10);
00485   hResidualLocalPhiCSC_ME[15]=fs->make<TH1F>("hResidualLocalPhiCSC_ME3/2","hResidualLocalPhiCSC_ME3/2",200,-1,1);
00486   hResidualLocalThetaCSC_ME[15]=fs->make<TH1F>("hResidualLocalThetaCSC_ME3/2","hResidualLocalThetaCSC_ME3/2",200,-1,1);
00487   hResidualLocalYCSC_ME[15] = fs->make<TH1F>("hResidualLocalYCSC_ME3/2","hResidualLocalYCSC_ME3/2",200,-10,10);
00488   hResidualLocalXCSC_ME[16]=fs->make<TH1F>("hResidualLocalXCSC_ME4/1","hResidualLocalXCSC_ME4/1",200,-10,10);
00489   hResidualLocalPhiCSC_ME[16]=fs->make<TH1F>("hResidualLocalPhiCSC_ME4/1","hResidualLocalPhiCSC_ME4/1",200,-1,1);
00490   hResidualLocalThetaCSC_ME[16]=fs->make<TH1F>("hResidualLocalThetaCSC_ME4/1","hResidualLocalThetaCSC_ME4/1",200,-1,1);
00491   hResidualLocalYCSC_ME[16] = fs->make<TH1F>("hResidualLocalYCSC_ME4/1","hResidualLocalYCSC_ME4/1",200,-10,10);
00492   hResidualLocalXCSC_ME[17]=fs->make<TH1F>("hResidualLocalXCSC_ME4/2","hResidualLocalXCSC_ME4/2",200,-10,10);
00493   hResidualLocalPhiCSC_ME[17]=fs->make<TH1F>("hResidualLocalPhiCSC_ME4/2","hResidualLocalPhiCSC_ME4/2",200,-1,1);
00494   hResidualLocalThetaCSC_ME[17]=fs->make<TH1F>("hResidualLocalThetaCSC_ME4/2","hResidualLocalThetaCSC_ME4/2",200,-1,1);
00495   hResidualLocalYCSC_ME[17] = fs->make<TH1F>("hResidualLocalYCSC_ME4/2","hResidualLocalYCSC_ME4/2",200,-10,10);
00496   hResidualGlobalRPhiCSC_ME[0]=fs->make<TH1F>("hResidualGlobalRPhiCSC_ME-4/1","hResidualGlobalRPhiCSC_ME-4/1",200,-10,10);
00497   hResidualGlobalPhiCSC_ME[0]=fs->make<TH1F>("hResidualGlobalPhiCSC_ME-4/1","hResidualGlobalPhiCSC_ME-4/1",200,-1,1);
00498   hResidualGlobalThetaCSC_ME[0]=fs->make<TH1F>("hResidualGlobalThetaCSC_ME-4/1","hResidualGlobalThetaCSC_ME-4/1",200,-1,1);
00499   hResidualGlobalRCSC_ME[0] = fs->make<TH1F>("hResidualGlobalRCSC_ME-4/1","hResidualGlobalRCSC_ME-4/1",200,-10,10);
00500   hResidualGlobalRPhiCSC_ME[1]=fs->make<TH1F>("hResidualGlobalRPhiCSC_ME-4/2","hResidualGlobalRPhiCSC_ME-4/2",200,-10,10);
00501   hResidualGlobalPhiCSC_ME[1]=fs->make<TH1F>("hResidualGlobalPhiCSC_ME-4/2","hResidualGlobalPhiCSC_ME-4/2",200,-1,1);
00502   hResidualGlobalThetaCSC_ME[1]=fs->make<TH1F>("hResidualGlobalThetaCSC_ME-4/2","hResidualGlobalThetaCSC_ME-4/2",200,-1,1);
00503   hResidualGlobalRCSC_ME[1] = fs->make<TH1F>("hResidualGlobalRCSC_ME-4/2","hResidualGlobalRCSC_ME-4/2",200,-10,10);
00504   hResidualGlobalRPhiCSC_ME[2]=fs->make<TH1F>("hResidualGlobalRPhiCSC_ME-3/1","hResidualGlobalRPhiCSC_ME-3/1",200,-10,10);
00505   hResidualGlobalPhiCSC_ME[2]=fs->make<TH1F>("hResidualGlobalPhiCSC_ME-3/1","hResidualGlobalPhiCSC_ME-3/1",200,-1,1);
00506   hResidualGlobalThetaCSC_ME[2]=fs->make<TH1F>("hResidualGlobalThetaCSC_ME-3/1","hResidualGlobalThetaCSC_ME-3/1",200,-1,1);
00507   hResidualGlobalRCSC_ME[2] = fs->make<TH1F>("hResidualGlobalRCSC_ME-3/1","hResidualGlobalRCSC_ME-3/1",200,-10,10);
00508   hResidualGlobalRPhiCSC_ME[3]=fs->make<TH1F>("hResidualGlobalRPhiCSC_ME-3/2","hResidualGlobalRPhiCSC_ME-3/2",200,-10,10);
00509   hResidualGlobalPhiCSC_ME[3]=fs->make<TH1F>("hResidualGlobalPhiCSC_ME-3/2","hResidualGlobalPhiCSC_ME-3/2",200,-1,1);
00510   hResidualGlobalThetaCSC_ME[3]=fs->make<TH1F>("hResidualGlobalThetaCSC_ME-3/2","hResidualGlobalThetaCSC_ME-3/2",200,-1,1);
00511   hResidualGlobalRCSC_ME[3] = fs->make<TH1F>("hResidualGlobalRCSC_ME-3/2","hResidualGlobalRCSC_ME-3/2",200,-10,10);
00512   hResidualGlobalRPhiCSC_ME[4]=fs->make<TH1F>("hResidualGlobalRPhiCSC_ME-2/1","hResidualGlobalRPhiCSC_ME-2/1",200,-10,10);
00513   hResidualGlobalPhiCSC_ME[4]=fs->make<TH1F>("hResidualGlobalPhiCSC_ME-2/1","hResidualGlobalPhiCSC_ME-2/1",200,-1,1);
00514   hResidualGlobalThetaCSC_ME[4]=fs->make<TH1F>("hResidualGlobalThetaCSC_ME-2/1","hResidualGlobalThetaCSC_ME-2/1",200,-1,1);
00515   hResidualGlobalRCSC_ME[4] = fs->make<TH1F>("hResidualGlobalRCSC_ME-2/1","hResidualGlobalRCSC_ME-2/1",200,-10,10);
00516   hResidualGlobalRPhiCSC_ME[5]=fs->make<TH1F>("hResidualGlobalRPhiCSC_ME-2/2","hResidualGlobalRPhiCSC_ME-2/2",200,-10,10);
00517   hResidualGlobalPhiCSC_ME[5]=fs->make<TH1F>("hResidualGlobalPhiCSC_ME-2/2","hResidualGlobalPhiCSC_ME-2/2",200,-1,1);
00518   hResidualGlobalThetaCSC_ME[5]=fs->make<TH1F>("hResidualGlobalThetaCSC_ME-2/2","hResidualGlobalThetaCSC_ME-2/2",200,-1,1);
00519   hResidualGlobalRCSC_ME[5] = fs->make<TH1F>("hResidualGlobalRCSC_ME-2/2","hResidualGlobalRCSC_ME-2/2",200,-10,10);
00520   hResidualGlobalRPhiCSC_ME[6]=fs->make<TH1F>("hResidualGlobalRPhiCSC_ME-1/1","hResidualGlobalRPhiCSC_ME-1/1",200,-10,10);
00521   hResidualGlobalPhiCSC_ME[6]=fs->make<TH1F>("hResidualGlobalPhiCSC_ME-1/1","hResidualGlobalPhiCSC_ME-1/1",200,-1,1);
00522   hResidualGlobalThetaCSC_ME[6]=fs->make<TH1F>("hResidualGlobalThetaCSC_ME-1/1","hResidualGlobalThetaCSC_ME-1/1",200,-1,1);
00523   hResidualGlobalRCSC_ME[6] = fs->make<TH1F>("hResidualGlobalRCSC_ME-1/1","hResidualGlobalRCSC_ME-1/1",200,-10,10);
00524   hResidualGlobalRPhiCSC_ME[7]=fs->make<TH1F>("hResidualGlobalRPhiCSC_ME-1/2","hResidualGlobalRPhiCSC_ME-1/2",200,-10,10);
00525   hResidualGlobalPhiCSC_ME[7]=fs->make<TH1F>("hResidualGlobalPhiCSC_ME-1/2","hResidualGlobalPhiCSC_ME-1/2",200,-1,1);
00526   hResidualGlobalThetaCSC_ME[7]=fs->make<TH1F>("hResidualGlobalThetaCSC_ME-1/2","hResidualGlobalThetaCSC_ME-1/2",200,-1,1);
00527   hResidualGlobalRCSC_ME[7] = fs->make<TH1F>("hResidualGlobalRCSC_ME-1/2","hResidualGlobalRCSC_ME-1/2",200,-10,10);
00528   hResidualGlobalRPhiCSC_ME[8]=fs->make<TH1F>("hResidualGlobalRPhiCSC_ME-1/3","hResidualGlobalRPhiCSC_ME-1/3",200,-10,10);
00529   hResidualGlobalPhiCSC_ME[8]=fs->make<TH1F>("hResidualGlobalPhiCSC_ME-1/3","hResidualGlobalPhiCSC_ME-1/3",200,-1,1);
00530   hResidualGlobalThetaCSC_ME[8]=fs->make<TH1F>("hResidualGlobalThetaCSC_ME-1/3","hResidualGlobalThetaCSC_ME-1/3",200,-1,1);
00531   hResidualGlobalRCSC_ME[8] = fs->make<TH1F>("hResidualGlobalRCSC_ME-1/3","hResidualGlobalRCSC_ME-1/3",200,-10,10);
00532   hResidualGlobalRPhiCSC_ME[9]=fs->make<TH1F>("hResidualGlobalRPhiCSC_ME1/1","hResidualGlobalRPhiCSC_ME1/1",200,-10,10);
00533   hResidualGlobalPhiCSC_ME[9]=fs->make<TH1F>("hResidualGlobalPhiCSC_ME1/1","hResidualGlobalPhiCSC_ME1/1",100,-1,1);
00534   hResidualGlobalThetaCSC_ME[9]=fs->make<TH1F>("hResidualGlobalThetaCSC_ME1/1","hResidualGlobalThetaCSC_ME1/1",200,-1,1);
00535   hResidualGlobalRCSC_ME[9] = fs->make<TH1F>("hResidualGlobalRCSC_ME1/1","hResidualGlobalRCSC_ME1/1",200,-10,10);
00536   hResidualGlobalRPhiCSC_ME[10]=fs->make<TH1F>("hResidualGlobalRPhiCSC_ME1/2","hResidualGlobalRPhiCSC_ME1/2",200,-10,10);
00537   hResidualGlobalPhiCSC_ME[10]=fs->make<TH1F>("hResidualGlobalPhiCSC_ME1/2","hResidualGlobalPhiCSC_ME1/2",200,-1,1);
00538   hResidualGlobalThetaCSC_ME[10]=fs->make<TH1F>("hResidualGlobalThetaCSC_ME1/2","hResidualGlobalThetaCSC_ME1/2",200,-1,1);
00539   hResidualGlobalRCSC_ME[10] = fs->make<TH1F>("hResidualGlobalRCSC_ME1/2","hResidualGlobalRCSC_ME1/2",200,-10,10);
00540   hResidualGlobalRPhiCSC_ME[11]=fs->make<TH1F>("hResidualGlobalRPhiCSC_ME1/3","hResidualGlobalRPhiCSC_ME1/3",200,-10,10);
00541   hResidualGlobalPhiCSC_ME[11]=fs->make<TH1F>("hResidualGlobalPhiCSC_ME1/3","hResidualGlobalPhiCSC_ME1/3",200,-1,1);
00542   hResidualGlobalThetaCSC_ME[11]=fs->make<TH1F>("hResidualGlobalThetaCSC_ME1/3","hResidualGlobalThetaCSC_ME1/3",200,-1,1);
00543   hResidualGlobalRCSC_ME[11] = fs->make<TH1F>("hResidualGlobalRCSC_ME1/3","hResidualGlobalRCSC_ME1/3",200,-10,10);
00544   hResidualGlobalRPhiCSC_ME[12]=fs->make<TH1F>("hResidualGlobalRPhiCSC_ME2/1","hResidualGlobalRPhiCSC_ME2/1",200,-10,10);
00545   hResidualGlobalPhiCSC_ME[12]=fs->make<TH1F>("hResidualGlobalPhiCSC_ME2/1","hResidualGlobalPhiCSC_ME2/1",200,-1,1);
00546   hResidualGlobalThetaCSC_ME[12]=fs->make<TH1F>("hResidualGlobalThetaCSC_ME2/1","hResidualGlobalThetaCSC_ME2/1",200,-1,1);
00547   hResidualGlobalRCSC_ME[12] = fs->make<TH1F>("hResidualGlobalRCSC_ME2/1","hResidualGlobalRCSC_ME2/1",200,-10,10);
00548   hResidualGlobalRPhiCSC_ME[13]=fs->make<TH1F>("hResidualGlobalRPhiCSC_ME2/2","hResidualGlobalRPhiCSC_ME2/2",200,-10,10);
00549   hResidualGlobalPhiCSC_ME[13]=fs->make<TH1F>("hResidualGlobalPhiCSC_ME2/2","hResidualGlobalPhiCSC_ME2/2",200,-1,1);
00550   hResidualGlobalThetaCSC_ME[13]=fs->make<TH1F>("hResidualGlobalThetaCSC_ME2/2","hResidualGlobalThetaCSC_ME2/2",200,-1,1);
00551   hResidualGlobalRCSC_ME[13] = fs->make<TH1F>("hResidualGlobalRCSC_ME2/2","hResidualGlobalRCSC_ME2/2",200,-10,10);
00552   hResidualGlobalRPhiCSC_ME[14]=fs->make<TH1F>("hResidualGlobalRPhiCSC_ME3/1","hResidualGlobalRPhiCSC_ME3/1",200,-10,10);
00553   hResidualGlobalPhiCSC_ME[14]=fs->make<TH1F>("hResidualGlobalPhiCSC_ME3/1","hResidualGlobalPhiCSC_ME3/1",200,-1,1);
00554   hResidualGlobalThetaCSC_ME[14]=fs->make<TH1F>("hResidualGlobalThetaCSC_ME3/1","hResidualGlobalThetaCSC_ME3/1",200,-1,1);
00555   hResidualGlobalRCSC_ME[14] = fs->make<TH1F>("hResidualGlobalRCSC_ME3/1","hResidualGlobalRCSC_ME3/1",200,-10,10);
00556   hResidualGlobalRPhiCSC_ME[15]=fs->make<TH1F>("hResidualGlobalRPhiCSC_ME3/2","hResidualGlobalRPhiCSC_ME3/2",200,-10,10);
00557   hResidualGlobalPhiCSC_ME[15]=fs->make<TH1F>("hResidualGlobalPhiCSC_ME3/2","hResidualGlobalPhiCSC_ME3/2",200,-1,1);
00558   hResidualGlobalThetaCSC_ME[15]=fs->make<TH1F>("hResidualGlobalThetaCSC_ME3/2","hResidualGlobalThetaCSC_ME3/2",200,-1,1);
00559   hResidualGlobalRCSC_ME[15] = fs->make<TH1F>("hResidualGlobalRCSC_ME3/2","hResidualGlobalRCSC_ME3/2",200,-10,10);
00560   hResidualGlobalRPhiCSC_ME[16]=fs->make<TH1F>("hResidualGlobalRPhiCSC_ME4/1","hResidualGlobalRPhiCSC_ME4/1",200,-10,10);
00561   hResidualGlobalPhiCSC_ME[16]=fs->make<TH1F>("hResidualGlobalPhiCSC_ME4/1","hResidualGlobalPhiCSC_ME4/1",200,-1,1);
00562   hResidualGlobalThetaCSC_ME[16]=fs->make<TH1F>("hResidualGlobalThetaCSC_ME4/1","hResidualGlobalThetaCSC_ME4/1",200,-1,1);
00563   hResidualGlobalRCSC_ME[16] = fs->make<TH1F>("hResidualGlobalRCSC_ME4/1","hResidualGlobalRCSC_ME4/1",200,-10,10);
00564   hResidualGlobalRPhiCSC_ME[17]=fs->make<TH1F>("hResidualGlobalRPhiCSC_ME4/2","hResidualGlobalRPhiCSC_ME4/2",200,-10,10);
00565   hResidualGlobalPhiCSC_ME[17]=fs->make<TH1F>("hResidualGlobalPhiCSC_ME4/2","hResidualGlobalPhiCSC_ME4/2",200,-1,1);
00566   hResidualGlobalThetaCSC_ME[17]=fs->make<TH1F>("hResidualGlobalThetaCSC_ME4/2","hResidualGlobalThetaCSC_ME4/2",200,-1,1);
00567   hResidualGlobalRCSC_ME[17] = fs->make<TH1F>("hResidualGlobalRCSC_ME4/2","hResidualGlobalRCSC_ME4/2",200,-10,10);
00568 
00569   //DQM plots: mean residual with RMS as error
00570   hprofLocalXDT=fs->make<TH1F>("hprofLocalXDT","Local X DT", 280,0, 280);
00571   hprofLocalPhiDT=fs->make<TH1F>("hprofLocalPhiDT","Local Phi DT", 280,0, 280);
00572   hprofLocalThetaDT=fs->make<TH1F>("hprofLocalThetaDT","Local Theta DT", 280,0, 280);
00573   hprofLocalYDT=fs->make<TH1F>("hprofLocalYDT","Local Y DT", 280,0, 280);
00574   hprofLocalXCSC=fs->make<TH1F>("hprofLocalXCSC","Local X CSC", 1026,0, 1026);
00575   hprofLocalPhiCSC=fs->make<TH1F>("hprofLocalPhiCSC","Local Phi CSC", 1026,0, 1026);
00576   hprofLocalThetaCSC=fs->make<TH1F>("hprofLocalThetaCSC","Local Theta CSC", 1026,0, 1026);
00577   hprofLocalYCSC=fs->make<TH1F>("hprofLocalYCSC","Local Y CSC", 1026,0, 1026);
00578   hprofGlobalRPhiDT=fs->make<TH1F>("hprofGlobalRPhiDT","Global RPhi DT", 280,0, 280);
00579   hprofGlobalPhiDT=fs->make<TH1F>("hprofGlobalPhiDT","Global Phi DT", 280,0, 280);
00580   hprofGlobalThetaDT=fs->make<TH1F>("hprofGlobalThetaDT","Global Theta DT", 280,0, 280);
00581   hprofGlobalZDT=fs->make<TH1F>("hprofGlobalZDT","Global Z DT", 280,0, 280);
00582   hprofGlobalRPhiCSC=fs->make<TH1F>("hprofGlobalRPhiCSC","Global RPhi CSC", 1026,0, 1026);
00583   hprofGlobalPhiCSC=fs->make<TH1F>("hprofGlobalPhiCSC","Global Phi CSC", 1026,0, 1026);
00584   hprofGlobalThetaCSC=fs->make<TH1F>("hprofGlobalThetaCSC","Global Theta CSC", 1026,0, 1026);
00585   hprofGlobalRCSC=fs->make<TH1F>("hprofGlobalRCSC","Global R CSC", 1026,0, 1026);
00586 
00587   // TH2F histos definition
00588   hprofGlobalPositionDT=fs->make<TH2F>("hprofGlobalPositionDT","Global DT position (cm) absolute MEAN residuals", 14,0, 14,40,0,40);
00589   hprofGlobalAngleDT=fs->make<TH2F>("hprofGlobalAngleDT","Global DT angle (rad) absolute MEAN residuals", 14,0, 14,40,0,40); 
00590   hprofGlobalPositionRmsDT=fs->make<TH2F>("hprofGlobalPositionRmsDT","Global DT position (cm) RMS residuals", 14,0, 14,40,0,40);
00591   hprofGlobalAngleRmsDT=fs->make<TH2F>("hprofGlobalAngleRmsDT","Global DT angle (rad) RMS residuals", 14,0, 14,40,0,40); 
00592   hprofLocalPositionDT=fs->make<TH2F>("hprofLocalPositionDT","Local DT position (cm) absolute MEAN residuals", 14,0, 14,40,0,40);
00593   hprofLocalAngleDT=fs->make<TH2F>("hprofLocalAngleDT","Local DT angle (rad) absolute MEAN residuals", 14,0, 14,40,0,40); 
00594   hprofLocalPositionRmsDT=fs->make<TH2F>("hprofLocalPositionRmsDT","Local DT position (cm) RMS residuals", 14,0, 14,40,0,40);
00595   hprofLocalAngleRmsDT=fs->make<TH2F>("hprofLocalAngleRmsDT","Local DT angle (rad) RMS residuals", 14,0, 14,40,0,40); 
00596 
00597   hprofGlobalPositionCSC=fs->make<TH2F>("hprofGlobalPositionCSC","Global CSC position (cm) absolute MEAN residuals", 36,0,36,36,0,36);
00598   hprofGlobalAngleCSC=fs->make<TH2F>("hprofGlobalAngleCSC","Global CSC angle (rad) absolute MEAN residuals", 36,0,36,36,0,36); 
00599   hprofGlobalPositionRmsCSC=fs->make<TH2F>("hprofGlobalPositionRmsCSC","Global CSC position (cm) RMS residuals", 36,0,36,36,0,36);
00600   hprofGlobalAngleRmsCSC=fs->make<TH2F>("hprofGlobalAngleRmsCSC","Global CSC angle (rad) RMS residuals", 36,0,36,36,0,36); 
00601   hprofLocalPositionCSC=fs->make<TH2F>("hprofLocalPositionCSC","Local CSC position (cm) absolute MEAN residuals", 36,0,36,36,0,36);
00602   hprofLocalAngleCSC=fs->make<TH2F>("hprofLocalAngleCSC","Local CSC angle (rad) absolute MEAN residuals", 36,0,36,36,0,36); 
00603   hprofLocalPositionRmsCSC=fs->make<TH2F>("hprofLocalPositionRmsCSC","Local CSC position (cm) RMS residuals", 36,0,36,36,0,36);
00604   hprofLocalAngleRmsCSC=fs->make<TH2F>("hprofLocalAngleRmsCSC","Local CSC angle (rad) RMS residuals", 36,0,36,36,0,36); 
00605 
00606   // histos options
00607   hprofGlobalPositionDT->GetYaxis()->SetLabelSize(0.025);
00608   hprofGlobalAngleDT->GetYaxis()->SetLabelSize(0.025);
00609   hprofGlobalPositionDT->GetZaxis()->SetTitle("(cm)");
00610   hprofGlobalAngleDT->GetZaxis()->SetTitle("(rad)");
00611   hprofGlobalPositionRmsDT->GetYaxis()->SetLabelSize(0.025);
00612   hprofGlobalAngleRmsDT->GetYaxis()->SetLabelSize(0.025);
00613   hprofGlobalPositionRmsDT->GetZaxis()->SetTitle("(cm)");
00614   hprofGlobalAngleRmsDT->GetZaxis()->SetTitle("(rad)");
00615   hprofLocalPositionDT->GetYaxis()->SetLabelSize(0.025);
00616   hprofLocalAngleDT->GetYaxis()->SetLabelSize(0.025);
00617   hprofLocalPositionDT->GetZaxis()->SetTitle("(cm)");
00618   hprofLocalAngleDT->GetZaxis()->SetTitle("(rad)");
00619   hprofLocalPositionRmsDT->GetYaxis()->SetLabelSize(0.025);
00620   hprofLocalAngleRmsDT->GetYaxis()->SetLabelSize(0.025);
00621   hprofLocalPositionRmsDT->GetZaxis()->SetTitle("(cm)");
00622   hprofLocalAngleRmsDT->GetZaxis()->SetTitle("(rad)");
00623 
00624   hprofGlobalPositionCSC->GetYaxis()->SetLabelSize(0.025);
00625   hprofGlobalAngleCSC->GetYaxis()->SetLabelSize(0.025);
00626   hprofGlobalPositionCSC->GetZaxis()->SetTitle("(cm)");
00627   hprofGlobalAngleCSC->GetZaxis()->SetTitle("(rad)");
00628   hprofGlobalPositionRmsCSC->GetYaxis()->SetLabelSize(0.025);
00629   hprofGlobalAngleRmsCSC->GetYaxis()->SetLabelSize(0.025);
00630   hprofGlobalPositionRmsCSC->GetZaxis()->SetTitle("(cm)");
00631   hprofGlobalAngleRmsCSC->GetZaxis()->SetTitle("(rad)");
00632   hprofLocalPositionCSC->GetYaxis()->SetLabelSize(0.025);
00633   hprofLocalAngleCSC->GetYaxis()->SetLabelSize(0.025);
00634   hprofLocalPositionCSC->GetZaxis()->SetTitle("(cm)");
00635   hprofLocalAngleCSC->GetZaxis()->SetTitle("(rad)");
00636   hprofLocalPositionRmsCSC->GetYaxis()->SetLabelSize(0.025);
00637   hprofLocalAngleRmsCSC->GetYaxis()->SetLabelSize(0.025);
00638   hprofLocalPositionRmsCSC->GetZaxis()->SetTitle("(cm)");
00639   hprofLocalAngleRmsCSC->GetZaxis()->SetTitle("(rad)");
00640 
00641   char binLabel[15];
00642   for (int i=1;i<15;i++){
00643   sprintf(binLabel, "Sec-%d", i );
00644   hprofGlobalPositionDT->GetXaxis()->SetBinLabel(i,binLabel);
00645   hprofGlobalAngleDT->GetXaxis()->SetBinLabel(i,binLabel);
00646   hprofGlobalPositionRmsDT->GetXaxis()->SetBinLabel(i,binLabel);
00647   hprofGlobalAngleRmsDT->GetXaxis()->SetBinLabel(i,binLabel);
00648   hprofLocalPositionDT->GetXaxis()->SetBinLabel(i,binLabel);
00649   hprofLocalAngleDT->GetXaxis()->SetBinLabel(i,binLabel);
00650   hprofLocalPositionRmsDT->GetXaxis()->SetBinLabel(i,binLabel);
00651   hprofLocalAngleRmsDT->GetXaxis()->SetBinLabel(i,binLabel);
00652   }
00653   
00654   for (int i=1;i<37;i++){
00655   sprintf(binLabel, "Ch-%d", i );
00656   hprofGlobalPositionCSC->GetXaxis()->SetBinLabel(i,binLabel);
00657   hprofGlobalAngleCSC->GetXaxis()->SetBinLabel(i,binLabel);
00658   hprofGlobalPositionRmsCSC->GetXaxis()->SetBinLabel(i,binLabel);
00659   hprofGlobalAngleRmsCSC->GetXaxis()->SetBinLabel(i,binLabel);
00660   hprofLocalPositionCSC->GetXaxis()->SetBinLabel(i,binLabel);
00661   hprofLocalAngleCSC->GetXaxis()->SetBinLabel(i,binLabel);
00662   hprofLocalPositionRmsCSC->GetXaxis()->SetBinLabel(i,binLabel);
00663   hprofLocalAngleRmsCSC->GetXaxis()->SetBinLabel(i,binLabel);
00664   }
00665   
00666   }
00667 
00668 }
00669 
00670 void MuonAlignmentAnalyzer::endJob(){
00671 
00672 
00673     edm::LogInfo("MuonAlignmentAnalyzer")  << "----------------- " << endl << endl;
00674 
00675   if(theDataType == "SimData")
00676     edm::LogInfo("MuonAlignmentAnalyzer")  << "Number of Sim tracks: " << numberOfSimTracks << endl << endl;
00677 
00678   if(doSAplots)
00679     edm::LogInfo("MuonAlignmentAnalyzer")  << "Number of SA Reco tracks: " << numberOfSARecTracks << endl << endl;
00680 
00681   if(doGBplots)
00682   edm::LogInfo("MuonAlignmentAnalyzer")  << "Number of GB Reco tracks: " << numberOfGBRecTracks << endl << endl;
00683 
00684   if(doResplots){
00685 
00686 //  delete thePropagator;
00687 
00688   edm::LogInfo("MuonAlignmentAnalyzer")  << "Number of Hits considered for residuals: " << numberOfHits << endl << endl;
00689 
00690 
00691 
00692   char binLabel[15];
00693 
00694   for(unsigned int i=0 ; i<unitsLocalX.size() ; i++)
00695   {
00696 
00697   TString nameHistoLocalX=unitsLocalX[i]->GetName();
00698 
00699   TString nameHistoLocalPhi=unitsLocalPhi[i]->GetName();
00700 
00701   TString nameHistoLocalTheta=unitsLocalTheta[i]->GetName();
00702 
00703   TString nameHistoLocalY=unitsLocalY[i]->GetName();
00704 
00705   TString nameHistoGlobalRPhi=unitsGlobalRPhi[i]->GetName();
00706 
00707   TString nameHistoGlobalPhi=unitsGlobalPhi[i]->GetName();
00708 
00709   TString nameHistoGlobalTheta=unitsGlobalTheta[i]->GetName();
00710 
00711   TString nameHistoGlobalRZ=unitsGlobalRZ[i]->GetName();
00712 
00713         if (nameHistoLocalX.Contains("MB")) // HistoLocalX DT
00714         {
00715         int wheel, station, sector;
00716 
00717         sscanf(nameHistoLocalX, "ResidualLocalX_W%dMB%1dS%d",&wheel,&station,&sector);
00718 
00719         Int_t nstation=station - 1;
00720         Int_t nwheel=wheel+2;
00721 
00722         Double_t MeanRPhi=unitsLocalX[i]->GetMean();
00723         Double_t ErrorRPhi=unitsLocalX[i]->GetMeanError();
00724 
00725         Int_t xbin=sector+14*nstation+14*4*nwheel;
00726 
00727         sprintf(binLabel, "MB%d/%dS%d", wheel, station, sector );
00728 
00729         hprofLocalXDT->GetYaxis()->SetTitle("X (cm)");
00730         hprofLocalXDT->SetMarkerStyle(21);
00731         hprofLocalXDT->SetMarkerColor(kRed);
00732         hprofLocalXDT->SetBinContent(xbin,MeanRPhi);
00733         hprofLocalXDT->SetBinError(xbin, ErrorRPhi);
00734         hprofLocalXDT->GetXaxis()->SetBinLabel(xbin, binLabel);
00735 
00736         Int_t ybin=1+nwheel*8+nstation*2;
00737         hprofLocalPositionDT->SetBinContent(sector,ybin,fabs(MeanRPhi));
00738         sprintf(binLabel, "MB%d/%d_LocalX",wheel, station );
00739         hprofLocalPositionDT->GetYaxis()->SetBinLabel(ybin,binLabel);
00740         hprofLocalPositionRmsDT->SetBinContent(sector,ybin,ErrorRPhi);
00741         hprofLocalPositionRmsDT->GetYaxis()->SetBinLabel(ybin,binLabel);
00742         }
00743 
00744         if (nameHistoLocalX.Contains("ME")) // HistoLocalX CSC
00745         {
00746 
00747         int station, ring, chamber;
00748 
00749         sscanf(nameHistoLocalX, "ResidualLocalX_ME%dR%1dC%d",&station,&ring,&chamber);
00750 
00751         Double_t MeanRPhi=unitsLocalX[i]->GetMean();
00752         Double_t ErrorRPhi=unitsLocalX[i]->GetMeanError();
00753         Int_t nstation;
00754 
00755         if (station<=-1)
00756         nstation=station+4;
00757         else
00758         nstation=station+3;
00759         
00760         Int_t nring=ring-1;
00761 
00762         Int_t xbin=36*4*nstation+36*nring+chamber;
00763 
00764         sprintf(binLabel, "ME%d/%dC%d", station, ring, chamber );
00765 
00766         hprofLocalXCSC->GetYaxis()->SetTitle("X (cm)");
00767         hprofLocalXCSC->SetMarkerStyle(21);
00768         hprofLocalXCSC->SetMarkerColor(kRed);
00769         hprofLocalXCSC->SetBinContent(xbin,MeanRPhi);
00770         hprofLocalXCSC->SetBinError(xbin, ErrorRPhi);
00771         hprofLocalXCSC->GetXaxis()->SetBinLabel(xbin, binLabel);
00772 
00773         Int_t ybin=abs(station)*2+ring;
00774         if(abs(station)==1) ybin=ring;
00775         if (station>0) ybin=ybin+9;
00776         else ybin = 10 -ybin;
00777         ybin=2*ybin;
00778         hprofLocalPositionCSC->SetBinContent(chamber,ybin,fabs(MeanRPhi));
00779         sprintf(binLabel, "ME%d/%d_LocalX", station,ring );
00780         hprofLocalPositionCSC->GetYaxis()->SetBinLabel(ybin,binLabel);
00781         hprofLocalPositionRmsCSC->SetBinContent(chamber,ybin,ErrorRPhi);
00782         hprofLocalPositionRmsCSC->GetYaxis()->SetBinLabel(ybin,binLabel);
00783         }
00784 
00785         if (nameHistoLocalTheta.Contains("MB")) // HistoLocalTheta DT
00786         {       
00787 
00788         int wheel, station, sector;
00789 
00790         sscanf(nameHistoLocalTheta, "ResidualLocalTheta_W%dMB%1dS%d",&wheel,&station,&sector);
00791 
00792         if(station != 4){
00793         Int_t nstation=station - 1;
00794         Int_t nwheel=wheel+2;
00795 
00796         Double_t MeanTheta=unitsLocalTheta[i]->GetMean();
00797         Double_t ErrorTheta=unitsLocalTheta[i]->GetMeanError();
00798 
00799         Int_t xbin=sector+14*nstation+14*4*nwheel;
00800 
00801         sprintf(binLabel, "MB%d/%dS%d", wheel, station, sector );
00802 
00803         hprofLocalThetaDT->GetYaxis()->SetTitle("Theta (rad)");
00804         hprofLocalThetaDT->SetBinContent(xbin,MeanTheta);
00805         hprofLocalThetaDT->SetBinError(xbin, ErrorTheta);
00806         hprofLocalThetaDT->SetMarkerStyle(21);
00807         hprofLocalThetaDT->SetMarkerColor(kRed);
00808         hprofLocalThetaDT->GetXaxis()->SetBinLabel(xbin, binLabel);
00809 
00810         Int_t ybin=2+nwheel*8+nstation*2;
00811         hprofLocalAngleDT->SetBinContent(sector,ybin,fabs(MeanTheta));
00812         sprintf(binLabel, "MB%d/%d_LocalTheta",wheel,station );
00813         hprofLocalAngleDT->GetYaxis()->SetBinLabel(ybin,binLabel);
00814         hprofLocalAngleRmsDT->SetBinContent(sector,ybin,ErrorTheta);
00815         hprofLocalAngleRmsDT->GetYaxis()->SetBinLabel(ybin,binLabel);
00816         
00817         }
00818         }
00819 
00820         if (nameHistoLocalPhi.Contains("MB")) // HistoLocalPhi DT
00821         {       
00822 
00823         int wheel, station, sector;
00824 
00825         sscanf(nameHistoLocalPhi, "ResidualLocalPhi_W%dMB%1dS%d",&wheel,&station,&sector);
00826 
00827         Int_t nstation=station - 1;
00828         Int_t nwheel=wheel+2;
00829 
00830         Double_t MeanPhi=unitsLocalPhi[i]->GetMean();
00831         Double_t ErrorPhi=unitsLocalPhi[i]->GetMeanError();
00832 
00833         Int_t xbin=sector+14*nstation+14*4*nwheel;
00834 
00835         sprintf(binLabel, "MB%d/%dS%d", wheel, station, sector );
00836 
00837         hprofLocalPhiDT->GetYaxis()->SetTitle("Phi (rad)");
00838         hprofLocalPhiDT->SetBinContent(xbin,MeanPhi);
00839         hprofLocalPhiDT->SetBinError(xbin, ErrorPhi);
00840         hprofLocalPhiDT->SetMarkerStyle(21);
00841         hprofLocalPhiDT->SetMarkerColor(kRed);
00842         hprofLocalPhiDT->GetXaxis()->SetBinLabel(xbin, binLabel);
00843         
00844         Int_t ybin=1+nwheel*8+nstation*2;
00845         hprofLocalAngleDT->SetBinContent(sector,ybin,fabs(MeanPhi));
00846         sprintf(binLabel, "MB%d/%d_LocalPhi", wheel,station );
00847         hprofLocalAngleDT->GetYaxis()->SetBinLabel(ybin,binLabel);
00848         hprofLocalAngleRmsDT->SetBinContent(sector,ybin,ErrorPhi);
00849         hprofLocalAngleRmsDT->GetYaxis()->SetBinLabel(ybin,binLabel);
00850         }
00851 
00852         if (nameHistoLocalPhi.Contains("ME")) // HistoLocalPhi CSC
00853         {
00854 
00855         int station, ring, chamber;
00856 
00857         sscanf(nameHistoLocalPhi, "ResidualLocalPhi_ME%dR%1dC%d",&station,&ring,&chamber);
00858 
00859         Double_t MeanPhi=unitsLocalPhi[i]->GetMean();
00860         Double_t ErrorPhi=unitsLocalPhi[i]->GetMeanError();
00861         Int_t nstation;
00862 
00863         if (station<=-1)
00864         nstation=station+4;
00865         else
00866         nstation=station+3;
00867 
00868         Int_t nring=ring-1;
00869 
00870 
00871         Int_t xbin=36*4*nstation+36*nring+chamber;
00872 
00873         sprintf(binLabel, "ME%d/%dC%d", station, ring, chamber );
00874 
00875         hprofLocalPhiCSC->GetYaxis()->SetTitle("Phi (rad)");
00876         hprofLocalPhiCSC->SetMarkerStyle(21);
00877         hprofLocalPhiCSC->SetMarkerColor(kRed);
00878         hprofLocalPhiCSC->SetBinContent(xbin,MeanPhi);
00879         hprofLocalPhiCSC->SetBinError(xbin, ErrorPhi);
00880         hprofLocalPhiCSC->GetXaxis()->SetBinLabel(xbin, binLabel);
00881 
00882         Int_t ybin=abs(station)*2+ring;
00883         if(abs(station)==1) ybin=ring;
00884         if (station>0) ybin=ybin+9;
00885         else ybin = 10 -ybin;
00886         ybin=2*ybin;
00887         hprofLocalAngleCSC->SetBinContent(chamber,ybin,fabs(MeanPhi));
00888         sprintf(binLabel, "ME%d/%d_LocalPhi", station,ring );
00889         hprofLocalAngleCSC->GetYaxis()->SetBinLabel(ybin,binLabel);
00890         hprofLocalAngleRmsCSC->SetBinContent(chamber,ybin,ErrorPhi);
00891         hprofLocalAngleRmsCSC->GetYaxis()->SetBinLabel(ybin,binLabel);
00892         }
00893 
00894         if (nameHistoLocalTheta.Contains("ME")) // HistoLocalTheta CSC
00895         {
00896 
00897         int station, ring, chamber;
00898 
00899         sscanf(nameHistoLocalTheta, "ResidualLocalTheta_ME%dR%1dC%d",&station,&ring,&chamber);
00900 
00901         Double_t MeanTheta=unitsLocalTheta[i]->GetMean();
00902         Double_t ErrorTheta=unitsLocalTheta[i]->GetMeanError();
00903         Int_t nstation;
00904 
00905         if (station<=-1)
00906         nstation=station+4;
00907         else
00908         nstation=station+3;
00909 
00910         Int_t nring=ring-1;
00911 
00912 
00913         Int_t xbin=36*4*nstation+36*nring+chamber;
00914 
00915         sprintf(binLabel, "ME%d/%dC%d", station, ring, chamber );
00916 
00917         hprofLocalThetaCSC->GetYaxis()->SetTitle("Theta (rad)");
00918         hprofLocalThetaCSC->SetMarkerStyle(21);
00919         hprofLocalThetaCSC->SetMarkerColor(kRed);
00920         hprofLocalThetaCSC->SetBinContent(xbin,MeanTheta);
00921         hprofLocalThetaCSC->SetBinError(xbin, ErrorTheta);
00922         hprofLocalThetaCSC->GetXaxis()->SetBinLabel(xbin, binLabel);
00923 
00924         Int_t ybin=abs(station)*2+ring;
00925         if(abs(station)==1) ybin=ring;
00926         if (station>0) ybin=ybin+9;
00927         else ybin = 10 -ybin;
00928         ybin=2*ybin+1;
00929         hprofLocalAngleCSC->SetBinContent(chamber,ybin,fabs(MeanTheta));
00930         sprintf(binLabel, "ME%d/%d_LocalTheta", station,ring );
00931         hprofLocalAngleCSC->GetYaxis()->SetBinLabel(ybin,binLabel);
00932         hprofLocalAngleRmsCSC->SetBinContent(chamber,ybin,ErrorTheta);
00933         hprofLocalAngleRmsCSC->GetYaxis()->SetBinLabel(ybin,binLabel);
00934         }
00935 
00936         if (nameHistoLocalY.Contains("MB")) // HistoLocalY DT
00937         {
00938 
00939         int wheel, station, sector;
00940 
00941         sscanf(nameHistoLocalY, "ResidualLocalY_W%dMB%1dS%d",&wheel,&station,&sector);
00942 
00943         if(station!=4){
00944         Int_t nstation=station - 1;
00945         Int_t nwheel=wheel+2;
00946 
00947         Double_t MeanZ=unitsLocalY[i]->GetMean();
00948         Double_t ErrorZ=unitsLocalY[i]->GetMeanError();
00949 
00950         Int_t xbin=sector+14*nstation+14*4*nwheel;
00951 
00952         sprintf(binLabel, "MB%d/%dS%d", wheel, station, sector );
00953 
00954         hprofLocalYDT->GetYaxis()->SetTitle("Y (cm)");
00955         hprofLocalYDT->SetMarkerStyle(21);
00956         hprofLocalYDT->SetMarkerColor(kRed);
00957         hprofLocalYDT->SetBinContent(xbin,MeanZ);
00958         hprofLocalYDT->SetBinError(xbin, ErrorZ);
00959         hprofLocalYDT->GetXaxis()->SetBinLabel(xbin, binLabel);
00960 
00961         Int_t ybin=2+nwheel*8+nstation*2;
00962         hprofLocalPositionDT->SetBinContent(sector,ybin,fabs(MeanZ));
00963         sprintf(binLabel, "MB%d/%d_LocalY", wheel,station );
00964         hprofLocalPositionDT->GetYaxis()->SetBinLabel(ybin,binLabel);
00965         hprofLocalPositionRmsDT->SetBinContent(sector,ybin,ErrorZ);
00966         hprofLocalPositionRmsDT->GetYaxis()->SetBinLabel(ybin,binLabel);
00967         }
00968         }
00969 
00970         if (nameHistoLocalY.Contains("ME")) // HistoLocalY CSC
00971         {
00972 
00973         int station, ring, chamber;
00974 
00975         sscanf(nameHistoLocalY, "ResidualLocalY_ME%dR%1dC%d",&station,&ring,&chamber);
00976 
00977         Double_t MeanR=unitsLocalY[i]->GetMean();
00978         Double_t ErrorR=unitsLocalY[i]->GetMeanError();
00979         Int_t nstation;
00980 
00981         if (station<=-1)
00982         nstation=station+4;
00983         else
00984         nstation=station+3;
00985 
00986         Int_t nring=ring-1;
00987 
00988 
00989         Int_t xbin=36*4*nstation+36*nring+chamber;
00990 
00991         sprintf(binLabel, "ME%d/%dC%d", station, ring, chamber );
00992 
00993         hprofLocalYCSC->GetYaxis()->SetTitle("Y (cm)");
00994         hprofLocalYCSC->SetMarkerStyle(21);
00995         hprofLocalYCSC->SetMarkerColor(kRed);
00996         hprofLocalYCSC->SetBinContent(xbin,MeanR);
00997         hprofLocalYCSC->SetBinError(xbin, ErrorR);
00998         hprofLocalYCSC->GetXaxis()->SetBinLabel(xbin, binLabel);
00999 
01000         Int_t ybin=abs(station)*2+ring;
01001         if(abs(station)==1) ybin=ring;
01002         if (station>0) ybin=ybin+9;
01003         else ybin = 10 -ybin;
01004         ybin=2*ybin+1;
01005         hprofLocalPositionCSC->SetBinContent(chamber,ybin,fabs(MeanR));
01006         sprintf(binLabel, "ME%d/%d_LocalY", station,ring );
01007         hprofLocalPositionCSC->GetYaxis()->SetBinLabel(ybin,binLabel);
01008         hprofLocalPositionRmsCSC->SetBinContent(chamber,ybin,ErrorR);
01009         hprofLocalPositionRmsCSC->GetYaxis()->SetBinLabel(ybin,binLabel);
01010         }
01011 
01012         if (nameHistoGlobalRPhi.Contains("MB")) // HistoGlobalRPhi DT
01013         {
01014         int wheel, station, sector;
01015 
01016         sscanf(nameHistoGlobalRPhi, "ResidualGlobalRPhi_W%dMB%1dS%d",&wheel,&station,&sector);
01017 
01018         Int_t nstation=station - 1;
01019         Int_t nwheel=wheel+2;
01020 
01021         Double_t MeanRPhi=unitsGlobalRPhi[i]->GetMean();
01022         Double_t ErrorRPhi=unitsGlobalRPhi[i]->GetMeanError();
01023 
01024         Int_t xbin=sector+14*nstation+14*4*nwheel;
01025 
01026         sprintf(binLabel, "MB%d/%dS%d", wheel, station, sector );
01027 
01028         hprofGlobalRPhiDT->GetYaxis()->SetTitle("RPhi (cm)");
01029         hprofGlobalRPhiDT->SetMarkerStyle(21);
01030         hprofGlobalRPhiDT->SetMarkerColor(kRed);
01031         hprofGlobalRPhiDT->SetBinContent(xbin,MeanRPhi);
01032         hprofGlobalRPhiDT->SetBinError(xbin, ErrorRPhi);
01033         hprofGlobalRPhiDT->GetXaxis()->SetBinLabel(xbin, binLabel);
01034 
01035         Int_t ybin=1+nwheel*8+nstation*2;
01036         hprofGlobalPositionDT->SetBinContent(sector,ybin,fabs(MeanRPhi));
01037         sprintf(binLabel, "MB%d/%d_GlobalRPhi", wheel,station );
01038         hprofGlobalPositionDT->GetYaxis()->SetBinLabel(ybin,binLabel);
01039         hprofGlobalPositionRmsDT->SetBinContent(sector,ybin,ErrorRPhi);
01040         hprofGlobalPositionRmsDT->GetYaxis()->SetBinLabel(ybin,binLabel);
01041         }
01042 
01043         if (nameHistoGlobalRPhi.Contains("ME")) // HistoGlobalRPhi CSC
01044         {
01045 
01046         int station, ring, chamber;
01047 
01048         sscanf(nameHistoGlobalRPhi, "ResidualGlobalRPhi_ME%dR%1dC%d",&station,&ring,&chamber);
01049 
01050         Double_t MeanRPhi=unitsGlobalRPhi[i]->GetMean();
01051         Double_t ErrorRPhi=unitsGlobalRPhi[i]->GetMeanError();
01052         Int_t nstation;
01053 
01054         if (station<=-1)
01055         nstation=station+4;
01056         else
01057         nstation=station+3;
01058         
01059         Int_t nring=ring-1;
01060 
01061         Int_t xbin=36*4*nstation+36*nring+chamber;
01062 
01063         sprintf(binLabel, "ME%d/%dC%d", station, ring, chamber );
01064 
01065         hprofGlobalRPhiCSC->GetYaxis()->SetTitle("RPhi (cm)");
01066         hprofGlobalRPhiCSC->SetMarkerStyle(21);
01067         hprofGlobalRPhiCSC->SetMarkerColor(kRed);
01068         hprofGlobalRPhiCSC->SetBinContent(xbin,MeanRPhi);
01069         hprofGlobalRPhiCSC->SetBinError(xbin, ErrorRPhi);
01070         hprofGlobalRPhiCSC->GetXaxis()->SetBinLabel(xbin, binLabel);
01071 
01072         Int_t ybin=abs(station)*2+ring;
01073         if(abs(station)==1) ybin=ring;
01074         if (station>0) ybin=ybin+9;
01075         else ybin = 10 -ybin;
01076         ybin=2*ybin;
01077         hprofGlobalPositionCSC->SetBinContent(chamber,ybin,fabs(MeanRPhi));
01078         sprintf(binLabel, "ME%d/%d_GlobalRPhi", station,ring );
01079         hprofGlobalPositionCSC->GetYaxis()->SetBinLabel(ybin,binLabel);
01080         hprofGlobalPositionRmsCSC->SetBinContent(chamber,ybin,ErrorRPhi);
01081         hprofGlobalPositionRmsCSC->GetYaxis()->SetBinLabel(ybin,binLabel);
01082         }
01083 
01084         if (nameHistoGlobalTheta.Contains("MB")) // HistoGlobalRTheta DT
01085         {       
01086 
01087         int wheel, station, sector;
01088 
01089         sscanf(nameHistoGlobalTheta, "ResidualGlobalTheta_W%dMB%1dS%d",&wheel,&station,&sector);
01090 
01091         if(station!=4){
01092         Int_t nstation=station - 1;
01093         Int_t nwheel=wheel+2;
01094 
01095         Double_t MeanTheta=unitsGlobalTheta[i]->GetMean();
01096         Double_t ErrorTheta=unitsGlobalTheta[i]->GetMeanError();
01097 
01098         Int_t xbin=sector+14*nstation+14*4*nwheel;
01099 
01100         sprintf(binLabel, "MB%d/%dS%d", wheel, station, sector );
01101 
01102         hprofGlobalThetaDT->GetYaxis()->SetTitle("Theta (rad)");
01103         hprofGlobalThetaDT->SetBinContent(xbin,MeanTheta);
01104         hprofGlobalThetaDT->SetBinError(xbin, ErrorTheta);
01105         hprofGlobalThetaDT->SetMarkerStyle(21);
01106         hprofGlobalThetaDT->SetMarkerColor(kRed);
01107         hprofGlobalThetaDT->GetXaxis()->SetBinLabel(xbin, binLabel);
01108 
01109         Int_t ybin=2+nwheel*8+nstation*2;
01110         hprofGlobalAngleDT->SetBinContent(sector,ybin,fabs(MeanTheta));
01111         sprintf(binLabel, "MB%d/%d_GlobalTheta", wheel,station );
01112         hprofGlobalAngleDT->GetYaxis()->SetBinLabel(ybin,binLabel);
01113         hprofGlobalAngleRmsDT->SetBinContent(sector,ybin,ErrorTheta);
01114         hprofGlobalAngleRmsDT->GetYaxis()->SetBinLabel(ybin,binLabel);
01115         }
01116         }
01117 
01118         if (nameHistoGlobalPhi.Contains("MB")) // HistoGlobalPhi DT
01119         {       
01120 
01121         int wheel, station, sector;
01122 
01123         sscanf(nameHistoGlobalPhi, "ResidualGlobalPhi_W%dMB%1dS%d",&wheel,&station,&sector);
01124 
01125         Int_t nstation=station - 1;
01126         Int_t nwheel=wheel+2;
01127 
01128         Double_t MeanPhi=unitsGlobalPhi[i]->GetMean();
01129         Double_t ErrorPhi=unitsGlobalPhi[i]->GetMeanError();
01130 
01131         Int_t xbin=sector+14*nstation+14*4*nwheel;
01132 
01133         sprintf(binLabel, "MB%d/%dS%d", wheel, station, sector );
01134 
01135         hprofGlobalPhiDT->GetYaxis()->SetTitle("Phi (rad)");
01136         hprofGlobalPhiDT->SetBinContent(xbin,MeanPhi);
01137         hprofGlobalPhiDT->SetBinError(xbin, ErrorPhi);
01138         hprofGlobalPhiDT->SetMarkerStyle(21);
01139         hprofGlobalPhiDT->SetMarkerColor(kRed);
01140         hprofGlobalPhiDT->GetXaxis()->SetBinLabel(xbin, binLabel);
01141 
01142         Int_t ybin=1+nwheel*8+nstation*2;
01143         hprofGlobalAngleDT->SetBinContent(sector,ybin,fabs(MeanPhi));
01144         sprintf(binLabel, "MB%d/%d_GlobalPhi", wheel,station );
01145         hprofGlobalAngleDT->GetYaxis()->SetBinLabel(ybin,binLabel);
01146         hprofGlobalAngleRmsDT->SetBinContent(sector,ybin,ErrorPhi);
01147         hprofGlobalAngleRmsDT->GetYaxis()->SetBinLabel(ybin,binLabel);
01148         }
01149 
01150         if (nameHistoGlobalPhi.Contains("ME")) // HistoGlobalPhi CSC
01151         {
01152 
01153         int station, ring, chamber;
01154 
01155         sscanf(nameHistoGlobalPhi, "ResidualGlobalPhi_ME%dR%1dC%d",&station,&ring,&chamber);
01156 
01157         Double_t MeanPhi=unitsGlobalPhi[i]->GetMean();
01158         Double_t ErrorPhi=unitsGlobalPhi[i]->GetMeanError();
01159         Int_t nstation;
01160 
01161         if (station<=-1)
01162         nstation=station+4;
01163         else
01164         nstation=station+3;
01165 
01166         Int_t nring=ring-1;
01167 
01168 
01169         Int_t xbin=36*4*nstation+36*nring+chamber;
01170 
01171         sprintf(binLabel, "ME%d/%dC%d", station, ring, chamber );
01172 
01173         hprofGlobalPhiCSC->GetYaxis()->SetTitle("Phi (rad)");
01174         hprofGlobalPhiCSC->SetMarkerStyle(21);
01175         hprofGlobalPhiCSC->SetMarkerColor(kRed);
01176         hprofGlobalPhiCSC->SetBinContent(xbin,MeanPhi);
01177         hprofGlobalPhiCSC->SetBinError(xbin, ErrorPhi);
01178         hprofGlobalPhiCSC->GetXaxis()->SetBinLabel(xbin, binLabel);
01179 
01180         Int_t ybin=abs(station)*2+ring;
01181         if(abs(station)==1) ybin=ring;
01182         if (station>0) ybin=ybin+9;
01183         else ybin = 10 -ybin;
01184         ybin=2*ybin;
01185         hprofGlobalAngleCSC->SetBinContent(chamber,ybin,fabs(MeanPhi));
01186         sprintf(binLabel, "ME%d/%d_GlobalPhi", station,ring );
01187         hprofGlobalAngleCSC->GetYaxis()->SetBinLabel(ybin,binLabel);
01188         hprofGlobalAngleRmsCSC->SetBinContent(chamber,ybin,ErrorPhi);
01189         hprofGlobalAngleRmsCSC->GetYaxis()->SetBinLabel(ybin,binLabel);
01190         }
01191 
01192         if (nameHistoGlobalTheta.Contains("ME")) // HistoGlobalTheta CSC
01193         {
01194 
01195         int station, ring, chamber;
01196 
01197         sscanf(nameHistoGlobalTheta, "ResidualGlobalTheta_ME%dR%1dC%d",&station,&ring,&chamber);
01198 
01199         Double_t MeanTheta=unitsGlobalTheta[i]->GetMean();
01200         Double_t ErrorTheta=unitsGlobalTheta[i]->GetMeanError();
01201         Int_t nstation;
01202 
01203         if (station<=-1)
01204         nstation=station+4;
01205         else
01206         nstation=station+3;
01207 
01208         Int_t nring=ring-1;
01209 
01210         Int_t xbin=36*4*nstation+36*nring+chamber;
01211 
01212         sprintf(binLabel, "ME%d/%dC%d", station, ring, chamber );
01213 
01214         hprofGlobalThetaCSC->GetYaxis()->SetTitle("Theta (rad)");
01215         hprofGlobalThetaCSC->SetMarkerStyle(21);
01216         hprofGlobalThetaCSC->SetMarkerColor(kRed);
01217         hprofGlobalThetaCSC->SetBinContent(xbin,MeanTheta);
01218         hprofGlobalThetaCSC->SetBinError(xbin, ErrorTheta);
01219         hprofGlobalThetaCSC->GetXaxis()->SetBinLabel(xbin, binLabel);
01220 
01221         Int_t ybin=abs(station)*2+ring;
01222         if(abs(station)==1) ybin=ring;
01223         if (station>0) ybin=ybin+9;
01224         else ybin = 10 -ybin;
01225         ybin=2*ybin+1;
01226         hprofGlobalAngleCSC->SetBinContent(chamber,ybin,fabs(MeanTheta));
01227         sprintf(binLabel, "ME%d/%d_GlobalTheta", station,ring );
01228         hprofGlobalAngleCSC->GetYaxis()->SetBinLabel(ybin,binLabel);
01229         hprofGlobalAngleRmsCSC->SetBinContent(chamber,ybin,ErrorTheta);
01230         hprofGlobalAngleRmsCSC->GetYaxis()->SetBinLabel(ybin,binLabel);
01231         }
01232 
01233         if (nameHistoGlobalRZ.Contains("MB")) // HistoGlobalZ DT
01234         {
01235 
01236         int wheel, station, sector;
01237 
01238         sscanf(nameHistoGlobalRZ, "ResidualGlobalZ_W%dMB%1dS%d",&wheel,&station,&sector);
01239         
01240         if(station!=4){
01241         Int_t nstation=station - 1;
01242         Int_t nwheel=wheel+2;
01243 
01244         Double_t MeanZ=unitsGlobalRZ[i]->GetMean();
01245         Double_t ErrorZ=unitsGlobalRZ[i]->GetMeanError();
01246 
01247         Int_t xbin=sector+14*nstation+14*4*nwheel;
01248 
01249         sprintf(binLabel, "MB%d/%dS%d", wheel, station, sector );
01250 
01251         hprofGlobalZDT->GetYaxis()->SetTitle("Z (cm)");
01252         hprofGlobalZDT->SetMarkerStyle(21);
01253         hprofGlobalZDT->SetMarkerColor(kRed);
01254 
01255         hprofGlobalZDT->SetBinContent(xbin,MeanZ);
01256         hprofGlobalZDT->SetBinError(xbin, ErrorZ);
01257         hprofGlobalZDT->GetXaxis()->SetBinLabel(xbin, binLabel);
01258 
01259         Int_t ybin=2+nwheel*8+nstation*2;
01260         hprofGlobalPositionDT->SetBinContent(sector,ybin,fabs(MeanZ));
01261         sprintf(binLabel, "MB%d/%d_GlobalZ", wheel,station );
01262         hprofGlobalPositionDT->GetYaxis()->SetBinLabel(ybin,binLabel);
01263         hprofGlobalPositionRmsDT->SetBinContent(sector,ybin,ErrorZ);
01264         hprofGlobalPositionRmsDT->GetYaxis()->SetBinLabel(ybin,binLabel);
01265         }
01266         }
01267 
01268         if (nameHistoGlobalRZ.Contains("ME")) // HistoGlobalR CSC
01269         {
01270 
01271         int station, ring, chamber;
01272 
01273         sscanf(nameHistoGlobalRZ, "ResidualGlobalR_ME%dR%1dC%d",&station,&ring,&chamber);
01274 
01275         Double_t MeanR=unitsGlobalRZ[i]->GetMean();
01276         Double_t ErrorR=unitsGlobalRZ[i]->GetMeanError();
01277         Int_t nstation;
01278 
01279         if (station<=-1)
01280         nstation=station+4;
01281         else
01282         nstation=station+3;
01283 
01284         Int_t nring=ring-1;
01285 
01286         Int_t xbin=36*4*nstation+36*nring+chamber;
01287 
01288         sprintf(binLabel, "ME%d/%dC%d", station, ring, chamber );
01289 
01290         hprofGlobalRCSC->GetYaxis()->SetTitle("R (cm)");
01291         hprofGlobalRCSC->SetMarkerStyle(21);
01292         hprofGlobalRCSC->SetMarkerColor(kRed);
01293         hprofGlobalRCSC->SetBinContent(xbin,MeanR);
01294         hprofGlobalRCSC->SetBinError(xbin, ErrorR);
01295         hprofGlobalRCSC->GetXaxis()->SetBinLabel(xbin, binLabel);
01296 
01297         Int_t ybin=abs(station)*2+ring;
01298         if(abs(station)==1) ybin=ring;
01299         if (station>0) ybin=ybin+9;
01300         else ybin = 10 -ybin;
01301         ybin=2*ybin+1;
01302         hprofGlobalPositionCSC->SetBinContent(chamber,ybin,fabs(MeanR));
01303         sprintf(binLabel, "ME%d/%d_GlobalR", station,ring );
01304         hprofGlobalPositionCSC->GetYaxis()->SetBinLabel(ybin,binLabel);
01305         hprofGlobalPositionRmsCSC->SetBinContent(chamber,ybin,ErrorR);
01306         hprofGlobalPositionRmsCSC->GetYaxis()->SetBinLabel(ybin,binLabel);
01307         }
01308 
01309     } // for in histos
01310 
01311   } // doResPlots
01312 
01313 }
01314  
01315 
01316 void MuonAlignmentAnalyzer::analyze(const Event & event, const EventSetup& eventSetup){
01317     
01318   GlobalVector p1,p2;
01319   std::vector< double > simPar[4] ; //pt,eta,phi,charge
01320   
01321 
01322 // ######### if data= MC, do Simulation Plots#####
01323   if(theDataType == "SimData"){
01324   double simEta=0;
01325   double simPt=0;
01326   double simPhi=0;
01327   int i=0, ie=0,ib=0;
01328 
01329   // Get the SimTrack collection from the event
01330     Handle<SimTrackContainer> simTracks;
01331     event.getByLabel("g4SimHits",simTracks);
01332   
01333 
01334     SimTrackContainer::const_iterator simTrack;
01335 
01336     for (simTrack = simTracks->begin(); simTrack != simTracks->end(); ++simTrack){
01337       if (abs((*simTrack).type()) == 13) {
01338         i++;
01339         simPt=(*simTrack).momentum().Pt();
01340         simEta=(*simTrack).momentum().eta();
01341         simPhi=(*simTrack).momentum().phi();
01342         numberOfSimTracks++;
01343         hSimPT->Fill(simPt);
01344         if(abs(simEta)<1.04) {hSimPT_Barrel->Fill(simPt);ib++;}
01345         else {hSimPT_Endcap->Fill(simPt);ie++;}
01346         hSimPTvsEta->Fill(simEta,simPt);
01347         hSimPTvsPhi->Fill(simPhi,simPt);
01348         hSimPhivsEta->Fill(simEta,simPhi);
01349 
01350         simPar[0].push_back(simPt);
01351         simPar[1].push_back(simEta);
01352         simPar[2].push_back(simPhi);
01353         simPar[3].push_back((*simTrack).charge());
01354         
01355 //      Save the muon pair
01356         if(i==1)  p1=GlobalVector((*simTrack).momentum().x(),(*simTrack).momentum().y(),(*simTrack).momentum().z());
01357         if(i==2)  p2=GlobalVector((*simTrack).momentum().x(),(*simTrack).momentum().y(),(*simTrack).momentum().z());
01358      }    
01359     }
01360         hSimNmuons->Fill(i);
01361         hSimNmuons_Barrel->Fill(ib);
01362         hSimNmuons_Endcap->Fill(ie);
01363 
01364  if(i>1){ // Take 2 first muons :-(
01365   TLorentzVector mu1(p1.x(), p1.y(), p1.z(), p1.mag());
01366   TLorentzVector mu2(p2.x(), p2.y(), p2.z(), p2.mag());
01367   TLorentzVector pair = mu1 + mu2;
01368   double Minv = pair.M();
01369   hSimInvM->Fill(Minv);
01370   if(abs(p1.eta())<1.04 && abs(p2.eta())<1.04) hSimInvM_Barrel->Fill(Minv);
01371   else if(abs(p1.eta())>=1.04 && abs(p2.eta())>=1.04) hSimInvM_Endcap->Fill(Minv);
01372   else  hSimInvM_Overlap->Fill(Minv);  
01373   }
01374 
01375   } //simData
01376   
01377   
01378 // ############ Stand Alone Muon plots ###############  
01379   if(doSAplots){
01380 
01381   double SArecPt=0.;
01382   double SAeta=0.;
01383   double SAphi=0.;
01384   int i=0, ie=0,ib=0;
01385   double ich=0;
01386 
01387   // Get the RecTrack collection from the event
01388   Handle<reco::TrackCollection> staTracks;
01389   event.getByLabel(theSTAMuonTag, staTracks);
01390   numberOfSARecTracks += staTracks->size();
01391 
01392   reco::TrackCollection::const_iterator staTrack;
01393 
01394   for (staTrack = staTracks->begin(); staTrack != staTracks->end(); ++staTrack){
01395     i++;    
01396     
01397     SArecPt = (*staTrack).pt();
01398     SAeta = (*staTrack).eta();
01399     SAphi = (*staTrack).phi();
01400     ich= (*staTrack).charge();
01401 
01402     hSAPTRec->Fill(SArecPt);
01403     hSAPhivsEta->Fill(SAeta,SAphi);
01404     hSAChi2->Fill((*staTrack).chi2());
01405     hSANhits->Fill((*staTrack).recHitsSize());
01406     if(abs(SAeta)<1.04) {hSAPTRec_Barrel->Fill(SArecPt); hSAChi2_Barrel->Fill((*staTrack).chi2()); hSANhits_Barrel->Fill((*staTrack).recHitsSize()); ib++;}
01407     else {hSAPTRec_Endcap->Fill(SArecPt); hSAChi2_Endcap->Fill((*staTrack).chi2()); hSANhits_Endcap->Fill((*staTrack).recHitsSize()); ie++;}
01408 
01409 // save the muon pair
01410     if(i==1)  p1=GlobalVector((*staTrack).momentum().x(),(*staTrack).momentum().y(),(*staTrack).momentum().z());
01411     if(i==2)  p2=GlobalVector((*staTrack).momentum().x(),(*staTrack).momentum().y(),(*staTrack).momentum().z());
01412 
01413    
01414     if(SArecPt && theDataType == "SimData"){  
01415 
01416      double candDeltaR= -999.0, dR;
01417      int iCand=0;
01418      if(simPar[0].size()>0){
01419      for(unsigned int  iSim = 0; iSim <simPar[0].size(); iSim++) {
01420      dR=deltaR(SAeta,SAphi,simPar[1][iSim],simPar[2][iSim]);
01421      if(candDeltaR<0 || dR<candDeltaR) {
01422         candDeltaR=dR;
01423         iCand=iSim;
01424         }
01425      }}
01426         
01427      double simPt=simPar[0][iCand];
01428       hSAPTres->Fill( (SArecPt-simPt)/simPt);
01429         if(abs(SAeta)<1.04) hSAPTres_Barrel->Fill((SArecPt-simPt)/simPt);
01430         else hSAPTres_Endcap->Fill((SArecPt-simPt)/simPt);
01431 
01432       hSAPTDiff->Fill(SArecPt-simPt);
01433 
01434       hSAPTDiffvsEta->Fill(SAeta,SArecPt-simPt);
01435       hSAPTDiffvsPhi->Fill(SAphi,SArecPt-simPt);
01436         double ptInvRes= ( ich/SArecPt - simPar[3][iCand]/simPt)/ (simPar[3][iCand]/simPt);
01437       hSAinvPTres->Fill( ptInvRes);
01438 
01439       hSAinvPTvsEta->Fill(SAeta,ptInvRes);
01440       hSAinvPTvsPhi->Fill(SAphi,ptInvRes);
01441       hSAinvPTvsNhits->Fill((*staTrack).recHitsSize(),ptInvRes);
01442       }
01443 
01444       hSAPTvsEta->Fill(SAeta,SArecPt);
01445       hSAPTvsPhi->Fill(SAphi,SArecPt);
01446 }
01447 
01448         hSANmuons->Fill(i);
01449         hSANmuons_Barrel->Fill(ib);
01450         hSANmuons_Endcap->Fill(ie);
01451 
01452   if(i>1){ // Take 2 first muons :-(
01453   TLorentzVector mu1(p1.x(), p1.y(), p1.z(), p1.mag());
01454   TLorentzVector mu2(p2.x(), p2.y(), p2.z(), p2.mag());
01455   TLorentzVector pair = mu1 + mu2;
01456   double Minv = pair.M();
01457   hSAInvM->Fill(Minv);
01458   if(abs(p1.eta())<1.04 && abs(p2.eta())<1.04) hSAInvM_Barrel->Fill(Minv);
01459   else if(abs(p1.eta())>=1.04 && abs(p2.eta())>=1.04) hSAInvM_Endcap->Fill(Minv);
01460   else hSAInvM_Overlap->Fill(Minv);
01461   } // 2 first muons
01462 
01463   }//end doSAplots
01464 
01465 
01466 
01467 // ############### Global Muons plots ##########
01468 
01469   if(doGBplots){  
01470   // Get the RecTrack collection from the event
01471   Handle<reco::TrackCollection> glbTracks;
01472   event.getByLabel(theGLBMuonTag, glbTracks);
01473   numberOfGBRecTracks += glbTracks->size();
01474 
01475   double GBrecPt = 0; 
01476   double GBeta = 0;
01477   double GBphi = 0;
01478   double ich =0;
01479   int i=0, ie=0,ib=0;
01480 
01481   reco::TrackCollection::const_iterator glbTrack;
01482 
01483   for (glbTrack = glbTracks->begin(); glbTrack != glbTracks->end(); ++glbTrack){
01484     i++;
01485 
01486     GBrecPt = (*glbTrack).pt(); 
01487     GBeta = (*glbTrack).eta();
01488     GBphi = (*glbTrack).phi();
01489     ich=   (*glbTrack).charge();
01490     
01491     hGBPTRec->Fill(GBrecPt);
01492     hGBPhivsEta->Fill(GBeta,GBphi);
01493     hGBChi2->Fill((*glbTrack).chi2());
01494     hGBNhits->Fill((*glbTrack).recHitsSize());
01495     if(abs(GBeta)<1.04) {hGBPTRec_Barrel->Fill(GBrecPt); hGBChi2_Barrel->Fill((*glbTrack).chi2()); hGBNhits_Barrel->Fill((*glbTrack).recHitsSize()); ib++;}
01496     else {hGBPTRec_Endcap->Fill(GBrecPt); hGBChi2_Endcap->Fill((*glbTrack).chi2()); hGBNhits_Endcap->Fill((*glbTrack).recHitsSize()); ie++;}
01497   
01498 // save the muon pair
01499     if(i==1)  p1=GlobalVector((*glbTrack).momentum().x(),(*glbTrack).momentum().y(),(*glbTrack).momentum().z());
01500     if(i==2)  p2=GlobalVector((*glbTrack).momentum().x(),(*glbTrack).momentum().y(),(*glbTrack).momentum().z());
01501 
01502     if(GBrecPt && theDataType == "SimData"){ 
01503      double candDeltaR= -999.0, dR;
01504      int iCand=0;
01505      if(simPar[0].size()>0){
01506      for(unsigned int  iSim = 0; iSim <simPar[0].size(); iSim++) {
01507      dR=deltaR(GBeta,GBphi,simPar[1][iSim],simPar[2][iSim]);
01508      if(candDeltaR<0 || dR<candDeltaR) {
01509         candDeltaR=dR;
01510         iCand=iSim;
01511         }
01512      }}
01513 
01514      double simPt=simPar[0][iCand];
01515         
01516       hGBPTres->Fill( (GBrecPt-simPt)/simPt);
01517         if(abs(GBeta)<1.04) hGBPTres_Barrel->Fill((GBrecPt-simPt)/simPt);
01518         else hGBPTres_Endcap->Fill((GBrecPt-simPt)/simPt);
01519 
01520       hGBPTDiff->Fill(GBrecPt-simPt);
01521 
01522       hGBPTDiffvsEta->Fill(GBeta,GBrecPt-simPt);
01523       hGBPTDiffvsPhi->Fill(GBphi,GBrecPt-simPt);
01524 
01525        double ptInvRes= ( ich/GBrecPt - simPar[3][iCand]/simPt)/ (simPar[3][iCand]/simPt);
01526       hGBinvPTres->Fill( ptInvRes);
01527 
01528       hGBinvPTvsEta->Fill(GBeta,ptInvRes);
01529       hGBinvPTvsPhi->Fill(GBphi,ptInvRes);
01530       hGBinvPTvsNhits->Fill((*glbTrack).recHitsSize(),ptInvRes);
01531     } 
01532 
01533 
01534       hGBPTvsEta->Fill(GBeta,GBrecPt);
01535       hGBPTvsPhi->Fill(GBphi,GBrecPt);
01536 
01537   }
01538 
01539         hGBNmuons->Fill(i);
01540         hGBNmuons_Barrel->Fill(ib);
01541         hGBNmuons_Endcap->Fill(ie);
01542 
01543    if(i>1){ // Take 2 first muons :-(
01544   TLorentzVector mu1(p1.x(), p1.y(), p1.z(), p1.mag());
01545   TLorentzVector mu2(p2.x(), p2.y(), p2.z(), p2.mag());
01546   TLorentzVector pair = mu1 + mu2;
01547   double Minv = pair.M();
01548   hGBInvM->Fill(Minv);
01549   if(abs(p1.eta())<1.04 && abs(p2.eta())<1.04)   hGBInvM_Barrel->Fill(Minv);
01550   else if(abs(p1.eta())>=1.04 && abs(p2.eta())>=1.04) hGBInvM_Endcap->Fill(Minv);
01551   else hGBInvM_Overlap->Fill(Minv);
01552   }
01553 
01554 } //end doGBplots
01555 
01556 
01557 // ############    Residual plots ###################
01558 
01559  if(doResplots){
01560 
01561   ESHandle<MagneticField> theMGField;
01562   eventSetup.get<IdealMagneticFieldRecord>().get(theMGField);
01563 
01564   ESHandle<GlobalTrackingGeometry> theTrackingGeometry;
01565   eventSetup.get<GlobalTrackingGeometryRecord>().get(theTrackingGeometry);
01566 
01567 
01568   // Get the RecTrack collection from the event
01569   Handle<reco::TrackCollection> staTracks;
01570   event.getByLabel(theSTAMuonTag, staTracks);
01571 
01572   // Get the 4D DTSegments
01573   edm::Handle<DTRecSegment4DCollection> all4DSegmentsDT;
01574   event.getByLabel(theRecHits4DTagDT, all4DSegmentsDT);
01575   DTRecSegment4DCollection::const_iterator segmentDT;
01576 
01577   // Get the 4D CSCSegments
01578   edm::Handle<CSCSegmentCollection> all4DSegmentsCSC;
01579   event.getByLabel(theRecHits4DTagCSC, all4DSegmentsCSC);
01580   CSCSegmentCollection::const_iterator segmentCSC;
01581   
01582    //Vectors used to perform the matching between Segments and hits from Track
01583   intDVector indexCollectionDT;
01584   intDVector indexCollectionCSC;
01585 
01586 /*    cout << "<MuonAlignmentAnalyzer> List of DTSegments found in Local Reconstruction" << endl;
01587     cout << "Number: " << all4DSegmentsDT->size() << endl;
01588     for (segmentDT = all4DSegmentsDT->begin(); segmentDT != all4DSegmentsDT->end(); ++segmentDT){
01589       const GeomDet* geomDet = theTrackingGeometry->idToDet((*segmentDT).geographicalId());
01590       cout << "<MuonAlignmentAnalyzer> " << geomDet->toGlobal((*segmentDT).localPosition()) << endl;
01591       cout << "<MuonAlignmentAnalyzer> Local " << (*segmentDT).localPosition() << std::endl;
01592     }
01593     cout << "<MuonAlignmentAnalyzer> List of CSCSegments found in Local Reconstruction" << endl;
01594     for (segmentCSC = all4DSegmentsCSC->begin(); segmentCSC != all4DSegmentsCSC->end(); ++segmentCSC){
01595       const GeomDet* geomDet = theTrackingGeometry->idToDet((*segmentCSC).geographicalId());
01596       cout << "<MuonAlignmentAnalyzer>" << geomDet->toGlobal((*segmentCSC).localPosition()) << endl;
01597     }
01598 */   
01599   thePropagator = new SteppingHelixPropagator(&*theMGField, alongMomentum);
01600 
01601   reco::TrackCollection::const_iterator staTrack;
01602   for (staTrack = staTracks->begin(); staTrack != staTracks->end(); ++staTrack){
01603 
01604         int countPoints   = 0;
01605 
01606     reco::TransientTrack track(*staTrack,&*theMGField,theTrackingGeometry); 
01607     
01608 
01609      if(staTrack->recHitsSize()>min1DTrackRecHitSize-1) {
01610 
01611     RecHitVector  my4DTrack = this->doMatching(*staTrack, all4DSegmentsDT, all4DSegmentsCSC, &indexCollectionDT, &indexCollectionCSC, theTrackingGeometry);
01612   
01613     
01614 //cut in number of segments
01615 
01616    if(my4DTrack.size()>min4DTrackSegmentSize-1 ){
01617 
01618 // start propagation
01619 //    TrajectoryStateOnSurface innerTSOS = track.impactPointState();
01620     TrajectoryStateOnSurface innerTSOS = track.innermostMeasurementState();
01621 
01622     //If the state is valid
01623     if(innerTSOS.isValid()) {
01624 
01625       //Loop over Associated segments
01626       for(RecHitVector::iterator rechit = my4DTrack.begin(); rechit != my4DTrack.end(); ++rechit) {
01627         
01628         const GeomDet* geomDet = theTrackingGeometry->idToDet((*rechit)->geographicalId());
01629 //Otherwise the propagator could throw an exception
01630     const Plane* pDest = dynamic_cast<const Plane*>(&geomDet->surface());
01631     const Cylinder* cDest = dynamic_cast<const Cylinder*>(&geomDet->surface());
01632 
01633     if(pDest != 0 || cDest != 0) {   //Donde antes iba el try
01634  
01635           TrajectoryStateOnSurface destiny = thePropagator->propagate(*(innerTSOS.freeState()), geomDet->surface());
01636 
01637           if(!destiny.isValid()|| !destiny.hasError()) continue;
01638 
01639 /*          cout << "<MuonAlignmentAnalyzer> Segment: " << geomDet->toGlobal((*rechit)->localPosition()) << endl;
01640             cout << "<MuonAlignmentAnalyzer> Segment local: " << (*rechit)->localPosition() << endl;
01641             cout << "<MuonAlignmentAnalyzer> Predicted: " << destiny.freeState()->position() << endl;
01642             cout << "<MuonAlignmentAnalyzer> Predicted local: " << destiny.localPosition() << endl;
01643 */
01644           const long rawId= (*rechit)->geographicalId().rawId();
01645           int position = -1;
01646           bool newDetector = true; 
01647           //Loop over the DetectorCollection to see if the detector is new and requires a new entry
01648           for(std::vector<long>::iterator myIds = detectorCollection.begin(); myIds != detectorCollection.end(); myIds++) {
01649                 ++position;
01650             //If matches newDetector = false
01651             if(*myIds == rawId) {
01652               newDetector = false;
01653               break;
01654             }
01655           }
01656 
01657             DetId myDet(rawId);
01658             int det = myDet.subdetId();
01659             int wheel=0,station=0,sector=0;
01660             int endcap=0,ring=0,chamber=0;
01661 
01662         double residualGlobalRPhi=0,residualGlobalPhi=0,residualGlobalR=0,residualGlobalTheta=0,residualGlobalZ=0;
01663         double residualLocalX=0,residualLocalPhi=0,residualLocalY=0,residualLocalTheta=0;
01664 
01665         // Fill generic histograms
01666             //If it's a DT
01667             if(det == 1) {
01668               DTChamberId myChamber(rawId);
01669               wheel=myChamber.wheel();
01670               station = myChamber.station();
01671               sector=myChamber.sector();
01672               
01673 //global                
01674                 residualGlobalRPhi = geomDet->toGlobal((*rechit)->localPosition()).perp() * geomDet->toGlobal((*rechit)->localPosition()).barePhi() -   destiny.freeState()->position().perp() * destiny.freeState()->position().barePhi();
01675 
01676 //local
01677                 residualLocalX = (*rechit)->localPosition().x() -destiny.localPosition().x();
01678                 
01679 //global                
01680                 residualGlobalPhi = geomDet->toGlobal(((RecSegment *)(*rechit))->localDirection()).barePhi() - destiny.globalDirection().barePhi();
01681 
01682 //local
01683                 residualLocalPhi = atan2(((RecSegment *)(*rechit))->localDirection().z(), 
01684                   ((RecSegment*)(*rechit))->localDirection().x()) - atan2(destiny.localDirection().z(), destiny.localDirection().x());
01685 
01686                 hResidualGlobalRPhiDT->Fill(residualGlobalRPhi);
01687                 hResidualGlobalPhiDT->Fill(residualGlobalPhi);
01688                 hResidualLocalXDT->Fill(residualLocalX);
01689                 hResidualLocalPhiDT->Fill(residualLocalPhi);
01690 
01691                 if(station!=4){
01692 //global                
01693                 residualGlobalZ = geomDet->toGlobal((*rechit)->localPosition()).z() - destiny.freeState()->position().z();
01694                 
01695 //local
01696                 residualLocalY = (*rechit)->localPosition().y() - destiny.localPosition().y();
01697                 
01698 //global                
01699                 residualGlobalTheta = geomDet->toGlobal(((RecSegment *)(*rechit))->localDirection()).bareTheta() - destiny.globalDirection().bareTheta();
01700 
01701 //local
01702                 residualLocalTheta = atan2(((RecSegment *)(*rechit))->localDirection().z(), 
01703                   ((RecSegment*)(*rechit))->localDirection().y()) - atan2(destiny.localDirection().z(), destiny.localDirection().y());
01704 
01705                 
01706                 hResidualGlobalThetaDT->Fill(residualGlobalTheta);
01707                 hResidualGlobalZDT->Fill(residualGlobalZ);
01708                 hResidualLocalThetaDT->Fill(residualLocalTheta);
01709                 hResidualLocalYDT->Fill(residualLocalY);
01710                 }
01711 
01712                 int index = wheel+2;
01713                 hResidualGlobalRPhiDT_W[index]->Fill(residualGlobalRPhi);
01714                 hResidualGlobalPhiDT_W[index]->Fill(residualGlobalPhi);
01715                 hResidualLocalXDT_W[index]->Fill(residualLocalX);
01716                 hResidualLocalPhiDT_W[index]->Fill(residualLocalPhi);
01717                 if(station!=4){
01718                 hResidualGlobalThetaDT_W[index]->Fill(residualGlobalTheta);
01719                 hResidualGlobalZDT_W[index]->Fill(residualGlobalZ);
01720                 hResidualLocalThetaDT_W[index]->Fill(residualLocalTheta);
01721                 hResidualLocalYDT_W[index]->Fill(residualLocalY);
01722                 }
01723                 
01724                 index=wheel*4+station+7;
01725                 hResidualGlobalRPhiDT_MB[index]->Fill(residualGlobalRPhi);
01726                 hResidualGlobalPhiDT_MB[index]->Fill(residualGlobalPhi);
01727                 hResidualLocalXDT_MB[index]->Fill(residualLocalX);
01728                 hResidualLocalPhiDT_MB[index]->Fill(residualLocalPhi);
01729 
01730                 if(station!=4){               
01731                 hResidualGlobalThetaDT_MB[index]->Fill(residualGlobalTheta);
01732                 hResidualGlobalZDT_MB[index]->Fill(residualGlobalZ);
01733                 hResidualLocalThetaDT_MB[index]->Fill(residualLocalTheta);
01734                 hResidualLocalYDT_MB[index]->Fill(residualLocalY);
01735                 }
01736             } 
01737             else if (det==2){
01738               CSCDetId myChamber(rawId);
01739               endcap= myChamber.endcap();
01740               station = myChamber.station();
01741                 if(endcap==2) station = -station;
01742               ring = myChamber.ring();
01743               chamber=myChamber.chamber();
01744 
01745 
01746 //global                
01747                 residualGlobalRPhi = geomDet->toGlobal((*rechit)->localPosition()).perp() * geomDet->toGlobal((*rechit)->localPosition()).barePhi() -   destiny.freeState()->position().perp() * destiny.freeState()->position().barePhi();
01748 
01749 //local
01750                 residualLocalX = (*rechit)->localPosition().x() -destiny.localPosition().x();
01751                 
01752 //global                
01753                 residualGlobalR = geomDet->toGlobal((*rechit)->localPosition()).perp() - destiny.freeState()->position().perp();
01754                 
01755 //local
01756                 residualLocalY = (*rechit)->localPosition().y() - destiny.localPosition().y();
01757                 
01758 //global                
01759                 residualGlobalPhi = geomDet->toGlobal(((RecSegment *)(*rechit))->localDirection()).barePhi() - destiny.globalDirection().barePhi();
01760 
01761 //local
01762                 residualLocalPhi = atan2(((RecSegment *)(*rechit))->localDirection().y(), 
01763                   ((RecSegment*)(*rechit))->localDirection().x()) - atan2(destiny.localDirection().y(), destiny.localDirection().x());
01764 
01765 //global                
01766                 residualGlobalTheta = geomDet->toGlobal(((RecSegment *)(*rechit))->localDirection()).bareTheta() - destiny.globalDirection().bareTheta();
01767 
01768 //local
01769                 residualLocalTheta = atan2(((RecSegment *)(*rechit))->localDirection().y(), 
01770                   ((RecSegment*)(*rechit))->localDirection().z()) - atan2(destiny.localDirection().y(), destiny.localDirection().z());
01771 
01772                 hResidualGlobalRPhiCSC->Fill(residualGlobalRPhi);
01773                 hResidualGlobalPhiCSC->Fill(residualGlobalPhi);
01774                 hResidualGlobalThetaCSC->Fill(residualGlobalTheta);
01775                 hResidualGlobalRCSC->Fill(residualGlobalR);
01776                 hResidualLocalXCSC->Fill(residualLocalX);
01777                 hResidualLocalPhiCSC->Fill(residualLocalPhi);
01778                 hResidualLocalThetaCSC->Fill(residualLocalTheta);
01779                 hResidualLocalYCSC->Fill(residualLocalY);
01780 
01781                 int index=2*station+ring+7;
01782                 if(station==-1) {index=5+ring;
01783                                 if(ring==4) index=6;}
01784                 if(station==1) {index=8+ring;
01785                                 if(ring==4) index=9;}
01786                 hResidualGlobalRPhiCSC_ME[index]->Fill(residualGlobalRPhi);
01787                 hResidualGlobalPhiCSC_ME[index]->Fill(residualGlobalPhi);
01788                 hResidualGlobalThetaCSC_ME[index]->Fill(residualGlobalTheta);
01789                 hResidualGlobalRCSC_ME[index]->Fill(residualGlobalR);
01790                 hResidualLocalXCSC_ME[index]->Fill(residualLocalX);
01791                 hResidualLocalPhiCSC_ME[index]->Fill(residualLocalPhi);
01792                 hResidualLocalThetaCSC_ME[index]->Fill(residualLocalTheta);
01793                 hResidualLocalYCSC_ME[index]->Fill(residualLocalY);
01794 
01795             }
01796             else{residualGlobalRPhi=0,residualGlobalPhi=0,residualGlobalR=0,residualGlobalTheta=0,residualGlobalZ=0;
01797             residualLocalX=0,residualLocalPhi=0,residualLocalY=0,residualLocalTheta=0,residualLocalY=0;
01798             }
01799 // Fill individual chamber histograms
01800   if(newDetector) {
01801             
01802             //Create an RawIdDetector, fill it and push it into the collection 
01803             detectorCollection.push_back(rawId);
01804 
01805             //This piece of code calculates the range of the residuals
01806             double rangeX = 3.0, rangeY =5.;
01807             switch(abs(station)) {
01808             case 1:
01809               {rangeX = resLocalXRangeStation1; rangeY = resLocalYRangeStation1;}
01810               break;
01811             case 2:
01812               {rangeX = resLocalXRangeStation2; rangeY = resLocalYRangeStation2;}
01813               break;
01814             case 3:
01815               {rangeX = resLocalXRangeStation3; rangeY = resLocalYRangeStation3;}
01816               break;
01817             case 4:
01818               {rangeX = resLocalXRangeStation4; rangeY = resLocalYRangeStation4;}
01819               break;
01820             default:
01821               break;
01822             }
01823 
01824         //create new histograms
01825 
01826             char nameOfHistoLocalX[50];
01827             char nameOfHistoLocalTheta[50];
01828             char nameOfHistoLocalY[50];
01829             char nameOfHistoLocalPhi[50];
01830             char nameOfHistoGlobalRPhi[50];
01831             char nameOfHistoGlobalTheta[50];
01832             char nameOfHistoGlobalR[50];
01833             char nameOfHistoGlobalPhi[50];
01834             char nameOfHistoGlobalZ[50];
01835         
01836             if(det==1){ // DT
01837             sprintf(nameOfHistoLocalX, "ResidualLocalX_W%dMB%1dS%1d",wheel,station,sector );
01838             sprintf(nameOfHistoLocalPhi, "ResidualLocalPhi_W%dMB%1dS%1d",wheel,station,sector);
01839             sprintf(nameOfHistoGlobalRPhi, "ResidualGlobalRPhi_W%dMB%1dS%1d",wheel,station,sector );
01840             sprintf(nameOfHistoGlobalPhi, "ResidualGlobalPhi_W%dMB%1dS%1d",wheel,station,sector);
01841             sprintf(nameOfHistoLocalTheta, "ResidualLocalTheta_W%dMB%1dS%1d",wheel,station,sector);
01842             sprintf(nameOfHistoLocalY, "ResidualLocalY_W%dMB%1dS%1d",wheel,station,sector);
01843             TH1F *histoLocalY = fs->make<TH1F>(nameOfHistoLocalY, nameOfHistoLocalY, nbins, -rangeY, rangeY);
01844             unitsLocalY.push_back(histoLocalY);
01845             sprintf(nameOfHistoGlobalTheta, "ResidualGlobalTheta_W%dMB%1dS%1d",wheel,station,sector);
01846             sprintf(nameOfHistoGlobalZ, "ResidualGlobalZ_W%dMB%1dS%1d",wheel,station,sector);
01847             TH1F *histoGlobalZ = fs->make<TH1F>(nameOfHistoGlobalZ, nameOfHistoGlobalZ, nbins, -rangeY, rangeY);
01848             unitsGlobalRZ.push_back(histoGlobalZ);
01849 
01850             }
01851             else if(det==2){ //CSC
01852             sprintf(nameOfHistoLocalX, "ResidualLocalX_ME%dR%1dC%1d",station,ring,chamber );
01853             sprintf(nameOfHistoLocalPhi, "ResidualLocalPhi_ME%dR%1dC%1d",station,ring,chamber);
01854             sprintf(nameOfHistoLocalTheta, "ResidualLocalTheta_ME%dR%1dC%1d",station,ring,chamber);
01855             sprintf(nameOfHistoLocalY, "ResidualLocalY_ME%dR%1dC%1d",station,ring,chamber);
01856             TH1F *histoLocalY = fs->make<TH1F>(nameOfHistoLocalY, nameOfHistoLocalY, nbins, -rangeY, rangeY);
01857             unitsLocalY.push_back(histoLocalY);
01858             sprintf(nameOfHistoGlobalRPhi, "ResidualGlobalRPhi_ME%dR%1dC%1d",station,ring,chamber );
01859             sprintf(nameOfHistoGlobalPhi, "ResidualGlobalPhi_ME%dR%1dC%1d",station,ring,chamber);
01860             sprintf(nameOfHistoGlobalTheta, "ResidualGlobalTheta_ME%dR%1dC%1d",station,ring,chamber);
01861             sprintf(nameOfHistoGlobalR, "ResidualGlobalR_ME%dR%1dC%1d",station,ring,chamber);
01862             TH1F *histoGlobalR = fs->make<TH1F>(nameOfHistoGlobalR, nameOfHistoGlobalR, nbins, -rangeY, rangeY);
01863             unitsGlobalRZ.push_back(histoGlobalR);
01864             }               
01865             
01866             // Common histos to DT and CSC
01867             TH1F *histoLocalX = fs->make<TH1F>(nameOfHistoLocalX, nameOfHistoLocalX, nbins, -rangeX, rangeX);
01868             TH1F *histoGlobalRPhi = fs->make<TH1F>(nameOfHistoGlobalRPhi, nameOfHistoGlobalRPhi, nbins, -rangeX, rangeX);
01869             TH1F *histoLocalPhi = fs->make<TH1F>(nameOfHistoLocalPhi, nameOfHistoLocalPhi, nbins, -resPhiRange, resPhiRange);
01870             TH1F *histoGlobalPhi = fs->make<TH1F>(nameOfHistoGlobalPhi, nameOfHistoGlobalPhi, nbins, -resPhiRange, resPhiRange);
01871             TH1F *histoGlobalTheta = fs->make<TH1F>(nameOfHistoGlobalTheta, nameOfHistoGlobalTheta, nbins, -resThetaRange, resThetaRange);
01872             TH1F *histoLocalTheta = fs->make<TH1F>(nameOfHistoLocalTheta, nameOfHistoLocalTheta, nbins, -resThetaRange, resThetaRange);
01873 
01874             histoLocalX->Fill(residualLocalX);
01875             histoLocalPhi->Fill(residualLocalPhi);
01876             histoLocalTheta->Fill(residualLocalTheta);  
01877             histoGlobalRPhi->Fill(residualGlobalRPhi);
01878             histoGlobalPhi->Fill(residualGlobalPhi);
01879             histoGlobalTheta->Fill(residualGlobalTheta);        
01880             //Push them into their respective vectors
01881             unitsLocalX.push_back(histoLocalX);
01882             unitsLocalPhi.push_back(histoLocalPhi);
01883             unitsLocalTheta.push_back(histoLocalTheta);
01884             unitsGlobalRPhi.push_back(histoGlobalRPhi);
01885             unitsGlobalPhi.push_back(histoGlobalPhi);
01886             unitsGlobalTheta.push_back(histoGlobalTheta);
01887 
01888             } // new detector
01889             else {
01890             //If the detector was not new, just fill the histogram
01891             unitsLocalX.at(position)->Fill(residualLocalX);
01892             unitsLocalPhi.at(position)->Fill(residualLocalPhi);
01893             unitsLocalTheta.at(position)->Fill(residualLocalTheta);
01894             unitsGlobalRPhi.at(position)->Fill(residualGlobalRPhi);
01895             unitsGlobalPhi.at(position)->Fill(residualGlobalPhi);
01896             unitsGlobalTheta.at(position)->Fill(residualGlobalTheta);
01897             if(det==1) {unitsLocalY.at(position)->Fill(residualLocalY); unitsGlobalRZ.at(position)->Fill(residualGlobalZ);}
01898             else if(det==2) {unitsLocalY.at(position)->Fill(residualLocalY); unitsGlobalRZ.at(position)->Fill(residualGlobalR);}                
01899             }
01900            
01901           countPoints++;
01902         
01903           innerTSOS = destiny;
01904 
01905 
01906         }else {
01907           edm::LogError("MuonAlignmentAnalyzer") <<" Error!! Exception in propagator catched" << endl;
01908           continue;
01909         }
01910 
01911         } //loop over my4DTrack
01912         } //TSOS was valid
01913 
01914         } // cut in at least 4 segments
01915 
01916         } //end cut in RecHitsSize>36
01917         numberOfHits=numberOfHits+countPoints;
01918         } //loop over STAtracks
01919 
01920   delete thePropagator;
01921 
01922  } //end doResplots
01923  
01924 
01925 }
01926 
01927 RecHitVector MuonAlignmentAnalyzer::doMatching(const reco::Track &staTrack, edm::Handle<DTRecSegment4DCollection> &all4DSegmentsDT, edm::Handle<CSCSegmentCollection> &all4DSegmentsCSC, intDVector *indexCollectionDT, intDVector *indexCollectionCSC, ESHandle<GlobalTrackingGeometry> &theTrackingGeometry) {
01928 
01929   DTRecSegment4DCollection::const_iterator segmentDT;
01930   CSCSegmentCollection::const_iterator segmentCSC;
01931   
01932   std::vector<int> positionDT;
01933   std::vector<int> positionCSC;
01934   RecHitVector my4DTrack;
01935   
01936   //Loop over the hits of the track
01937   for(unsigned int counter = 0; counter != staTrack.recHitsSize()-1; counter++) {
01938     
01939     TrackingRecHitRef myRef = staTrack.recHit(counter);
01940     const TrackingRecHit *rechit = myRef.get();
01941     const GeomDet* geomDet = theTrackingGeometry->idToDet(rechit->geographicalId());
01942     
01943     //It's a DT Hit
01944     if(geomDet->subDetector() == GeomDetEnumerators::DT) {
01945       
01946       //Take the layer associated to this hit
01947       DTLayerId myLayer(rechit->geographicalId().rawId());
01948       
01949       int NumberOfDTSegment = 0;
01950       //Loop over segments
01951       for(segmentDT = all4DSegmentsDT->begin(); segmentDT != all4DSegmentsDT->end(); ++segmentDT) {
01952         
01953         //By default the chamber associated to this Segment is new
01954         bool isNewChamber = true;
01955         
01956         //Loop over segments already included in the vector of segments in the actual track
01957         for(std::vector<int>::iterator positionIt = positionDT.begin(); positionIt != positionDT.end(); positionIt++) {
01958           
01959           //If this segment has been used before isNewChamber = false
01960           if(NumberOfDTSegment == *positionIt) isNewChamber = false;
01961         }
01962         
01963         //Loop over vectors of segments associated to previous tracks
01964         for(std::vector<std::vector<int> >::iterator collect = indexCollectionDT->begin(); collect != indexCollectionDT->end(); ++collect) {
01965           
01966           //Loop over segments associated to a track
01967           for(std::vector<int>::iterator positionIt = (*collect).begin(); positionIt != (*collect).end(); positionIt++) {
01968             
01969             //If this segment was used in a previos track then isNewChamber = false
01970             if(NumberOfDTSegment == *positionIt) isNewChamber = false;
01971           }
01972         }
01973         
01974         //If the chamber is new
01975         if(isNewChamber) {
01976           
01977           DTChamberId myChamber((*segmentDT).geographicalId().rawId());
01978           //If the layer of the hit belongs to the chamber of the 4D Segment
01979           if(myLayer.wheel() == myChamber.wheel() && myLayer.station() == myChamber.station() && myLayer.sector() == myChamber.sector()) {
01980             
01981             //push position of the segment and tracking rechit
01982             positionDT.push_back(NumberOfDTSegment);
01983             my4DTrack.push_back((TrackingRecHit *) &(*segmentDT));
01984           }
01985         }
01986         NumberOfDTSegment++;
01987       }
01988       //In case is a CSC
01989     } else if (geomDet->subDetector() == GeomDetEnumerators::CSC) {
01990       
01991       //Take the layer associated to this hit
01992       CSCDetId myLayer(rechit->geographicalId().rawId());
01993       
01994       int NumberOfCSCSegment = 0;
01995       //Loop over 4Dsegments
01996       for(segmentCSC = all4DSegmentsCSC->begin(); segmentCSC != all4DSegmentsCSC->end(); segmentCSC++) {
01997         
01998         //By default the chamber associated to the segment is new
01999         bool isNewChamber = true;
02000         
02001         //Loop over segments in the current track
02002         for(std::vector<int>::iterator positionIt = positionCSC.begin(); positionIt != positionCSC.end(); positionIt++) {
02003           
02004           //If this segment has been used then newchamber = false
02005           if(NumberOfCSCSegment == *positionIt) isNewChamber = false;
02006         }
02007         //Loop over vectors of segments in previous tracks
02008         for(std::vector<std::vector<int> >::iterator collect = indexCollectionCSC->begin(); collect != indexCollectionCSC->end(); ++collect) {
02009           
02010           //Loop over segments in a track
02011           for(std::vector<int>::iterator positionIt = (*collect).begin(); positionIt != (*collect).end(); positionIt++) {
02012             
02013             //If the segment was used in a previous track isNewChamber = false
02014             if(NumberOfCSCSegment == *positionIt) isNewChamber = false;
02015           }
02016         }
02017         //If the chamber is new
02018         if(isNewChamber) {
02019           
02020           CSCDetId myChamber((*segmentCSC).geographicalId().rawId());
02021           //If the chambers are the same
02022           if(myLayer.chamberId() == myChamber.chamberId()) {
02023             //push
02024             positionCSC.push_back(NumberOfCSCSegment);
02025             my4DTrack.push_back((TrackingRecHit *) &(*segmentCSC));
02026           }
02027         }
02028         NumberOfCSCSegment++;
02029       }
02030     }
02031   }
02032   
02033   indexCollectionDT->push_back(positionDT);
02034   indexCollectionCSC->push_back(positionCSC);
02035   
02036   return my4DTrack;
02037 }
02038 
02039 DEFINE_FWK_MODULE(MuonAlignmentAnalyzer);

Generated on Tue Jun 9 17:24:56 2009 for CMSSW by  doxygen 1.5.4