CMS 3D CMS Logo

CSCValidation.h

Go to the documentation of this file.
00001 #ifndef RecoLocalMuon_CSCValidation_H
00002 #define RecoLocalMuon_CSCValidation_H
00003 
00019 // user include files
00020 #include "FWCore/Framework/interface/MakerMacros.h"
00021 #include "FWCore/Framework/interface/Frameworkfwd.h"
00022 #include "FWCore/Framework/interface/EDAnalyzer.h"
00023 #include "FWCore/Framework/interface/EDFilter.h"
00024 #include "FWCore/Framework/interface/Event.h"
00025 #include "DataFormats/Common/interface/Handle.h"
00026 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00027 #include "FWCore/Framework/interface/EventSetup.h"
00028 #include "FWCore/Framework/interface/ESHandle.h"
00029 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00030 
00031 #include "DataFormats/CSCDigi/interface/CSCWireDigi.h"
00032 #include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h"
00033 #include "DataFormats/CSCDigi/interface/CSCStripDigi.h"
00034 #include "DataFormats/CSCDigi/interface/CSCStripDigiCollection.h"
00035 #include "DataFormats/CSCDigi/interface/CSCComparatorDigi.h"
00036 #include "DataFormats/CSCDigi/interface/CSCComparatorDigiCollection.h"
00037 
00038 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
00039 #include <DataFormats/CSCRecHit/interface/CSCRecHit2D.h>
00040 #include <DataFormats/CSCRecHit/interface/CSCSegmentCollection.h>
00041 
00042 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutRecord.h"
00043 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutCollection.h"
00044 
00045 #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
00046 #include "Geometry/CSCGeometry/interface/CSCChamber.h"
00047 #include "Geometry/CSCGeometry/interface/CSCLayer.h"
00048 #include "Geometry/CSCGeometry/interface/CSCLayerGeometry.h"
00049 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00050 
00051 #include "DataFormats/TrackReco/interface/Track.h"
00052 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00053 #include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
00054 #include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
00055 
00056 #include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h"
00057 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
00058 
00059 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00060 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
00061 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
00062 #include "DataFormats/GeometryVector/interface/LocalVector.h"
00063 #include "DataFormats/CLHEP/interface/AlgebraicObjects.h"
00064 #include "DataFormats/MuonDetId/interface/CSCIndexer.h"
00065 
00066 #include "CondFormats/CSCObjects/interface/CSCDBGains.h"
00067 #include "CondFormats/DataRecord/interface/CSCDBGainsRcd.h"
00068 #include "CondFormats/CSCObjects/interface/CSCDBNoiseMatrix.h"
00069 #include "CondFormats/DataRecord/interface/CSCDBNoiseMatrixRcd.h"
00070 #include "CondFormats/CSCObjects/interface/CSCDBCrosstalk.h"
00071 #include "CondFormats/DataRecord/interface/CSCDBCrosstalkRcd.h"
00072 #include "CondFormats/CSCObjects/interface/CSCDBPedestals.h"
00073 #include "CondFormats/DataRecord/interface/CSCDBPedestalsRcd.h"
00074 
00075 #include "CommonTools/Statistics/interface/ChiSquaredProbability.h"
00076 
00077 #include "RecoLocalMuon/CSCValidation/src/CSCValHists.h"
00078 #include "TVector3.h"
00079 #include "TH1F.h"
00080 #include "TH2F.h"
00081 #include "TFile.h"
00082 #include "TString.h"
00083 #include "TTree.h"
00084 #include "TProfile2D.h"
00085 
00086 class CSCValidation : public edm::EDAnalyzer {
00087 public:
00089   CSCValidation(const edm::ParameterSet& pset);
00090 
00092   virtual ~CSCValidation();
00093 
00095   void analyze(const edm::Event & event, const edm::EventSetup& eventSetup);
00096   void endJob();
00097 
00098   // for noise module
00099   struct ltrh
00100   {
00101     bool operator()(const CSCRecHit2D rh1, const CSCRecHit2D rh2) const
00102     {
00103       return ((rh1.localPosition()).x()-(rh2.localPosition()).x()) < 0;
00104     }
00105   };
00106 
00107 
00108 protected:
00109 
00110 private: 
00111 
00112   // these are the "modules"
00113   // if you would like to add code to CSCValidation, please do so by adding an
00114   // extra module in the form of an additional private member function
00115   void  doOccupancies(edm::Handle<CSCStripDigiCollection> strips, edm::Handle<CSCWireDigiCollection> wires,
00116                       edm::Handle<CSCRecHit2DCollection> recHits, edm::Handle<CSCSegmentCollection> cscSegments);
00117   void  doStripDigis(edm::Handle<CSCStripDigiCollection> strips);
00118   void  doWireDigis(edm::Handle<CSCWireDigiCollection> wires);
00119   void  doRecHits(edm::Handle<CSCRecHit2DCollection> recHits,edm::Handle<CSCStripDigiCollection> strips,
00120                   edm::ESHandle<CSCGeometry> cscGeom);
00121   void  doSimHits(edm::Handle<CSCRecHit2DCollection> recHits, edm::Handle<edm::PSimHitContainer> simHits);
00122   void  doPedestalNoise(edm::Handle<CSCStripDigiCollection> strips);
00123   void  doSegments(edm::Handle<CSCSegmentCollection> cscSegments, edm::ESHandle<CSCGeometry> cscGeom);
00124   void  doEfficiencies(edm::Handle<CSCWireDigiCollection> wires, edm::Handle<CSCStripDigiCollection> strips,
00125                        edm::Handle<CSCRecHit2DCollection> recHits, edm::Handle<CSCSegmentCollection> cscSegments,
00126                        edm::ESHandle<CSCGeometry> cscGeom);
00127   void  doGasGain(const CSCWireDigiCollection &, const CSCStripDigiCollection &, const CSCRecHit2DCollection &);
00128   void  doCalibrations(const edm::EventSetup& eventSetup);
00129   void  doAFEBTiming(const CSCWireDigiCollection &);
00130   void  doCompTiming(const CSCComparatorDigiCollection &);
00131   void  doADCTiming(const CSCStripDigiCollection &, const CSCRecHit2DCollection  &);
00132   void  doNoiseHits(edm::Handle<CSCRecHit2DCollection> recHits, edm::Handle<CSCSegmentCollection> cscSegments,
00133                     edm::ESHandle<CSCGeometry> cscGeom,  edm::Handle<CSCStripDigiCollection> strips);
00134   bool  doTrigger(edm::Handle<L1MuGMTReadoutCollection> pCollection);
00135   void  doStandalone(edm::Handle<reco::TrackCollection> saMuons);
00136 
00137   // some useful functions
00138   float  fitX(HepMatrix sp, HepMatrix ep);
00139   float  getTiming(const CSCStripDigiCollection& stripdigis, CSCDetId idRH, int centerStrip);
00140   float  getSignal(const CSCStripDigiCollection& stripdigis, CSCDetId idRH, int centerStrip);
00141   float  getthisSignal(const CSCStripDigiCollection& stripdigis, CSCDetId idRH, int centerStrip);
00142   int    getWidth(const CSCStripDigiCollection& stripdigis, CSCDetId idRH, int centerStrip);
00143   void   findNonAssociatedRecHits(edm::ESHandle<CSCGeometry> cscGeom,  edm::Handle<CSCStripDigiCollection> strips);
00144   int    chamberSerial( CSCDetId id );
00145 
00146   // these functions handle Stoyan's efficiency code
00147   void  fillEfficiencyHistos(int bin, int flag);
00148   void  getEfficiency(float bin, float Norm, std::vector<float> &eff);
00149   void  histoEfficiency(TH1F *readHisto, TH1F *writeHisto);
00150   double lineParametrization(double z1Position, double z2Position, double z1Direction){
00151     double parameterLine = (z2Position-z1Position)/z1Direction;
00152     return parameterLine;
00153   }
00154   double extrapolate1D(double initPosition, double initDirection, double parameterOfTheLine){
00155     double extrapolatedPosition = initPosition + initDirection*parameterOfTheLine;
00156     return extrapolatedPosition; 
00157   }
00158   bool withinSensitiveRegion(LocalPoint localPos, const std::vector<float> layerBounds, int station, int ring, float shiftFromEdge, float shiftFromDeadZone);
00159 
00160 
00161   // counters
00162   int nEventsAnalyzed;
00163   int rhTreeCount;
00164   int segTreeCount;
00165 
00166   //
00167   //
00168   // The root file for the histograms.
00169   TFile *theFile;
00170 
00171   //
00172   //
00173   // input parameters for this module
00174   bool makePlots;
00175   bool makeComparisonPlots;
00176   std::string refRootFile;
00177   bool writeTreeToFile;
00178   bool isSimulation;
00179   std::string rootFileName;
00180   bool detailedAnalysis;
00181   bool useDigis;
00182   bool useTrigger;
00183 
00184   edm::InputTag stripDigiTag;
00185   edm::InputTag wireDigiTag;
00186   edm::InputTag compDigiTag;
00187   edm::InputTag cscRecHitTag;
00188   edm::InputTag cscSegTag;
00189   edm::InputTag saMuonTag;
00190   edm::InputTag l1aTag;
00191   edm::InputTag simHitTag;
00192 
00193   bool makeOccupancyPlots;
00194   bool makeStripPlots;
00195   bool makeWirePlots;
00196   bool makeRecHitPlots;
00197   bool makeSimHitPlots;
00198   bool makeSegmentPlots;
00199   bool makePedNoisePlots;
00200   bool makeEfficiencyPlots;
00201   bool makeGasGainPlots;
00202   bool makeAFEBTimingPlots;
00203   bool makeCompTimingPlots;
00204   bool makeADCTimingPlots;
00205   bool makeRHNoisePlots;
00206   bool makeCalibPlots;
00207   bool makeStandalonePlots;
00208   bool makeTriggerPlots;
00209 
00210   // The histo managing object
00211   CSCValHists *histos;
00212 
00213   // tmp histos for Efficiency
00214   TH1F *hSSTE;
00215   TH1F *hRHSTE;
00216   TH1F *hSEff;
00217   TH1F *hRHEff;
00218   TH2F *hSSTE2;
00219   TH2F *hRHSTE2;
00220   TH2F *hStripSTE2;
00221   TH2F *hWireSTE2;
00222   TH2F *hSEff2;
00223   TH2F *hRHEff2;
00224   TH2F *hStripEff2;
00225   TH2F *hWireEff2;
00226   TH2F *hEffDenominator;
00227   TH2F *hSensitiveAreaEvt;
00228 
00229   // occupancy
00230   TH2I *hOWires;
00231   TH2I *hOStrips;
00232   TH2I *hORecHits;
00233   TH2I *hOSegments;
00234 
00236   std::vector<int>     nmbhvsegm;
00237   std::map<int, std::vector<int> >   m_wire_hvsegm;
00238   std::map<int, int>   m_single_wire_layer;
00239 
00240   //maps to store the DetId and associated RecHits  
00241   std::multimap<CSCDetId , CSCRecHit2D> AllRechits;
00242   std::multimap<CSCDetId , CSCRecHit2D> SegRechits;
00243   std::multimap<CSCDetId , CSCRecHit2D> NonAssociatedRechits;
00244   std::map<CSCRecHit2D,float,ltrh> distRHmap;
00245 
00246   int typeIndex(CSCDetId id){
00247     // linearlized index bases on endcap, station, and ring
00248     int index = 0;
00249     if (id.station() == 1){
00250       index = id.ring() + 1;
00251       if (id.ring() == 4) index = 1;
00252     }
00253     else index = id.station()*2 + id.ring();
00254     if (id.endcap() == 1) index = index + 10;
00255     if (id.endcap() == 2) index = 11 - index;
00256     return index;
00257   }
00258   
00259 
00260 
00261 
00262 };
00263 #endif

Generated on Tue Jun 9 17:43:53 2009 for CMSSW by  doxygen 1.5.4