Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-09-29 01:11:46

0001 #ifndef DPGAnalysisSkims_CSCSkim_H
0002 #define DPGAnalysisSkims_CSCSkim_H
0003 
0004 /** \class CSCSkim
0005  *
0006  * This simple program selects minimal CSC events for output.
0007  *
0008  * Michael Schmitt, Northwestern University, July 2008
0009  */
0010 
0011 #include <memory>
0012 #include <iostream>
0013 #include <vector>
0014 #include <map>
0015 #include <string>
0016 #include <iomanip>
0017 #include <fstream>
0018 
0019 #include "FWCore/Framework/interface/ConsumesCollector.h"
0020 #include "FWCore/Framework/interface/MakerMacros.h"
0021 #include "FWCore/Framework/interface/Frameworkfwd.h"
0022 #include "FWCore/Framework/interface/one/EDFilter.h"
0023 #include "FWCore/Framework/interface/Event.h"
0024 #include "DataFormats/Common/interface/Handle.h"
0025 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0026 #include "FWCore/Framework/interface/EventSetup.h"
0027 #include "FWCore/Framework/interface/ESHandle.h"
0028 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0029 
0030 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0031 #include "DataFormats/CSCDigi/interface/CSCWireDigi.h"
0032 #include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h"
0033 #include "DataFormats/CSCDigi/interface/CSCStripDigi.h"
0034 #include "DataFormats/CSCDigi/interface/CSCStripDigiCollection.h"
0035 #include <DataFormats/CSCRecHit/interface/CSCRecHit2D.h>
0036 #include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h"
0037 #include <DataFormats/CSCRecHit/interface/CSCSegmentCollection.h>
0038 
0039 #include "DataFormats/DTRecHit/interface/DTRecSegment4D.h"
0040 #include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
0041 
0042 #include "DataFormats/MuonReco/interface/Muon.h"
0043 #include "DataFormats/MuonReco/interface/MuonFwd.h"
0044 #include "DataFormats/TrackReco/interface/Track.h"
0045 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0046 #include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
0047 #include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
0048 
0049 #include "Geometry/DTGeometry/interface/DTGeometry.h"
0050 #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
0051 #include "Geometry/CSCGeometry/interface/CSCChamber.h"
0052 #include "Geometry/CSCGeometry/interface/CSCLayer.h"
0053 #include "Geometry/CSCGeometry/interface/CSCLayerGeometry.h"
0054 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0055 
0056 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0057 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
0058 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
0059 #include "DataFormats/GeometryVector/interface/LocalVector.h"
0060 #include "DataFormats/CLHEP/interface/AlgebraicObjects.h"
0061 
0062 // #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
0063 
0064 #include "TVector3.h"
0065 #include "TH1F.h"
0066 #include "TH2F.h"
0067 #include "TFile.h"
0068 #include "TString.h"
0069 #include "TTree.h"
0070 
0071 class CSCSkim : public edm::one::EDFilter<> {
0072 public:
0073   // Constructor
0074   explicit CSCSkim(const edm::ParameterSet &pset);
0075 
0076   // Destructor
0077   ~CSCSkim() override;
0078 
0079   // Analysis routines
0080   void beginJob() override;
0081   bool filter(edm::Event &event, const edm::EventSetup &eventSetup) override;
0082   void endJob() override;
0083 
0084 protected:
0085 private:
0086   // main skimming routine
0087   bool doCSCSkimming(edm::Handle<CSCRecHit2DCollection> cscRecHits, edm::Handle<CSCSegmentCollection> cscSegments);
0088 
0089   // extra skimming routine for alignment studies
0090   bool doOverlapSkimming(edm::Handle<CSCSegmentCollection> cscSegments);
0091 
0092   // skimming routine for messy events
0093   bool doMessyEventSkimming(edm::Handle<CSCRecHit2DCollection> cscRecHits,
0094                             edm::Handle<CSCSegmentCollection> cscSegments);
0095 
0096   // select events with DIGIs in a certain chamber
0097   bool doCertainChamberSelection(edm::Handle<CSCWireDigiCollection> wires, edm::Handle<CSCStripDigiCollection> strips);
0098 
0099   // select events which might probe the DT-CSC overlap region
0100   bool doDTOverlap(edm::Handle<CSCSegmentCollection> cscSegments);
0101 
0102   // select muons which go through inner part of stations 1,2,3,4
0103   bool doHaloLike(edm::Handle<CSCSegmentCollection> cscSegments);
0104 
0105   // select events with long stand-alone (cosmic) muons
0106   bool doLongSATrack(edm::Handle<reco::TrackCollection> saTracks);
0107 
0108   // select events suitable for magnetic field studies - they have a track in the tracker
0109   bool doBFieldStudySelection(edm::Handle<reco::TrackCollection> saTracks,
0110                               edm::Handle<reco::TrackCollection> Tracks,
0111                               edm::Handle<reco::MuonCollection> gMuons);
0112 
0113   // some useful functions
0114   int chamberSerial(int kE, int kS, int kR, int kCh);
0115 
0116   // counters
0117   int nEventsAnalyzed;
0118   int nEventsSelected;
0119   int nEventsChambersBothSides;
0120   int nEventsOverlappingChambers;
0121   int nEventsMessy;
0122   int nEventsCertainChamber;
0123   int nEventsDTOverlap;
0124   int nEventsHaloLike;
0125   int nEventsLongSATrack;
0126   int nEventsForBFieldStudies;
0127 
0128   // run and event number
0129   int iRun;
0130   int iEvent;
0131 
0132   // The root file for the histograms.
0133   TFile *theHistogramFile;
0134 
0135   // file names
0136   std::string outputFileName;
0137   std::string histogramFileName;
0138 
0139   // es token names
0140   const edm::ESGetToken<CSCGeometry, MuonGeometryRecord> m_CSCGeomToken;
0141 
0142   // token names
0143   edm::EDGetTokenT<CSCWireDigiCollection> wds_token;
0144   edm::EDGetTokenT<CSCStripDigiCollection> sds_token;
0145   edm::EDGetTokenT<CSCWireDigiCollection> wdr_token;
0146   edm::EDGetTokenT<CSCStripDigiCollection> sdr_token;
0147 
0148   edm::EDGetTokenT<CSCRecHit2DCollection> rh_token;
0149   edm::EDGetTokenT<CSCSegmentCollection> seg_token;
0150   edm::EDGetTokenT<reco::TrackCollection> sam_token;
0151   edm::EDGetTokenT<reco::TrackCollection> trk_token;
0152   edm::EDGetTokenT<reco::MuonCollection> glm_token;
0153 
0154   // parameters for the selection
0155   bool isSimulation;
0156   int typeOfSkim;
0157   int nLayersWithHitsMinimum;
0158   int minimumHitChambers;
0159   int minimumSegments;
0160   bool demandChambersBothSides;
0161   bool makeHistograms;
0162   bool makeHistogramsForMessyEvents;
0163   int whichEndcap;
0164   int whichStation;
0165   int whichRing;
0166   int whichChamber;
0167   // parameters for B-field study skim
0168   float pMin;
0169   float zLengthMin;
0170   int nCSCHitsMin;
0171   float zInnerMax;
0172   int nTrHitsMin;
0173   float zLengthTrMin;
0174   float rExtMax;
0175   float redChiSqMax;
0176   int nValidHitsMin;
0177 
0178   // histograms for skimming module
0179   TH1F *hxnRecHits;
0180   TH1F *hxnSegments;
0181   TH1F *hxnHitChambers;
0182   TH1F *hxnRecHitsSel;
0183   TH1F *mevnRecHits0;
0184   TH1F *mevnChambers0;
0185   TH1F *mevnSegments0;
0186   TH1F *mevnRecHits1;
0187   TH1F *mevnChambers1;
0188   TH1F *mevnSegments1;
0189 
0190   TH1F *xxP, *xxnValidHits, *xxnCSCHits, *xxredChiSq, *xxnTrackerHits;
0191 };
0192 #endif