CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/Validation/GlobalRecHits/interface/GlobalRecHitsAnalyzer.h

Go to the documentation of this file.
00001 #ifndef GlobalRecHitsAnalyzer_h
00002 #define GlobalRecHitsAnalyzer_h
00003 
00015 // framework & common header files
00016 #include "FWCore/Framework/interface/EDAnalyzer.h"
00017 #include "FWCore/Framework/interface/Frameworkfwd.h"
00018 #include "FWCore/Framework/interface/Event.h"
00019 #include "FWCore/Framework/interface/EventSetup.h"
00020 #include "DataFormats/Common/interface/Handle.h"
00021 #include "FWCore/Framework/interface/ESHandle.h"
00022 
00023 //DQM services
00024 #include "DQMServices/Core/interface/DQMStore.h"
00025 #include "FWCore/ServiceRegistry/interface/Service.h"
00026 
00027 #include "DataFormats/Provenance/interface/Provenance.h"
00028 #include "FWCore/Framework/interface/MakerMacros.h" 
00029 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00030 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00031 
00032 // ecal calorimeter info
00033 #include "DataFormats/EcalDigi/interface/EBDataFrame.h"
00034 #include "DataFormats/EcalDigi/interface/EEDataFrame.h"
00035 #include "DataFormats/EcalDigi/interface/ESDataFrame.h"
00036 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
00037 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00038 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00039 #include "DataFormats/EcalDetId/interface/ESDetId.h"
00040 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00041 
00042 // hcal calorimeter info
00043 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
00044 #include "DataFormats/HcalDetId/interface/HcalElectronicsId.h"
00045 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00046 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
00047 #include "DataFormats/HcalDigi/interface/HcalQIESample.h"
00048 #include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
00049 #include "CalibFormats/HcalObjects/interface/HcalCoderDb.h"
00050 #include "CalibFormats/HcalObjects/interface/HcalCalibrations.h"
00051 #include "DataFormats/HcalDigi/interface/HBHEDataFrame.h"
00052 #include "DataFormats/HcalDigi/interface/HFDataFrame.h"
00053 #include "DataFormats/HcalDigi/interface/HODataFrame.h"
00054 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00055 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
00056 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00057 #include "CalibFormats/HcalObjects/interface/HcalDbService.h"
00058 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00059 #include "DataFormats/HcalRecHit/interface/HcalSourcePositionData.h"
00060 
00061 // silicon strip info
00062 #include "DataFormats/Common/interface/DetSetVector.h"
00063 #include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
00064 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00065 #include "DataFormats/SiStripDetId/interface/TIBDetId.h"
00066 #include "DataFormats/SiStripDetId/interface/TOBDetId.h"
00067 #include "DataFormats/SiStripDetId/interface/TIDDetId.h"
00068 #include "DataFormats/SiStripDetId/interface/TECDetId.h"
00069 #include "SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h" 
00070 #include "Geometry/CommonTopologies/interface/StripTopology.h"
00071 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
00072 #include "Geometry/TrackerGeometryBuilder/interface/GluedGeomDet.h"
00073 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00074 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00075 #include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h"
00076 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetType.h"
00077 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
00078 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00079 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h" 
00080 #include "DataFormats/SiStripCluster/interface/SiStripClusterCollection.h" 
00081 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2DCollection.h" 
00082 #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2DCollection.h" 
00083 #include "DataFormats/Common/interface/OwnVector.h" 
00084 
00085 // silicon pixel info
00086 #include "DataFormats/SiPixelDigi/interface/PixelDigi.h"
00087 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00088 #include "DataFormats/SiPixelDetId/interface/PXFDetId.h"
00089 #include "DataFormats/SiPixelDetId/interface/PXBDetId.h"
00090 #include "Geometry/CommonTopologies/interface/PixelTopology.h"
00091 #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h"
00092 #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetType.h"
00093 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
00094 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h"
00095 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h"
00096 
00097 // muon DT info
00098 #include "DataFormats/DTDigi/interface/DTDigi.h"
00099 #include "DataFormats/DTDigi/interface/DTDigiCollection.h"
00100 #include "DataFormats/MuonDetId/interface/DTWireId.h"
00101 #include "DataFormats/MuonDetId/interface/DTLayerId.h"
00102 #include "DataFormats/DTRecHit/interface/DTRecHitCollection.h"
00103 #include "Geometry/DTGeometry/interface/DTLayer.h"
00104 #include "Geometry/DTGeometry/interface/DTGeometry.h"
00105 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00106 #include "Validation/DTRecHits/interface/DTHitQualityUtils.h"
00107 
00108 // muon CSC info
00109 #include "DataFormats/CSCDigi/interface/CSCStripDigi.h"
00110 #include "DataFormats/CSCDigi/interface/CSCStripDigiCollection.h"
00111 #include "DataFormats/CSCDigi/interface/CSCWireDigi.h"
00112 #include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h"
00113 #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
00114 #include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h"
00115 #include "DataFormats/CSCRecHit/interface/CSCRecHit2D.h"
00116 #include "Geometry/CSCGeometry/interface/CSCLayer.h"
00117 
00118 // muon RPC info
00119 #include "Geometry/RPCGeometry/interface/RPCGeometry.h"
00120 #include "DataFormats/RPCDigi/interface/RPCDigiCollection.h"
00121 #include "DataFormats/MuonDetId/interface/RPCDetId.h"
00122 #include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h"
00123 #include "Geometry/RPCGeometry/interface/RPCRoll.h"
00124 
00125 // event info
00126 #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
00127 #include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
00128 #include "SimDataFormats/CaloHit/interface/PCaloHit.h"
00129 #include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
00130 #include "SimDataFormats/TrackingHit/interface/PSimHit.h" 
00131 
00132 // general info 
00133 #include "DataFormats/DetId/interface/DetId.h"
00134 #include "Geometry/CommonDetUnit/interface/GeomDetType.h" 
00135 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h" 
00136 
00137 #include <iostream>
00138 #include <stdlib.h>
00139 #include <string>
00140 #include <memory>
00141 #include <vector>
00142 #include <map>
00143 #include <math.h>
00144 
00145 #include "TString.h"
00146 #include "DQMServices/Core/interface/MonitorElement.h"
00147 
00148 
00149 class GlobalRecHitsAnalyzer : public edm::EDAnalyzer
00150 {
00151 
00152  public:
00153 
00154   typedef std::map<uint32_t,float,std::less<uint32_t> > MapType;
00155 
00156   explicit GlobalRecHitsAnalyzer(const edm::ParameterSet&);
00157   virtual ~GlobalRecHitsAnalyzer();
00158   virtual void beginJob();
00159   virtual void endJob();  
00160   virtual void analyze(const edm::Event&, const edm::EventSetup&);
00161   
00162  private:
00163 
00164   // production related methods
00165   void fillECal(const edm::Event&, const edm::EventSetup&);
00166   //void storeECal(PGlobalRecHit&);
00167   void fillHCal(const edm::Event&, const edm::EventSetup&);
00168   //void storeHCal(PGlobalRecHit&);
00169   void fillTrk(const edm::Event&, const edm::EventSetup&);
00170   //void storeTrk(PGlobalRecHit&);
00171   void fillMuon(const edm::Event&, const edm::EventSetup&);
00172   //void storeMuon(PGlobalRecHit&);  
00173 
00174   //void clear();
00175 
00176  private:
00177 
00178   //  parameter information
00179   std::string fName;
00180   int verbosity;
00181   int frequency;
00182   std::string label;
00183   bool getAllProvenances;
00184   bool printProvenanceInfo;
00185   std::string hitsProducer;
00186 
00187   DQMStore *dbe;
00188 
00189   // Electromagnetic info
00190   // ECal info
00191  
00192   MonitorElement *mehEcaln[3];
00193   MonitorElement *mehEcalRes[3];
00194 
00195   edm::InputTag ECalEBSrc_;
00196   edm::InputTag ECalUncalEBSrc_;
00197   edm::InputTag ECalEESrc_;
00198   edm::InputTag ECalUncalEESrc_;
00199   edm::InputTag ECalESSrc_;
00200 
00201   // HCal info
00202 
00203   MonitorElement *mehHcaln[4];
00204   MonitorElement *mehHcalRes[4];
00205 
00206   edm::InputTag HCalSrc_;
00207 
00208   // Tracker info
00209   // SiStrip
00210   
00211   MonitorElement *mehSiStripn[19];
00212   MonitorElement *mehSiStripResX[19];
00213   MonitorElement *mehSiStripResY[19];
00214 
00215   edm::InputTag SiStripSrc_;
00216 
00217   std::vector<PSimHit> matched;
00218   std::pair<LocalPoint,LocalVector> 
00219     projectHit( const PSimHit& hit,
00220                 const StripGeomDetUnit* stripDet,
00221                 const BoundPlane& plane);
00222   edm::ParameterSet conf_;
00223 
00224   // SiPxl
00225 
00226   MonitorElement *mehSiPixeln[7];
00227   MonitorElement *mehSiPixelResX[7];
00228   MonitorElement *mehSiPixelResY[7];
00229 
00230   edm::InputTag SiPxlSrc_;
00231 
00232   // Muon info
00233   // DT
00234 
00235   MonitorElement *mehDtMuonn;
00236   MonitorElement *mehCSCn;
00237   MonitorElement *mehRPCn;
00238   MonitorElement *mehDtMuonRes;
00239   MonitorElement *mehCSCResRDPhi;
00240   MonitorElement *mehRPCResX;
00241 
00242   edm::InputTag MuDTSrc_;
00243   edm::InputTag MuDTSimSrc_;
00244 
00245   // Return a map between DTRecHit1DPair and wireId
00246   std::map<DTWireId, std::vector<DTRecHit1DPair> >
00247     map1DRecHitsPerWire(const DTRecHitCollection* dt1DRecHitPairs);
00248   
00249   // Compute SimHit distance from wire (cm)
00250   float simHitDistFromWire(const DTLayer* layer,
00251                            DTWireId wireId,
00252                            const PSimHit& hit);
00253   
00254   // Find the RecHit closest to the muon SimHit
00255   template  <typename type>
00256     const type* 
00257     findBestRecHit(const DTLayer* layer,
00258                    DTWireId wireId,
00259                    const std::vector<type>& recHits,
00260                    const float simHitDist);
00261   
00262   // Compute the distance from wire (cm) of a hits in a DTRecHit1DPair
00263   float recHitDistFromWire(const DTRecHit1DPair& hitPair, 
00264                            const DTLayer* layer);
00265   // Compute the distance from wire (cm) of a hits in a DTRecHit1D
00266   float recHitDistFromWire(const DTRecHit1D& recHit, const DTLayer* layer);
00267     
00268   // Does the real job
00269   template  <typename type>
00270     int compute(const DTGeometry *dtGeom,
00271                  std::map<DTWireId, std::vector<PSimHit> > simHitsPerWire,
00272                  std::map<DTWireId, std::vector<type> > recHitsPerWire,
00273                  int step);
00274 
00275   // CSC
00276   //Defined above....
00277 
00278   edm::InputTag MuCSCSrc_;
00279 
00280   std::map<int, edm::PSimHitContainer> theMap;
00281   void plotResolution(const PSimHit &simHit, const CSCRecHit2D &recHit,
00282                       const CSCLayer *layer, int chamberType);
00283 
00284   // RPC
00285 
00286   //Defined above...
00287 
00288   edm::InputTag MuRPCSrc_;
00289   edm::InputTag MuRPCSimSrc_;
00290 
00291   // private statistics information
00292   unsigned int count;
00293 
00294 }; // end class declaration
00295 
00296 #endif
00297 
00298 #ifndef GlobalHitMap
00299 #define GlobalHitMap
00300 
00301 // geometry mapping
00302 static const int dTrk             = 1;
00303 static const int sdPxlBrl         = 1;
00304 static const int sdPxlFwd         = 2;
00305 static const int sdSiTIB          = 3;
00306 static const int sdSiTID          = 4;
00307 static const int sdSiTOB          = 5;
00308 static const int sdSiTEC          = 6;
00309 
00310 static const int dMuon            = 2;
00311 static const int sdMuonDT         = 1;
00312 static const int sdMuonCSC        = 2;
00313 static const int sdMuonRPC        = 3;
00314 static const int sdMuonRPCRgnBrl  = 0;
00315 static const int sdMuonRPCRgnFwdp = 1;
00316 static const int sdMuonRPCRgnFwdn = -1;
00317 
00318 static const int dEcal            = 3;
00319 static const int sdEcalBrl        = 1;
00320 static const int sdEcalFwd        = 2;
00321 static const int sdEcalPS         = 3;
00322 static const int sdEcalTT         = 4;
00323 static const int sdEcalLPnD       = 5;
00324 
00325 static const int dHcal            = 4;
00326 static const int sdHcalEmpty      = 0;
00327 static const int sdHcalBrl        = 1;
00328 static const int sdHcalEC         = 2;
00329 static const int sdHcalOut        = 3;
00330 static const int sdHcalFwd        = 4;
00331 static const int sdHcalTT         = 5;
00332 static const int sdHcalCalib      = 6;
00333 static const int sdHcalCompst     = 7;
00334 
00335 #endif //PGlobalRecHitsProducer_h