Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-01-13 01:43:58

0001 // -*- C++ -*-
0002 //
0003 // Package:    TestGEMCSCSegmentAnalyzer
0004 // Class:      TestGEMCSCSegmentAnalyzer
0005 //
0006 /**\class TestGEMCSCSegmentAnalyzer TestGEMCSCSegmentAnalyzer.cc MyAnalyzers/TestGEMCSCSegmentAnalyzer/src/TestGEMCSCSegmentAnalyzer.cc
0007 
0008  Description: [one line class summary]
0009 
0010  Implementation:
0011      [Notes on implementation]
0012 */
0013 //
0014 // Original Author:  Raffaella Radogna
0015 
0016 // system include files
0017 #include <memory>
0018 #include <fstream>
0019 #include <sys/time.h>
0020 #include <string>
0021 #include <sstream>
0022 #include <iostream>
0023 #include <iomanip>
0024 #include <math.h>
0025 
0026 // root include files
0027 #include "TFile.h"
0028 #include "TH1F.h"
0029 #include "TH2F.h"
0030 
0031 // user include files
0032 #include "FWCore/Framework/interface/Frameworkfwd.h"
0033 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0034 #include "FWCore/Framework/interface/Event.h"
0035 #include "FWCore/Framework/interface/ESHandle.h"
0036 #include "FWCore/Framework/interface/MakerMacros.h"
0037 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0038 #include "FWCore/ServiceRegistry/interface/Service.h"
0039 #include "FWCore/Utilities/interface/InputTag.h"
0040 
0041 #include <DataFormats/GEMRecHit/interface/GEMCSCSegmentCollection.h>
0042 #include <DataFormats/GEMRecHit/interface/GEMRecHit.h>
0043 #include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h"
0044 
0045 #include <Geometry/CSCGeometry/interface/CSCChamberSpecs.h>  //?
0046 #include <Geometry/CSCGeometry/interface/CSCChamber.h>       //?
0047 #include <Geometry/CSCGeometry/interface/CSCLayer.h>         //?
0048 #include <Geometry/CSCGeometry/interface/CSCGeometry.h>
0049 #include <Geometry/GEMGeometry/interface/GEMGeometry.h>
0050 #include <Geometry/GEMGeometry/interface/GEMEtaPartition.h>
0051 #include <Geometry/Records/interface/MuonGeometryRecord.h>
0052 #include <DataFormats/MuonDetId/interface/CSCDetId.h>
0053 #include <DataFormats/MuonDetId/interface/GEMDetId.h>
0054 
0055 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0056 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
0057 #include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
0058 #include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
0059 #include "DataFormats/TrackingRecHit/interface/TrackingRecHitFwd.h"
0060 //
0061 // class declaration
0062 //
0063 
0064 using namespace std;
0065 using namespace edm;
0066 
0067 class TestGEMCSCSegmentAnalyzer : public edm::one::EDAnalyzer<> {
0068 public:
0069   explicit TestGEMCSCSegmentAnalyzer(const edm::ParameterSet&);
0070   ~TestGEMCSCSegmentAnalyzer();
0071 
0072 private:
0073   virtual void beginJob();
0074   virtual void analyze(const edm::Event&, const edm::EventSetup&);
0075   virtual void endJob();
0076 
0077   virtual void beginRun(edm::Run const&, edm::EventSetup const&);
0078   //virtual void endRun(edm::Run const&, edm::EventSetup const&);
0079   //virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
0080   //virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
0081 
0082   edm::PSimHitContainer SimHitMatched(std::vector<GEMRecHit>::const_iterator,
0083                                       edm::ESHandle<GEMGeometry>,
0084                                       const edm::Event&);
0085 
0086   // ----------member data ---------------------------
0087   edm::ESHandle<GEMGeometry> gemGeom;
0088   edm::ESHandle<CSCGeometry> cscGeom;
0089 
0090   bool debug;
0091   std::string rootFileName;
0092 
0093   const edm::ESGetToken<CSCGeometry, MuonGeometryRecord> kCSCGeometryToken_;
0094   const edm::ESGetToken<GEMGeometry, MuonGeometryRecord> kGEMGeometryToken_;
0095   edm::EDGetTokenT<edm::SimTrackContainer> SimTrack_Token;
0096   edm::EDGetTokenT<CSCSegmentCollection> CSCSegment_Token;
0097   edm::EDGetTokenT<GEMCSCSegmentCollection> GEMCSCSegment_Token;
0098   edm::EDGetTokenT<edm::PSimHitContainer> GEMSimHit_Token;
0099 
0100   std::unique_ptr<TFile> outputfile;
0101 
0102   std::unique_ptr<TH1F> CSC_fitchi2;
0103   std::unique_ptr<TH1F> GEMCSC_fitchi2;
0104   std::unique_ptr<TH1F> GEMCSC_fitchi2_odd;
0105   std::unique_ptr<TH1F> GEMCSC_fitchi2_even;
0106   std::unique_ptr<TH1F> GEMCSC_NumGEMRH;
0107   std::unique_ptr<TH1F> GEMCSC_NumCSCRH;
0108   std::unique_ptr<TH1F> GEMCSC_NumGEMCSCRH;
0109   std::unique_ptr<TH1F> GEMCSC_NumGEMCSCSeg;
0110 
0111   std::unique_ptr<TH1F> GEMCSC_SSegm_LPx;
0112   std::unique_ptr<TH1F> GEMCSC_SSegm_LPy;
0113   std::unique_ptr<TH1F> GEMCSC_SSegm_LPEx;
0114   std::unique_ptr<TH1F> GEMCSC_SSegm_LPEy;
0115   std::unique_ptr<TH1F> GEMCSC_SSegm_LDx;
0116   std::unique_ptr<TH1F> GEMCSC_SSegm_LDy;
0117   std::unique_ptr<TH1F> GEMCSC_SSegm_LDEx;
0118   std::unique_ptr<TH1F> GEMCSC_SSegm_LDEy;
0119   std::unique_ptr<TH2F> GEMCSC_SSegm_LDEy_vs_ndof;
0120   std::unique_ptr<TH2F> GEMCSC_SSegm_LPEy_vs_ndof;
0121   std::unique_ptr<TH1F> GEMCSC_CSCSegm_LPx;
0122   std::unique_ptr<TH1F> GEMCSC_CSCSegm_LPy;
0123   std::unique_ptr<TH1F> GEMCSC_CSCSegm_LPEx;
0124   std::unique_ptr<TH1F> GEMCSC_CSCSegm_LPEy;
0125   std::unique_ptr<TH1F> GEMCSC_CSCSegm_LDx;
0126   std::unique_ptr<TH1F> GEMCSC_CSCSegm_LDy;
0127   std::unique_ptr<TH1F> GEMCSC_CSCSegm_LDEx;
0128   std::unique_ptr<TH1F> GEMCSC_CSCSegm_LDEy;
0129   std::unique_ptr<TH2F> GEMCSC_CSCSegm_LDEy_vs_ndof;
0130   std::unique_ptr<TH2F> GEMCSC_CSCSegm_LPEy_vs_ndof;
0131 
0132   std::unique_ptr<TH1F> SIMGEMCSC_SSegm_LDx;
0133   std::unique_ptr<TH1F> SIMGEMCSC_SSegm_LDy;
0134   std::unique_ptr<TH1F> SIMGEMCSC_SSegm_LDEx;
0135   std::unique_ptr<TH1F> SIMGEMCSC_SSegm_LDEy;
0136 
0137   std::unique_ptr<TH1F> GEMCSC_Residuals_x;
0138   std::unique_ptr<TH1F> GEMCSC_Residuals_gem_x;
0139   std::unique_ptr<TH1F> GEMCSC_Residuals_csc_x;
0140   std::unique_ptr<TH1F> GEMCSC_Residuals_gem_odd_x;
0141   std::unique_ptr<TH1F> GEMCSC_Residuals_csc_odd_x;
0142   std::unique_ptr<TH1F> GEMCSC_Residuals_gem_even_x;
0143   std::unique_ptr<TH1F> GEMCSC_Residuals_csc_even_x;
0144   std::unique_ptr<TH1F> GEMCSC_Residuals_cscl1_x;
0145   std::unique_ptr<TH1F> GEMCSC_Residuals_cscl2_x;
0146   std::unique_ptr<TH1F> GEMCSC_Residuals_cscl3_x;
0147   std::unique_ptr<TH1F> GEMCSC_Residuals_cscl4_x;
0148   std::unique_ptr<TH1F> GEMCSC_Residuals_cscl5_x;
0149   std::unique_ptr<TH1F> GEMCSC_Residuals_cscl6_x;
0150   std::unique_ptr<TH1F> GEMCSC_Residuals_geml1_x;
0151   std::unique_ptr<TH1F> GEMCSC_Residuals_geml2_x;
0152   std::unique_ptr<TH1F> GEMCSC_Pool_x;
0153   std::unique_ptr<TH1F> GEMCSC_Pool_gem_x;
0154   std::unique_ptr<TH1F> GEMCSC_Pool_csc_x;
0155   std::unique_ptr<TH1F> GEMCSC_Pool_gem_odd_x;
0156   std::unique_ptr<TH1F> GEMCSC_Pool_csc_odd_x;
0157   std::unique_ptr<TH1F> GEMCSC_Pool_gem_even_x;
0158   std::unique_ptr<TH1F> GEMCSC_Pool_csc_even_x;
0159   std::unique_ptr<TH1F> GEMCSC_Pool_cscl1_x;
0160   std::unique_ptr<TH1F> GEMCSC_Pool_cscl2_x;
0161   std::unique_ptr<TH1F> GEMCSC_Pool_cscl3_x;
0162   std::unique_ptr<TH1F> GEMCSC_Pool_cscl4_x;
0163   std::unique_ptr<TH1F> GEMCSC_Pool_cscl5_x;
0164   std::unique_ptr<TH1F> GEMCSC_Pool_cscl6_x;
0165   std::unique_ptr<TH1F> GEMCSC_Pool_geml1_x;
0166   std::unique_ptr<TH1F> GEMCSC_Pool_geml2_x;
0167   std::unique_ptr<TH1F> GEMCSC_Residuals_y;
0168   std::unique_ptr<TH1F> GEMCSC_Residuals_gem_y;
0169   std::unique_ptr<TH1F> GEMCSC_Residuals_csc_y;
0170   std::unique_ptr<TH1F> GEMCSC_Residuals_gem_odd_y;
0171   std::unique_ptr<TH1F> GEMCSC_Residuals_csc_odd_y;
0172   std::unique_ptr<TH1F> GEMCSC_Residuals_gem_even_y;
0173   std::unique_ptr<TH1F> GEMCSC_Residuals_csc_even_y;
0174   std::unique_ptr<TH1F> GEMCSC_Residuals_cscl1_y;
0175   std::unique_ptr<TH1F> GEMCSC_Residuals_cscl2_y;
0176   std::unique_ptr<TH1F> GEMCSC_Residuals_cscl3_y;
0177   std::unique_ptr<TH1F> GEMCSC_Residuals_cscl4_y;
0178   std::unique_ptr<TH1F> GEMCSC_Residuals_cscl5_y;
0179   std::unique_ptr<TH1F> GEMCSC_Residuals_cscl6_y;
0180   std::unique_ptr<TH1F> GEMCSC_Residuals_geml1_y;
0181   std::unique_ptr<TH1F> GEMCSC_Residuals_geml2_y;
0182   std::unique_ptr<TH1F> GEMCSC_Pool_y;
0183   std::unique_ptr<TH1F> GEMCSC_Pool_gem_y;
0184   std::unique_ptr<TH1F> GEMCSC_Pool_csc_y;
0185   std::unique_ptr<TH1F> GEMCSC_Pool_gem_odd_y;
0186   std::unique_ptr<TH1F> GEMCSC_Pool_csc_odd_y;
0187   std::unique_ptr<TH1F> GEMCSC_Pool_gem_even_y;
0188   std::unique_ptr<TH1F> GEMCSC_Pool_csc_even_y;
0189   std::unique_ptr<TH1F> GEMCSC_Pool_cscl1_y;
0190   std::unique_ptr<TH1F> GEMCSC_Pool_cscl2_y;
0191   std::unique_ptr<TH1F> GEMCSC_Pool_cscl3_y;
0192   std::unique_ptr<TH1F> GEMCSC_Pool_cscl4_y;
0193   std::unique_ptr<TH1F> GEMCSC_Pool_cscl5_y;
0194   std::unique_ptr<TH1F> GEMCSC_Pool_cscl6_y;
0195   std::unique_ptr<TH1F> GEMCSC_Pool_geml1_y;
0196   std::unique_ptr<TH1F> GEMCSC_Pool_geml2_y;
0197 
0198   std::unique_ptr<TH1F> GEMCSC_Pool_gem_x_newE;
0199   std::unique_ptr<TH1F> GEMCSC_Pool_gem_y_newE;
0200   std::unique_ptr<TH1F> GEMCSC_Pool_gem_odd_x_newE;
0201   std::unique_ptr<TH1F> GEMCSC_Pool_gem_odd_y_newE;
0202   std::unique_ptr<TH1F> GEMCSC_Pool_gem_x_newE_mp;
0203   std::unique_ptr<TH1F> GEMCSC_Pool_gem_y_newE_mp;
0204   std::unique_ptr<TH1F> GEMCSC_Pool_gem_odd_x_newE_mp;
0205   std::unique_ptr<TH1F> GEMCSC_Pool_gem_odd_y_newE_mp;
0206   std::unique_ptr<TH1F> GEMCSC_Pool_gem_x_newE_mm;
0207   std::unique_ptr<TH1F> GEMCSC_Pool_gem_y_newE_mm;
0208   std::unique_ptr<TH1F> GEMCSC_Pool_gem_odd_x_newE_mm;
0209   std::unique_ptr<TH1F> GEMCSC_Pool_gem_odd_y_newE_mm;
0210 
0211   std::unique_ptr<TH1F> GEMCSC_Dphi_min_afterCut;
0212   std::unique_ptr<TH1F> GEMCSC_Dtheta_min_afterCut;
0213   std::unique_ptr<TH1F> GEMCSC_DR_min_afterCut;
0214   std::unique_ptr<TH1F> GEMCSC_Dphi_min_afterCut_odd;
0215   std::unique_ptr<TH1F> GEMCSC_Dphi_min_afterCut_even;
0216   std::unique_ptr<TH1F> GEMCSC_Dphi_min_afterCut_l1;
0217   std::unique_ptr<TH1F> GEMCSC_Dphi_min_afterCut_l1_odd;
0218   std::unique_ptr<TH1F> GEMCSC_Dphi_min_afterCut_l1_even;
0219   std::unique_ptr<TH1F> GEMCSC_Dphi_min_afterCut_l2;
0220   std::unique_ptr<TH1F> GEMCSC_Dphi_min_afterCut_l2_odd;
0221   std::unique_ptr<TH1F> GEMCSC_Dphi_min_afterCut_l2_even;
0222   std::unique_ptr<TH1F> GEMCSC_Dphi_cscS_min_afterCut;
0223   std::unique_ptr<TH1F> GEMCSC_Dtheta_cscS_min_afterCut;
0224   std::unique_ptr<TH1F> GEMCSC_Dtheta_cscS_min_afterCut_odd;
0225   std::unique_ptr<TH1F> GEMCSC_Dtheta_cscS_min_afterCut_even;
0226   std::unique_ptr<TH1F> GEMCSC_DR_cscS_min_afterCut;
0227 
0228   std::unique_ptr<TH1F> GEMCSC_Dphi_cscS_min_afterCut_l1;
0229   std::unique_ptr<TH1F> GEMCSC_Dphi_cscS_min_afterCut_l1_odd;
0230   std::unique_ptr<TH1F> GEMCSC_Dphi_cscS_min_afterCut_l1_even;
0231   std::unique_ptr<TH1F> GEMCSC_Dphi_cscS_min_afterCut_l2;
0232   std::unique_ptr<TH1F> GEMCSC_Dphi_cscS_min_afterCut_l2_odd;
0233   std::unique_ptr<TH1F> GEMCSC_Dphi_cscS_min_afterCut_l2_even;
0234 
0235   std::unique_ptr<TH1F> GEMCSC_Dphi_cscS_min_afterCut_odd;
0236   std::unique_ptr<TH1F> GEMCSC_Dphi_cscS_min_afterCut_even;
0237   std::unique_ptr<TH1F> GEMCSC_Dphi_cscS_min_afterCut_odd_r1;
0238   std::unique_ptr<TH1F> GEMCSC_Dphi_cscS_min_afterCut_odd_r2;
0239   std::unique_ptr<TH1F> GEMCSC_Dphi_cscS_min_afterCut_odd_r3;
0240   std::unique_ptr<TH1F> GEMCSC_Dphi_cscS_min_afterCut_odd_r4;
0241   std::unique_ptr<TH1F> GEMCSC_Dphi_cscS_min_afterCut_odd_r5;
0242   std::unique_ptr<TH1F> GEMCSC_Dphi_cscS_min_afterCut_odd_r6;
0243   std::unique_ptr<TH1F> GEMCSC_Dphi_cscS_min_afterCut_odd_r7;
0244   std::unique_ptr<TH1F> GEMCSC_Dphi_cscS_min_afterCut_odd_r8;
0245 
0246   std::unique_ptr<TH1F> GEMCSC_SSegm_xe_l1;
0247   std::unique_ptr<TH1F> GEMCSC_SSegm_ye_l1;
0248   std::unique_ptr<TH1F> GEMCSC_SSegm_ze_l1;
0249   std::unique_ptr<TH1F> GEMCSC_SSegm_sigmaxe_l1;
0250   std::unique_ptr<TH1F> GEMCSC_SSegm_sigmaye_l1;
0251   std::unique_ptr<TH1F> GEMCSC_SSegm_xe_l1_odd;
0252   std::unique_ptr<TH1F> GEMCSC_SSegm_ye_l1_odd;
0253   std::unique_ptr<TH1F> GEMCSC_SSegm_ze_l1_odd;
0254   std::unique_ptr<TH1F> GEMCSC_SSegm_sigmaxe_l1_odd;
0255   std::unique_ptr<TH1F> GEMCSC_SSegm_sigmaye_l1_odd;
0256   std::unique_ptr<TH1F> GEMCSC_SSegm_xe_l1_even;
0257   std::unique_ptr<TH1F> GEMCSC_SSegm_ye_l1_even;
0258   std::unique_ptr<TH1F> GEMCSC_SSegm_ze_l1_even;
0259   std::unique_ptr<TH1F> GEMCSC_SSegm_sigmaxe_l1_even;
0260   std::unique_ptr<TH1F> GEMCSC_SSegm_sigmaye_l1_even;
0261 
0262   std::unique_ptr<TH1F> GEMCSC_SSegm_xe_l2;
0263   std::unique_ptr<TH1F> GEMCSC_SSegm_ye_l2;
0264   std::unique_ptr<TH1F> GEMCSC_SSegm_ze_l2;
0265   std::unique_ptr<TH1F> GEMCSC_SSegm_sigmaxe_l2;
0266   std::unique_ptr<TH1F> GEMCSC_SSegm_sigmaye_l2;
0267   std::unique_ptr<TH1F> GEMCSC_SSegm_xe_l2_odd;
0268   std::unique_ptr<TH1F> GEMCSC_SSegm_ye_l2_odd;
0269   std::unique_ptr<TH1F> GEMCSC_SSegm_ze_l2_odd;
0270   std::unique_ptr<TH1F> GEMCSC_SSegm_sigmaxe_l2_odd;
0271   std::unique_ptr<TH1F> GEMCSC_SSegm_sigmaye_l2_odd;
0272   std::unique_ptr<TH1F> GEMCSC_SSegm_xe_l2_even;
0273   std::unique_ptr<TH1F> GEMCSC_SSegm_ye_l2_even;
0274   std::unique_ptr<TH1F> GEMCSC_SSegm_ze_l2_even;
0275   std::unique_ptr<TH1F> GEMCSC_SSegm_sigmaxe_l2_even;
0276   std::unique_ptr<TH1F> GEMCSC_SSegm_sigmaye_l2_even;
0277 
0278   std::unique_ptr<TH1F> GEMCSC_CSCSegm_xe_l1;
0279   std::unique_ptr<TH1F> GEMCSC_CSCSegm_ye_l1;
0280   std::unique_ptr<TH1F> GEMCSC_CSCSegm_ze_l1;
0281   std::unique_ptr<TH1F> GEMCSC_CSCSegm_sigmaxe_l1;
0282   std::unique_ptr<TH1F> GEMCSC_CSCSegm_sigmaye_l1;
0283   std::unique_ptr<TH1F> GEMCSC_CSCSegm_xe_l1_odd;
0284   std::unique_ptr<TH1F> GEMCSC_CSCSegm_ye_l1_odd;
0285   std::unique_ptr<TH1F> GEMCSC_CSCSegm_ze_l1_odd;
0286   std::unique_ptr<TH1F> GEMCSC_CSCSegm_sigmaxe_l1_odd;
0287   std::unique_ptr<TH1F> GEMCSC_CSCSegm_sigmaye_l1_odd;
0288   std::unique_ptr<TH1F> GEMCSC_CSCSegm_xe_l1_even;
0289   std::unique_ptr<TH1F> GEMCSC_CSCSegm_ye_l1_even;
0290   std::unique_ptr<TH1F> GEMCSC_CSCSegm_ze_l1_even;
0291   std::unique_ptr<TH1F> GEMCSC_CSCSegm_sigmaxe_l1_even;
0292   std::unique_ptr<TH1F> GEMCSC_CSCSegm_sigmaye_l1_even;
0293 
0294   std::unique_ptr<TH1F> GEMCSC_CSCSegm_xe_l2;
0295   std::unique_ptr<TH1F> GEMCSC_CSCSegm_ye_l2;
0296   std::unique_ptr<TH1F> GEMCSC_CSCSegm_ze_l2;
0297   std::unique_ptr<TH1F> GEMCSC_CSCSegm_sigmaxe_l2;
0298   std::unique_ptr<TH1F> GEMCSC_CSCSegm_sigmaye_l2;
0299   std::unique_ptr<TH1F> GEMCSC_CSCSegm_xe_l2_odd;
0300   std::unique_ptr<TH1F> GEMCSC_CSCSegm_ye_l2_odd;
0301   std::unique_ptr<TH1F> GEMCSC_CSCSegm_ze_l2_odd;
0302   std::unique_ptr<TH1F> GEMCSC_CSCSegm_sigmaxe_l2_odd;
0303   std::unique_ptr<TH1F> GEMCSC_CSCSegm_sigmaye_l2_odd;
0304   std::unique_ptr<TH1F> GEMCSC_CSCSegm_xe_l2_even;
0305   std::unique_ptr<TH1F> GEMCSC_CSCSegm_ye_l2_even;
0306   std::unique_ptr<TH1F> GEMCSC_CSCSegm_ze_l2_even;
0307   std::unique_ptr<TH1F> GEMCSC_CSCSegm_sigmaxe_l2_even;
0308   std::unique_ptr<TH1F> GEMCSC_CSCSegm_sigmaye_l2_even;
0309 
0310   std::unique_ptr<TH2F> SIM_etaVScharge;
0311   std::unique_ptr<TH2F> SIM_etaVStype;
0312   std::unique_ptr<TH2F> SIMGEMCSC_theta_cscSsh_vs_ndof_odd;
0313   std::unique_ptr<TH2F> SIMGEMCSC_theta_cscSsh_vs_ndof_even;
0314 
0315   std::unique_ptr<TH1F> SIMGEMCSC_Dphi_SS_min_afterCut;
0316   std::unique_ptr<TH1F> SIMGEMCSC_Dtheta_SS_min_afterCut;
0317   std::unique_ptr<TH1F> SIMGEMCSC_Dtheta_SS_min_afterCut_odd;
0318   std::unique_ptr<TH1F> SIMGEMCSC_Dtheta_SS_min_afterCut_even;
0319   std::unique_ptr<TH1F> SIMGEMCSC_Dphi_SS_min_afterCut_odd;
0320   std::unique_ptr<TH1F> SIMGEMCSC_Dphi_SS_min_afterCut_even;
0321 
0322   std::unique_ptr<TH1F> SIMGEMCSC_Dphi_cscS_min_afterCut;
0323   std::unique_ptr<TH1F> SIMGEMCSC_Dtheta_cscS_min_afterCut;
0324   std::unique_ptr<TH1F> SIMGEMCSC_Dtheta_cscS_min_afterCut_odd;
0325   std::unique_ptr<TH1F> SIMGEMCSC_Dtheta_cscS_min_afterCut_even;
0326   std::unique_ptr<TH1F> SIMGEMCSC_Dphi_cscS_min_afterCut_odd;
0327   std::unique_ptr<TH1F> SIMGEMCSC_Dphi_cscS_min_afterCut_even;
0328   std::unique_ptr<TH1F> SIMGEMCSC_Residuals_gem_x;
0329   std::unique_ptr<TH1F> SIMGEMCSC_Residuals_gem_y;
0330   std::unique_ptr<TH1F> SIMGEMCSC_Pool_gem_x_newE;
0331   std::unique_ptr<TH1F> SIMGEMCSC_Pool_gem_y_newE;
0332   std::unique_ptr<TH1F> SIMGEMCSC_Residuals_gem_odd_x;
0333   std::unique_ptr<TH1F> SIMGEMCSC_Residuals_gem_odd_y;
0334   std::unique_ptr<TH1F> SIMGEMCSC_Pool_gem_x_newE_odd;
0335   std::unique_ptr<TH1F> SIMGEMCSC_Pool_gem_y_newE_odd;
0336   std::unique_ptr<TH1F> SIMGEMCSC_Residuals_gem_even_x;
0337   std::unique_ptr<TH1F> SIMGEMCSC_Residuals_gem_even_y;
0338   std::unique_ptr<TH1F> SIMGEMCSC_Pool_gem_x_newE_even;
0339   std::unique_ptr<TH1F> SIMGEMCSC_Pool_gem_y_newE_even;
0340   std::unique_ptr<TH1F> SIMGEMCSC_Residuals_gem_rhsh_x;
0341   std::unique_ptr<TH1F> SIMGEMCSC_Residuals_gem_rhsh_y;
0342   std::unique_ptr<TH1F> SIMGEMCSC_Pool_gem_rhsh_x_newE;
0343   std::unique_ptr<TH1F> SIMGEMCSC_Pool_gem_rhsh_y_newE;
0344 };
0345 //
0346 // constants, enums and typedefs
0347 //
0348 // constructors and destructor
0349 //
0350 TestGEMCSCSegmentAnalyzer::TestGEMCSCSegmentAnalyzer(const edm::ParameterSet& iConfig)
0351     : kCSCGeometryToken_(esConsumes<CSCGeometry, MuonGeometryRecord>()),
0352       kGEMGeometryToken_(esConsumes<GEMGeometry, MuonGeometryRecord>()) {
0353   //now do what ever initialization is needed
0354   debug = iConfig.getUntrackedParameter<bool>("Debug");
0355   rootFileName = iConfig.getUntrackedParameter<std::string>("RootFileName");
0356 
0357   // outputfile = new TFile(rootFileName.c_str(), "RECREATE" );
0358   outputfile.reset(TFile::Open(rootFileName.c_str(), "CREATE"));
0359   outputfile->cd();
0360 
0361   SimTrack_Token = consumes<edm::SimTrackContainer>(edm::InputTag("g4SimHits"));
0362   CSCSegment_Token = consumes<CSCSegmentCollection>(edm::InputTag("cscSegments"));
0363   GEMCSCSegment_Token = consumes<GEMCSCSegmentCollection>(edm::InputTag("gemcscSegments"));
0364   GEMSimHit_Token = consumes<edm::PSimHitContainer>(edm::InputTag("g4SimHits", "MuonGEMHits"));
0365 
0366   SIM_etaVScharge =
0367       std::unique_ptr<TH2F>(new TH2F("SimTrack_etaVScharge", "SimTrack_etaVScharge", 500, -2.5, 2.5, 6, -3, 3));
0368   SIM_etaVStype =
0369       std::unique_ptr<TH2F>(new TH2F("SimTrack_etaVStype", "SimTrack_etaVStype", 500, -2.5, 2.5, 30, -15, 15));
0370   CSC_fitchi2 = std::unique_ptr<TH1F>(new TH1F("ReducedChi2_csc", "ReducedChi2_csc", 160, 0., 4.));
0371 
0372   GEMCSC_fitchi2 = std::unique_ptr<TH1F>(new TH1F("ReducedChi2_gemcsc", "ReducedChi2_gemcsc", 160, 0., 4.));
0373   GEMCSC_fitchi2_odd = std::unique_ptr<TH1F>(new TH1F("ReducedChi2_odd_gemcsc", "ReducedChi2_odd_gemcsc", 160, 0., 4.));
0374   GEMCSC_fitchi2_even =
0375       std::unique_ptr<TH1F>(new TH1F("ReducedChi2_even_gemcsc", "ReducedChi2_even_gemcsc", 160, 0., 4.));
0376   GEMCSC_NumGEMRH = std::unique_ptr<TH1F>(new TH1F("NumGEMRH", "NumGEMRH", 20, 0., 20));
0377   GEMCSC_NumCSCRH = std::unique_ptr<TH1F>(new TH1F("NumCSCRH", "NumCSCRH", 20, 0., 20));
0378   GEMCSC_NumGEMCSCRH = std::unique_ptr<TH1F>(new TH1F("NumGEMCSCRH", "NumGEMCSCRH", 20, 0., 20));
0379   GEMCSC_NumGEMCSCSeg = std::unique_ptr<TH1F>(new TH1F("NumGMCSCSeg", "NumGEMCSCSeg", 20, 0., 20));
0380   GEMCSC_SSegm_LPx = std::unique_ptr<TH1F>(new TH1F("SuperS_LPx", "SuperS_LPx", 1200, -60., 60));
0381   GEMCSC_SSegm_LPy = std::unique_ptr<TH1F>(new TH1F("SuperS_LPy", "SuperS_LPy", 4000, -200., 200));
0382   GEMCSC_SSegm_LPEx = std::unique_ptr<TH1F>(new TH1F("SuperS_LPEx", "SuperS_LPEx", 10000, 0., 0.5));
0383   GEMCSC_SSegm_LPEy = std::unique_ptr<TH1F>(new TH1F("SuperS_LPEy", "SuperS_LPEy", 10000, 0., 5));
0384   //GEMCSC_SSegm_LPEz = std::unique_ptr<TH1F>(new TH1F("SuperS_LPEz","SuperS_LPEz",1000,0.,0.5));
0385   GEMCSC_SSegm_LDx = std::unique_ptr<TH1F>(new TH1F("SuperS_LDx", "SuperS_LDx", 1000, -2., 2));
0386   GEMCSC_SSegm_LDy = std::unique_ptr<TH1F>(new TH1F("SuperS_LDy", "SuperS_LDy", 1000, -2., 2));
0387   GEMCSC_SSegm_LDEx = std::unique_ptr<TH1F>(new TH1F("SuperS_LDEx", "SuperS_LDEx", 10000, 0., 0.05));
0388   GEMCSC_SSegm_LDEy = std::unique_ptr<TH1F>(new TH1F("SuperS_LDEy", "SuperS_LDEy", 10000, 0., 0.5));
0389   GEMCSC_SSegm_LDEy_vs_ndof =
0390       std::unique_ptr<TH2F>(new TH2F("SSegm_LDEy_vs_ndof", "SSegm_LDEy vs ndof", 1000, 0., 0.05, 15, -0.5, 14.5));
0391   GEMCSC_SSegm_LPEy_vs_ndof =
0392       std::unique_ptr<TH2F>(new TH2F("SSegm_LPEy_vs_ndof", "SSegm_LPEy vs ndof", 1000, 0., 0.5, 15, -0.5, 14.5));
0393   //GEMCSC_SSegm_LDEz = std::unique_ptr<TH1F>(new TH1F("SuperS_LDEz","SuperS_LDEz",1000,0.,0.05));
0394   GEMCSC_CSCSegm_LPx = std::unique_ptr<TH1F>(new TH1F("CSCSegm_LPx", "CSCSegm_LPx", 1200, -60., 60));
0395   GEMCSC_CSCSegm_LPy = std::unique_ptr<TH1F>(new TH1F("CSCSegm_LPy", "CSCSegm_LPy", 4000, -200., 200));
0396   GEMCSC_CSCSegm_LPEx = std::unique_ptr<TH1F>(new TH1F("CSCSegm_LPEx", "CSCSegm_LPEx", 10000, 0., 0.5));
0397   GEMCSC_CSCSegm_LPEy = std::unique_ptr<TH1F>(new TH1F("CSCSegm_LPEy", "CSCSegm_LPEy", 10000, 0., 5));
0398   //GEMCSC_CSCSegm_LPEz = std::unique_ptr<TH1F>(new TH1F("CSCSegm_LPEz","CSCSegm_LPEz",1000,0.,0.5));
0399   GEMCSC_CSCSegm_LDx = std::unique_ptr<TH1F>(new TH1F("CSCSegm_LDx", "CSCSegm_LDx", 1000, -2., 2));
0400   GEMCSC_CSCSegm_LDy = std::unique_ptr<TH1F>(new TH1F("CSCSegm_LDy", "CSCSegm_LDy", 1000, -2., 2));
0401   GEMCSC_CSCSegm_LDEx = std::unique_ptr<TH1F>(new TH1F("CSCSegm_LDEx", "CSCSegm_LDEx", 10000, 0., 0.05));
0402   GEMCSC_CSCSegm_LDEy = std::unique_ptr<TH1F>(new TH1F("CSCSegm_LDEy", "CSCSegm_LDEy", 10000, 0., 0.5));
0403   //GEMCSC_CSCSegm_LDEz = std::unique_ptr<TH1F>(new TH1F("CSCSegm_LDEz","CSCSegm_LDEz",1000,0.,0.05));
0404   GEMCSC_CSCSegm_LDEy_vs_ndof =
0405       std::unique_ptr<TH2F>(new TH2F("CSCSegm_LDEy_vs_ndof", "CSCSegm_LDEy vs ndof", 1000, 0., 0.05, 15, -0.5, 14.5));
0406   GEMCSC_CSCSegm_LPEy_vs_ndof =
0407       std::unique_ptr<TH2F>(new TH2F("CSCSegm_LPEy_vs_ndof", "CSCSegm_LPEy vs ndof", 1000, 0., 0.5, 15, -0.5, 14.5));
0408   SIMGEMCSC_SSegm_LDx = std::unique_ptr<TH1F>(new TH1F("SSegm_LDx_expected", "SSegm_LDx", 1000, -2., 2));
0409   SIMGEMCSC_SSegm_LDy = std::unique_ptr<TH1F>(new TH1F("SSegm_LDy_expected", "SSegm_LDy", 1000, -2., 2));
0410   SIMGEMCSC_SSegm_LDEx = std::unique_ptr<TH1F>(new TH1F("SuperS_LDEx_expected", "SuperS_LDEx", 10000, 0., 0.005));
0411   SIMGEMCSC_SSegm_LDEy = std::unique_ptr<TH1F>(new TH1F("SuperS_LDEy_expected", "SuperS_LDEy", 1000, 0., 0.05));
0412 
0413   GEMCSC_SSegm_xe_l1 = std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_xe_l1", "GEMCSC_SSegm_xe_l1", 1200, -60., 60));
0414   GEMCSC_SSegm_ye_l1 = std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_ye_l1", "GEMCSC_SSegm_ye_l1", 4000, -200., 200));
0415   GEMCSC_SSegm_ze_l1 = std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_ze_l1", "GEMCSC_SSegm_ze_l1", 12000, -600., 600));
0416   GEMCSC_SSegm_xe_l1_odd =
0417       std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_xe_l1_odd", "GEMCSC_SSegm_xe_l1_odd", 1200, -60., 60));
0418   GEMCSC_SSegm_ye_l1_odd =
0419       std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_ye_l1_odd", "GEMCSC_SSegm_ye_l1_odd", 4000, -200., 200));
0420   GEMCSC_SSegm_ze_l1_odd =
0421       std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_ze_l1_odd", "GEMCSC_SSegm_ze_l1_odd", 12000, -600., 600));
0422   GEMCSC_SSegm_xe_l1_even =
0423       std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_xe_l1_even", "GEMCSC_SSegm_xe_l1_even", 1200, -60., 60));
0424   GEMCSC_SSegm_ye_l1_even =
0425       std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_ye_l1_even", "GEMCSC_SSegm_ye_l1_even", 4000, -200., 200));
0426   GEMCSC_SSegm_ze_l1_even =
0427       std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_ze_l1_even", "GEMCSC_SSegm_ze_l1_even", 12000, -600., 600));
0428   GEMCSC_SSegm_xe_l2 = std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_xe_l2", "GEMCSC_SSegm_xe_l2", 1200, -60., 60));
0429   GEMCSC_SSegm_ye_l2 = std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_ye_l2", "GEMCSC_SSegm_ye_l2", 4000, -200., 200));
0430   GEMCSC_SSegm_ze_l2 = std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_ze_l2", "GEMCSC_SSegm_ze_l2", 12000, -600., 600));
0431   GEMCSC_SSegm_xe_l2_odd =
0432       std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_xe_l2_odd", "GEMCSC_SSegm_xe_l2_odd", 1200, -60., 60));
0433   GEMCSC_SSegm_ye_l2_odd =
0434       std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_ye_l2_odd", "GEMCSC_SSegm_ye_l2_odd", 4000, -200., 200));
0435   GEMCSC_SSegm_ze_l2_odd =
0436       std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_ze_l2_odd", "GEMCSC_SSegm_ze_l2_odd", 12000, -600., 600));
0437   GEMCSC_SSegm_xe_l2_even =
0438       std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_xe_l2_even", "GEMCSC_SSegm_xe_l2_even", 1200, -60., 60));
0439   GEMCSC_SSegm_ye_l2_even =
0440       std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_ye_l2_even", "GEMCSC_SSegm_ye_l2_even", 4000, -200., 200));
0441   GEMCSC_SSegm_ze_l2_even =
0442       std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_ze_l2_even", "GEMCSC_SSegm_ze_l2_even", 12000, -600., 600));
0443 
0444   GEMCSC_CSCSegm_xe_l1 =
0445       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_xe_l1", "GEMCSC_CSCSegm_xe_l1", 1200, -60., 60));
0446   GEMCSC_CSCSegm_ye_l1 =
0447       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_ye_l1", "GEMCSC_CSCSegm_ye_l1", 4000, -200., 200));
0448   GEMCSC_CSCSegm_ze_l1 =
0449       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_ze_l1", "GEMCSC_CSCSegm_ze_l1", 12000, -600., 600));
0450   GEMCSC_CSCSegm_xe_l1_odd =
0451       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_xe_l1_odd", "GEMCSC_CSCSegm_xe_l1_odd", 1200, -60., 60));
0452   GEMCSC_CSCSegm_ye_l1_odd =
0453       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_ye_l1_odd", "GEMCSC_CSCSegm_ye_l1_odd", 4000, -200., 200));
0454   GEMCSC_CSCSegm_ze_l1_odd =
0455       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_ze_l1_odd", "GEMCSC_CSCSegm_ze_l1_odd", 12000, -600., 600));
0456   GEMCSC_CSCSegm_xe_l1_even =
0457       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_xe_l1_even", "GEMCSC_CSCSegm_xe_l1_even", 1200, -60., 60));
0458   GEMCSC_CSCSegm_ye_l1_even =
0459       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_ye_l1_even", "GEMCSC_CSCSegm_ye_l1_even", 4000, -200., 200));
0460   GEMCSC_CSCSegm_ze_l1_even =
0461       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_ze_l1_even", "GEMCSC_CSCSegm_ze_l1_even", 12000, -600., 600));
0462   GEMCSC_CSCSegm_xe_l2 =
0463       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_xe_l2", "GEMCSC_CSCSegm_xe_l2", 1200, -60., 60));
0464   GEMCSC_CSCSegm_ye_l2 =
0465       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_ye_l2", "GEMCSC_CSCSegm_ye_l2", 4000, -200., 200));
0466   GEMCSC_CSCSegm_ze_l2 =
0467       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_ze_l2", "GEMCSC_CSCSegm_ze_l2", 12000, -600., 600));
0468   GEMCSC_CSCSegm_xe_l2_odd =
0469       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_xe_l2_odd", "GEMCSC_CSCSegm_xe_l2_odd", 1200, -60., 60));
0470   GEMCSC_CSCSegm_ye_l2_odd =
0471       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_ye_l2_odd", "GEMCSC_CSCSegm_ye_l2_odd", 4000, -200., 200));
0472   GEMCSC_CSCSegm_ze_l2_odd =
0473       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_ze_l2_odd", "GEMCSC_CSCSegm_ze_l2_odd", 12000, -600., 600));
0474   GEMCSC_CSCSegm_xe_l2_even =
0475       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_xe_l2_even", "GEMCSC_CSCSegm_xe_l2_even", 1200, -60., 60));
0476   GEMCSC_CSCSegm_ye_l2_even =
0477       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_ye_l2_even", "GEMCSC_CSCSegm_ye_l2_even", 4000, -200., 200));
0478   GEMCSC_CSCSegm_ze_l2_even =
0479       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_ze_l2_even", "GEMCSC_CSCSegm_ze_l2_even", 12000, -600., 600));
0480 
0481   GEMCSC_SSegm_sigmaxe_l1 =
0482       std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_sigmaxe_l1", "GEMCSC_SSegm_sigmaxe_l1", 1000, 0., 0.5));
0483   GEMCSC_SSegm_sigmaye_l1 =
0484       std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_sigmaye_l1", "GEMCSC_SSegm_sigmaye_l1", 1000, 0., 10));
0485   GEMCSC_SSegm_sigmaxe_l1_odd =
0486       std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_sigmaxe_l1_odd", "GEMCSC_SSegm_sigmaxe_l1_odd", 1000, 0., 0.5));
0487   GEMCSC_SSegm_sigmaye_l1_odd =
0488       std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_sigmaye_l1_odd", "GEMCSC_SSegm_sigmaye_l1_odd", 1000, 0., 10));
0489   GEMCSC_SSegm_sigmaxe_l1_even =
0490       std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_sigmaxe_l1_even", "GEMCSC_SSegm_sigmaxe_l1_even", 1000, 0., 0.5));
0491   GEMCSC_SSegm_sigmaye_l1_even =
0492       std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_sigmaye_l1_even", "GEMCSC_SSegm_sigmaye_l1_even", 1000, 0., 10));
0493   GEMCSC_SSegm_sigmaxe_l2 =
0494       std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_sigmaxe_l2", "GEMCSC_SSegm_sigmaxe_l2", 1000, 0., 0.5));
0495   GEMCSC_SSegm_sigmaye_l2 =
0496       std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_sigmaye_l2", "GEMCSC_SSegm_sigmaye_l2", 1000, 0., 10));
0497   GEMCSC_SSegm_sigmaxe_l2_odd =
0498       std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_sigmaxe_l2_odd", "GEMCSC_SSegm_sigmaxe_l2_odd", 1000, 0., 0.5));
0499   GEMCSC_SSegm_sigmaye_l2_odd =
0500       std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_sigmaye_l2_odd", "GEMCSC_SSegm_sigmaye_l2_odd", 1000, 0., 10));
0501   GEMCSC_SSegm_sigmaxe_l2_even =
0502       std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_sigmaxe_l2_even", "GEMCSC_SSegm_sigmaxe_l2_even", 1000, 0., 0.5));
0503   GEMCSC_SSegm_sigmaye_l2_even =
0504       std::unique_ptr<TH1F>(new TH1F("GEMCSC_SSegm_sigmaye_l2_even", "GEMCSC_SSegm_sigmaye_l2_even", 1000, 0., 10));
0505   GEMCSC_CSCSegm_sigmaxe_l1 =
0506       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_sigmaxe_l1", "GEMCSC_CSCSegm_sigmaxe_l1", 1000, 0., 0.5));
0507   GEMCSC_CSCSegm_sigmaye_l1 =
0508       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_sigmaye_l1", "GEMCSC_CSCSegm_sigmaye_l1", 1000, 0., 10));
0509   GEMCSC_CSCSegm_sigmaxe_l1_odd =
0510       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_sigmaxe_l1_odd", "GEMCSC_CSCSegm_sigmaxe_l1_odd", 1000, 0., 0.5));
0511   GEMCSC_CSCSegm_sigmaye_l1_odd =
0512       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_sigmaye_l1_odd", "GEMCSC_CSCSegm_sigmaye_l1_odd", 1000, 0., 10));
0513   GEMCSC_CSCSegm_sigmaxe_l1_even = std::unique_ptr<TH1F>(
0514       new TH1F("GEMCSC_CSCSegm_sigmaxe_l1_even", "GEMCSC_CSCSegm_sigmaxe_l1_even", 1000, 0., 0.5));
0515   GEMCSC_CSCSegm_sigmaye_l1_even =
0516       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_sigmaye_l1_even", "GEMCSC_CSCSegm_sigmaye_l1_even", 1000, 0., 10));
0517   GEMCSC_CSCSegm_sigmaxe_l2 =
0518       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_sigmaxe_l2", "GEMCSC_CSCSegm_sigmaxe_l2", 1000, 0., 0.5));
0519   GEMCSC_CSCSegm_sigmaye_l2 =
0520       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_sigmaye_l2", "GEMCSC_CSCSegm_sigmaye_l2", 1000, 0., 10));
0521   GEMCSC_CSCSegm_sigmaxe_l2_odd =
0522       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_sigmaxe_l2_odd", "GEMCSC_CSCSegm_sigmaxe_l2_odd", 1000, 0., 0.5));
0523   GEMCSC_CSCSegm_sigmaye_l2_odd =
0524       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_sigmaye_l2_odd", "GEMCSC_CSCSegm_sigmaye_l2_odd", 1000, 0., 10));
0525   GEMCSC_CSCSegm_sigmaxe_l2_even = std::unique_ptr<TH1F>(
0526       new TH1F("GEMCSC_CSCSegm_sigmaxe_l2_even", "GEMCSC_CSCSegm_sigmaxe_l2_even", 1000, 0., 0.5));
0527   GEMCSC_CSCSegm_sigmaye_l2_even =
0528       std::unique_ptr<TH1F>(new TH1F("GEMCSC_CSCSegm_sigmaye_l2_even", "GEMCSC_CSCSegm_sigmaye_l2_even", 1000, 0., 10));
0529 
0530   GEMCSC_Residuals_x = std::unique_ptr<TH1F>(new TH1F("xGEMCSCRes", "xGEMCSCRes", 100, -0.5, 0.5));
0531   GEMCSC_Residuals_gem_x = std::unique_ptr<TH1F>(new TH1F("xGEMRes", "xGEMRes", 100, -0.5, 0.5));
0532   GEMCSC_Residuals_csc_x = std::unique_ptr<TH1F>(new TH1F("xCSCRes", "xCSCRes", 100, -0.5, 0.5));
0533   GEMCSC_Residuals_gem_even_x = std::unique_ptr<TH1F>(new TH1F("xGEMRes_even", "xGEMRes even", 100, -0.5, 0.5));
0534   GEMCSC_Residuals_csc_even_x = std::unique_ptr<TH1F>(new TH1F("xCSCRes_even", "xCSCRes even", 100, -0.5, 0.5));
0535   GEMCSC_Residuals_gem_odd_x = std::unique_ptr<TH1F>(new TH1F("xGEMRes_odd", "xGEMRes odd", 100, -0.5, 0.5));
0536   GEMCSC_Residuals_csc_odd_x = std::unique_ptr<TH1F>(new TH1F("xCSCRes_odd", "xCSCRes odd", 100, -0.5, 0.5));
0537   GEMCSC_Residuals_cscl1_x = std::unique_ptr<TH1F>(new TH1F("xGEMCSCRes_cscl1", "xGEMCSCRes_cscl1", 100, -0.5, 0.5));
0538   GEMCSC_Residuals_cscl2_x = std::unique_ptr<TH1F>(new TH1F("xGEMCSCRes_cscl2", "xGEMCSCRes_cscl2", 100, -0.5, 0.5));
0539   GEMCSC_Residuals_cscl3_x = std::unique_ptr<TH1F>(new TH1F("xGEMCSCRes_cscl3", "xGEMCSCRes_cscl3", 100, -0.5, 0.5));
0540   GEMCSC_Residuals_cscl4_x = std::unique_ptr<TH1F>(new TH1F("xGEMCSCRes_cscl4", "xGEMCSCRes_cscl4", 100, -0.5, 0.5));
0541   GEMCSC_Residuals_cscl5_x = std::unique_ptr<TH1F>(new TH1F("xGEMCSCRes_cscl5", "xGEMCSCRes_cscl5", 100, -0.5, 0.5));
0542   GEMCSC_Residuals_cscl6_x = std::unique_ptr<TH1F>(new TH1F("xGEMCSCRes_cscl6", "xGEMCSCRes_cscl6", 100, -0.5, 0.5));
0543   GEMCSC_Residuals_geml1_x = std::unique_ptr<TH1F>(new TH1F("xGEMCSCRes_geml1", "xGEMCSCRes_geml1", 100, -0.5, 0.5));
0544   GEMCSC_Residuals_geml2_x = std::unique_ptr<TH1F>(new TH1F("xGEMCSCRes_geml2", "xGEMCSCRes_geml2", 100, -0.5, 0.5));
0545   GEMCSC_Pool_x = std::unique_ptr<TH1F>(new TH1F("xGEMCSCPool", "xGEMCSCPool", 100, -5., 5.));
0546   GEMCSC_Pool_gem_x = std::unique_ptr<TH1F>(new TH1F("xGEMPool", "xGEMPool", 100, -5., 5.));
0547   GEMCSC_Pool_csc_x = std::unique_ptr<TH1F>(new TH1F("xCSCPool", "xCSCPool", 100, -5., 5.));
0548   GEMCSC_Pool_gem_even_x = std::unique_ptr<TH1F>(new TH1F("xGEMPool_even", "xGEMPool even", 100, -5., 5.));
0549   GEMCSC_Pool_csc_even_x = std::unique_ptr<TH1F>(new TH1F("xCSCPool_even", "xCSCPool even", 100, -5., 5.));
0550   GEMCSC_Pool_gem_odd_x = std::unique_ptr<TH1F>(new TH1F("xGEMPool_odd", "xGEMPool odd", 100, -5., 5.));
0551   GEMCSC_Pool_csc_odd_x = std::unique_ptr<TH1F>(new TH1F("xCSCPool_odd", "xCSCPool odd", 100, -5., 5.));
0552   GEMCSC_Pool_cscl1_x = std::unique_ptr<TH1F>(new TH1F("xGEMCSCPool_cscl1", "xGEMCSCPool_cscl1", 100, -5., 5.));
0553   GEMCSC_Pool_cscl2_x = std::unique_ptr<TH1F>(new TH1F("xGEMCSCPool_cscl2", "xGEMCSCPool_cscl2", 100, -5., 5.));
0554   GEMCSC_Pool_cscl3_x = std::unique_ptr<TH1F>(new TH1F("xGEMCSCPool_cscl3", "xGEMCSCPool_cscl3", 100, -5., 5.));
0555   GEMCSC_Pool_cscl4_x = std::unique_ptr<TH1F>(new TH1F("xGEMCSCPool_cscl4", "xGEMCSCPool_cscl4", 100, -5., 5.));
0556   GEMCSC_Pool_cscl5_x = std::unique_ptr<TH1F>(new TH1F("xGEMCSCPool_cscl5", "xGEMCSCPool_cscl5", 100, -5., 5.));
0557   GEMCSC_Pool_cscl6_x = std::unique_ptr<TH1F>(new TH1F("xGEMCSCPool_cscl6", "xGEMCSCPool_cscl6", 100, -5., 5.));
0558   GEMCSC_Pool_geml1_x = std::unique_ptr<TH1F>(new TH1F("xGEMCSCPool_geml1", "xGEMCSCPool_geml1", 100, -5., 5.));
0559   GEMCSC_Pool_geml2_x = std::unique_ptr<TH1F>(new TH1F("xGEMCSCPool_geml2", "xGEMCSCPool_geml2", 100, -5., 5.));
0560   GEMCSC_Residuals_y = std::unique_ptr<TH1F>(new TH1F("yGEMCSCRes", "yGEMCSCRes", 100, -10., 10.));
0561   GEMCSC_Residuals_gem_y = std::unique_ptr<TH1F>(new TH1F("yGEMRes", "yGEMRes", 100, -10., 10.));
0562   GEMCSC_Residuals_csc_y = std::unique_ptr<TH1F>(new TH1F("yCSCRes", "yCSCRes", 100, -5., 5.));
0563   GEMCSC_Residuals_gem_even_y = std::unique_ptr<TH1F>(new TH1F("yGEMRes_even", "yGEMRes even", 100, -10., 10.));
0564   GEMCSC_Residuals_csc_even_y = std::unique_ptr<TH1F>(new TH1F("yCSCRes_even", "yCSCRes even", 100, -5., 5.));
0565   GEMCSC_Residuals_gem_odd_y = std::unique_ptr<TH1F>(new TH1F("yGEMRes_odd", "yGEMRes odd", 100, -10., 10.));
0566   GEMCSC_Residuals_csc_odd_y = std::unique_ptr<TH1F>(new TH1F("yCSCRes_odd", "yCSCRes odd", 100, -5., 5.));
0567   GEMCSC_Residuals_cscl1_y = std::unique_ptr<TH1F>(new TH1F("yGEMCSCRes_cscl1", "yGEMCSCRes_cscl1", 100, -5., 5.));
0568   GEMCSC_Residuals_cscl2_y = std::unique_ptr<TH1F>(new TH1F("yGEMCSCRes_cscl2", "yGEMCSCRes_cscl2", 100, -5., 5.));
0569   GEMCSC_Residuals_cscl3_y = std::unique_ptr<TH1F>(new TH1F("yGEMCSCRes_cscl3", "yGEMCSCRes_cscl3", 100, -5., 5.));
0570   GEMCSC_Residuals_cscl4_y = std::unique_ptr<TH1F>(new TH1F("yGEMCSCRes_cscl4", "yGEMCSCRes_cscl4", 100, -5., 5.));
0571   GEMCSC_Residuals_cscl5_y = std::unique_ptr<TH1F>(new TH1F("yGEMCSCRes_cscl5", "yGEMCSCRes_cscl5", 100, -5., 5.));
0572   GEMCSC_Residuals_cscl6_y = std::unique_ptr<TH1F>(new TH1F("yGEMCSCRes_cscl6", "yGEMCSCRes_cscl6", 100, -5., 5.));
0573   GEMCSC_Residuals_geml1_y = std::unique_ptr<TH1F>(new TH1F("yGEMCSCRes_geml1", "yGEMCSCRes_geml1", 100, -5., 5.));
0574   GEMCSC_Residuals_geml2_y = std::unique_ptr<TH1F>(new TH1F("yGEMCSCRes_geml2", "yGEMCSCRes_geml2", 100, -5., 5.));
0575   GEMCSC_Pool_y = std::unique_ptr<TH1F>(new TH1F("yGEMCSCPool", "yGEMCSCPool", 100, -5., 5.));
0576   GEMCSC_Pool_gem_y = std::unique_ptr<TH1F>(new TH1F("yGEMPool", "yGEMPool", 100, -5., 5.));
0577   GEMCSC_Pool_csc_y = std::unique_ptr<TH1F>(new TH1F("yCSCPool", "yCSCPool", 100, -5., 5.));
0578   GEMCSC_Pool_gem_even_y = std::unique_ptr<TH1F>(new TH1F("yGEMPool_even", "yGEMPool even", 100, -5., 5.));
0579   GEMCSC_Pool_csc_even_y = std::unique_ptr<TH1F>(new TH1F("yCSCPool_even", "yCSCPool even", 100, -5., 5.));
0580   GEMCSC_Pool_gem_odd_y = std::unique_ptr<TH1F>(new TH1F("yGEMPool_odd", "yGEMPool odd", 100, -5., 5.));
0581   GEMCSC_Pool_csc_odd_y = std::unique_ptr<TH1F>(new TH1F("yCSCPool_odd", "yCSCPool odd", 100, -5., 5.));
0582   GEMCSC_Pool_cscl1_y = std::unique_ptr<TH1F>(new TH1F("yGEMCSCPool_cscl1", "yGEMCSCPool_cscl1", 100, -5., 5.));
0583   GEMCSC_Pool_cscl2_y = std::unique_ptr<TH1F>(new TH1F("yGEMCSCPool_cscl2", "yGEMCSCPool_cscl2", 100, -5., 5.));
0584   GEMCSC_Pool_cscl3_y = std::unique_ptr<TH1F>(new TH1F("yGEMCSCPool_cscl3", "yGEMCSCPool_cscl3", 100, -5., 5.));
0585   GEMCSC_Pool_cscl4_y = std::unique_ptr<TH1F>(new TH1F("yGEMCSCPool_cscl4", "yGEMCSCPool_cscl4", 100, -5., 5.));
0586   GEMCSC_Pool_cscl5_y = std::unique_ptr<TH1F>(new TH1F("yGEMCSCPool_cscl5", "yGEMCSCPool_cscl5", 100, -5., 5.));
0587   GEMCSC_Pool_cscl6_y = std::unique_ptr<TH1F>(new TH1F("yGEMCSCPool_cscl6", "yGEMCSCPool_cscl6", 100, -5., 5.));
0588   GEMCSC_Pool_geml1_y = std::unique_ptr<TH1F>(new TH1F("yGEMCSCPool_geml1", "yGEMCSCPool_geml1", 100, -5., 5.));
0589   GEMCSC_Pool_geml2_y = std::unique_ptr<TH1F>(new TH1F("yGEMCSCPool_geml2", "yGEMCSCPool_geml2", 100, -5., 5.));
0590 
0591   GEMCSC_Pool_gem_x_newE = std::unique_ptr<TH1F>(new TH1F("xGEMPool_newE", "xGEMPool_newE", 100, -5., 5.));
0592   GEMCSC_Pool_gem_y_newE = std::unique_ptr<TH1F>(new TH1F("yGEMPool_newE", "yGEMPool_newE", 100, -5., 5.));
0593   GEMCSC_Pool_gem_odd_x_newE = std::unique_ptr<TH1F>(new TH1F("xGEMPool_odd_newE", "xGEMPool odd newE", 100, -5., 5.));
0594   GEMCSC_Pool_gem_odd_y_newE = std::unique_ptr<TH1F>(new TH1F("yGEMPool_odd_newE", "yGEMPool odd newE", 100, -5., 5.));
0595   GEMCSC_Pool_gem_x_newE_mp = std::unique_ptr<TH1F>(new TH1F("xGEMPool_newE_mp", "xGEMPool_newE muon+", 100, -5., 5.));
0596   GEMCSC_Pool_gem_y_newE_mp = std::unique_ptr<TH1F>(new TH1F("yGEMPool_newE_mp", "yGEMPool_newE muon+", 100, -5., 5.));
0597   GEMCSC_Pool_gem_odd_x_newE_mp =
0598       std::unique_ptr<TH1F>(new TH1F("xGEMPool_odd_newE_mp", "xGEMPool odd newE muon+", 100, -5., 5.));
0599   GEMCSC_Pool_gem_odd_y_newE_mp =
0600       std::unique_ptr<TH1F>(new TH1F("yGEMPool_odd_newE_mp", "yGEMPool odd newE muon+", 100, -5., 5.));
0601   GEMCSC_Pool_gem_x_newE_mm = std::unique_ptr<TH1F>(new TH1F("xGEMPool_newE_mm", "xGEMPool_newE muon-", 100, -5., 5.));
0602   GEMCSC_Pool_gem_y_newE_mm = std::unique_ptr<TH1F>(new TH1F("yGEMPool_newE_mm", "yGEMPool_newE muon-", 100, -5., 5.));
0603   GEMCSC_Pool_gem_odd_x_newE_mm =
0604       std::unique_ptr<TH1F>(new TH1F("xGEMPool_odd_newE_mm", "xGEMPool odd newE muon-", 100, -5., 5.));
0605   GEMCSC_Pool_gem_odd_y_newE_mm =
0606       std::unique_ptr<TH1F>(new TH1F("yGEMPool_odd_newE_mm", "yGEMPool odd newE muon-", 100, -5., 5.));
0607 
0608   GEMCSC_Dphi_min_afterCut = std::unique_ptr<TH1F>(
0609       new TH1F("Dphi_gemRHgemcscS_min_afterCut", "Dphi_gemRHgemcscS_min_afterCut", 800000, -4., 4.));
0610   GEMCSC_Dtheta_min_afterCut = std::unique_ptr<TH1F>(
0611       new TH1F("Dtheta_gemRHgemcscS_min_afterCut", "Dtheta_gemRHgemcscS_min_afterCut", 60000, -3., 3.));
0612   GEMCSC_DR_min_afterCut =
0613       std::unique_ptr<TH1F>(new TH1F("DR_gemRHgemcscS_min_afterCut", "DR_gemRHgemcscS_min_afterCut", 60000, -3., 3.));
0614   GEMCSC_Dphi_min_afterCut_odd = std::unique_ptr<TH1F>(
0615       new TH1F("Dphi_gemRHgemcscS_min_afterCut_odd", "Dphi_gemRHgemcscS_min_afterCut_odd", 800000, -4., 4.));
0616   GEMCSC_Dphi_min_afterCut_even = std::unique_ptr<TH1F>(
0617       new TH1F("Dphi_gemRHgemcscS_min_afterCut_even", "Dphi_gemRHgemcscS_min_afterCut_even", 800000, -4., 4.));
0618   GEMCSC_Dphi_min_afterCut_l1 = std::unique_ptr<TH1F>(
0619       new TH1F("Dphi_gemRHgemcscS_min_afterCut_l1", "Dphi_gemRHgemcscS_min_afterCut_l1", 800000, -4., 4.));
0620   GEMCSC_Dphi_min_afterCut_l1_odd = std::unique_ptr<TH1F>(
0621       new TH1F("Dphi_gemRHgemcscS_min_afterCut_l1_odd", "Dphi_gemRHgemcscS_min_afterCut_l1_odd", 800000, -4., 4.));
0622   GEMCSC_Dphi_min_afterCut_l1_even = std::unique_ptr<TH1F>(
0623       new TH1F("Dphi_gemRHgemcscS_min_afterCut_l1_even", "Dphi_gemRHgemcscS_min_afterCut_l1_even", 800000, -4., 4.));
0624   GEMCSC_Dphi_min_afterCut_l2 = std::unique_ptr<TH1F>(
0625       new TH1F("Dphi_gemRHgemcscS_min_afterCut_l2", "Dphi_gemRHgemcscS_min_afterCut_l2", 800000, -4., 4.));
0626   GEMCSC_Dphi_min_afterCut_l2_odd = std::unique_ptr<TH1F>(
0627       new TH1F("Dphi_gemRHgemcscS_min_afterCut_l2_odd", "Dphi_gemRHgemcscS_min_afterCut_l2_odd", 800000, -4., 4.));
0628   GEMCSC_Dphi_min_afterCut_l2_even = std::unique_ptr<TH1F>(
0629       new TH1F("Dphi_gemRHgemcscS_min_afterCut_l2_even", "Dphi_gemRHgemcscS_min_afterCut_l2_even", 800000, -4., 4.));
0630 
0631   GEMCSC_Dphi_cscS_min_afterCut =
0632       std::unique_ptr<TH1F>(new TH1F("Dphi_gemRHcscS_min_afterCut", "Dphi_gemRHcscS_min_afterCut", 800000, -4., 4.));
0633   GEMCSC_Dtheta_cscS_min_afterCut =
0634       std::unique_ptr<TH1F>(new TH1F("Dtheta_gemRHcscS_min_afterCut", "Dtheta_gemRHcscS_min_afterCut", 60000, -3., 3.));
0635   GEMCSC_DR_cscS_min_afterCut =
0636       std::unique_ptr<TH1F>(new TH1F("DR_gemRHcscS_min_afterCut", "DR_gemRHcscS_min_afterCut", 60000, -3., 3.));
0637   GEMCSC_Dphi_cscS_min_afterCut_l1 = std::unique_ptr<TH1F>(
0638       new TH1F("Dphi_gemRHcscS_min_afterCut_l1", "Dphi_gemRHcscS_min_afterCut_l1", 800000, -4., 4.));
0639   GEMCSC_Dphi_cscS_min_afterCut_l1_odd = std::unique_ptr<TH1F>(
0640       new TH1F("Dphi_gemRHcscS_min_afterCut_l1_odd", "Dphi_gemRHcscS_min_afterCut_l1_odd", 800000, -4., 4.));
0641   GEMCSC_Dphi_cscS_min_afterCut_l1_even = std::unique_ptr<TH1F>(
0642       new TH1F("Dphi_gemRHcscS_min_afterCut_l1_even", "Dphi_gemRHcscS_min_afterCut_l1_even", 800000, -4., 4.));
0643   GEMCSC_Dphi_cscS_min_afterCut_l2 = std::unique_ptr<TH1F>(
0644       new TH1F("Dphi_gemRHcscS_min_afterCut_l2", "Dphi_gemRHcscS_min_afterCut_l2", 800000, -4., 4.));
0645   GEMCSC_Dphi_cscS_min_afterCut_l2_odd = std::unique_ptr<TH1F>(
0646       new TH1F("Dphi_gemRHcscS_min_afterCut_l2_odd", "Dphi_gemRHcscS_min_afterCut_l2_odd", 800000, -4., 4.));
0647   GEMCSC_Dphi_cscS_min_afterCut_l2_even = std::unique_ptr<TH1F>(
0648       new TH1F("Dphi_gemRHcscS_min_afterCut_l2_even", "Dphi_gemRHcscS_min_afterCut_l2_even", 800000, -4., 4.));
0649 
0650   GEMCSC_Dphi_cscS_min_afterCut_odd = std::unique_ptr<TH1F>(
0651       new TH1F("Dphi_gemRHcscS_min_afterCut_odd", "Dphi_gemRHcscS_min_afterCut_odd", 800000, -4., 4.));
0652   GEMCSC_Dphi_cscS_min_afterCut_even = std::unique_ptr<TH1F>(
0653       new TH1F("Dphi_gemRHcscS_min_afterCut_even", "Dphi_gemRHcscS_min_afterCut_even", 800000, -4., 4.));
0654   GEMCSC_Dphi_cscS_min_afterCut_odd_r1 = std::unique_ptr<TH1F>(
0655       new TH1F("Dphi_gemRHcscS_min_afterCut_odd_r1", "Dphi_gemRHcscS_min_afterCut_odd_r1", 800000, -4., 4.));
0656   GEMCSC_Dphi_cscS_min_afterCut_odd_r2 = std::unique_ptr<TH1F>(
0657       new TH1F("Dphi_gemRHcscS_min_afterCut_odd_r2", "Dphi_gemRHcscS_min_afterCut_odd_r2", 800000, -4., 4.));
0658   GEMCSC_Dphi_cscS_min_afterCut_odd_r3 = std::unique_ptr<TH1F>(
0659       new TH1F("Dphi_gemRHcscS_min_afterCut_odd_r3", "Dphi_gemRHcscS_min_afterCut_odd_r3", 800000, -4., 4.));
0660   GEMCSC_Dphi_cscS_min_afterCut_odd_r4 = std::unique_ptr<TH1F>(
0661       new TH1F("Dphi_gemRHcscS_min_afterCut_odd_r4", "Dphi_gemRHcscS_min_afterCut_odd_r4", 800000, -4., 4.));
0662   GEMCSC_Dphi_cscS_min_afterCut_odd_r5 = std::unique_ptr<TH1F>(
0663       new TH1F("Dphi_gemRHcscS_min_afterCut_odd_r5", "Dphi_gemRHcscS_min_afterCut_odd_r5", 800000, -4., 4.));
0664   GEMCSC_Dphi_cscS_min_afterCut_odd_r6 = std::unique_ptr<TH1F>(
0665       new TH1F("Dphi_gemRHcscS_min_afterCut_odd_r6", "Dphi_gemRHcscS_min_afterCut_odd_r6", 800000, -4., 4.));
0666   GEMCSC_Dphi_cscS_min_afterCut_odd_r7 = std::unique_ptr<TH1F>(
0667       new TH1F("Dphi_gemRHcscS_min_afterCut_odd_r7", "Dphi_gemRHcscS_min_afterCut_odd_r7", 800000, -4., 4.));
0668   GEMCSC_Dphi_cscS_min_afterCut_odd_r8 = std::unique_ptr<TH1F>(
0669       new TH1F("Dphi_gemRHcscS_min_afterCut_odd_r8", "Dphi_gemRHcscS_min_afterCut_odd_r8", 800000, -4., 4.));
0670   GEMCSC_Dtheta_cscS_min_afterCut_odd = std::unique_ptr<TH1F>(
0671       new TH1F("Dtheta_gemRHcscS_min_afterCut_odd", "Dtheta_gemRHcscS_min_afterCut_odd", 60000, -3., 3.));
0672   GEMCSC_Dtheta_cscS_min_afterCut_even = std::unique_ptr<TH1F>(
0673       new TH1F("Dtheta_gemRHcscS_min_afterCut_even", "Dtheta_gemRHcscS_min_afterCut_even", 60000, -3., 3.));
0674 
0675   SIMGEMCSC_Dphi_cscS_min_afterCut =
0676       std::unique_ptr<TH1F>(new TH1F("Dphi_gemSHcscS_min_afterCut", "Dphi_gemSHcscS_min_afterCut", 800000, -4., 4.));
0677   SIMGEMCSC_Dtheta_cscS_min_afterCut =
0678       std::unique_ptr<TH1F>(new TH1F("Dtheta_gemSHcscS_min_afterCut", "Dtheta_gemSHcscS_min_afterCut", 60000, -3., 3.));
0679   SIMGEMCSC_Dphi_cscS_min_afterCut_odd = std::unique_ptr<TH1F>(
0680       new TH1F("Dphi_gemSHcscS_min_afterCut_odd", "Dphi_gemSHcscS_min_afterCut_odd", 800000, -4., 4.));
0681   SIMGEMCSC_Dphi_cscS_min_afterCut_even = std::unique_ptr<TH1F>(
0682       new TH1F("Dphi_gemSHcscS_min_afterCut_even", "Dphi_gemSHcscS_min_afterCut_even", 800000, -4., 4.));
0683   SIMGEMCSC_Dtheta_cscS_min_afterCut_odd = std::unique_ptr<TH1F>(
0684       new TH1F("Dtheta_gemSHcscS_min_afterCut_odd", "Dtheta_gemSHcscS_min_afterCut_odd", 60000, -3., 3.));
0685   SIMGEMCSC_Dtheta_cscS_min_afterCut_even = std::unique_ptr<TH1F>(
0686       new TH1F("Dtheta_gemSHcscS_min_afterCut_even", "Dtheta_gemSHcscS_min_afterCut_even", 60000, -3., 3.));
0687 
0688   SIMGEMCSC_Dphi_SS_min_afterCut =
0689       std::unique_ptr<TH1F>(new TH1F("Dphi_gemSHSS_min_afterCut", "Dphi_gemSHSS_min_afterCut", 800000, -4., 4.));
0690   SIMGEMCSC_Dtheta_SS_min_afterCut =
0691       std::unique_ptr<TH1F>(new TH1F("Dtheta_gemSHSS_min_afterCut", "Dtheta_gemSHSS_min_afterCut", 60000, -3., 3.));
0692   SIMGEMCSC_Dphi_SS_min_afterCut_odd = std::unique_ptr<TH1F>(
0693       new TH1F("Dphi_gemSHSS_min_afterCut_odd", "Dphi_gemSHSS_min_afterCut_odd", 800000, -4., 4.));
0694   SIMGEMCSC_Dphi_SS_min_afterCut_even = std::unique_ptr<TH1F>(
0695       new TH1F("Dphi_gemSHSS_min_afterCut_even", "Dphi_gemSHSS_min_afterCut_even", 800000, -4., 4.));
0696   SIMGEMCSC_Dtheta_SS_min_afterCut_odd = std::unique_ptr<TH1F>(
0697       new TH1F("Dtheta_gemSHSS_min_afterCut_odd", "Dtheta_gemSHSS_min_afterCut_odd", 60000, -3., 3.));
0698   SIMGEMCSC_Dtheta_SS_min_afterCut_even = std::unique_ptr<TH1F>(
0699       new TH1F("Dtheta_gemSHSS_min_afterCut_even", "Dtheta_gemSHSS_min_afterCut_even", 60000, -3., 3.));
0700 
0701   SIMGEMCSC_theta_cscSsh_vs_ndof_odd = std::unique_ptr<TH2F>(
0702       new TH2F("SIMGEMCSCSegm_theta_cscSsh_vs_ndof_odd", "theta_cscSsh vs ndof odd", 30000, 0., 3., 15, -0.5, 14.5));
0703   SIMGEMCSC_theta_cscSsh_vs_ndof_even = std::unique_ptr<TH2F>(
0704       new TH2F("SIMGEMCSCSegm_theta_cscSsh_vs_ndof_even", "theta_cscSsh vs ndof even", 30000, 0., 3., 15, -0.5, 14.5));
0705 
0706   SIMGEMCSC_Residuals_gem_x = std::unique_ptr<TH1F>(new TH1F("xGEMRes_simhit", "xGEMRes", 100, -0.5, 0.5));
0707   SIMGEMCSC_Residuals_gem_y = std::unique_ptr<TH1F>(new TH1F("yGEMRes_simhit", "yGEMRes", 100, -10., 10.));
0708   SIMGEMCSC_Pool_gem_x_newE = std::unique_ptr<TH1F>(new TH1F("xGEMPool_newE_simhit", "xGEMPool newE", 100, -10., 10.));
0709   SIMGEMCSC_Pool_gem_y_newE = std::unique_ptr<TH1F>(new TH1F("yGEMPool_newE_simhit", "yGEMPool newE", 100, -10., 10.));
0710   SIMGEMCSC_Residuals_gem_odd_x = std::unique_ptr<TH1F>(new TH1F("xGEMRes_odd_simhit", "xGEMRes", 100, -0.5, 0.5));
0711   SIMGEMCSC_Residuals_gem_odd_y = std::unique_ptr<TH1F>(new TH1F("yGEMRes_odd_simhit", "yGEMRes", 100, -10., 10.));
0712   SIMGEMCSC_Pool_gem_x_newE_odd =
0713       std::unique_ptr<TH1F>(new TH1F("xGEMPool_odd_newE_simhit", "xGEMPool newE", 100, -10., 10.));
0714   SIMGEMCSC_Pool_gem_y_newE_odd =
0715       std::unique_ptr<TH1F>(new TH1F("yGEMPool_odd_newE_simhit", "yGEMPool newE", 100, -10., 10.));
0716   SIMGEMCSC_Residuals_gem_even_x = std::unique_ptr<TH1F>(new TH1F("xGEMRes_even_simhit", "xGEMRes", 100, -0.5, 0.5));
0717   SIMGEMCSC_Residuals_gem_even_y = std::unique_ptr<TH1F>(new TH1F("yGEMRes_even_simhit", "yGEMRes", 100, -10., 10.));
0718   SIMGEMCSC_Pool_gem_x_newE_even =
0719       std::unique_ptr<TH1F>(new TH1F("xGEMPool_even_newE_simhit", "xGEMPool newE", 100, -10., 10.));
0720   SIMGEMCSC_Pool_gem_y_newE_even =
0721       std::unique_ptr<TH1F>(new TH1F("yGEMPool_even_newE_simhit", "yGEMPool newE", 100, -10., 10.));
0722 
0723   SIMGEMCSC_Residuals_gem_rhsh_x = std::unique_ptr<TH1F>(new TH1F("xGEMRes_shrh", "xGEMRes", 100, -0.5, 0.5));
0724   SIMGEMCSC_Residuals_gem_rhsh_y = std::unique_ptr<TH1F>(new TH1F("yGEMRes_shrh", "yGEMRes", 100, -10., 10.));
0725   SIMGEMCSC_Pool_gem_rhsh_x_newE = std::unique_ptr<TH1F>(new TH1F("xGEMPool_shrh", "xGEMPool sh rh", 100, -5., 5.));
0726   SIMGEMCSC_Pool_gem_rhsh_y_newE = std::unique_ptr<TH1F>(new TH1F("yGEMPool_shrh", "yGEMPool sh rh", 100, -5., 5.));
0727 }
0728 
0729 TestGEMCSCSegmentAnalyzer::~TestGEMCSCSegmentAnalyzer() {
0730   SIM_etaVScharge->Write();
0731   SIM_etaVStype->Write();
0732 
0733   CSC_fitchi2->Write();
0734   GEMCSC_fitchi2->Write();
0735   GEMCSC_fitchi2_odd->Write();
0736   GEMCSC_fitchi2_even->Write();
0737   GEMCSC_NumGEMRH->Write();
0738   GEMCSC_NumCSCRH->Write();
0739   GEMCSC_NumGEMCSCRH->Write();
0740   GEMCSC_NumGEMCSCSeg->Write();
0741   GEMCSC_SSegm_LPx->Write();
0742   GEMCSC_SSegm_LPy->Write();
0743   GEMCSC_SSegm_LPEx->Write();
0744   GEMCSC_SSegm_LPEy->Write();
0745   //GEMCSC_SSegm_LPEz->Write();
0746   GEMCSC_SSegm_LDx->Write();
0747   GEMCSC_SSegm_LDy->Write();
0748   GEMCSC_SSegm_LDEx->Write();
0749   GEMCSC_SSegm_LDEy->Write();
0750   //GEMCSC_SSegm_LDEz->Write();
0751   GEMCSC_CSCSegm_LPx->Write();
0752   GEMCSC_CSCSegm_LPy->Write();
0753   GEMCSC_CSCSegm_LPEx->Write();
0754   GEMCSC_CSCSegm_LPEy->Write();
0755   //GEMCSC_CSCSegm_LPEz->Write();
0756   GEMCSC_CSCSegm_LDx->Write();
0757   GEMCSC_CSCSegm_LDy->Write();
0758   GEMCSC_CSCSegm_LDEx->Write();
0759   GEMCSC_CSCSegm_LDEy->Write();
0760   //GEMCSC_CSCSegm_LDEz->Write();
0761   GEMCSC_SSegm_LDEy_vs_ndof->Write();
0762   GEMCSC_SSegm_LPEy_vs_ndof->Write();
0763   GEMCSC_CSCSegm_LDEy_vs_ndof->Write();
0764   GEMCSC_CSCSegm_LPEy_vs_ndof->Write();
0765   SIMGEMCSC_SSegm_LDx->Write();
0766   SIMGEMCSC_SSegm_LDy->Write();
0767   SIMGEMCSC_SSegm_LDEx->Write();
0768   SIMGEMCSC_SSegm_LDEy->Write();
0769   GEMCSC_Residuals_x->Write();
0770   GEMCSC_Residuals_gem_x->Write();
0771   GEMCSC_Residuals_csc_x->Write();
0772   GEMCSC_Residuals_gem_even_x->Write();
0773   GEMCSC_Residuals_csc_even_x->Write();
0774   GEMCSC_Residuals_gem_odd_x->Write();
0775   GEMCSC_Residuals_csc_odd_x->Write();
0776   GEMCSC_Residuals_cscl1_x->Write();
0777   GEMCSC_Residuals_cscl2_x->Write();
0778   GEMCSC_Residuals_cscl3_x->Write();
0779   GEMCSC_Residuals_cscl4_x->Write();
0780   GEMCSC_Residuals_cscl5_x->Write();
0781   GEMCSC_Residuals_cscl6_x->Write();
0782   GEMCSC_Residuals_geml1_x->Write();
0783   GEMCSC_Residuals_geml2_x->Write();
0784   GEMCSC_Pool_x->Write();
0785   GEMCSC_Pool_gem_x->Write();
0786   GEMCSC_Pool_csc_x->Write();
0787   GEMCSC_Pool_gem_even_x->Write();
0788   GEMCSC_Pool_csc_even_x->Write();
0789   GEMCSC_Pool_gem_odd_x->Write();
0790   GEMCSC_Pool_csc_odd_x->Write();
0791   GEMCSC_Pool_cscl1_x->Write();
0792   GEMCSC_Pool_cscl2_x->Write();
0793   GEMCSC_Pool_cscl3_x->Write();
0794   GEMCSC_Pool_cscl4_x->Write();
0795   GEMCSC_Pool_cscl5_x->Write();
0796   GEMCSC_Pool_cscl6_x->Write();
0797   GEMCSC_Pool_geml1_x->Write();
0798   GEMCSC_Pool_geml2_x->Write();
0799   GEMCSC_Residuals_y->Write();
0800   GEMCSC_Residuals_gem_y->Write();
0801   GEMCSC_Residuals_csc_y->Write();
0802   GEMCSC_Residuals_gem_even_y->Write();
0803   GEMCSC_Residuals_csc_even_y->Write();
0804   GEMCSC_Residuals_gem_odd_y->Write();
0805   GEMCSC_Residuals_csc_odd_y->Write();
0806   GEMCSC_Residuals_cscl1_y->Write();
0807   GEMCSC_Residuals_cscl2_y->Write();
0808   GEMCSC_Residuals_cscl3_y->Write();
0809   GEMCSC_Residuals_cscl4_y->Write();
0810   GEMCSC_Residuals_cscl5_y->Write();
0811   GEMCSC_Residuals_cscl6_y->Write();
0812   GEMCSC_Residuals_geml1_y->Write();
0813   GEMCSC_Residuals_geml2_y->Write();
0814   GEMCSC_Pool_y->Write();
0815   GEMCSC_Pool_gem_y->Write();
0816   GEMCSC_Pool_csc_y->Write();
0817   GEMCSC_Pool_gem_even_y->Write();
0818   GEMCSC_Pool_csc_even_y->Write();
0819   GEMCSC_Pool_gem_odd_y->Write();
0820   GEMCSC_Pool_csc_odd_y->Write();
0821   GEMCSC_Pool_cscl1_y->Write();
0822   GEMCSC_Pool_cscl2_y->Write();
0823   GEMCSC_Pool_cscl3_y->Write();
0824   GEMCSC_Pool_cscl4_y->Write();
0825   GEMCSC_Pool_cscl5_y->Write();
0826   GEMCSC_Pool_cscl6_y->Write();
0827   GEMCSC_Pool_geml1_y->Write();
0828   GEMCSC_Pool_geml2_y->Write();
0829   GEMCSC_Pool_gem_x_newE->Write();
0830   GEMCSC_Pool_gem_y_newE->Write();
0831   GEMCSC_Pool_gem_odd_x_newE->Write();
0832   GEMCSC_Pool_gem_odd_y_newE->Write();
0833   GEMCSC_Pool_gem_x_newE_mp->Write();
0834   GEMCSC_Pool_gem_y_newE_mp->Write();
0835   GEMCSC_Pool_gem_odd_x_newE_mp->Write();
0836   GEMCSC_Pool_gem_odd_y_newE_mp->Write();
0837   GEMCSC_Pool_gem_x_newE_mm->Write();
0838   GEMCSC_Pool_gem_y_newE_mm->Write();
0839   GEMCSC_Pool_gem_odd_x_newE_mm->Write();
0840   GEMCSC_Pool_gem_odd_y_newE_mm->Write();
0841 
0842   GEMCSC_SSegm_xe_l1->Write();
0843   GEMCSC_SSegm_ye_l1->Write();
0844   GEMCSC_SSegm_ze_l1->Write();
0845   GEMCSC_SSegm_sigmaxe_l1->Write();
0846   GEMCSC_SSegm_sigmaye_l1->Write();
0847   GEMCSC_SSegm_xe_l1_odd->Write();
0848   GEMCSC_SSegm_ye_l1_odd->Write();
0849   GEMCSC_SSegm_ze_l1_odd->Write();
0850   GEMCSC_SSegm_sigmaxe_l1_odd->Write();
0851   GEMCSC_SSegm_sigmaye_l1_odd->Write();
0852   GEMCSC_SSegm_xe_l1_even->Write();
0853   GEMCSC_SSegm_ye_l1_even->Write();
0854   GEMCSC_SSegm_ze_l1_even->Write();
0855   GEMCSC_SSegm_sigmaxe_l1_even->Write();
0856   GEMCSC_SSegm_sigmaye_l1_even->Write();
0857 
0858   GEMCSC_SSegm_xe_l2->Write();
0859   GEMCSC_SSegm_ye_l2->Write();
0860   GEMCSC_SSegm_ze_l2->Write();
0861   GEMCSC_SSegm_sigmaxe_l2->Write();
0862   GEMCSC_SSegm_sigmaye_l2->Write();
0863   GEMCSC_SSegm_xe_l2_odd->Write();
0864   GEMCSC_SSegm_ye_l2_odd->Write();
0865   GEMCSC_SSegm_ze_l2_odd->Write();
0866   GEMCSC_SSegm_sigmaxe_l2_odd->Write();
0867   GEMCSC_SSegm_sigmaye_l2_odd->Write();
0868   GEMCSC_SSegm_xe_l2_even->Write();
0869   GEMCSC_SSegm_ye_l2_even->Write();
0870   GEMCSC_SSegm_ze_l2_even->Write();
0871   GEMCSC_SSegm_sigmaxe_l2_even->Write();
0872   GEMCSC_SSegm_sigmaye_l2_even->Write();
0873 
0874   GEMCSC_CSCSegm_xe_l1->Write();
0875   GEMCSC_CSCSegm_ye_l1->Write();
0876   GEMCSC_CSCSegm_ze_l1->Write();
0877   GEMCSC_CSCSegm_sigmaxe_l1->Write();
0878   GEMCSC_CSCSegm_sigmaye_l1->Write();
0879   GEMCSC_CSCSegm_xe_l1_odd->Write();
0880   GEMCSC_CSCSegm_ye_l1_odd->Write();
0881   GEMCSC_CSCSegm_ze_l1_odd->Write();
0882   GEMCSC_CSCSegm_sigmaxe_l1_odd->Write();
0883   GEMCSC_CSCSegm_sigmaye_l1_odd->Write();
0884   GEMCSC_CSCSegm_xe_l1_even->Write();
0885   GEMCSC_CSCSegm_ye_l1_even->Write();
0886   GEMCSC_CSCSegm_ze_l1_even->Write();
0887   GEMCSC_CSCSegm_sigmaxe_l1_even->Write();
0888   GEMCSC_CSCSegm_sigmaye_l1_even->Write();
0889 
0890   GEMCSC_CSCSegm_xe_l2->Write();
0891   GEMCSC_CSCSegm_ye_l2->Write();
0892   GEMCSC_CSCSegm_ze_l2->Write();
0893   GEMCSC_CSCSegm_sigmaxe_l2->Write();
0894   GEMCSC_CSCSegm_sigmaye_l2->Write();
0895   GEMCSC_CSCSegm_xe_l2_odd->Write();
0896   GEMCSC_CSCSegm_ye_l2_odd->Write();
0897   GEMCSC_CSCSegm_ze_l2_odd->Write();
0898   GEMCSC_CSCSegm_sigmaxe_l2_odd->Write();
0899   GEMCSC_CSCSegm_sigmaye_l2_odd->Write();
0900   GEMCSC_CSCSegm_xe_l2_even->Write();
0901   GEMCSC_CSCSegm_ye_l2_even->Write();
0902   GEMCSC_CSCSegm_ze_l2_even->Write();
0903   GEMCSC_CSCSegm_sigmaxe_l2_even->Write();
0904   GEMCSC_CSCSegm_sigmaye_l2_even->Write();
0905 
0906   GEMCSC_Dphi_min_afterCut->Write();
0907   GEMCSC_Dtheta_min_afterCut->Write();
0908   GEMCSC_Dphi_min_afterCut_odd->Write();
0909   GEMCSC_Dphi_min_afterCut_even->Write();
0910   GEMCSC_DR_min_afterCut->Write();
0911   GEMCSC_Dphi_min_afterCut_l1->Write();
0912   GEMCSC_Dphi_min_afterCut_l1_odd->Write();
0913   GEMCSC_Dphi_min_afterCut_l1_even->Write();
0914   GEMCSC_Dphi_min_afterCut_l2->Write();
0915   GEMCSC_Dphi_min_afterCut_l2_odd->Write();
0916   GEMCSC_Dphi_min_afterCut_l2_even->Write();
0917 
0918   GEMCSC_Dphi_cscS_min_afterCut->Write();
0919   GEMCSC_Dtheta_cscS_min_afterCut->Write();
0920   GEMCSC_Dtheta_cscS_min_afterCut_odd->Write();
0921   GEMCSC_Dtheta_cscS_min_afterCut_even->Write();
0922   GEMCSC_DR_cscS_min_afterCut->Write();
0923 
0924   GEMCSC_Dphi_cscS_min_afterCut_l1->Write();
0925   GEMCSC_Dphi_cscS_min_afterCut_l1_odd->Write();
0926   GEMCSC_Dphi_cscS_min_afterCut_l1_even->Write();
0927   GEMCSC_Dphi_cscS_min_afterCut_l2->Write();
0928   GEMCSC_Dphi_cscS_min_afterCut_l2_odd->Write();
0929   GEMCSC_Dphi_cscS_min_afterCut_l2_even->Write();
0930 
0931   GEMCSC_Dphi_cscS_min_afterCut_odd->Write();
0932   GEMCSC_Dphi_cscS_min_afterCut_even->Write();
0933   GEMCSC_Dphi_cscS_min_afterCut_odd_r1->Write();
0934   GEMCSC_Dphi_cscS_min_afterCut_odd_r2->Write();
0935   GEMCSC_Dphi_cscS_min_afterCut_odd_r3->Write();
0936   GEMCSC_Dphi_cscS_min_afterCut_odd_r4->Write();
0937   GEMCSC_Dphi_cscS_min_afterCut_odd_r5->Write();
0938   GEMCSC_Dphi_cscS_min_afterCut_odd_r6->Write();
0939   GEMCSC_Dphi_cscS_min_afterCut_odd_r7->Write();
0940   GEMCSC_Dphi_cscS_min_afterCut_odd_r8->Write();
0941 
0942   SIMGEMCSC_Dphi_SS_min_afterCut->Write();
0943   SIMGEMCSC_Dtheta_SS_min_afterCut->Write();
0944   SIMGEMCSC_Dtheta_SS_min_afterCut_odd->Write();
0945   SIMGEMCSC_Dtheta_SS_min_afterCut_even->Write();
0946   SIMGEMCSC_Dphi_SS_min_afterCut_odd->Write();
0947   SIMGEMCSC_Dphi_SS_min_afterCut_even->Write();
0948 
0949   SIMGEMCSC_Dphi_cscS_min_afterCut->Write();
0950   SIMGEMCSC_Dtheta_cscS_min_afterCut->Write();
0951   SIMGEMCSC_Dtheta_cscS_min_afterCut_odd->Write();
0952   SIMGEMCSC_Dtheta_cscS_min_afterCut_even->Write();
0953   SIMGEMCSC_Dphi_cscS_min_afterCut_odd->Write();
0954   SIMGEMCSC_Dphi_cscS_min_afterCut_even->Write();
0955   SIMGEMCSC_Residuals_gem_x->Write();
0956   SIMGEMCSC_Residuals_gem_y->Write();
0957   SIMGEMCSC_Pool_gem_x_newE->Write();
0958   SIMGEMCSC_Pool_gem_y_newE->Write();
0959   SIMGEMCSC_Residuals_gem_odd_x->Write();
0960   SIMGEMCSC_Residuals_gem_odd_y->Write();
0961   SIMGEMCSC_Pool_gem_x_newE_odd->Write();
0962   SIMGEMCSC_Pool_gem_y_newE_odd->Write();
0963   SIMGEMCSC_Residuals_gem_even_x->Write();
0964   SIMGEMCSC_Residuals_gem_even_y->Write();
0965   SIMGEMCSC_Pool_gem_x_newE_even->Write();
0966   SIMGEMCSC_Pool_gem_y_newE_even->Write();
0967 
0968   SIMGEMCSC_Residuals_gem_rhsh_x->Write();
0969   SIMGEMCSC_Residuals_gem_rhsh_y->Write();
0970   SIMGEMCSC_Pool_gem_rhsh_x_newE->Write();
0971   SIMGEMCSC_Pool_gem_rhsh_y_newE->Write();
0972 
0973   SIMGEMCSC_theta_cscSsh_vs_ndof_odd->Write();
0974   SIMGEMCSC_theta_cscSsh_vs_ndof_even->Write();
0975 }
0976 
0977 // ------------ method called for each event  ------------
0978 void TestGEMCSCSegmentAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0979   const auto gemGeom = iSetup.getHandle(kGEMGeometryToken_);
0980   if (not gemGeom.isValid()) {
0981     edm::LogError("GEMCSCSegment") << "invalid GEMGeometry";
0982     return;
0983   }
0984 
0985   const auto cscGeom = iSetup.getHandle(kCSCGeometryToken_);
0986   if (not cscGeom.isValid()) {
0987     edm::LogError("GEMCSCSegment") << "invalid CSCGeometry";
0988     return;
0989   }
0990   const CSCGeometry* cscGeom_ = &*cscGeom;
0991 
0992   // ================
0993   // Sim Tracks
0994   // ================
0995   edm::Handle<edm::SimTrackContainer> simTracks;
0996   iEvent.getByToken(SimTrack_Token, simTracks);
0997   // edm::Handle<edm::SimTrackContainer> simTracks;
0998   // iEvent.getByLabel("g4SimHits",simTracks);
0999 
1000   edm::SimTrackContainer::const_iterator simTrack;
1001 
1002   for (simTrack = simTracks->begin(); simTrack != simTracks->end(); ++simTrack) {
1003     if (!(abs((*simTrack).type()) == 13))
1004       continue;
1005     double simEta = (*simTrack).momentum().eta();
1006     //double simPhi = (*simTrack).momentum().phi();
1007     int qGen = simTrack->charge();
1008     SIM_etaVScharge->Fill(simEta, qGen);
1009     SIM_etaVStype->Fill(simEta, (*simTrack).type());
1010   }
1011 
1012   // ================
1013   // CSC Segments
1014   // ================
1015   edm::Handle<CSCSegmentCollection> cscSegment;
1016   iEvent.getByToken(CSCSegment_Token, cscSegment);
1017   // edm::Handle<CSCSegmentCollection> cscSegment;
1018   // iEvent.getByLabel("cscSegments","",cscSegment);
1019 
1020   for (auto cscs = cscSegment->begin(); cscs != cscSegment->end(); cscs++) {
1021     CSCDetId CSCId = cscs->cscDetId();
1022     if (!(CSCId.station() == 1 && (CSCId.ring() == 1 || CSCId.ring() == 4)))
1023       continue;
1024 
1025     auto cscrhs = cscs->specificRecHits();
1026   }
1027 
1028   // ================
1029   // GEMCSC Segments
1030   // ================
1031   edm::Handle<GEMCSCSegmentCollection> gemcscSegment;
1032   iEvent.getByToken(GEMCSCSegment_Token, gemcscSegment);
1033   // edm::Handle<GEMCSCSegmentCollection> gemcscSegment;
1034   // iEvent.getByLabel("gemcscSegments","", gemcscSegment);
1035   // iEvent.getByLabel("gemcscSegments","", "RECO", gemcscSegment);
1036   // iEvent.getByLabel("gemcscSegments", "", "GEMCSCREC", gemcscSegment);
1037 
1038   if (gemcscSegment->size() != 0)
1039     GEMCSC_NumGEMCSCSeg->Fill(gemcscSegment->size());
1040 
1041   for (auto gemcscs = gemcscSegment->begin(); gemcscs != gemcscSegment->end(); gemcscs++) {
1042     auto gemrhs_if = gemcscs->gemRecHits();
1043     if (debug) {
1044       std::cout << "GEM-CSC Segment with " << gemcscs->gemRecHits().size() << " GEM rechits and "
1045                 << gemcscs->cscSegment().specificRecHits().size() << " CSC rechits" << std::endl;
1046     }
1047     if (gemrhs_if.size() == 0)
1048       continue;
1049     // if(gemrhs_if.size()!=0) continue;
1050 
1051     // --- some printout for debug -----------------------------------------------------------------------------------------------------------------------------------
1052     if (debug) {
1053       std::cout << "GEM-CSC Segment with " << gemcscs->gemRecHits().size() << " GEM rechits and "
1054                 << gemcscs->cscSegment().specificRecHits().size() << " CSC rechits" << std::endl;
1055       auto gemrhs = gemcscs->gemRecHits();
1056       for (auto rh = gemrhs.begin(); rh != gemrhs.end(); rh++) {
1057         GEMDetId gemId((*rh).geographicalId());
1058         const GEMEtaPartition* id_etapart = gemGeom->etaPartition(gemId);
1059         const BoundPlane& GEMSurface = id_etapart->surface();
1060         GlobalPoint GEMGlobalPoint = GEMSurface.toGlobal((*rh).localPosition());
1061         std::cout << "GEM Rechit in " << gemId << " = " << gemId.rawId() << " at X = " << GEMGlobalPoint.x()
1062                   << " Y = " << GEMGlobalPoint.y() << " Z = " << GEMGlobalPoint.z() << std::endl;
1063       }
1064       CSCSegment cscSeg = gemcscs->cscSegment();
1065       auto cscrhs = cscSeg.specificRecHits();
1066       for (auto rh = cscrhs.begin(); rh != cscrhs.end(); rh++) {
1067         CSCDetId cscId = (CSCDetId)(*rh).cscDetId();
1068         GlobalPoint CSCGlobalPoint = cscGeom->idToDet(cscId)->toGlobal((*rh).localPosition());
1069         std::cout << "CSC Rechit in " << cscId << " = " << cscId.rawId() << " at X = " << CSCGlobalPoint.x()
1070                   << " Y = " << CSCGlobalPoint.y() << " Z = " << CSCGlobalPoint.z() << std::endl;
1071       }
1072     }
1073     // --- some printout for debug -----------------------------------------------------------------------------------------------------------------------------------
1074 
1075     ///////// GEMCSC seg //////////////////////////////////////
1076     CSCDetId gemcscId = gemcscs->cscDetId();
1077     const CSCChamber* cscChamber = cscGeom_->chamber(gemcscId);
1078 
1079     auto gemcscsegLP = gemcscs->localPosition();
1080     auto gemcscsegLD = gemcscs->localDirection();
1081     auto gemcscsegLEP = gemcscs->localPositionError();
1082     auto gemcscsegLED = gemcscs->localDirectionError();
1083     GEMCSC_SSegm_LPx->Fill(gemcscsegLP.x());
1084     GEMCSC_SSegm_LPy->Fill(gemcscsegLP.y());
1085     GEMCSC_SSegm_LPEx->Fill(sqrt(gemcscsegLEP.xx()));
1086     GEMCSC_SSegm_LPEy->Fill(sqrt(gemcscsegLEP.yy()));
1087     //GEMCSC_SSegm_LPEz->Fill(gemcscsegLEP.zz());
1088     GEMCSC_SSegm_LDx->Fill(gemcscsegLD.x());
1089     GEMCSC_SSegm_LDy->Fill(gemcscsegLD.y());
1090     GEMCSC_SSegm_LDEx->Fill(sqrt(gemcscsegLED.xx()));
1091     GEMCSC_SSegm_LDEy->Fill(sqrt(gemcscsegLED.yy()));
1092     //GEMCSC_SSegm_LDEz->Fill(gemcscsegLED.zz());
1093     GEMCSC_SSegm_LPEy_vs_ndof->Fill(gemcscsegLEP.yy(), gemcscs->degreesOfFreedom());
1094     GEMCSC_SSegm_LDEy_vs_ndof->Fill(gemcscsegLED.yy(), gemcscs->degreesOfFreedom());
1095 
1096     GEMCSC_fitchi2->Fill(gemcscs->chi2() / gemcscs->degreesOfFreedom());
1097 
1098     CSCDetId id((*gemcscs).geographicalId());
1099     int chamber = id.chamber();
1100     if (chamber % 2 != 0) {
1101       GEMCSC_fitchi2_odd->Fill(gemcscs->chi2() / gemcscs->degreesOfFreedom());
1102     } else {
1103       GEMCSC_fitchi2_even->Fill(gemcscs->chi2() / gemcscs->degreesOfFreedom());
1104     }
1105 
1106     GEMCSC_NumGEMCSCRH->Fill(gemcscs->cscSegment().specificRecHits().size() + gemcscs->gemRecHits().size());
1107 
1108     ///////// CSC seg /////////////////////////////////////
1109     CSCSegment cscSeg = gemcscs->cscSegment();
1110     //CSCDetId CSCId_new = cscSeg.cscDetId();
1111     //if(!(CSCId_new.station() == 1 && CSCId_new.ring() == 1)) continue;
1112     auto cscrhs = cscSeg.specificRecHits();
1113     GEMCSC_NumCSCRH->Fill(cscrhs.size());
1114 
1115     auto cscsegLP = cscSeg.localPosition();
1116     auto cscsegLD = cscSeg.localDirection();
1117     auto cscsegLEP = cscSeg.localPositionError();
1118     auto cscsegLED = cscSeg.localDirectionError();
1119 
1120     GEMCSC_CSCSegm_LPx->Fill(cscsegLP.x());
1121     GEMCSC_CSCSegm_LPy->Fill(cscsegLP.y());
1122     GEMCSC_CSCSegm_LPEx->Fill(sqrt(cscsegLEP.xx()));
1123     GEMCSC_CSCSegm_LPEy->Fill(sqrt(cscsegLEP.yy()));
1124     //GEMCSC_CSCSegm_LPEz->Fill(cscsegLEP.zz());
1125     GEMCSC_CSCSegm_LDx->Fill(cscsegLD.x());
1126     GEMCSC_CSCSegm_LDy->Fill(cscsegLD.y());
1127     GEMCSC_CSCSegm_LDEx->Fill(sqrt(cscsegLED.xx()));
1128     GEMCSC_CSCSegm_LDEy->Fill(sqrt(cscsegLED.yy()));
1129     //GEMCSC_CSCSegm_LDEz->Fill(cscsegLED.zz());
1130     GEMCSC_CSCSegm_LPEy_vs_ndof->Fill(cscsegLEP.yy(), cscSeg.degreesOfFreedom());
1131     GEMCSC_CSCSegm_LDEy_vs_ndof->Fill(cscsegLED.yy(), cscSeg.degreesOfFreedom());
1132 
1133     CSC_fitchi2->Fill(cscSeg.chi2() / cscSeg.degreesOfFreedom());
1134 
1135     //////////////////////// CSC RH
1136     for (auto rh = cscrhs.begin(); rh != cscrhs.end(); rh++) {
1137       //CSCDetId cscrhId = rh.cscDetId();
1138       CSCDetId cscrhId = (CSCDetId)(*rh).cscDetId();
1139       const CSCLayer* cscrhRef = cscGeom_->layer(cscrhId);
1140 
1141       auto cscrhLP = rh->localPosition();
1142       auto cscrhLEP = rh->localPositionError();
1143       auto cscrhGP = cscrhRef->toGlobal(cscrhLP);
1144       auto cscrhLP_inSegmRef = cscChamber->toLocal(cscrhGP);
1145       float xe = gemcscsegLP.x() + gemcscsegLD.x() * cscrhLP_inSegmRef.z() / gemcscsegLD.z();
1146       float ye = gemcscsegLP.y() + gemcscsegLD.y() * cscrhLP_inSegmRef.z() / gemcscsegLD.z();
1147       float ze = cscrhLP_inSegmRef.z();
1148       LocalPoint extrPoint(xe, ye, ze);  // in segment rest frame
1149       //float sigma_xe = gemcscsegLEP.xx()+gemcscsegLED.xx()*cscrhLP_inSegmRef.z()*cscrhLP_inSegmRef.z();
1150       //float sigma_ye = gemcscsegLEP.yy()+gemcscsegLED.yy()*cscrhLP_inSegmRef.z()*cscrhLP_inSegmRef.z();
1151       auto extSegm = cscrhRef->toLocal(cscChamber->toGlobal(extrPoint));  // in layer restframe
1152 
1153       GEMCSC_Residuals_x->Fill(cscrhLP.x() - extSegm.x());
1154       GEMCSC_Residuals_y->Fill(cscrhLP.y() - extSegm.y());
1155       GEMCSC_Pool_x->Fill((cscrhLP.x() - extSegm.x()) / sqrt(cscrhLEP.xx()));
1156       GEMCSC_Pool_y->Fill((cscrhLP.y() - extSegm.y()) / sqrt(cscrhLEP.yy()));
1157       GEMCSC_Residuals_csc_x->Fill(cscrhLP.x() - extSegm.x());
1158       GEMCSC_Residuals_csc_y->Fill(cscrhLP.y() - extSegm.y());
1159       GEMCSC_Pool_csc_x->Fill((cscrhLP.x() - extSegm.x()) / sqrt(cscrhLEP.xx()));
1160       GEMCSC_Pool_csc_y->Fill((cscrhLP.y() - extSegm.y()) / sqrt(cscrhLEP.yy()));
1161 
1162       CSCDetId id((*rh).geographicalId());
1163       int chamber = id.chamber();
1164       if (chamber % 2 != 0) {
1165         //std::cout<<"camera dispari"<<chamber<<std::endl;
1166         GEMCSC_Residuals_csc_odd_x->Fill(cscrhLP.x() - extSegm.x());
1167         GEMCSC_Residuals_csc_odd_y->Fill(cscrhLP.y() - extSegm.y());
1168         GEMCSC_Pool_csc_odd_x->Fill((cscrhLP.x() - extSegm.x()) / sqrt(cscrhLEP.xx()));
1169         GEMCSC_Pool_csc_odd_y->Fill((cscrhLP.y() - extSegm.y()) / sqrt(cscrhLEP.yy()));
1170       } else {
1171         GEMCSC_Residuals_csc_even_x->Fill(cscrhLP.x() - extSegm.x());
1172         GEMCSC_Residuals_csc_even_y->Fill(cscrhLP.y() - extSegm.y());
1173         GEMCSC_Pool_csc_even_x->Fill((cscrhLP.x() - extSegm.x()) / sqrt(cscrhLEP.xx()));
1174         GEMCSC_Pool_csc_even_y->Fill((cscrhLP.y() - extSegm.y()) / sqrt(cscrhLEP.yy()));
1175       }
1176 
1177       switch (cscrhId.layer()) {
1178         case 1:
1179           GEMCSC_Residuals_cscl1_x->Fill(cscrhLP.x() - extSegm.x());
1180           GEMCSC_Residuals_cscl1_y->Fill(cscrhLP.y() - extSegm.y());
1181           GEMCSC_Pool_cscl1_x->Fill((cscrhLP.x() - extSegm.x()) / sqrt(cscrhLEP.xx()));
1182           GEMCSC_Pool_cscl1_y->Fill((cscrhLP.x() - extSegm.y()) / sqrt(cscrhLEP.yy()));
1183           break;
1184         case 2:
1185           GEMCSC_Residuals_cscl2_x->Fill(cscrhLP.x() - extSegm.x());
1186           GEMCSC_Residuals_cscl2_y->Fill(cscrhLP.y() - extSegm.y());
1187           GEMCSC_Pool_cscl2_x->Fill((cscrhLP.x() - extSegm.x()) / sqrt(cscrhLEP.xx()));
1188           GEMCSC_Pool_cscl2_y->Fill((cscrhLP.x() - extSegm.y()) / sqrt(cscrhLEP.yy()));
1189           break;
1190 
1191         case 3:
1192           GEMCSC_Residuals_cscl3_x->Fill(cscrhLP.x() - extSegm.x());
1193           GEMCSC_Residuals_cscl3_y->Fill(cscrhLP.y() - extSegm.y());
1194           GEMCSC_Pool_cscl3_x->Fill((cscrhLP.x() - extSegm.x()) / sqrt(cscrhLEP.xx()));
1195           GEMCSC_Pool_cscl3_y->Fill((cscrhLP.x() - extSegm.y()) / sqrt(cscrhLEP.yy()));
1196           break;
1197         case 4:
1198           GEMCSC_Residuals_cscl4_x->Fill(cscrhLP.x() - extSegm.x());
1199           GEMCSC_Residuals_cscl4_y->Fill(cscrhLP.y() - extSegm.y());
1200           GEMCSC_Pool_cscl4_x->Fill((cscrhLP.x() - extSegm.x()) / sqrt(cscrhLEP.xx()));
1201           GEMCSC_Pool_cscl4_y->Fill((cscrhLP.x() - extSegm.y()) / sqrt(cscrhLEP.yy()));
1202           break;
1203         case 5:
1204           GEMCSC_Residuals_cscl5_x->Fill(cscrhLP.x() - extSegm.x());
1205           GEMCSC_Residuals_cscl5_y->Fill(cscrhLP.y() - extSegm.y());
1206           GEMCSC_Pool_cscl5_x->Fill((cscrhLP.x() - extSegm.x()) / sqrt(cscrhLEP.xx()));
1207           GEMCSC_Pool_cscl5_y->Fill((cscrhLP.x() - extSegm.y()) / sqrt(cscrhLEP.yy()));
1208           break;
1209         case 6:
1210           GEMCSC_Residuals_cscl6_x->Fill(cscrhLP.x() - extSegm.x());
1211           GEMCSC_Residuals_cscl6_y->Fill(cscrhLP.y() - extSegm.y());
1212           GEMCSC_Pool_cscl6_x->Fill((cscrhLP.x() - extSegm.x()) / sqrt(cscrhLEP.xx()));
1213           GEMCSC_Pool_cscl6_y->Fill((cscrhLP.x() - extSegm.y()) / sqrt(cscrhLEP.yy()));
1214           break;
1215         default:
1216           std::cout << " Unphysical GEMCSC layer " << cscrhId << std::endl;
1217       }
1218     }
1219     //////////////////
1220 
1221     //////// GEM recHits ////////////////////
1222     auto gemrhs = gemcscs->gemRecHits();
1223     GEMCSC_NumGEMRH->Fill(gemrhs.size());
1224     for (auto rh = gemrhs.begin(); rh != gemrhs.end(); rh++) {
1225       GEMDetId id((*rh).geographicalId());
1226       int chamber = id.chamber();
1227 
1228       //GEMDetId gemid(rh->geographicalId());
1229       auto gemrhId = rh->gemId();
1230       const GEMEtaPartition* gemrhRef = gemGeom->etaPartition(gemrhId);
1231       auto gemrhLP = rh->localPosition();
1232       auto gemrhLEP = rh->localPositionError();
1233       auto gemrhGP = gemrhRef->toGlobal(gemrhLP);
1234       auto gemrhLP_inSegmRef = cscChamber->toLocal(gemrhGP);
1235       float phi_rh = gemrhGP.phi();
1236       float theta_rh = gemrhGP.theta();
1237       float eta_rh = gemrhGP.eta();
1238       float xe = gemcscsegLP.x() + gemcscsegLD.x() * gemrhLP_inSegmRef.z() / gemcscsegLD.z();
1239       float ye = gemcscsegLP.y() + gemcscsegLD.y() * gemrhLP_inSegmRef.z() / gemcscsegLD.z();
1240       float ze = gemrhLP_inSegmRef.z();
1241       LocalPoint extrPoint(xe, ye, ze);  // in segment rest frame
1242       float sigma_xe = sqrt(gemcscsegLEP.xx() + gemcscsegLED.xx() * gemrhLP_inSegmRef.z() * gemrhLP_inSegmRef.z());
1243       float sigma_ye = sqrt(gemcscsegLEP.yy() + gemcscsegLED.yy() * gemrhLP_inSegmRef.z() * gemrhLP_inSegmRef.z());
1244       auto extrPoinGP_fromSegmRef = cscChamber->toGlobal(extrPoint);
1245       float phi_ext = extrPoinGP_fromSegmRef.phi();
1246       float theta_ext = extrPoinGP_fromSegmRef.theta();
1247 
1248       auto extSegm = gemrhRef->toLocal(cscChamber->toGlobal(extrPoint));  // in layer restframe
1249 
1250       GEMCSC_Dphi_min_afterCut->Fill(phi_ext - phi_rh);
1251       GEMCSC_Dtheta_min_afterCut->Fill((theta_ext - theta_rh));
1252       GEMCSC_DR_min_afterCut->Fill((theta_ext - theta_rh) * (theta_ext - theta_rh) +
1253                                    (phi_ext - phi_rh) * (phi_ext - phi_rh));
1254 
1255       switch (gemrhId.layer()) {
1256         case 1:
1257           GEMCSC_SSegm_xe_l1->Fill(xe);
1258           GEMCSC_SSegm_ye_l1->Fill(ye);
1259           GEMCSC_SSegm_ze_l1->Fill(ze);
1260           GEMCSC_SSegm_sigmaxe_l1->Fill(sigma_xe);
1261           GEMCSC_SSegm_sigmaye_l1->Fill(sigma_ye);
1262           GEMCSC_Dphi_min_afterCut_l1->Fill((phi_ext - phi_rh));
1263           if (chamber % 2 != 0) {
1264             GEMCSC_Dphi_min_afterCut_l1_odd->Fill((phi_ext - phi_rh));
1265             GEMCSC_Dphi_min_afterCut_odd->Fill((phi_ext - phi_rh));
1266             GEMCSC_SSegm_xe_l1_odd->Fill(xe);
1267             GEMCSC_SSegm_ye_l1_odd->Fill(ye);
1268             GEMCSC_SSegm_ze_l1_odd->Fill(ze);
1269             GEMCSC_SSegm_sigmaxe_l1_odd->Fill(sigma_xe);
1270             GEMCSC_SSegm_sigmaye_l1_odd->Fill(sigma_ye);
1271           } else {
1272             GEMCSC_Dphi_min_afterCut_l1_even->Fill((phi_ext - phi_rh));
1273             GEMCSC_Dphi_min_afterCut_even->Fill((phi_ext - phi_rh));
1274             GEMCSC_SSegm_xe_l1_even->Fill(xe);
1275             GEMCSC_SSegm_ye_l1_even->Fill(ye);
1276             GEMCSC_SSegm_ze_l1_even->Fill(ze);
1277             GEMCSC_SSegm_sigmaxe_l1_even->Fill(sigma_xe);
1278             GEMCSC_SSegm_sigmaye_l1_even->Fill(sigma_ye);
1279           }
1280 
1281           break;
1282         case 2:
1283           GEMCSC_SSegm_xe_l2->Fill(xe);
1284           GEMCSC_SSegm_ye_l2->Fill(ye);
1285           GEMCSC_SSegm_ze_l2->Fill(ze);
1286           GEMCSC_SSegm_sigmaxe_l2->Fill(sigma_xe);
1287           GEMCSC_SSegm_sigmaye_l2->Fill(sigma_ye);
1288           GEMCSC_Dphi_min_afterCut_l2->Fill((phi_ext - phi_rh));
1289           if (chamber % 2 != 0) {
1290             GEMCSC_Dphi_min_afterCut_l2_odd->Fill((phi_ext - phi_rh));
1291             GEMCSC_Dphi_min_afterCut_odd->Fill((phi_ext - phi_rh));
1292             GEMCSC_SSegm_xe_l2_odd->Fill(xe);
1293             GEMCSC_SSegm_ye_l2_odd->Fill(ye);
1294             GEMCSC_SSegm_ze_l2_odd->Fill(ze);
1295             GEMCSC_SSegm_sigmaxe_l2_odd->Fill(sigma_xe);
1296             GEMCSC_SSegm_sigmaye_l2_odd->Fill(sigma_ye);
1297           } else {
1298             GEMCSC_Dphi_min_afterCut_l2_even->Fill((phi_ext - phi_rh));
1299             GEMCSC_Dphi_min_afterCut_even->Fill((phi_ext - phi_rh));
1300             GEMCSC_SSegm_xe_l2_even->Fill(xe);
1301             GEMCSC_SSegm_ye_l2_even->Fill(ye);
1302             GEMCSC_SSegm_ze_l2_even->Fill(ze);
1303             GEMCSC_SSegm_sigmaxe_l2_even->Fill(sigma_xe);
1304             GEMCSC_SSegm_sigmaye_l2_even->Fill(sigma_ye);
1305           }
1306 
1307           break;
1308         default:
1309           std::cout << " Unphysical GEMCSC layer " << gemrhId << std::endl;
1310       }
1311 
1312       GEMCSC_Residuals_x->Fill(gemrhLP.x() - extSegm.x());
1313       GEMCSC_Residuals_y->Fill(gemrhLP.y() - extSegm.y());
1314       GEMCSC_Pool_x->Fill((gemrhLP.x() - extSegm.x()) / sqrt(gemrhLEP.xx()));
1315       GEMCSC_Pool_y->Fill((gemrhLP.y() - extSegm.y()) / sqrt(gemrhLEP.yy()));
1316       GEMCSC_Residuals_gem_x->Fill(gemrhLP.x() - extSegm.x());
1317       GEMCSC_Residuals_gem_y->Fill(gemrhLP.y() - extSegm.y());
1318       GEMCSC_Pool_gem_x->Fill((gemrhLP.x() - extSegm.x()) / sqrt(gemrhLEP.xx()));
1319       GEMCSC_Pool_gem_y->Fill((gemrhLP.y() - extSegm.y()) / sqrt(gemrhLEP.yy()));
1320       GEMCSC_Pool_gem_x_newE->Fill((gemrhLP.x() - extSegm.x()) / sqrt(gemrhLEP.xx() + sigma_xe * sigma_xe));
1321       GEMCSC_Pool_gem_y_newE->Fill((gemrhLP.y() - extSegm.y()) / sqrt(gemrhLEP.yy() + sigma_ye * sigma_ye));
1322 
1323       if (eta_rh > 0) {
1324         GEMCSC_Pool_gem_x_newE_mp->Fill((gemrhLP.x() - extSegm.x()) / sqrt(gemrhLEP.xx() + sigma_xe * sigma_xe));
1325         GEMCSC_Pool_gem_y_newE_mp->Fill((gemrhLP.y() - extSegm.y()) / sqrt(gemrhLEP.yy() + sigma_ye * sigma_ye));
1326       }
1327       if (eta_rh < 0) {
1328         GEMCSC_Pool_gem_x_newE_mm->Fill((gemrhLP.x() - extSegm.x()) / sqrt(gemrhLEP.xx() + sigma_xe * sigma_xe));
1329         GEMCSC_Pool_gem_y_newE_mm->Fill((gemrhLP.y() - extSegm.y()) / sqrt(gemrhLEP.yy() + sigma_ye * sigma_ye));
1330       }
1331 
1332       if (chamber % 2 != 0) {
1333         GEMCSC_Residuals_gem_odd_x->Fill(gemrhLP.x() - extSegm.x());
1334         GEMCSC_Residuals_gem_odd_y->Fill(gemrhLP.y() - extSegm.y());
1335         GEMCSC_Pool_gem_odd_x->Fill((gemrhLP.x() - extSegm.x()) / sqrt(gemrhLEP.xx()));
1336         GEMCSC_Pool_gem_odd_y->Fill((gemrhLP.y() - extSegm.y()) / sqrt(gemrhLEP.yy()));
1337         GEMCSC_Pool_gem_odd_x_newE->Fill((gemrhLP.x() - extSegm.x()) / sqrt(gemrhLEP.xx() + sigma_xe * sigma_xe));
1338         GEMCSC_Pool_gem_odd_y_newE->Fill((gemrhLP.y() - extSegm.y()) / sqrt(gemrhLEP.yy() + sigma_ye * sigma_ye));
1339         if (eta_rh > 0) {
1340           GEMCSC_Pool_gem_odd_x_newE_mp->Fill((gemrhLP.x() - extSegm.x()) / sqrt(gemrhLEP.xx() + sigma_xe * sigma_xe));
1341           GEMCSC_Pool_gem_odd_y_newE_mp->Fill((gemrhLP.y() - extSegm.y()) / sqrt(gemrhLEP.yy() + sigma_ye * sigma_ye));
1342         }
1343         if (eta_rh < 0) {
1344           GEMCSC_Pool_gem_odd_x_newE_mm->Fill((gemrhLP.x() - extSegm.x()) / sqrt(gemrhLEP.xx() + sigma_xe * sigma_xe));
1345           GEMCSC_Pool_gem_odd_y_newE_mm->Fill((gemrhLP.y() - extSegm.y()) / sqrt(gemrhLEP.yy() + sigma_ye * sigma_ye));
1346         }
1347       } else {
1348         GEMCSC_Residuals_gem_even_x->Fill(gemrhLP.x() - extSegm.x());
1349         GEMCSC_Residuals_gem_even_y->Fill(gemrhLP.y() - extSegm.y());
1350         GEMCSC_Pool_gem_even_x->Fill((gemrhLP.x() - extSegm.x()) / sqrt(gemrhLEP.xx()));
1351         GEMCSC_Pool_gem_even_y->Fill((gemrhLP.y() - extSegm.y()) / sqrt(gemrhLEP.yy()));
1352       }
1353 
1354       switch (gemrhId.layer()) {
1355         case 1:
1356           GEMCSC_Residuals_geml1_x->Fill(gemrhLP.x() - extSegm.x());
1357           GEMCSC_Residuals_geml1_y->Fill(gemrhLP.y() - extSegm.y());
1358           GEMCSC_Pool_geml1_x->Fill((gemrhLP.x() - extSegm.x()) / sqrt(gemrhLEP.xx()));
1359           GEMCSC_Pool_geml1_y->Fill((gemrhLP.x() - extSegm.y()) / sqrt(gemrhLEP.yy()));
1360           break;
1361         case 2:
1362           GEMCSC_Residuals_geml2_x->Fill(gemrhLP.x() - extSegm.x());
1363           GEMCSC_Residuals_geml2_y->Fill(gemrhLP.y() - extSegm.y());
1364           GEMCSC_Pool_geml2_x->Fill((gemrhLP.x() - extSegm.x()) / sqrt(gemrhLEP.xx()));
1365           GEMCSC_Pool_geml2_y->Fill((gemrhLP.x() - extSegm.y()) / sqrt(gemrhLEP.yy()));
1366           break;
1367         default:
1368           std::cout << " Unphysical GEMCSC layer " << gemrhId << std::endl;
1369       }
1370 
1371       float xe_csc = cscsegLP.x() + cscsegLD.x() * gemrhLP_inSegmRef.z() / cscsegLD.z();
1372       float ye_csc = cscsegLP.y() + cscsegLD.y() * gemrhLP_inSegmRef.z() / cscsegLD.z();
1373       float ze_csc = gemrhLP_inSegmRef.z();
1374       LocalPoint extrPoint_csc(xe_csc, ye_csc, ze_csc);  // in segment rest frame
1375       float sigma_xe_csc = sqrt(cscsegLEP.xx() + cscsegLED.xx() * gemrhLP_inSegmRef.z() * gemrhLP_inSegmRef.z());
1376       float sigma_ye_csc = sqrt(cscsegLEP.yy() + cscsegLED.yy() * gemrhLP_inSegmRef.z() * gemrhLP_inSegmRef.z());
1377       auto extrPoinGP_csc_fromSegmRef = cscChamber->toGlobal(extrPoint_csc);
1378       float phi_ext_csc = extrPoinGP_csc_fromSegmRef.phi();
1379       float theta_ext_csc = extrPoinGP_csc_fromSegmRef.theta();
1380 
1381       //auto extSegm_csc = gemrhRef->toLocal(cscChamber->toGlobal(extrPoint_csc)); // in layer restframe
1382 
1383       GEMCSC_Dphi_cscS_min_afterCut->Fill((phi_ext_csc - phi_rh));
1384       GEMCSC_Dtheta_cscS_min_afterCut->Fill((theta_ext_csc - theta_rh));
1385       GEMCSC_DR_cscS_min_afterCut->Fill((theta_ext_csc - theta_rh) * (theta_ext_csc - theta_rh) +
1386                                         (phi_ext_csc - phi_rh) * (phi_ext_csc - phi_rh));
1387       if (chamber % 2 != 0) {
1388         GEMCSC_Dphi_cscS_min_afterCut_odd->Fill((phi_ext_csc - phi_rh));
1389         GEMCSC_Dtheta_cscS_min_afterCut_odd->Fill((theta_ext_csc - theta_rh));
1390         switch (gemrhId.roll()) {
1391           case 1:
1392             GEMCSC_Dphi_cscS_min_afterCut_odd_r1->Fill((phi_ext_csc - phi_rh));
1393             break;
1394           case 2:
1395             GEMCSC_Dphi_cscS_min_afterCut_odd_r2->Fill((phi_ext_csc - phi_rh));
1396             break;
1397           case 3:
1398             GEMCSC_Dphi_cscS_min_afterCut_odd_r3->Fill((phi_ext_csc - phi_rh));
1399             break;
1400           case 4:
1401             GEMCSC_Dphi_cscS_min_afterCut_odd_r4->Fill((phi_ext_csc - phi_rh));
1402             break;
1403           case 5:
1404             GEMCSC_Dphi_cscS_min_afterCut_odd_r5->Fill((phi_ext_csc - phi_rh));
1405             break;
1406           case 6:
1407             GEMCSC_Dphi_cscS_min_afterCut_odd_r6->Fill((phi_ext_csc - phi_rh));
1408             break;
1409           case 7:
1410             GEMCSC_Dphi_cscS_min_afterCut_odd_r7->Fill((phi_ext_csc - phi_rh));
1411             break;
1412           case 8:
1413             GEMCSC_Dphi_cscS_min_afterCut_odd_r8->Fill((phi_ext_csc - phi_rh));
1414             break;
1415           default:
1416             std::cout << " Unphysical GEM roll " << gemrhId << std::endl;
1417         }
1418       } else {
1419         GEMCSC_Dtheta_cscS_min_afterCut_even->Fill((theta_ext_csc - theta_rh));
1420         GEMCSC_Dphi_cscS_min_afterCut_even->Fill((phi_ext_csc - phi_rh));
1421       }
1422 
1423       switch (gemrhId.layer()) {
1424         case 1:
1425           GEMCSC_CSCSegm_xe_l1->Fill(xe_csc);
1426           GEMCSC_CSCSegm_ye_l1->Fill(ye_csc);
1427           GEMCSC_CSCSegm_ze_l1->Fill(ze_csc);
1428           GEMCSC_CSCSegm_sigmaxe_l1->Fill(sigma_xe_csc);
1429           GEMCSC_CSCSegm_sigmaye_l1->Fill(sigma_ye_csc);
1430           GEMCSC_Dphi_cscS_min_afterCut_l1->Fill((phi_ext_csc - phi_rh));
1431           if (chamber % 2 != 0) {
1432             GEMCSC_Dphi_cscS_min_afterCut_l1_odd->Fill((phi_ext_csc - phi_rh));
1433             GEMCSC_CSCSegm_xe_l1_odd->Fill(xe_csc);
1434             GEMCSC_CSCSegm_ye_l1_odd->Fill(ye_csc);
1435             GEMCSC_CSCSegm_ze_l1_odd->Fill(ze_csc);
1436             GEMCSC_CSCSegm_sigmaxe_l1_odd->Fill(sigma_xe_csc);
1437             GEMCSC_CSCSegm_sigmaye_l1_odd->Fill(sigma_ye_csc);
1438           } else {
1439             GEMCSC_Dphi_cscS_min_afterCut_l1_even->Fill((phi_ext_csc - phi_rh));
1440             GEMCSC_CSCSegm_xe_l1_even->Fill(xe_csc);
1441             GEMCSC_CSCSegm_ye_l1_even->Fill(ye_csc);
1442             GEMCSC_CSCSegm_ze_l1_even->Fill(ze_csc);
1443             GEMCSC_CSCSegm_sigmaxe_l1_even->Fill(sigma_xe_csc);
1444             GEMCSC_CSCSegm_sigmaye_l1_even->Fill(sigma_ye_csc);
1445           }
1446 
1447           break;
1448         case 2:
1449           GEMCSC_CSCSegm_xe_l2->Fill(xe_csc);
1450           GEMCSC_CSCSegm_ye_l2->Fill(ye_csc);
1451           GEMCSC_CSCSegm_ze_l2->Fill(ze_csc);
1452           GEMCSC_CSCSegm_sigmaxe_l2->Fill(sigma_xe_csc);
1453           GEMCSC_CSCSegm_sigmaye_l2->Fill(sigma_ye_csc);
1454 
1455           GEMCSC_Dphi_cscS_min_afterCut_l2->Fill((phi_ext_csc - phi_rh));
1456           if (chamber % 2 != 0) {
1457             GEMCSC_Dphi_cscS_min_afterCut_l2_odd->Fill((phi_ext_csc - phi_rh));
1458             GEMCSC_CSCSegm_xe_l2_odd->Fill(xe_csc);
1459             GEMCSC_CSCSegm_ye_l2_odd->Fill(ye_csc);
1460             GEMCSC_CSCSegm_ze_l2_odd->Fill(ze_csc);
1461             GEMCSC_CSCSegm_sigmaxe_l2_odd->Fill(sigma_xe_csc);
1462             GEMCSC_CSCSegm_sigmaye_l2_odd->Fill(sigma_ye_csc);
1463           } else {
1464             GEMCSC_Dphi_cscS_min_afterCut_l2_even->Fill((phi_ext_csc - phi_rh));
1465             GEMCSC_CSCSegm_xe_l2_even->Fill(xe_csc);
1466             GEMCSC_CSCSegm_ye_l2_even->Fill(ye_csc);
1467             GEMCSC_CSCSegm_ze_l2_even->Fill(ze_csc);
1468             GEMCSC_CSCSegm_sigmaxe_l2_even->Fill(sigma_xe_csc);
1469             GEMCSC_CSCSegm_sigmaye_l2_even->Fill(sigma_ye_csc);
1470           }
1471 
1472           break;
1473         default:
1474           std::cout << " Unphysical GEMCSC layer " << gemrhId << std::endl;
1475       }
1476 
1477       int Nsimhit = 0;
1478       edm::PSimHitContainer selGEMSimHit = SimHitMatched(rh, gemGeom, iEvent);
1479 
1480       for (edm::PSimHitContainer::const_iterator itHit = selGEMSimHit.begin(); itHit != selGEMSimHit.end(); ++itHit) {
1481         Nsimhit++;
1482         if (Nsimhit > 1)
1483           continue;
1484 
1485         //const GEMEtaPartition* gemshRef  = gemGeom->etaPartition(gemshId);
1486         LocalPoint gemshLP = itHit->localPosition();
1487         GlobalPoint gemshGP(gemGeom->idToDet(itHit->detUnitId())->surface().toGlobal(gemshLP));
1488         //auto gemrhGP = gemrhRef->toGlobal(gemrhLP);
1489         auto gemshLP_inSegmRef = cscChamber->toLocal(gemshGP);
1490         //auto gemshLEP = itHit->localPositionError();
1491         //LocalPoint lp = itHit->entryPoint();
1492         //std::cout <<" entry Position x = "<<lp.x()<<" y= "<<lp.y()<<" z= "<<lp.z()<<std::endl;
1493         //auto gemshLP_inSegmRef = cscChamber->toLocal(gemshGP);
1494         //GlobalPoint hitGP_sim(gemGeom->idToDet(itHit->detUnitId())->surface().toGlobal(lp));
1495         float phi_sh = gemshGP.phi();
1496         float theta_sh = gemshGP.theta();
1497         //float eta_sh = gemshGP.eta();
1498 
1499         float xe_sh = gemcscsegLP.x() + gemcscsegLD.x() * gemshLP_inSegmRef.z() / gemcscsegLD.z();
1500         float ye_sh = gemcscsegLP.y() + gemcscsegLD.y() * gemshLP_inSegmRef.z() / gemcscsegLD.z();
1501         float ze_sh = gemshLP_inSegmRef.z();
1502         LocalPoint extrPoint_sh(xe_sh, ye_sh, ze_sh);  // in segment rest frame
1503         //float sigma_xe_sh = sqrt (gemcscsegLEP.xx());
1504         //float sigma_ye_sh = sqrt (gemcscsegLEP.yy());
1505         float sigma_xe_sh = sqrt(gemcscsegLEP.xx() + gemcscsegLED.xx() * gemshLP_inSegmRef.z() * gemshLP_inSegmRef.z());
1506         float sigma_ye_sh = sqrt(gemcscsegLEP.yy() + gemcscsegLED.yy() * gemshLP_inSegmRef.z() * gemshLP_inSegmRef.z());
1507         auto extSegm_sh = gemrhRef->toLocal(cscChamber->toGlobal(extrPoint_sh));
1508         auto extrPoinGP_fromSegmRef_sh = cscChamber->toGlobal(extrPoint_sh);
1509         float phi_ext_sh = extrPoinGP_fromSegmRef_sh.phi();
1510         float theta_ext_sh = extrPoinGP_fromSegmRef_sh.theta();
1511 
1512         float dxdz = (gemshLP_inSegmRef.x() - cscsegLP.x()) / gemshLP_inSegmRef.z();
1513         float dydz = (gemshLP_inSegmRef.y() - cscsegLP.y()) / gemshLP_inSegmRef.z();
1514         float sigma_dxdz = cscsegLEP.xx() / (gemshLP_inSegmRef.z() * gemshLP_inSegmRef.z());
1515         float sigma_dydz = cscsegLEP.yy() / (gemshLP_inSegmRef.z() * gemshLP_inSegmRef.z());
1516         SIMGEMCSC_SSegm_LDx->Fill(dxdz);
1517         SIMGEMCSC_SSegm_LDy->Fill(dydz);
1518         SIMGEMCSC_SSegm_LDEx->Fill(sigma_dxdz);
1519         SIMGEMCSC_SSegm_LDEy->Fill(sigma_dydz);
1520 
1521         float xe_csc_sh = cscsegLP.x() + cscsegLD.x() * gemshLP_inSegmRef.z() / cscsegLD.z();
1522         float ye_csc_sh = cscsegLP.y() + cscsegLD.y() * gemshLP_inSegmRef.z() / cscsegLD.z();
1523         float ze_csc_sh = gemshLP_inSegmRef.z();
1524         LocalPoint extrPoint_csc_sh(xe_csc_sh, ye_csc_sh, ze_csc_sh);  // in segment rest frame
1525         //float sigma_xe_csc_sh = sqrt(cscsegLEP.xx()+cscsegLED.xx()*gemshLP_inSegmRef.z()*gemshLP_inSegmRef.z());
1526         //float sigma_ye_csc_sh = sqrt(cscsegLEP.yy()+cscsegLED.yy()*gemshLP_inSegmRef.z()*gemshLP_inSegmRef.z());
1527         auto extrPoinGP_csc_fromSegmRef_sh = cscChamber->toGlobal(extrPoint_csc_sh);
1528         float phi_ext_csc_sh = extrPoinGP_csc_fromSegmRef_sh.phi();
1529         float theta_ext_csc_sh = extrPoinGP_csc_fromSegmRef_sh.theta();
1530 
1531         SIMGEMCSC_Dphi_cscS_min_afterCut->Fill((phi_ext_csc_sh - phi_sh));
1532         SIMGEMCSC_Dtheta_cscS_min_afterCut->Fill((theta_ext_csc_sh - theta_sh));
1533         SIMGEMCSC_Dphi_SS_min_afterCut->Fill((phi_ext_sh - phi_sh));
1534         SIMGEMCSC_Dtheta_SS_min_afterCut->Fill((theta_ext_sh - theta_sh));
1535 
1536         SIMGEMCSC_Residuals_gem_x->Fill(gemshLP.x() - extSegm_sh.x());
1537         SIMGEMCSC_Residuals_gem_y->Fill(gemshLP.y() - extSegm_sh.y());
1538         SIMGEMCSC_Pool_gem_x_newE->Fill((gemshLP.x() - extSegm_sh.x()) / sqrt(sigma_xe_sh * sigma_xe_sh));
1539         SIMGEMCSC_Pool_gem_y_newE->Fill((gemshLP.y() - extSegm_sh.y()) / sqrt(sigma_ye_sh * sigma_ye_sh));
1540 
1541         SIMGEMCSC_Residuals_gem_rhsh_x->Fill(gemshLP.x() - gemrhLP.x());
1542         SIMGEMCSC_Residuals_gem_rhsh_y->Fill(gemshLP.y() - gemrhLP.y());
1543         SIMGEMCSC_Pool_gem_rhsh_x_newE->Fill((gemshLP.x() - gemrhLP.x()) / sqrt(gemrhLEP.xx()));
1544         SIMGEMCSC_Pool_gem_rhsh_y_newE->Fill((gemshLP.y() - gemrhLP.y()) / sqrt(gemrhLEP.yy()));
1545 
1546         if (chamber % 2 != 0) {
1547           SIMGEMCSC_Residuals_gem_odd_x->Fill(gemshLP.x() - extSegm_sh.x());
1548           SIMGEMCSC_Residuals_gem_odd_y->Fill(gemshLP.y() - extSegm_sh.y());
1549           SIMGEMCSC_Pool_gem_x_newE_odd->Fill((gemshLP.x() - extSegm_sh.x()) / sqrt(sigma_xe_sh * sigma_xe_sh));
1550           SIMGEMCSC_Pool_gem_y_newE_odd->Fill((gemshLP.y() - extSegm_sh.y()) / sqrt(sigma_ye_sh * sigma_ye_sh));
1551           SIMGEMCSC_Dphi_cscS_min_afterCut_odd->Fill((phi_ext_csc_sh - phi_sh));
1552           SIMGEMCSC_Dtheta_cscS_min_afterCut_odd->Fill((theta_ext_csc_sh - theta_sh));
1553           SIMGEMCSC_Dphi_SS_min_afterCut_odd->Fill((phi_ext_sh - phi_sh));
1554           SIMGEMCSC_Dtheta_SS_min_afterCut_odd->Fill((theta_ext_sh - theta_sh));
1555           SIMGEMCSC_theta_cscSsh_vs_ndof_odd->Fill((theta_ext_csc_sh - theta_sh), cscSeg.degreesOfFreedom());
1556 
1557         } else {
1558           SIMGEMCSC_Residuals_gem_even_x->Fill(gemshLP.x() - extSegm_sh.x());
1559           SIMGEMCSC_Residuals_gem_even_y->Fill(gemshLP.y() - extSegm_sh.y());
1560           SIMGEMCSC_Pool_gem_x_newE_even->Fill((gemshLP.x() - extSegm_sh.x()) / sqrt(sigma_xe_sh * sigma_xe_sh));
1561           SIMGEMCSC_Pool_gem_y_newE_even->Fill((gemshLP.y() - extSegm_sh.y()) / sqrt(sigma_ye_sh * sigma_ye_sh));
1562           SIMGEMCSC_Dphi_cscS_min_afterCut_even->Fill((phi_ext_csc_sh - phi_sh));
1563           SIMGEMCSC_Dtheta_cscS_min_afterCut_even->Fill((theta_ext_csc_sh - theta_sh));
1564           SIMGEMCSC_Dphi_SS_min_afterCut_even->Fill((phi_ext_sh - phi_sh));
1565           SIMGEMCSC_Dtheta_SS_min_afterCut_even->Fill((theta_ext_sh - theta_sh));
1566           SIMGEMCSC_theta_cscSsh_vs_ndof_even->Fill((theta_ext_csc_sh - theta_sh), cscSeg.degreesOfFreedom());
1567         }
1568 
1569       }  // fine loop sim hit compatibili
1570 
1571     }  // fine loop gem rh
1572 
1573     /////////////////////////////////////////////
1574     auto gemcscrhs = gemcscs->recHits();
1575     for (auto rh = gemcscrhs.begin(); rh != gemcscrhs.end(); rh++) {
1576       // if (rh->geographicalId().subdetId() == MuonSubdetId::CSC){
1577       DetId d = DetId((*rh)->rawId());
1578       if (d.subdetId() == MuonSubdetId::CSC) {
1579         std::cout << "CSC found" << std::endl;
1580 
1581         // CSCDetId id(rh->geographicalId());
1582         CSCDetId id(d);
1583 
1584         //int layer = id.layer();
1585         int station = id.station();
1586         int ring = id.ring();
1587         //int chamber = id.chamber();
1588         //int roll = id.roll();
1589 
1590         std::cout << "CSC Region"
1591                   << " Station " << station << " ring " << ring << std::endl;
1592 
1593       }
1594       // else if (rh->geographicalId().subdetId() == MuonSubdetId::GEM){
1595       else if (d.subdetId() == MuonSubdetId::GEM) {
1596         // std::cout<<"GEM found"<<std::endl;
1597 
1598         // GEMDetId id(rh->geographicalId());
1599         GEMDetId id(d);
1600         int region = id.region();
1601         int layer = id.layer();
1602         int station = id.station();
1603         int ring = id.ring();
1604         int chamber = id.chamber();
1605         int roll = id.roll();
1606 
1607         std::cout << "GEM Region" << region << " Station " << station << " ring " << ring << " layer " << layer
1608                   << " chamber " << chamber << " roll " << roll << std::endl;
1609       }
1610     }
1611 
1612     auto gemcscsegGD = cscChamber->toGlobal(gemcscs->localPosition());
1613     for (simTrack = simTracks->begin(); simTrack != simTracks->end(); ++simTrack) {
1614       double simEta = (*simTrack).momentum().eta();
1615       double simPhi = (*simTrack).momentum().phi();
1616       double dR = sqrt(pow((simEta - gemcscsegGD.eta()), 2) + pow((simPhi - gemcscsegGD.phi()), 2));
1617       if (dR > 0.1)
1618         continue;
1619     }
1620 
1621   }  // loop gemcsc segments
1622 
1623   std::cout << "------------------------------------------------------------------------------" << std::endl;
1624   std::cout << "------------------------------------------------------------------------------" << std::endl;
1625 }
1626 
1627 //
1628 // member functions
1629 //
1630 
1631 edm::PSimHitContainer TestGEMCSCSegmentAnalyzer::SimHitMatched(std::vector<GEMRecHit>::const_iterator recHit,
1632                                                                edm::ESHandle<GEMGeometry> gemGeom,
1633                                                                const Event& iEvent) {
1634   edm::PSimHitContainer selectedGEMHits;
1635 
1636   GEMDetId id((*recHit).geographicalId());
1637 
1638   int region = id.region();
1639   int layer = id.layer();
1640   int station = id.station();
1641   int chamber = id.chamber();
1642   int roll = id.roll();
1643 
1644   int cls = recHit->clusterSize();
1645   int firstStrip = recHit->firstClusterStrip();
1646 
1647   edm::Handle<edm::PSimHitContainer> GEMHits;
1648   iEvent.getByToken(GEMSimHit_Token, GEMHits);
1649   // edm::Handle<edm::PSimHitContainer> GEMHits;
1650   // iEvent.getByLabel(edm::InputTag("g4SimHits","MuonGEMHits"), GEMHits);
1651 
1652   for (edm::PSimHitContainer::const_iterator itHit = GEMHits->begin(); itHit != GEMHits->end(); ++itHit) {
1653     if (!(abs(itHit->particleType()) == 13))
1654       continue;
1655     GEMDetId idGem = GEMDetId(itHit->detUnitId());
1656     int region_sim = idGem.region();
1657     int layer_sim = idGem.layer();
1658     int station_sim = idGem.station();
1659     int chamber_sim = idGem.chamber();
1660     int roll_sim = idGem.roll();
1661 
1662     LocalPoint lp = itHit->entryPoint();
1663     // GlobalPoint hitGP_sim(gemGeom->idToDet(itHit->detUnitId())->surface().toGlobal(lp));
1664     float strip_sim = gemGeom->etaPartition(idGem)->strip(lp);
1665     if (region != region_sim)
1666       continue;
1667     if (layer != layer_sim)
1668       continue;
1669     if (station != station_sim)
1670       continue;
1671     if (chamber != chamber_sim)
1672       continue;
1673     if (roll != roll_sim)
1674       continue;
1675     for (int i = firstStrip; i < (firstStrip + cls); i++) {
1676       if (abs(strip_sim - i) < 1) {
1677         selectedGEMHits.push_back(*itHit);
1678       }
1679     }
1680   }
1681 
1682   return selectedGEMHits;
1683 }
1684 
1685 // ------------ method called once each job just before starting event loop  ------------
1686 void TestGEMCSCSegmentAnalyzer::beginJob() {}
1687 
1688 // ------------ method called once each job just after ending the event loop  ------------
1689 void TestGEMCSCSegmentAnalyzer::endJob() {}
1690 
1691 // ------------ method called when starting to processes a run  ------------
1692 void TestGEMCSCSegmentAnalyzer::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
1693   //iSetup.get<MuonGeometryRecord>().get(gemGeom);
1694   //iSetup.get<MuonGeometryRecord>().get(cscGeom);
1695 }
1696 
1697 //define this as a plug-in
1698 DEFINE_FWK_MODULE(TestGEMCSCSegmentAnalyzer);