CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/DQMOffline/Muon/src/CSCOfflineMonitor.h

Go to the documentation of this file.
00001 #ifndef RecoLocalMuon_CSCOfflineMonitor_H
00002 #define RecoLocalMuon_CSCOfflineMonitor_H
00003 
00016 // user include files
00017 #include "FWCore/Framework/interface/MakerMacros.h"
00018 #include "FWCore/Framework/interface/Frameworkfwd.h"
00019 #include "FWCore/Framework/interface/EDAnalyzer.h"
00020 #include "FWCore/Framework/interface/EDFilter.h"
00021 #include "FWCore/Framework/interface/Event.h"
00022 #include "DataFormats/Common/interface/Handle.h"
00023 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00024 #include "FWCore/Framework/interface/EventSetup.h"
00025 #include "FWCore/Framework/interface/ESHandle.h"
00026 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00027 #include "FWCore/ServiceRegistry/interface/Service.h"
00028 #include <FWCore/Utilities/interface/InputTag.h>
00029 
00030 #include "DataFormats/CSCDigi/interface/CSCALCTDigi.h"
00031 #include "DataFormats/CSCDigi/interface/CSCALCTDigiCollection.h"
00032 #include "DataFormats/CSCDigi/interface/CSCCLCTDigi.h"
00033 #include "DataFormats/CSCDigi/interface/CSCCLCTDigiCollection.h"
00034 #include "DataFormats/CSCDigi/interface/CSCWireDigi.h"
00035 #include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h"
00036 #include "DataFormats/CSCDigi/interface/CSCStripDigi.h"
00037 #include "DataFormats/CSCDigi/interface/CSCStripDigiCollection.h"
00038 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
00039 #include <DataFormats/CSCRecHit/interface/CSCRecHit2D.h>
00040 #include <DataFormats/CSCRecHit/interface/CSCSegmentCollection.h>
00041 #include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h"
00042 
00043 #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
00044 #include "Geometry/CSCGeometry/interface/CSCChamber.h"
00045 #include "Geometry/CSCGeometry/interface/CSCLayer.h"
00046 #include "Geometry/CSCGeometry/interface/CSCLayerGeometry.h"
00047 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00048 
00049 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00050 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
00051 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
00052 #include "DataFormats/GeometryVector/interface/LocalVector.h"
00053 #include "DataFormats/CLHEP/interface/AlgebraicObjects.h"
00054 
00055 #include "CommonTools/Statistics/interface/ChiSquaredProbability.h"
00056 
00057 #include "DQMServices/Core/interface/DQMStore.h"
00058 #include "DQMServices/Core/interface/MonitorElement.h"
00059 
00060 #include "CondFormats/CSCObjects/interface/CSCCrateMap.h"
00061 #include "CondFormats/DataRecord/interface/CSCCrateMapRcd.h"
00062 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
00063 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
00064 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
00065 
00066 #include "EventFilter/CSCRawToDigi/interface/CSCCLCTData.h"
00067 #include "EventFilter/CSCRawToDigi/interface/CSCDCCExaminer.h"
00068 #include "EventFilter/CSCRawToDigi/interface/CSCDCCEventData.h"
00069 #include "EventFilter/CSCRawToDigi/interface/CSCDDUEventData.h"
00070 #include "EventFilter/CSCRawToDigi/interface/CSCEventData.h"
00071 #include "EventFilter/CSCRawToDigi/interface/CSCTMBData.h"
00072 #include "EventFilter/CSCRawToDigi/interface/CSCTMBHeader.h"
00073 
00074 class CSCOfflineMonitor : public edm::EDAnalyzer {
00075 public:
00077   CSCOfflineMonitor(const edm::ParameterSet& pset);
00078 
00080   virtual ~CSCOfflineMonitor();
00081 
00082   // Operations
00083   void beginJob(void);
00084   void finalize(); 
00085   virtual void endRun( edm::Run const &, edm::EventSetup const & ) ; // call finialize() 
00086   virtual void endJob() ; // call finalize()
00087 
00088 
00090   void analyze(const edm::Event & event, const edm::EventSetup& eventSetup);
00091 
00092 
00093 protected:
00094 
00095 private: 
00096 
00097   bool finalizedHistograms_;
00098 
00099   edm::ParameterSet param;
00100   edm::InputTag stripDigiTag_;
00101   edm::InputTag wireDigiTag_;
00102   edm::InputTag alctDigiTag_;
00103   edm::InputTag clctDigiTag_;
00104   edm::InputTag cscRecHitTag_;
00105   edm::InputTag cscSegTag_; 
00106   edm::InputTag FEDRawDataCollectionTag_; 
00107 
00108   // some useful functions
00109 
00110   // modules:
00111   void  doOccupancies(edm::Handle<CSCStripDigiCollection> strips, edm::Handle<CSCWireDigiCollection> wires,
00112                       edm::Handle<CSCRecHit2DCollection> recHits, edm::Handle<CSCSegmentCollection> cscSegments,
00113                       edm::Handle<CSCCLCTDigiCollection> clcts);
00114   void  doStripDigis(edm::Handle<CSCStripDigiCollection> strips);
00115   void  doWireDigis(edm::Handle<CSCWireDigiCollection> wires);
00116   void  doRecHits(edm::Handle<CSCRecHit2DCollection> recHits,edm::Handle<CSCStripDigiCollection> strips,
00117                   edm::ESHandle<CSCGeometry> cscGeom);
00118   void  doPedestalNoise(edm::Handle<CSCStripDigiCollection> strips);
00119   void  doSegments(edm::Handle<CSCSegmentCollection> cscSegments, edm::ESHandle<CSCGeometry> cscGeom);
00120   void  doResolution(edm::Handle<CSCSegmentCollection> cscSegments, edm::ESHandle<CSCGeometry> cscGeom);
00121   void  doEfficiencies(edm::Handle<CSCWireDigiCollection> wires, edm::Handle<CSCStripDigiCollection> strips,
00122                        edm::Handle<CSCRecHit2DCollection> recHits, edm::Handle<CSCSegmentCollection> cscSegments,
00123                        edm::ESHandle<CSCGeometry> cscGeom);
00124   void  doBXMonitor(edm::Handle<CSCALCTDigiCollection> alcts, edm::Handle<CSCCLCTDigiCollection> clcts, const edm::Event & event, const edm::EventSetup& eventSetup);
00125 
00126 
00127   // used by modules:
00128   float      fitX(CLHEP::HepMatrix sp, CLHEP::HepMatrix ep);
00129   float      getSignal(const CSCStripDigiCollection& stripdigis, CSCDetId idRH, int centerStrip);
00130   int        typeIndex(CSCDetId id, int flag = 1);
00131   int        chamberSerial(CSCDetId id);
00132   void       applyCSClabels(MonitorElement *meHisto);
00133 
00134   // for efficiency calculation
00135   // these functions handle Stoyan's efficiency code
00136   void  fillEfficiencyHistos(int bin, int flag);
00137   void  getEfficiency(float bin, float Norm, std::vector<float> &eff);
00138   void  histoEfficiency(TH1F *readHisto, MonitorElement *writeHisto);
00139   double lineParametrization(double z1Position, double z2Position, double z1Direction){
00140     double parameterLine = (z2Position-z1Position)/z1Direction;
00141     return parameterLine;
00142   }
00143   double extrapolate1D(double initPosition, double initDirection, double parameterOfTheLine){
00144     double extrapolatedPosition = initPosition + initDirection*parameterOfTheLine;
00145     return extrapolatedPosition; 
00146   }
00147   bool withinSensitiveRegion(LocalPoint localPos, const std::vector<float> layerBounds,
00148                              int station, int ring, float shiftFromEdge, float shiftFromDeadZone);
00149 
00150   // for BX monitor plots
00151   void harvestChamberMeans(MonitorElement* meMean1D, MonitorElement *meMean2D, TH2F *hNum, MonitorElement *meDenom);
00152   void normalize(MonitorElement* me);
00153 
00154   // DQM
00155   DQMStore* dbe;
00156 
00157   // Wire digis
00158   MonitorElement *hWirenGroupsTotal;
00159   std::vector<MonitorElement*> hWireTBin;
00160   std::vector<MonitorElement*> hWireNumber;
00161 
00162   // Strip Digis
00163   MonitorElement *hStripNFired;
00164   std::vector<MonitorElement*> hStripNumber;
00165   std::vector<MonitorElement*> hStripPed;
00166 
00167   // recHits
00168   MonitorElement *hRHnrechits;
00169   std::vector<MonitorElement*> hRHGlobal;
00170   std::vector<MonitorElement*> hRHSumQ;
00171   std::vector<MonitorElement*> hRHTiming;
00172   std::vector<MonitorElement*> hRHTimingAnode;
00173   std::vector<MonitorElement*> hRHRatioQ;
00174   std::vector<MonitorElement*> hRHstpos;
00175   std::vector<MonitorElement*> hRHsterr;
00176 
00177   // Segments
00178   MonitorElement *hSnSegments;
00179   MonitorElement *hSnhitsAll;
00180   std::vector<MonitorElement*> hSnhits;
00181   MonitorElement *hSChiSqAll;
00182   std::vector<MonitorElement*> hSChiSq;
00183   MonitorElement *hSChiSqProbAll;
00184   std::vector<MonitorElement*> hSChiSqProb;
00185   MonitorElement *hSGlobalTheta;
00186   MonitorElement *hSGlobalPhi;
00187   MonitorElement *hSTimeCathode;
00188   MonitorElement *hSTimeCombined;
00189   MonitorElement *hSTimeVsZ;
00190   MonitorElement *hSTimeVsTOF;
00191 
00192   // Resolution
00193   std::vector<MonitorElement*> hSResid;
00194 
00195   // occupancy histos
00196   MonitorElement *hOWires;
00197   MonitorElement *hOWiresAndCLCT;
00198   MonitorElement *hOStrips;
00199   MonitorElement *hOStripsAndWiresAndCLCT;
00200   MonitorElement *hORecHits;
00201   MonitorElement *hOSegments;
00202   MonitorElement *hOWireSerial;
00203   MonitorElement *hOStripSerial;
00204   MonitorElement *hORecHitsSerial;
00205   MonitorElement *hOSegmentsSerial;
00206   MonitorElement *hCSCOccupancy;
00207 
00208   // Efficiency
00209   TH1F *hSSTE;
00210   TH1F *hRHSTE;
00211   MonitorElement *hSEff;
00212   MonitorElement *hRHEff;
00213   TH2F *hSSTE2;
00214   TH2F *hRHSTE2;
00215   TH2F *hStripSTE2;
00216   TH2F *hWireSTE2;
00217   MonitorElement *hSEff2;
00218   MonitorElement *hRHEff2;
00219   MonitorElement *hStripEff2;
00220   MonitorElement *hWireEff2;
00221   MonitorElement *hStripReadoutEff2;
00222   TH2F *hEffDenominator;
00223   MonitorElement *hSensitiveAreaEvt;
00224 
00225   // BX monitor
00226   MonitorElement *hALCTgetBX;
00227   MonitorElement *hALCTgetBXSerial;
00228   MonitorElement *hALCTgetBXChamberMeans;
00229   MonitorElement *hALCTgetBX2DMeans;
00230   MonitorElement *hALCTgetBX2Denominator;
00231   TH2F *hALCTgetBX2DNumerator;
00232 
00233   MonitorElement *hALCTMatch;
00234   MonitorElement *hALCTMatchSerial;
00235   MonitorElement *hALCTMatchChamberMeans;
00236   MonitorElement *hALCTMatch2DMeans;
00237   MonitorElement *hALCTMatch2Denominator;
00238   TH2F *hALCTMatch2DNumerator;
00239   
00240   MonitorElement *hCLCTL1A;
00241   MonitorElement *hCLCTL1ASerial;
00242   MonitorElement *hCLCTL1AChamberMeans;
00243   MonitorElement *hCLCTL1A2DMeans;
00244   MonitorElement *hCLCTL1A2Denominator;
00245   TH2F *hCLCTL1A2DNumerator;
00246 
00247 
00248 };
00249 #endif