#ifndef RecoLocalMuon_CSCValidation_H #define RecoLocalMuon_CSCValidation_H /** \class CSCValidation * * Package to validate local CSC reconstruction: * DIGIS * recHits * segments * L1 trigger * CSC STA muons * Various efficiencies * * Responsible: * Andy Kubik, Northwestern University */ // user include files #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/EDAnalyzer.h" #include "FWCore/Framework/interface/EDFilter.h" #include "FWCore/Framework/interface/Event.h" #include "DataFormats/Common/interface/Handle.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DataFormats/CSCDigi/interface/CSCWireDigi.h" #include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h" #include "DataFormats/CSCDigi/interface/CSCStripDigi.h" #include "DataFormats/CSCDigi/interface/CSCStripDigiCollection.h" #include "DataFormats/CSCDigi/interface/CSCComparatorDigi.h" #include "DataFormats/CSCDigi/interface/CSCComparatorDigiCollection.h" #include "DataFormats/MuonDetId/interface/CSCDetId.h" #include #include #include "DataFormats/MuonDetId/interface/RPCDetId.h" #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutRecord.h" #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutCollection.h" #include "Geometry/CSCGeometry/interface/CSCGeometry.h" #include "Geometry/CSCGeometry/interface/CSCChamber.h" #include "Geometry/CSCGeometry/interface/CSCLayer.h" #include "Geometry/CSCGeometry/interface/CSCLayerGeometry.h" #include "Geometry/Records/interface/MuonGeometryRecord.h" #include "DataFormats/TrackReco/interface/Track.h" #include "DataFormats/TrackReco/interface/TrackFwd.h" #include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h" #include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h" #include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h" #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" #include "DataFormats/GeometryVector/interface/GlobalPoint.h" #include "DataFormats/GeometryVector/interface/GlobalVector.h" #include "DataFormats/GeometryVector/interface/LocalPoint.h" #include "DataFormats/GeometryVector/interface/LocalVector.h" #include "DataFormats/CLHEP/interface/AlgebraicObjects.h" #include "DataFormats/MuonDetId/interface/CSCIndexer.h" #include "CondFormats/CSCObjects/interface/CSCDBGains.h" #include "CondFormats/DataRecord/interface/CSCDBGainsRcd.h" #include "CondFormats/CSCObjects/interface/CSCDBNoiseMatrix.h" #include "CondFormats/DataRecord/interface/CSCDBNoiseMatrixRcd.h" #include "CondFormats/CSCObjects/interface/CSCDBCrosstalk.h" #include "CondFormats/DataRecord/interface/CSCDBCrosstalkRcd.h" #include "CondFormats/CSCObjects/interface/CSCDBPedestals.h" #include "CondFormats/DataRecord/interface/CSCDBPedestalsRcd.h" #include "CommonTools/Statistics/interface/ChiSquaredProbability.h" #include "RecoLocalMuon/CSCValidation/src/CSCValHists.h" #include "TVector3.h" #include "TH1F.h" #include "TH2F.h" #include "TFile.h" #include "TString.h" #include "TTree.h" #include "TProfile2D.h" class CSCValidation : public edm::EDAnalyzer { public: /// Constructor CSCValidation(const edm::ParameterSet& pset); /// Destructor virtual ~CSCValidation(); /// Perform the analysis void analyze(const edm::Event & event, const edm::EventSetup& eventSetup); void endJob(); // for noise module struct ltrh { bool operator()(const CSCRecHit2D rh1, const CSCRecHit2D rh2) const { return ((rh1.localPosition()).x()-(rh2.localPosition()).x()) < 0; } }; protected: private: // these are the "modules" // if you would like to add code to CSCValidation, please do so by adding an // extra module in the form of an additional private member function void doOccupancies(edm::Handle strips, edm::Handle wires, edm::Handle recHits, edm::Handle cscSegments); void doStripDigis(edm::Handle strips); void doWireDigis(edm::Handle wires); void doRecHits(edm::Handle recHits, edm::ESHandle cscGeom); void doSimHits(edm::Handle recHits, edm::Handle simHits); void doPedestalNoise(edm::Handle strips); void doSegments(edm::Handle cscSegments, edm::ESHandle cscGeom); void doResolution(edm::Handle cscSegments, edm::ESHandle cscGeom); void doEfficiencies(edm::Handle wires, edm::Handle strips, edm::Handle recHits, edm::Handle cscSegments, edm::ESHandle cscGeom); void doGasGain(const CSCWireDigiCollection &, const CSCStripDigiCollection &, const CSCRecHit2DCollection &); void doCalibrations(const edm::EventSetup& eventSetup); void doAFEBTiming(const CSCWireDigiCollection &); void doCompTiming(const CSCComparatorDigiCollection &); void doADCTiming(const CSCRecHit2DCollection &); void doNoiseHits(edm::Handle recHits, edm::Handle cscSegments, edm::ESHandle cscGeom, edm::Handle strips); bool doTrigger(edm::Handle pCollection); void doStandalone(edm::Handle saMuons); // some useful functions bool filterEvents(edm::Handle recHits, edm::Handle cscSegments, edm::Handle saMuons); float fitX(CLHEP::HepMatrix sp, CLHEP::HepMatrix ep); float getSignal(const CSCStripDigiCollection& stripdigis, CSCDetId idRH, int centerStrip); float getthisSignal(const CSCStripDigiCollection& stripdigis, CSCDetId idRH, int centerStrip); int getWidth(const CSCStripDigiCollection& stripdigis, CSCDetId idRH, int centerStrip); void findNonAssociatedRecHits(edm::ESHandle cscGeom, edm::Handle strips); int chamberSerial( CSCDetId id ); // these functions handle Stoyan's efficiency code void fillEfficiencyHistos(int bin, int flag); void getEfficiency(float bin, float Norm, std::vector &eff); void histoEfficiency(TH1F *readHisto, TH1F *writeHisto); double lineParametrization(double z1Position, double z2Position, double z1Direction){ double parameterLine = (z2Position-z1Position)/z1Direction; return parameterLine; } double extrapolate1D(double initPosition, double initDirection, double parameterOfTheLine){ double extrapolatedPosition = initPosition + initDirection*parameterOfTheLine; return extrapolatedPosition; } bool withinSensitiveRegion(LocalPoint localPos, const std::vector layerBounds, int station, int ring, float shiftFromEdge, float shiftFromDeadZone); // counters int nEventsAnalyzed; int rhTreeCount; int segTreeCount; bool firstEvent; bool cleanEvent; // // // The root file for the histograms. TFile *theFile; // // // input parameters for this module bool makePlots; bool makeComparisonPlots; std::string refRootFile; bool writeTreeToFile; bool isSimulation; std::string rootFileName; bool detailedAnalysis; bool useDigis; // filters bool useQualityFilter; bool useTriggerFilter; // quality filter parameters double pMin; double chisqMax; int nCSCHitsMin, nCSCHitsMax; double lengthMin, lengthMax; double deltaPhiMax; double polarMin, polarMax; edm::InputTag stripDigiTag; edm::InputTag wireDigiTag; edm::InputTag compDigiTag; edm::InputTag cscRecHitTag; edm::InputTag cscSegTag; edm::InputTag saMuonTag; edm::InputTag l1aTag; edm::InputTag simHitTag; // module on/off switches bool makeOccupancyPlots; bool makeTriggerPlots; bool makeStripPlots; bool makeWirePlots; bool makeRecHitPlots; bool makeSimHitPlots; bool makeSegmentPlots; bool makeResolutionPlots; bool makePedNoisePlots; bool makeEfficiencyPlots; bool makeGasGainPlots; bool makeAFEBTimingPlots; bool makeCompTimingPlots; bool makeADCTimingPlots; bool makeRHNoisePlots; bool makeCalibPlots; bool makeStandalonePlots; // The histo managing object CSCValHists *histos; // tmp histos for Efficiency TH1F *hSSTE; TH1F *hRHSTE; TH1F *hSEff; TH1F *hRHEff; TH2F *hSSTE2; TH2F *hRHSTE2; TH2F *hStripSTE2; TH2F *hWireSTE2; TH2F *hSEff2; TH2F *hRHEff2; TH2F *hStripEff2; TH2F *hWireEff2; TH2F *hEffDenominator; TH2F *hSensitiveAreaEvt; // occupancy TH2I *hOWires; TH2I *hOStrips; TH2I *hORecHits; TH2I *hOSegments; /// Maps and vectors for module doGasGain() std::vector nmbhvsegm; std::map > m_wire_hvsegm; std::map m_single_wire_layer; //maps to store the DetId and associated RecHits std::multimap AllRechits; std::multimap SegRechits; std::multimap NonAssociatedRechits; std::map distRHmap; int typeIndex(CSCDetId id){ // linearlized index bases on endcap, station, and ring int index = 0; if (id.station() == 1){ index = id.ring() + 1; if (id.ring() == 4) index = 1; } else index = id.station()*2 + id.ring(); if (id.endcap() == 1) index = index + 10; if (id.endcap() == 2) index = 11 - index; return index; } }; #endif