Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:44:22

0001 #ifndef RecoLocalMuon_CSCOfflineMonitor_H
0002 #define RecoLocalMuon_CSCOfflineMonitor_H
0003 
0004 /** \class CSCOfflineMonitor
0005  *
0006  * Simple package for offline CSC DQM based on RecoLocalMuon/CSCValidation:
0007  *    digis, rechits, segments
0008  *
0009  * Andrew Kubik, Northwestern University, Oct 2008
0010  *
0011  */
0012 
0013 #include "FWCore/Framework/interface/ConsumesCollector.h"
0014 #include "FWCore/Framework/interface/MakerMacros.h"
0015 #include "FWCore/Framework/interface/Frameworkfwd.h"
0016 #include "FWCore/Framework/interface/Event.h"
0017 #include "DataFormats/Common/interface/Handle.h"
0018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0019 #include "FWCore/Framework/interface/EventSetup.h"
0020 #include "FWCore/Framework/interface/ESHandle.h"
0021 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0022 #include "FWCore/ServiceRegistry/interface/Service.h"
0023 #include "FWCore/Utilities/interface/InputTag.h"
0024 
0025 #include "DataFormats/CSCDigi/interface/CSCALCTDigi.h"
0026 #include "DataFormats/CSCDigi/interface/CSCALCTDigiCollection.h"
0027 #include "DataFormats/CSCDigi/interface/CSCCLCTDigi.h"
0028 #include "DataFormats/CSCDigi/interface/CSCCLCTDigiCollection.h"
0029 #include "DataFormats/CSCDigi/interface/CSCWireDigi.h"
0030 #include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h"
0031 #include "DataFormats/CSCDigi/interface/CSCStripDigi.h"
0032 #include "DataFormats/CSCDigi/interface/CSCStripDigiCollection.h"
0033 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0034 #include "DataFormats/CSCRecHit/interface/CSCRecHit2D.h"
0035 #include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h"
0036 #include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h"
0037 
0038 #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
0039 #include "Geometry/CSCGeometry/interface/CSCChamber.h"
0040 #include "Geometry/CSCGeometry/interface/CSCLayer.h"
0041 #include "Geometry/CSCGeometry/interface/CSCLayerGeometry.h"
0042 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0043 
0044 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0045 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
0046 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
0047 #include "DataFormats/GeometryVector/interface/LocalVector.h"
0048 #include "DataFormats/CLHEP/interface/AlgebraicObjects.h"
0049 
0050 #include "CommonTools/Statistics/interface/ChiSquaredProbability.h"
0051 
0052 #include "DQMServices/Core/interface/DQMStore.h"
0053 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0054 
0055 #include "CondFormats/CSCObjects/interface/CSCCrateMap.h"
0056 #include "CondFormats/DataRecord/interface/CSCCrateMapRcd.h"
0057 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
0058 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0059 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
0060 
0061 #include "EventFilter/CSCRawToDigi/interface/CSCComparatorData.h"
0062 #include "EventFilter/CSCRawToDigi/interface/CSCDCCExaminer.h"
0063 #include "EventFilter/CSCRawToDigi/interface/CSCDCCEventData.h"
0064 #include "EventFilter/CSCRawToDigi/interface/CSCDDUEventData.h"
0065 #include "EventFilter/CSCRawToDigi/interface/CSCEventData.h"
0066 #include "EventFilter/CSCRawToDigi/interface/CSCTMBData.h"
0067 #include "EventFilter/CSCRawToDigi/interface/CSCTMBHeader.h"
0068 
0069 class CSCOfflineMonitor : public DQMEDAnalyzer {
0070 public:
0071   CSCOfflineMonitor(const edm::ParameterSet &pset);
0072   ~CSCOfflineMonitor() override{};
0073 
0074   enum LabelType { SMALL, EXTENDED };
0075   enum AxisType { X = 1, Y = 2, Z = 3 };
0076 
0077 protected:
0078   void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
0079   void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override;
0080 
0081 private:
0082   edm::ParameterSet param;
0083 
0084   edm::EDGetTokenT<FEDRawDataCollection> rd_token;
0085   edm::EDGetTokenT<CSCWireDigiCollection> wd_token;
0086   edm::EDGetTokenT<CSCStripDigiCollection> sd_token;
0087   edm::EDGetTokenT<CSCALCTDigiCollection> al_token;
0088   edm::EDGetTokenT<CSCCLCTDigiCollection> cl_token;
0089   edm::EDGetTokenT<CSCRecHit2DCollection> rh_token;
0090   edm::EDGetTokenT<CSCSegmentCollection> se_token;
0091 
0092   const edm::ESGetToken<CSCGeometry, MuonGeometryRecord> cscGeomToken_;
0093 
0094   const edm::ESGetToken<CSCCrateMap, CSCCrateMapRcd> hcrateToken_;
0095 
0096   // modules
0097   void doOccupancies(edm::Handle<CSCStripDigiCollection> strips,
0098                      edm::Handle<CSCWireDigiCollection> wires,
0099                      edm::Handle<CSCRecHit2DCollection> recHits,
0100                      edm::Handle<CSCSegmentCollection> cscSegments,
0101                      edm::Handle<CSCCLCTDigiCollection> clcts);
0102   void doStripDigis(edm::Handle<CSCStripDigiCollection> strips);
0103   void doWireDigis(edm::Handle<CSCWireDigiCollection> wires);
0104   void doRecHits(edm::Handle<CSCRecHit2DCollection> recHits,
0105                  edm::Handle<CSCStripDigiCollection> strips,
0106                  edm::ESHandle<CSCGeometry> cscGeom);
0107   void doPedestalNoise(edm::Handle<CSCStripDigiCollection> strips, edm::ESHandle<CSCGeometry> cscGeom);
0108   void doSegments(edm::Handle<CSCSegmentCollection> cscSegments, edm::ESHandle<CSCGeometry> cscGeom);
0109   void doResolution(edm::Handle<CSCSegmentCollection> cscSegments, edm::ESHandle<CSCGeometry> cscGeom);
0110   void doEfficiencies(edm::Handle<CSCWireDigiCollection> wires,
0111                       edm::Handle<CSCStripDigiCollection> strips,
0112                       edm::Handle<CSCRecHit2DCollection> recHits,
0113                       edm::Handle<CSCSegmentCollection> cscSegments,
0114                       edm::ESHandle<CSCGeometry> cscGeom);
0115   void doBXMonitor(edm::Handle<CSCALCTDigiCollection> alcts,
0116                    edm::Handle<CSCCLCTDigiCollection> clcts,
0117                    const edm::Event &event,
0118                    const edm::EventSetup &eventSetup);
0119 
0120   // used by modules
0121   float fitX(const CLHEP::HepMatrix &sp, const CLHEP::HepMatrix &ep);
0122   float getSignal(const CSCStripDigiCollection &stripdigis, CSCDetId idRH, int centerStrip);
0123   int typeIndex(CSCDetId id, int flag = 1);
0124   int chamberSerial(CSCDetId id);
0125   void applyCSClabels(MonitorElement *meHisto, LabelType t, AxisType a);
0126 
0127   // for efficiency calculations
0128   // - these functions handle Stoyan's efficiency code
0129 
0130   void fillEfficiencyHistos(int bin, int flag);
0131   //  void  getEfficiency(float bin, float Norm, std::vector<float> &eff);
0132   //  void  histoEfficiency(TH1F *readHisto, MonitorElement *writeHisto);
0133 
0134   double lineParametrization(double z1Position, double z2Position, double z1Direction) {
0135     double parameterLine = (z2Position - z1Position) / z1Direction;
0136     return parameterLine;
0137   }
0138 
0139   double extrapolate1D(double initPosition, double initDirection, double parameterOfTheLine) {
0140     double extrapolatedPosition = initPosition + initDirection * parameterOfTheLine;
0141     return extrapolatedPosition;
0142   }
0143 
0144   bool withinSensitiveRegion(LocalPoint localPos,
0145                              const std::array<const float, 4> &layerBounds,
0146                              int station,
0147                              int ring,
0148                              float shiftFromEdge,
0149                              float shiftFromDeadZone);
0150 
0151   // for BX monitor plots
0152   //  void harvestChamberMeans(MonitorElement* meMean1D, MonitorElement *meMean2D, MonitorElement *hNum, MonitorElement *meDenom);
0153   //  void normalize(MonitorElement* me);
0154 
0155   // Wire digis
0156   MonitorElement *hWirenGroupsTotal;
0157   MonitorElement *hWirenGroupsTotalHi;
0158   std::vector<MonitorElement *> hWireTBin;
0159   std::vector<MonitorElement *> hWireNumber;
0160 
0161   // Strip Digis
0162   MonitorElement *hStripNFired;
0163   MonitorElement *hStripNFiredHi;
0164   std::vector<MonitorElement *> hStripNumber;
0165   std::vector<MonitorElement *> hStripPed;
0166 
0167   // Rechits
0168   MonitorElement *hRHnrechits;
0169   MonitorElement *hRHnrechitsHi;
0170   std::vector<MonitorElement *> hRHGlobal;
0171   std::vector<MonitorElement *> hRHSumQ;
0172   std::vector<MonitorElement *> hRHTiming;
0173   std::vector<MonitorElement *> hRHTimingAnode;
0174   std::vector<MonitorElement *> hRHRatioQ;
0175   std::vector<MonitorElement *> hRHstpos;
0176   std::vector<MonitorElement *> hRHsterr;
0177 
0178   // Segments
0179   MonitorElement *hSnSegments;
0180   MonitorElement *hSnhitsAll;
0181   std::vector<MonitorElement *> hSnhits;
0182   MonitorElement *hSChiSqAll;
0183   std::vector<MonitorElement *> hSChiSq;
0184   MonitorElement *hSChiSqProbAll;
0185   std::vector<MonitorElement *> hSChiSqProb;
0186   MonitorElement *hSGlobalTheta;
0187   MonitorElement *hSGlobalPhi;
0188   MonitorElement *hSTimeDiff;
0189   std::vector<MonitorElement *> hSTimeDiffByChamberType;
0190   MonitorElement *hSTimeAnode;
0191   std::vector<MonitorElement *> hSTimeAnodeByChamberType;
0192   MonitorElement *hSTimeCathode;
0193   std::vector<MonitorElement *> hSTimeCathodeByChamberType;
0194   MonitorElement *hSTimeCombined;
0195   std::vector<MonitorElement *> hSTimeCombinedByChamberType;
0196   MonitorElement *hSTimeDiffSerial;
0197   MonitorElement *hSTimeAnodeSerial;
0198   MonitorElement *hSTimeCathodeSerial;
0199   MonitorElement *hSTimeCombinedSerial;
0200   MonitorElement *hSTimeVsZ;
0201   MonitorElement *hSTimeVsTOF;
0202 
0203   // Resolution
0204   std::vector<MonitorElement *> hSResid;
0205 
0206   // Occupancies
0207   MonitorElement *hOWires;
0208   MonitorElement *hOWiresAndCLCT;
0209   MonitorElement *hOStrips;
0210   MonitorElement *hOStripsAndWiresAndCLCT;
0211   MonitorElement *hORecHits;
0212   MonitorElement *hOSegments;
0213   MonitorElement *hOWireSerial;
0214   MonitorElement *hOStripSerial;
0215   MonitorElement *hORecHitsSerial;
0216   MonitorElement *hOSegmentsSerial;
0217   MonitorElement *hCSCOccupancy;
0218 
0219   // Efficiencies
0220   MonitorElement *hSnum;
0221   MonitorElement *hSden;
0222   MonitorElement *hRHnum;
0223   MonitorElement *hRHden;
0224   //  MonitorElement *hSEff;
0225   //  MonitorElement *hRHEff;
0226   MonitorElement *hSSTE2;
0227   MonitorElement *hRHSTE2;
0228   MonitorElement *hStripSTE2;
0229   MonitorElement *hWireSTE2;
0230   //  MonitorElement *hSEff2;
0231   //  MonitorElement *hRHEff2;
0232   //  MonitorElement *hStripEff2;
0233   //  MonitorElement *hWireEff2;
0234   //  MonitorElement *hStripReadoutEff2;
0235   MonitorElement *hEffDenominator;
0236   MonitorElement *hSensitiveAreaEvt;
0237 
0238   // BX monitoring
0239   MonitorElement *hALCTgetBX;
0240   MonitorElement *hALCTgetBXSerial;
0241   //  MonitorElement *hALCTgetBXChamberMeans;
0242   //  MonitorElement *hALCTgetBX2DMeans;
0243   MonitorElement *hALCTgetBX2Denominator;
0244   MonitorElement *hALCTgetBX2DNumerator;
0245 
0246   MonitorElement *hALCTMatch;
0247   MonitorElement *hALCTMatchSerial;
0248   //  MonitorElement *hALCTMatchChamberMeans;
0249   //  MonitorElement *hALCTMatch2DMeans;
0250   MonitorElement *hALCTMatch2Denominator;
0251   MonitorElement *hALCTMatch2DNumerator;
0252 
0253   MonitorElement *hCLCTL1A;
0254   MonitorElement *hCLCTL1ASerial;
0255   //  MonitorElement *hCLCTL1AChamberMeans;
0256   //  MonitorElement *hCLCTL1A2DMeans;
0257   MonitorElement *hCLCTL1A2Denominator;
0258   MonitorElement *hCLCTL1A2DNumerator;
0259 };
0260 #endif