CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/Validation/GlobalRecHits/interface/GlobalRecHitsProducer.h

Go to the documentation of this file.
00001 #ifndef GlobalRecHitsProducer_h
00002 #define GlobalRecHitsProducer_h
00003 
00015 // framework & common header files
00016 #include "FWCore/Framework/interface/EDProducer.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 
00028 
00029 //#include "DataFormats/Common/interface/Provenance.h"
00030 #include "DataFormats/Provenance/interface/Provenance.h"
00031 #include "FWCore/Framework/interface/MakerMacros.h" 
00032 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00033 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00034 
00035 // ecal calorimeter info
00036 #include "DataFormats/EcalDigi/interface/EBDataFrame.h"
00037 #include "DataFormats/EcalDigi/interface/EEDataFrame.h"
00038 #include "DataFormats/EcalDigi/interface/ESDataFrame.h"
00039 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
00040 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00041 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00042 #include "DataFormats/EcalDetId/interface/ESDetId.h"
00043 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00044 
00045 // hcal calorimeter info
00046 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
00047 #include "DataFormats/HcalDetId/interface/HcalElectronicsId.h"
00048 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00049 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
00050 #include "DataFormats/HcalDigi/interface/HcalQIESample.h"
00051 #include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
00052 #include "CalibFormats/HcalObjects/interface/HcalCoderDb.h"
00053 #include "CalibFormats/HcalObjects/interface/HcalCalibrations.h"
00054 #include "DataFormats/HcalDigi/interface/HBHEDataFrame.h"
00055 #include "DataFormats/HcalDigi/interface/HFDataFrame.h"
00056 #include "DataFormats/HcalDigi/interface/HODataFrame.h"
00057 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00058 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
00059 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00060 #include "CalibFormats/HcalObjects/interface/HcalDbService.h"
00061 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00062 #include "DataFormats/HcalRecHit/interface/HcalSourcePositionData.h"
00063 
00064 // silicon strip info
00065 #include "DataFormats/Common/interface/DetSetVector.h"
00066 #include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
00067 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00068 #include "DataFormats/SiStripDetId/interface/TIBDetId.h"
00069 #include "DataFormats/SiStripDetId/interface/TOBDetId.h"
00070 #include "DataFormats/SiStripDetId/interface/TIDDetId.h"
00071 #include "DataFormats/SiStripDetId/interface/TECDetId.h"
00072 #include "SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h" 
00073 #include "Geometry/CommonTopologies/interface/StripTopology.h"
00074 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
00075 #include "Geometry/TrackerGeometryBuilder/interface/GluedGeomDet.h"
00076 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00077 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00078 #include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h"
00079 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetType.h"
00080 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
00081 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00082 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h" 
00083 #include "DataFormats/SiStripCluster/interface/SiStripClusterCollection.h" 
00084 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2DCollection.h" 
00085 #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2DCollection.h" 
00086 #include "DataFormats/Common/interface/OwnVector.h" 
00087 
00088 // silicon pixel info
00089 #include "DataFormats/SiPixelDigi/interface/PixelDigi.h"
00090 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00091 #include "DataFormats/SiPixelDetId/interface/PXFDetId.h"
00092 #include "DataFormats/SiPixelDetId/interface/PXBDetId.h"
00093 #include "Geometry/CommonTopologies/interface/PixelTopology.h"
00094 #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h"
00095 #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetType.h"
00096 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
00097 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h"
00098 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h"
00099 
00100 // muon DT info
00101 #include "DataFormats/DTDigi/interface/DTDigi.h"
00102 #include "DataFormats/DTDigi/interface/DTDigiCollection.h"
00103 #include "DataFormats/MuonDetId/interface/DTWireId.h"
00104 #include "DataFormats/MuonDetId/interface/DTLayerId.h"
00105 #include "DataFormats/DTRecHit/interface/DTRecHitCollection.h"
00106 #include "Geometry/DTGeometry/interface/DTLayer.h"
00107 #include "Geometry/DTGeometry/interface/DTGeometry.h"
00108 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00109 //#include "Validation/GlobalRecHits/interface/DTHitQualityUtils.h"
00110 #include "Validation/DTRecHits/interface/DTHitQualityUtils.h"
00111 
00112 // muon CSC info
00113 #include "DataFormats/CSCDigi/interface/CSCStripDigi.h"
00114 #include "DataFormats/CSCDigi/interface/CSCStripDigiCollection.h"
00115 #include "DataFormats/CSCDigi/interface/CSCWireDigi.h"
00116 #include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h"
00117 #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
00118 #include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h"
00119 #include "DataFormats/CSCRecHit/interface/CSCRecHit2D.h"
00120 #include "Geometry/CSCGeometry/interface/CSCLayer.h"
00121 
00122 // muon RPC info
00123 #include "Geometry/RPCGeometry/interface/RPCGeometry.h"
00124 #include "DataFormats/RPCDigi/interface/RPCDigiCollection.h"
00125 #include "DataFormats/MuonDetId/interface/RPCDetId.h"
00126 #include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h"
00127 #include "Geometry/RPCGeometry/interface/RPCRoll.h"
00128 
00129 // event info
00130 #include "SimDataFormats/ValidationFormats/interface/PValidationFormats.h"
00131 #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
00132 #include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
00133 #include "SimDataFormats/CaloHit/interface/PCaloHit.h"
00134 #include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
00135 #include "SimDataFormats/TrackingHit/interface/PSimHit.h" 
00136 
00137 // general info 
00138 #include "DataFormats/DetId/interface/DetId.h"
00139 #include "Geometry/CommonDetUnit/interface/GeomDetType.h" 
00140 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h" 
00141 
00142 // helper files
00143 //#include <CLHEP/Vector/LorentzVector.h>
00144 //#include <CLHEP/Units/SystemOfUnits.h>
00145 
00146 #include <iostream>
00147 #include <stdlib.h>
00148 #include <string>
00149 #include <memory>
00150 #include <vector>
00151 #include <map>
00152 #include <math.h>
00153 
00154 #include "TString.h"
00155 
00156 class PGlobalRecHit;
00157 
00158 class GlobalRecHitsProducer : public edm::EDProducer
00159 {
00160 
00161  public:
00162 
00163   typedef std::vector<float> FloatVector;
00164   typedef std::vector<double> DoubleVector;
00165   typedef std::vector<int> IntVector;
00166   typedef std::map<uint32_t,float,std::less<uint32_t> > MapType;
00167 
00168   explicit GlobalRecHitsProducer(const edm::ParameterSet&);
00169   virtual ~GlobalRecHitsProducer();
00170   virtual void beginJob();
00171   virtual void endJob();  
00172   virtual void produce(edm::Event&, const edm::EventSetup&);
00173   
00174  private:
00175 
00176   // production related methods
00177   void fillECal(edm::Event&, const edm::EventSetup&);
00178   void storeECal(PGlobalRecHit&);
00179   void fillHCal(edm::Event&, const edm::EventSetup&);
00180   void storeHCal(PGlobalRecHit&);
00181   void fillTrk(edm::Event&, const edm::EventSetup&);
00182   void storeTrk(PGlobalRecHit&);
00183   void fillMuon(edm::Event&, const edm::EventSetup&);
00184   void storeMuon(PGlobalRecHit&);  
00185 
00186   void clear();
00187 
00188  private:
00189 
00190   //  parameter information
00191   std::string fName;
00192   int verbosity;
00193   int frequency;
00194   std::string label;
00195   bool getAllProvenances;
00196   bool printProvenanceInfo;
00197 
00198   // Electromagnetic info
00199   // ECal info
00200  
00201   FloatVector EBRE; 
00202   FloatVector EBSHE;
00203 
00204   FloatVector EERE; 
00205   FloatVector EESHE;
00206 
00207   FloatVector ESRE; 
00208   FloatVector ESSHE;
00209 
00210   edm::InputTag ECalEBSrc_;
00211   edm::InputTag ECalUncalEBSrc_;
00212   edm::InputTag ECalEESrc_;
00213   edm::InputTag ECalUncalEESrc_;
00214   edm::InputTag ECalESSrc_;
00215 
00216   // HCal info
00217 
00218   FloatVector HBCalREC;
00219   FloatVector HBCalR;
00220   FloatVector HBCalSHE;
00221 
00222   FloatVector HECalREC;
00223   FloatVector HECalR;
00224   FloatVector HECalSHE;
00225 
00226   FloatVector HOCalREC;
00227   FloatVector HOCalR;
00228   FloatVector HOCalSHE;
00229 
00230   FloatVector HFCalREC;
00231   FloatVector HFCalR;
00232   FloatVector HFCalSHE;
00233 
00234   edm::InputTag HCalSrc_;
00235 
00236   // Tracker info
00237   // SiStrip
00238   
00239   FloatVector TIBL1RX, TIBL2RX, TIBL3RX, TIBL4RX;
00240   FloatVector TIBL1RY, TIBL2RY, TIBL3RY, TIBL4RY;
00241   FloatVector TIBL1SX, TIBL2SX, TIBL3SX, TIBL4SX;
00242   FloatVector TIBL1SY, TIBL2SY, TIBL3SY, TIBL4SY;
00243 
00244   FloatVector TOBL1RX, TOBL2RX, TOBL3RX, TOBL4RX;
00245   FloatVector TOBL1RY, TOBL2RY, TOBL3RY, TOBL4RY;
00246   FloatVector TOBL1SX, TOBL2SX, TOBL3SX, TOBL4SX;
00247   FloatVector TOBL1SY, TOBL2SY, TOBL3SY, TOBL4SY;
00248 
00249   FloatVector TIDW1RX, TIDW2RX, TIDW3RX;
00250   FloatVector TIDW1RY, TIDW2RY, TIDW3RY;
00251   FloatVector TIDW1SX, TIDW2SX, TIDW3SX;
00252   FloatVector TIDW1SY, TIDW2SY, TIDW3SY;
00253 
00254   FloatVector TECW1RX, TECW2RX, TECW3RX, TECW4RX, TECW5RX, TECW6RX, TECW7RX,
00255     TECW8RX;
00256   FloatVector TECW1RY, TECW2RY, TECW3RY, TECW4RY, TECW5RY, TECW6RY, TECW7RY,
00257     TECW8RY;
00258   FloatVector TECW1SX, TECW2SX, TECW3SX, TECW4SX, TECW5SX, TECW6SX, TECW7SX,
00259     TECW8SX;
00260   FloatVector TECW1SY, TECW2SY, TECW3SY, TECW4SY, TECW5SY, TECW6SY, TECW7SY,
00261     TECW8SY;
00262 
00263   edm::InputTag SiStripSrc_;
00264 
00265   std::vector<PSimHit> matched;
00266   std::pair<LocalPoint,LocalVector> 
00267     projectHit( const PSimHit& hit,
00268                 const StripGeomDetUnit* stripDet,
00269                 const BoundPlane& plane);
00270   edm::ParameterSet conf_;
00271 
00272   // SiPxl
00273 
00274   FloatVector BRL1RX, BRL2RX, BRL3RX;
00275   FloatVector BRL1RY, BRL2RY, BRL3RY;
00276   FloatVector BRL1SX, BRL2SX, BRL3SX;
00277   FloatVector BRL1SY, BRL2SY, BRL3SY;
00278 
00279   FloatVector FWD1pRX, FWD1nRX, FWD2pRX, FWD2nRX;
00280   FloatVector FWD1pRY, FWD1nRY, FWD2pRY, FWD2nRY;
00281   FloatVector FWD1pSX, FWD1nSX, FWD2pSX, FWD2nSX;
00282   FloatVector FWD1pSY, FWD1nSY, FWD2pSY, FWD2nSY;
00283 
00284   edm::InputTag SiPxlSrc_;
00285 
00286   // Muon info
00287   // DT
00288 
00289   FloatVector DTRHD;
00290   FloatVector DTSHD;
00291 
00292   edm::InputTag MuDTSrc_;
00293   edm::InputTag MuDTSimSrc_;
00294 
00295   // Return a map between DTRecHit1DPair and wireId
00296   std::map<DTWireId, std::vector<DTRecHit1DPair> >
00297     map1DRecHitsPerWire(const DTRecHitCollection* dt1DRecHitPairs);
00298   
00299   // Compute SimHit distance from wire (cm)
00300   float simHitDistFromWire(const DTLayer* layer,
00301                            DTWireId wireId,
00302                            const PSimHit& hit);
00303   
00304   // Find the RecHit closest to the muon SimHit
00305   template  <typename type>
00306     const type* 
00307     findBestRecHit(const DTLayer* layer,
00308                    DTWireId wireId,
00309                    const std::vector<type>& recHits,
00310                    const float simHitDist);
00311   
00312   // Compute the distance from wire (cm) of a hits in a DTRecHit1DPair
00313   float recHitDistFromWire(const DTRecHit1DPair& hitPair, 
00314                            const DTLayer* layer);
00315   // Compute the distance from wire (cm) of a hits in a DTRecHit1D
00316   float recHitDistFromWire(const DTRecHit1D& recHit, const DTLayer* layer);
00317     
00318   // Does the real job
00319   template  <typename type>
00320     int compute(const DTGeometry *dtGeom,
00321                  std::map<DTWireId, std::vector<PSimHit> > simHitsPerWire,
00322                  std::map<DTWireId, std::vector<type> > recHitsPerWire,
00323                  int step);
00324 
00325   // CSC
00326 
00327   FloatVector CSCRHPHI;
00328   FloatVector CSCRHPERP;
00329   FloatVector CSCSHPHI;
00330 
00331   edm::InputTag MuCSCSrc_;
00332 
00333   std::map<int, edm::PSimHitContainer> theMap;
00334   void plotResolution(const PSimHit &simHit, const CSCRecHit2D &recHit,
00335                       const CSCLayer *layer, int chamberType);
00336 
00337   // RPC
00338 
00339   FloatVector RPCRHX;
00340   FloatVector RPCSHX;
00341 
00342   edm::InputTag MuRPCSrc_;
00343   edm::InputTag MuRPCSimSrc_;
00344 
00345   // private statistics information
00346   unsigned int count;
00347 
00348 }; // end class declaration
00349 
00350 #endif
00351 
00352 #ifndef GlobalHitMap
00353 #define GlobalHitMap
00354 
00355 // geometry mapping
00356 static const int dTrk             = 1;
00357 static const int sdPxlBrl         = 1;
00358 static const int sdPxlFwd         = 2;
00359 static const int sdSiTIB          = 3;
00360 static const int sdSiTID          = 4;
00361 static const int sdSiTOB          = 5;
00362 static const int sdSiTEC          = 6;
00363 
00364 static const int dMuon            = 2;
00365 static const int sdMuonDT         = 1;
00366 static const int sdMuonCSC        = 2;
00367 static const int sdMuonRPC        = 3;
00368 static const int sdMuonRPCRgnBrl  = 0;
00369 static const int sdMuonRPCRgnFwdp = 1;
00370 static const int sdMuonRPCRgnFwdn = -1;
00371 
00372 static const int dEcal            = 3;
00373 static const int sdEcalBrl        = 1;
00374 static const int sdEcalFwd        = 2;
00375 static const int sdEcalPS         = 3;
00376 static const int sdEcalTT         = 4;
00377 static const int sdEcalLPnD       = 5;
00378 
00379 static const int dHcal            = 4;
00380 static const int sdHcalEmpty      = 0;
00381 static const int sdHcalBrl        = 1;
00382 static const int sdHcalEC         = 2;
00383 static const int sdHcalOut        = 3;
00384 static const int sdHcalFwd        = 4;
00385 static const int sdHcalTT         = 5;
00386 static const int sdHcalCalib      = 6;
00387 static const int sdHcalCompst     = 7;
00388 
00389 #endif //PGlobalRecHitsProducer_h