Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:24:56

0001 // -*- C++ -*-
0002 //
0003 // Package:    TestGEMRecHitAnalyzer
0004 // Class:      TestGEMRecHitAnalyzer
0005 //
0006 /**\class TestGEMRecHitAnalyzer TestGEMRecHitAnalyzer.cc MyAnalyzers/TestGEMRecHitAnalyzer/src/TestGEMRecHitAnalyzer.cc
0007 
0008  Description: [one line class summary]
0009 
0010  Implementation:
0011      [Notes on implementation]
0012 */
0013 //
0014 // Original Author:  Piet Verwilligen,161 R-006,+41227676292,
0015 //         Created:  Wed Oct 24 17:28:30 CEST 2012
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 #include <fstream>
0022 #include <sys/time.h>
0023 #include <string>
0024 #include <sstream>
0025 #include <iostream>
0026 #include <iomanip>
0027 
0028 // root include files
0029 #include "TFile.h"
0030 #include "TH1F.h"
0031 #include "TH2F.h"
0032 #include "TF1.h"
0033 #include "THStack.h"
0034 #include "TLegend.h"
0035 #include "TLatex.h"
0036 #include "TTree.h"
0037 #include "TCanvas.h"
0038 #include "TDirectoryFile.h"
0039 #include "TGraph.h"
0040 #include "TGraphErrors.h"
0041 #include "TGraphAsymmErrors.h"
0042 
0043 // user include files
0044 #include "FWCore/Framework/interface/Frameworkfwd.h"
0045 #include "FWCore/Framework/interface/EDAnalyzer.h"
0046 #include "FWCore/Framework/interface/Event.h"
0047 #include "FWCore/Framework/interface/ESHandle.h"
0048 #include "FWCore/Framework/interface/MakerMacros.h"
0049 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0050 #include "FWCore/ServiceRegistry/interface/Service.h"
0051 
0052 #include <DataFormats/GEMRecHit/interface/GEMRecHit.h>
0053 #include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h"
0054 #include <DataFormats/GEMDigi/interface/GEMDigiCollection.h>
0055 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
0056 
0057 #include "Geometry/GEMGeometry/interface/GEMGeometry.h"
0058 #include <Geometry/GEMGeometry/interface/GEMEtaPartition.h>
0059 #include <Geometry/Records/interface/MuonGeometryRecord.h>
0060 
0061 #include <Geometry/CommonDetUnit/interface/GeomDet.h>
0062 #include "DataFormats/Provenance/interface/Timestamp.h"
0063 
0064 #include <Geometry/GEMGeometry/interface/GEMGeometry.h>
0065 #include <Geometry/DTGeometry/interface/DTGeometry.h>
0066 #include <Geometry/CSCGeometry/interface/CSCGeometry.h>
0067 
0068 #include <DataFormats/GEMDigi/interface/GEMDigiCollection.h>
0069 #include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h"
0070 #include <DataFormats/MuonDetId/interface/GEMDetId.h>
0071 #include <DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h>
0072 #include <DataFormats/CSCRecHit/interface/CSCSegmentCollection.h>
0073 #include <Geometry/CommonDetUnit/interface/GeomDet.h>
0074 #include <Geometry/Records/interface/MuonGeometryRecord.h>
0075 #include <Geometry/CommonTopologies/interface/GEMStripTopology.h>
0076 
0077 //
0078 // class declaration
0079 //
0080 
0081 class TestGEMRecHitAnalyzer : public edm::EDAnalyzer {
0082 public:
0083   explicit TestGEMRecHitAnalyzer(const edm::ParameterSet&);
0084   ~TestGEMRecHitAnalyzer();
0085 
0086   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0087 
0088 private:
0089   virtual void analyze(const edm::Event&, const edm::EventSetup&);
0090 
0091   // ----------member data ---------------------------
0092   edm::ESHandle<GEMGeometry> gemGeom;
0093   edm::EDGetTokenT<GEMRecHitCollection> GEMRecHit_Token;
0094 
0095   std::string rootFileName;
0096   std::unique_ptr<TFile> outputfile;
0097   std::unique_ptr<TH1F> BX_RecHits_GE1in_Plus, BX_RecHits_GE1out_Plus, BX_RecHits_GE1in_Minus, BX_RecHits_GE1out_Minus;
0098   std::unique_ptr<TH1F> ST_RecHits_GE1in_Plus, ST_RecHits_GE1out_Plus, ST_RecHits_GE1in_Minus, ST_RecHits_GE1out_Minus;
0099   std::unique_ptr<TH1F> CL_RecHits_GE1in_Plus, CL_RecHits_GE1out_Plus, CL_RecHits_GE1in_Minus, CL_RecHits_GE1out_Minus;
0100   std::unique_ptr<TCanvas> BX_RecHits_GE1, ST_RecHits_GE1, CL_RecHits_GE1;
0101 
0102   std::vector<double> x_n1i, y_n1i, z_n1i, r_n1i, x_n1o, y_n1o, z_n1o, r_n1o;  // XYZR GE1 Minus in and out
0103   std::vector<double> x_p1i, y_p1i, z_p1i, r_p1i, x_p1o, y_p1o, z_p1o, r_p1o;  // XYZR GE1 Plus in and out
0104   std::vector<double> x_n1, y_n1, z_n1, r_n1, x_p1, y_p1, z_p1, r_p1;
0105 
0106   std::unique_ptr<TGraph> GE1in_Plus_XY_All, GE1in_Minus_XY_All, GE1out_Plus_XY_All, GE1out_Minus_XY_All,
0107       GE1out_Plus_YZ_All, GE1out_Minus_YZ_All, GE1in_Plus_YZ_All, GE1in_Minus_YZ_All, GE1_Plus_YZ_All, GE1_Minus_YZ_All;
0108   std::unique_ptr<TCanvas> Canvas_GE1_Plus_XY, Canvas_GE1_Minus_XY, Canvas_GE1_Plus_YZ, Canvas_GE1_Minus_YZ;
0109 };
0110 
0111 //
0112 // constants, enums and typedefs
0113 //
0114 int n_bx = 11;
0115 double n1_bx = -5.5, n2_bx = 5.5;
0116 int n_st = 501;
0117 double n1_st = 0, n2_st = 500;
0118 int n_cl = 26;
0119 double n1_cl = -0.5, n2_cl = 25.5;
0120 
0121 //
0122 // static data member definitions
0123 //
0124 
0125 //
0126 // constructors and destructor
0127 //
0128 TestGEMRecHitAnalyzer::TestGEMRecHitAnalyzer(const edm::ParameterSet& iConfig)
0129 
0130 {
0131   //now do what ever initialization is needed
0132   GEMRecHit_Token = consumes<GEMRecHitCollection>(edm::InputTag("gemRecHits"));
0133   rootFileName = iConfig.getUntrackedParameter<std::string>("RootFileName");
0134   outputfile.reset(TFile::Open(rootFileName.c_str(), "RECREATE"));
0135 
0136   BX_RecHits_GE1in_Plus =
0137       std::unique_ptr<TH1F>(new TH1F("BX_RecHits_GE1in_Plus", "BX_RecHits_GE1in_Plus", n_bx, n1_bx, n2_bx));
0138   BX_RecHits_GE1out_Plus =
0139       std::unique_ptr<TH1F>(new TH1F("BX_RecHits_GE1out_Plus", "BX_RecHits_GE1out_Plus", n_bx, n1_bx, n2_bx));
0140   BX_RecHits_GE1in_Minus =
0141       std::unique_ptr<TH1F>(new TH1F("BX_RecHits_GE1in_Minus", "BX_RecHits_GE1in_Minus", n_bx, n1_bx, n2_bx));
0142   BX_RecHits_GE1out_Minus =
0143       std::unique_ptr<TH1F>(new TH1F("BX_RecHits_GE1out_Minus", "BX_RecHits_GE1out_Minus", n_bx, n1_bx, n2_bx));
0144 
0145   ST_RecHits_GE1in_Plus =
0146       std::unique_ptr<TH1F>(new TH1F("ST_RecHits_GE1in_Plus", "ST_RecHits_GE1in_Plus", n_st, n1_st, n2_st));
0147   ST_RecHits_GE1out_Plus =
0148       std::unique_ptr<TH1F>(new TH1F("ST_RecHits_GE1out_Plus", "ST_RecHits_GE1out_Plus", n_st, n1_st, n2_st));
0149   ST_RecHits_GE1in_Minus =
0150       std::unique_ptr<TH1F>(new TH1F("ST_RecHits_GE1in_Minus", "ST_RecHits_GE1in_Minus", n_st, n1_st, n2_st));
0151   ST_RecHits_GE1out_Minus =
0152       std::unique_ptr<TH1F>(new TH1F("ST_RecHits_GE1out_Minus", "ST_RecHits_GE1out_Minus", n_st, n1_st, n2_st));
0153 
0154   CL_RecHits_GE1in_Plus =
0155       std::unique_ptr<TH1F>(new TH1F("CL_RecHits_GE1in_Plus", "CL_RecHits_GE1in_Plus", n_cl, n1_cl, n2_cl));
0156   CL_RecHits_GE1out_Plus =
0157       std::unique_ptr<TH1F>(new TH1F("CL_RecHits_GE1out_Plus", "CL_RecHits_GE1out_Plus", n_cl, n1_cl, n2_cl));
0158   CL_RecHits_GE1in_Minus =
0159       std::unique_ptr<TH1F>(new TH1F("CL_RecHits_GE1in_Minus", "CL_RecHits_GE1in_Minus", n_cl, n1_cl, n2_cl));
0160   CL_RecHits_GE1out_Minus =
0161       std::unique_ptr<TH1F>(new TH1F("CL_RecHits_GE1out_Minus", "CL_RecHits_GE1out_Minus", n_cl, n1_cl, n2_cl));
0162 }
0163 
0164 TestGEMRecHitAnalyzer::~TestGEMRecHitAnalyzer() {
0165   // do anything here that needs to be done at desctruction time
0166   // (e.g. close files, deallocate resources etc.)
0167 
0168   int mar1 = 4;
0169   int mar2 = 5;
0170   int col1 = 2;
0171   int col2 = 4;
0172 
0173   outputfile->cd();
0174   BX_RecHits_GE1in_Plus->Write();
0175   BX_RecHits_GE1out_Plus->Write();
0176   BX_RecHits_GE1in_Minus->Write();
0177   BX_RecHits_GE1out_Minus->Write();
0178 
0179   ST_RecHits_GE1in_Plus->Write();
0180   ST_RecHits_GE1out_Plus->Write();
0181   ST_RecHits_GE1in_Minus->Write();
0182   ST_RecHits_GE1out_Minus->Write();
0183 
0184   CL_RecHits_GE1in_Plus->Write();
0185   CL_RecHits_GE1out_Plus->Write();
0186   CL_RecHits_GE1in_Minus->Write();
0187   CL_RecHits_GE1out_Minus->Write();
0188 
0189   BX_RecHits_GE1 = std::unique_ptr<TCanvas>(new TCanvas("BX_RecHits_GE1", "BX_RecHits_GE1", 800, 600));
0190   ST_RecHits_GE1 = std::unique_ptr<TCanvas>(new TCanvas("ST_RecHits_GE1", "ST_RecHits_GE1", 800, 600));
0191   CL_RecHits_GE1 = std::unique_ptr<TCanvas>(new TCanvas("CL_RecHits_GE1", "CL_RecHits_GE1", 800, 600));
0192 
0193   BX_RecHits_GE1->cd();
0194   BX_RecHits_GE1->Divide(2, 2);
0195   BX_RecHits_GE1->cd(1);
0196   BX_RecHits_GE1in_Plus->Draw();
0197   BX_RecHits_GE1in_Plus->GetXaxis()->SetTitle("BX [-]");
0198   BX_RecHits_GE1in_Plus->GetYaxis()->SetTitle("entries [-]");
0199   BX_RecHits_GE1in_Plus->SetTitle("GE+1in RecHits");
0200   BX_RecHits_GE1->cd(2);
0201   BX_RecHits_GE1out_Plus->Draw();
0202   BX_RecHits_GE1out_Plus->GetXaxis()->SetTitle("BX [-]");
0203   BX_RecHits_GE1out_Plus->GetYaxis()->SetTitle("entries [-]");
0204   BX_RecHits_GE1out_Plus->SetTitle("GE+1out RecHits");
0205   BX_RecHits_GE1->cd(3);
0206   BX_RecHits_GE1in_Minus->Draw();
0207   BX_RecHits_GE1in_Minus->GetXaxis()->SetTitle("BX [-]");
0208   BX_RecHits_GE1in_Minus->GetYaxis()->SetTitle("entries [-]");
0209   BX_RecHits_GE1in_Minus->SetTitle("GE-1in RecHits");
0210   BX_RecHits_GE1->cd(4);
0211   BX_RecHits_GE1out_Minus->Draw();
0212   BX_RecHits_GE1out_Minus->GetXaxis()->SetTitle("BX [-]");
0213   BX_RecHits_GE1out_Minus->GetYaxis()->SetTitle("entries [-]");
0214   BX_RecHits_GE1out_Minus->SetTitle("GE-1out RecHits");
0215 
0216   ST_RecHits_GE1->cd();
0217   ST_RecHits_GE1->Divide(2, 2);
0218   ST_RecHits_GE1->cd(1);
0219   ST_RecHits_GE1in_Plus->Draw();
0220   ST_RecHits_GE1in_Plus->GetXaxis()->SetTitle("First Strip of Cluster [-]");
0221   ST_RecHits_GE1in_Plus->GetYaxis()->SetTitle("entries [-]");
0222   ST_RecHits_GE1in_Plus->SetTitle("GE+1in RecHits");
0223   ST_RecHits_GE1->cd(2);
0224   ST_RecHits_GE1out_Plus->Draw();
0225   ST_RecHits_GE1out_Plus->GetXaxis()->SetTitle("First Strip of Cluster [-]");
0226   ST_RecHits_GE1out_Plus->GetYaxis()->SetTitle("entries [-]");
0227   ST_RecHits_GE1out_Plus->SetTitle("GE+1out RecHits");
0228   ST_RecHits_GE1->cd(3);
0229   ST_RecHits_GE1in_Minus->Draw();
0230   ST_RecHits_GE1in_Minus->GetXaxis()->SetTitle("First Strip of Cluster [-]");
0231   ST_RecHits_GE1in_Minus->GetYaxis()->SetTitle("entries [-]");
0232   ST_RecHits_GE1in_Minus->SetTitle("GE-1in RecHits");
0233   ST_RecHits_GE1->cd(4);
0234   ST_RecHits_GE1out_Minus->Draw();
0235   ST_RecHits_GE1out_Minus->GetXaxis()->SetTitle("First Strip of Cluster [-]");
0236   ST_RecHits_GE1out_Minus->GetYaxis()->SetTitle("entries [-]");
0237   ST_RecHits_GE1out_Minus->SetTitle("GE-1out RecHits");
0238 
0239   CL_RecHits_GE1->cd();
0240   CL_RecHits_GE1->Divide(2, 2);
0241   CL_RecHits_GE1->cd(1);
0242   CL_RecHits_GE1in_Plus->Draw();
0243   CL_RecHits_GE1in_Plus->GetXaxis()->SetTitle("Clustersize [-]");
0244   CL_RecHits_GE1in_Plus->GetYaxis()->SetTitle("entries [-]");
0245   CL_RecHits_GE1in_Plus->SetTitle("GE+1in RecHits");
0246   CL_RecHits_GE1->cd(2);
0247   CL_RecHits_GE1out_Plus->Draw();
0248   CL_RecHits_GE1out_Plus->GetXaxis()->SetTitle("Clustersize [-]");
0249   CL_RecHits_GE1out_Plus->GetYaxis()->SetTitle("entries [-]");
0250   CL_RecHits_GE1out_Plus->SetTitle("GE+1out RecHits");
0251   CL_RecHits_GE1->cd(3);
0252   CL_RecHits_GE1in_Minus->Draw();
0253   CL_RecHits_GE1in_Minus->GetXaxis()->SetTitle("Clustersize [-]");
0254   CL_RecHits_GE1in_Minus->GetYaxis()->SetTitle("entries [-]");
0255   CL_RecHits_GE1in_Minus->SetTitle("GE-1in RecHits");
0256   CL_RecHits_GE1->cd(4);
0257   CL_RecHits_GE1out_Minus->Draw();
0258   CL_RecHits_GE1out_Minus->GetXaxis()->SetTitle("Clustersize [-]");
0259   CL_RecHits_GE1out_Minus->GetYaxis()->SetTitle("entries [-]");
0260   CL_RecHits_GE1out_Minus->SetTitle("GE-1out RecHits");
0261 
0262   const int n_n1i = x_n1i.size();
0263   double x_an1i[n_n1i];
0264   double y_an1i[n_n1i];
0265   double z_an1i[n_n1i];
0266   double r_an1i[n_n1i];
0267   const int n_n1o = x_n1o.size();
0268   double x_an1o[n_n1o];
0269   double y_an1o[n_n1o];
0270   double z_an1o[n_n1o];
0271   double r_an1o[n_n1o];
0272   const int n_p1i = x_p1i.size();
0273   double x_ap1i[n_p1i];
0274   double y_ap1i[n_p1i];
0275   double z_ap1i[n_p1i];
0276   double r_ap1i[n_p1i];
0277   const int n_p1o = x_p1o.size();
0278   double x_ap1o[n_p1o];
0279   double y_ap1o[n_p1o];
0280   double z_ap1o[n_p1o];
0281   double r_ap1o[n_p1o];
0282   const int n_n1 = x_n1.size(); /*double x_an1[n_n1]; double y_an1[n_n1];*/
0283   double z_an1[n_n1];
0284   double r_an1[n_n1];
0285   const int n_p1 = x_p1.size(); /*double x_ap1[n_p1]; double y_ap1[n_p1];*/
0286   double z_ap1[n_p1];
0287   double r_ap1[n_p1];
0288 
0289   for (int i = 0; i < n_n1i; ++i) {
0290     x_an1i[i] = x_n1i[i];
0291     y_an1i[i] = y_n1i[i];
0292     z_an1i[i] = z_n1i[i];
0293     r_an1i[i] = r_n1i[i];
0294   }
0295   for (int i = 0; i < n_n1o; ++i) {
0296     x_an1o[i] = x_n1o[i];
0297     y_an1o[i] = y_n1o[i];
0298     z_an1o[i] = z_n1o[i];
0299     r_an1o[i] = r_n1o[i];
0300   }
0301   for (int i = 0; i < n_p1i; ++i) {
0302     x_ap1i[i] = x_p1i[i];
0303     y_ap1i[i] = y_p1i[i];
0304     z_ap1i[i] = z_p1i[i];
0305     r_ap1i[i] = r_p1i[i];
0306   }
0307   for (int i = 0; i < n_p1o; ++i) {
0308     x_ap1o[i] = x_p1o[i];
0309     y_ap1o[i] = y_p1o[i];
0310     z_ap1o[i] = z_p1o[i];
0311     r_ap1o[i] = r_p1o[i];
0312   }
0313   for (int i = 0; i < n_n1; ++i) { /*x_an1[i] = x_n1[i]; y_an1[i] = y_n1[i];*/
0314     z_an1[i] = z_n1[i];
0315     r_an1[i] = r_n1[i];
0316   }
0317   for (int i = 0; i < n_p1; ++i) { /*x_ap1[i] = x_p1[i]; y_ap1[i] = y_p1[i];*/
0318     z_ap1[i] = z_p1[i];
0319     r_ap1[i] = r_p1[i];
0320   }
0321 
0322   GE1in_Minus_XY_All = std::unique_ptr<TGraph>(new TGraph(n_n1i, x_an1i, y_an1i));
0323   std::cout << "GE-1in All SimHits: " << n_n1i << std::endl;
0324   GE1out_Minus_XY_All = std::unique_ptr<TGraph>(new TGraph(n_n1o, x_an1o, y_an1o));
0325   std::cout << "GE-1out All SimHits: " << n_n1o << std::endl;
0326   GE1in_Plus_XY_All = std::unique_ptr<TGraph>(new TGraph(n_p1i, x_ap1i, y_ap1i));
0327   std::cout << "GE+1in All SimHits: " << n_p1i << std::endl;
0328   GE1out_Plus_XY_All = std::unique_ptr<TGraph>(new TGraph(n_p1o, x_ap1o, y_ap1o));
0329   std::cout << "GE+1out All SimHits: " << n_p1o << std::endl;
0330 
0331   GE1in_Minus_YZ_All = std::unique_ptr<TGraph>(new TGraph(n_n1i, z_an1i, r_an1i));
0332   GE1out_Minus_YZ_All = std::unique_ptr<TGraph>(new TGraph(n_n1o, z_an1o, r_an1o));
0333   GE1in_Plus_YZ_All = std::unique_ptr<TGraph>(new TGraph(n_p1i, z_ap1i, r_ap1i));
0334   GE1out_Plus_YZ_All = std::unique_ptr<TGraph>(new TGraph(n_p1o, z_ap1o, r_ap1o));
0335 
0336   GE1_Minus_YZ_All = std::unique_ptr<TGraph>(new TGraph(n_n1, z_an1, r_an1));
0337   GE1_Plus_YZ_All = std::unique_ptr<TGraph>(new TGraph(n_p1, z_ap1, r_ap1));
0338 
0339   Canvas_GE1_Plus_XY = std::unique_ptr<TCanvas>(new TCanvas("Canvas_GE1_Plus_XY", "Canvas_GE1_Plus_XY", 800, 600));
0340   Canvas_GE1_Minus_XY = std::unique_ptr<TCanvas>(new TCanvas("Canvas_GE1_Minus_XY", "Canvas_GE1_Minus_XY", 800, 600));
0341   Canvas_GE1_Plus_YZ = std::unique_ptr<TCanvas>(new TCanvas("Canvas_GE1_Plus_YZ", "Canvas_GE1_Plus_YZ", 600, 800));
0342   Canvas_GE1_Minus_YZ = std::unique_ptr<TCanvas>(new TCanvas("Canvas_GE1_Minus_YZ", "Canvas_GE1_Minus_YZ", 600, 800));
0343 
0344   // XY and RZ Graphs
0345   Canvas_GE1_Plus_XY->cd();
0346   GE1in_Plus_XY_All->SetMarkerStyle(mar1);
0347   GE1in_Plus_XY_All->SetMarkerColor(col1);
0348   GE1in_Plus_XY_All->Draw("AP");
0349   GE1out_Plus_XY_All->SetMarkerStyle(mar2);
0350   GE1out_Plus_XY_All->SetMarkerColor(col2);
0351   GE1out_Plus_XY_All->Draw("Psame");
0352   GE1in_Plus_XY_All->GetXaxis()->SetTitle("X [cm]");
0353   GE1in_Plus_XY_All->GetYaxis()->SetTitle("Y [cm]");
0354   GE1in_Plus_XY_All->SetTitle("GE+1 RecHits");
0355 
0356   Canvas_GE1_Minus_XY->cd();
0357   GE1in_Minus_XY_All->SetMarkerStyle(mar1);
0358   GE1in_Minus_XY_All->SetMarkerColor(col1);
0359   GE1in_Minus_XY_All->Draw("AP");
0360   GE1out_Minus_XY_All->SetMarkerStyle(mar2);
0361   GE1out_Minus_XY_All->SetMarkerColor(col2);
0362   GE1out_Minus_XY_All->Draw("Psame");
0363   GE1in_Minus_XY_All->GetXaxis()->SetTitle("X [cm]");
0364   GE1in_Minus_XY_All->GetYaxis()->SetTitle("Y [cm]");
0365   GE1in_Minus_XY_All->SetTitle("GE-1 RecHits");
0366 
0367   Canvas_GE1_Plus_YZ->cd();
0368   GE1_Plus_YZ_All->SetMarkerStyle(0);
0369   GE1_Plus_YZ_All->SetMarkerColor(0);
0370   GE1_Plus_YZ_All->Draw("AP");
0371   GE1_Plus_YZ_All->GetXaxis()->SetTitle("Z [cm]");
0372   GE1_Plus_YZ_All->GetYaxis()->SetTitle("R [cm]");
0373   GE1_Plus_YZ_All->SetTitle("GE+1 RecHits");
0374   GE1in_Plus_YZ_All->SetMarkerStyle(mar1);
0375   GE1in_Plus_YZ_All->SetMarkerColor(col1);
0376   GE1in_Plus_YZ_All->Draw("Psame");
0377   GE1out_Plus_YZ_All->SetMarkerStyle(mar2);
0378   GE1out_Plus_YZ_All->SetMarkerColor(col2);
0379   GE1out_Plus_YZ_All->Draw("Psame");
0380   // GE1in_Plus_YZ_All->GetXaxis()->SetTitle("Z [cm]");    GE1in_Plus_YZ_All->GetYaxis()->SetTitle("R [cm]");     GE1in_Plus_YZ_All->SetTitle("GE1 Plus RecHits");
0381   // GE1in_Plus_YZ_All->GetXaxis()->SetRangeUser(563,573);
0382   // TLatex latex1; latex1.SetNDC();  latex1.SetTextAlign(23);
0383   // latex1.SetTextSize(0.03); latex1.DrawLatex(0.175,0.50,"#color[15]{RE+1/2}"); latex1.DrawLatex(0.325,0.50,"#color[15]{RE+2/2}"); latex1.DrawLatex(0.675,0.50,"#color[15]{RE+3/2}"); latex1.DrawLatex(0.825,0.50,"#color[15]{RE+4/2}");
0384   // latex1.SetTextSize(0.03); latex1.DrawLatex(0.175,0.875,"#color[15]{RE+1/3}"); latex1.DrawLatex(0.325,0.875,"#color[15]{RE+2/3}"); latex1.DrawLatex(0.675,0.875,"#color[15]{RE+3/3}"); latex1.DrawLatex(0.825,0.875,"#color[15]{RE+4/3}");
0385 
0386   Canvas_GE1_Minus_YZ->cd();
0387   GE1_Minus_YZ_All->SetMarkerStyle(0);
0388   GE1_Minus_YZ_All->SetMarkerColor(0);
0389   GE1_Minus_YZ_All->Draw("AP");
0390   GE1_Minus_YZ_All->GetXaxis()->SetTitle("Z [cm]");
0391   GE1_Minus_YZ_All->GetYaxis()->SetTitle("R [cm]");
0392   GE1_Minus_YZ_All->SetTitle("GE-1 RecHits");
0393   GE1in_Minus_YZ_All->SetMarkerStyle(mar1);
0394   GE1in_Minus_YZ_All->SetMarkerColor(col1);
0395   GE1in_Minus_YZ_All->Draw("Psame");
0396   GE1out_Minus_YZ_All->SetMarkerStyle(mar2);
0397   GE1out_Minus_YZ_All->SetMarkerColor(col2);
0398   GE1out_Minus_YZ_All->Draw("Psame");
0399   // GE1in_Minus_YZ_All->GetXaxis()->SetTitle("Z [cm]");   GE1in_Minus_YZ_All->GetYaxis()->SetTitle("R [cm]");    GE1in_Minus_YZ_All->SetTitle("GE Minus RecHits");
0400   // GE1in_Minus_YZ_All->GetXaxis()->SetRangeUser(-573, -563);
0401   // TLatex latex2; latex2.SetNDC();  latex2.SetTextAlign(23);
0402   // latex2.SetTextSize(0.03); latex2.DrawLatex(0.175,0.50,"#color[15]{RE-4/2}"); latex2.DrawLatex(0.325,0.50,"#color[15]{RE-3/2}"); latex2.DrawLatex(0.675,0.50,"#color[15]{RE-2/2}"); latex2.DrawLatex(0.825,0.50,"#color[15]{RE-1/2}");
0403   // latex2.SetTextSize(0.03); latex2.DrawLatex(0.175,0.875,"#color[15]{RE-4/3}"); latex2.DrawLatex(0.325,0.875,"#color[15]{RE-3/3}"); latex2.DrawLatex(0.675,0.875,"#color[15]{RE-2/3}"); latex2.DrawLatex(0.825,0.875,"#color[15]{RE-1/3}");
0404 
0405   BX_RecHits_GE1->Write();
0406   ST_RecHits_GE1->Write();
0407   CL_RecHits_GE1->Write();
0408   Canvas_GE1_Plus_XY->Write();
0409   Canvas_GE1_Minus_XY->Write();
0410   Canvas_GE1_Plus_YZ->Write();
0411   Canvas_GE1_Minus_YZ->Write();
0412 }
0413 
0414 //
0415 // member functions
0416 //
0417 
0418 // ------------ method called for each event  ------------
0419 void TestGEMRecHitAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0420   iSetup.get<MuonGeometryRecord>().get(gemGeom);
0421 
0422   // ================
0423   // GEM recHits
0424   // ================
0425   edm::Handle<GEMRecHitCollection> gemRecHits;
0426   iEvent.getByToken(GEMRecHit_Token, gemRecHits);
0427 
0428   // count the number of GEM rechits
0429   int nGEM = 0;
0430   GEMRecHitCollection::const_iterator recHit;
0431   for (recHit = gemRecHits->begin(); recHit != gemRecHits->end(); recHit++) {
0432     nGEM++;
0433   }
0434 
0435   // std::cout<<"The Number of RecHits is "<<nGEM<<std::endl;
0436   for (recHit = gemRecHits->begin(); recHit != gemRecHits->end(); recHit++) {
0437     GEMDetId rollId = (GEMDetId)(*recHit).gemId();
0438     LocalPoint recHitPos = recHit->localPosition();
0439     const GEMEtaPartition* rollasociated = gemGeom->etaPartition(rollId);
0440     const BoundPlane& GEMSurface = rollasociated->surface();
0441     GlobalPoint GEMGlobalPoint = GEMSurface.toGlobal(recHitPos);
0442 
0443     int region = rollId.region();
0444     int station = rollId.station();
0445     // int ring    = rollId.ring();
0446     int layer = rollId.layer();
0447     // int etapart = rollId.roll();
0448     // int chamber = rollId.chamber();
0449 
0450     std::cout << "GEM Rec Hit in [DetId] = [" << rollId << "] with BX = " << recHit->BunchX()
0451               << " and Global Position = " << GEMGlobalPoint << std::endl;
0452 
0453     int bx = recHit->BunchX();
0454     int cl = recHit->clusterSize();
0455     int st = recHit->firstClusterStrip();
0456 
0457     // Positive Endcap
0458     if (region == 1 && station == 1) {
0459       x_p1.push_back(GEMGlobalPoint.x());
0460       y_p1.push_back(GEMGlobalPoint.y());
0461       z_p1.push_back(GEMGlobalPoint.z());
0462       r_p1.push_back(sqrt(pow(GEMGlobalPoint.x(), 2) + pow(GEMGlobalPoint.y(), 2)));
0463       // Layers
0464       if (layer == 1) {
0465         BX_RecHits_GE1in_Plus->Fill(bx);
0466         ST_RecHits_GE1in_Plus->Fill(st);
0467         CL_RecHits_GE1in_Plus->Fill(cl);
0468         x_p1i.push_back(GEMGlobalPoint.x());
0469         y_p1i.push_back(GEMGlobalPoint.y());
0470         z_p1i.push_back(GEMGlobalPoint.z());
0471         r_p1i.push_back(sqrt(pow(GEMGlobalPoint.x(), 2) + pow(GEMGlobalPoint.y(), 2)));
0472       }
0473       if (layer == 2) {
0474         BX_RecHits_GE1out_Plus->Fill(bx);
0475         ST_RecHits_GE1out_Plus->Fill(st);
0476         CL_RecHits_GE1out_Plus->Fill(cl);
0477         x_p1o.push_back(GEMGlobalPoint.x());
0478         y_p1o.push_back(GEMGlobalPoint.y());
0479         z_p1o.push_back(GEMGlobalPoint.z());
0480         r_p1o.push_back(sqrt(pow(GEMGlobalPoint.x(), 2) + pow(GEMGlobalPoint.y(), 2)));
0481       }
0482     }
0483     // Negative Endcap
0484     if (region == -1 && station == 1) {
0485       x_n1.push_back(GEMGlobalPoint.x());
0486       y_n1.push_back(GEMGlobalPoint.y());
0487       z_n1.push_back(GEMGlobalPoint.z());
0488       r_n1.push_back(sqrt(pow(GEMGlobalPoint.x(), 2) + pow(GEMGlobalPoint.y(), 2)));
0489       // Layers
0490       if (layer == 1) {
0491         BX_RecHits_GE1in_Minus->Fill(bx);
0492         ST_RecHits_GE1in_Minus->Fill(st);
0493         CL_RecHits_GE1in_Minus->Fill(cl);
0494         x_n1i.push_back(GEMGlobalPoint.x());
0495         y_n1i.push_back(GEMGlobalPoint.y());
0496         z_n1i.push_back(GEMGlobalPoint.z());
0497         r_n1i.push_back(sqrt(pow(GEMGlobalPoint.x(), 2) + pow(GEMGlobalPoint.y(), 2)));
0498       }
0499       if (layer == 2) {
0500         BX_RecHits_GE1out_Minus->Fill(bx);
0501         ST_RecHits_GE1out_Minus->Fill(st);
0502         CL_RecHits_GE1out_Minus->Fill(cl);
0503         x_n1o.push_back(GEMGlobalPoint.x());
0504         y_n1o.push_back(GEMGlobalPoint.y());
0505         z_n1o.push_back(GEMGlobalPoint.z());
0506         r_n1o.push_back(sqrt(pow(GEMGlobalPoint.x(), 2) + pow(GEMGlobalPoint.y(), 2)));
0507       }
0508     }
0509   }
0510 }
0511 
0512 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
0513 void TestGEMRecHitAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0514   // The following says we do not know what parameters are allowed so do no validation
0515   // Please change this to state exactly what you do use, even if it is no parameters
0516   edm::ParameterSetDescription desc;
0517   desc.setUnknown();
0518   descriptions.addDefault(desc);
0519 }
0520 
0521 //define this as a plug-in
0522 DEFINE_FWK_MODULE(TestGEMRecHitAnalyzer);