Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-13 03:16:20

0001 #ifndef GlobalRecHitsProducer_h
0002 #define GlobalRecHitsProducer_h
0003 
0004 /** \class GlobalHitsProducer
0005  *  
0006  *  Class to fill PGlobalRecHit object to be inserted into data stream 
0007  *  containing information about various sub-systems in global coordinates 
0008  *  with full geometry
0009  *
0010  *  \author M. Strang SUNY-Buffalo
0011  */
0012 
0013 // framework & common header files
0014 #include "FWCore/Framework/interface/one/EDProducer.h"
0015 #include "FWCore/Framework/interface/Frameworkfwd.h"
0016 #include "FWCore/Framework/interface/Event.h"
0017 #include "FWCore/Framework/interface/EventSetup.h"
0018 #include "DataFormats/Common/interface/Handle.h"
0019 #include "FWCore/Framework/interface/ESHandle.h"
0020 
0021 //DQM services
0022 #include "DQMServices/Core/interface/DQMStore.h"
0023 #include "FWCore/ServiceRegistry/interface/Service.h"
0024 
0025 //#include "DataFormats/Common/interface/Provenance.h"
0026 #include "DataFormats/Provenance/interface/Provenance.h"
0027 #include "FWCore/Framework/interface/MakerMacros.h"
0028 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0029 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0030 
0031 // ecal calorimeter info
0032 #include "DataFormats/EcalDigi/interface/EBDataFrame.h"
0033 #include "DataFormats/EcalDigi/interface/EEDataFrame.h"
0034 #include "DataFormats/EcalDigi/interface/ESDataFrame.h"
0035 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
0036 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0037 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0038 #include "DataFormats/EcalDetId/interface/ESDetId.h"
0039 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
0040 
0041 // hcal calorimeter info
0042 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
0043 #include "DataFormats/HcalDetId/interface/HcalElectronicsId.h"
0044 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0045 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
0046 #include "DataFormats/HcalDigi/interface/HcalQIESample.h"
0047 #include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
0048 #include "CalibFormats/HcalObjects/interface/HcalCoderDb.h"
0049 #include "CalibFormats/HcalObjects/interface/HcalCalibrations.h"
0050 #include "DataFormats/HcalDigi/interface/HBHEDataFrame.h"
0051 #include "DataFormats/HcalDigi/interface/HFDataFrame.h"
0052 #include "DataFormats/HcalDigi/interface/HODataFrame.h"
0053 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0054 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
0055 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0056 #include "CalibFormats/HcalObjects/interface/HcalDbService.h"
0057 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
0058 #include "DataFormats/HcalRecHit/interface/HcalSourcePositionData.h"
0059 
0060 // silicon strip info
0061 #include "DataFormats/Common/interface/DetSetVector.h"
0062 #include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
0063 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0064 #include "SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h"
0065 #include "Geometry/CommonTopologies/interface/StripTopology.h"
0066 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
0067 #include "Geometry/CommonDetUnit/interface/GluedGeomDet.h"
0068 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0069 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0070 #include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h"
0071 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetType.h"
0072 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
0073 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0074 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
0075 #include "DataFormats/SiStripCluster/interface/SiStripClusterCollection.h"
0076 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2DCollection.h"
0077 #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2DCollection.h"
0078 #include "DataFormats/Common/interface/OwnVector.h"
0079 
0080 // silicon pixel info
0081 #include "DataFormats/SiPixelDigi/interface/PixelDigi.h"
0082 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
0083 #include "Geometry/CommonTopologies/interface/PixelTopology.h"
0084 #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
0085 #include "Geometry/CommonDetUnit/interface/PixelGeomDetType.h"
0086 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
0087 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h"
0088 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h"
0089 
0090 // muon DT info
0091 #include "DataFormats/DTDigi/interface/DTDigi.h"
0092 #include "DataFormats/DTDigi/interface/DTDigiCollection.h"
0093 #include "DataFormats/MuonDetId/interface/DTWireId.h"
0094 #include "DataFormats/MuonDetId/interface/DTLayerId.h"
0095 #include "DataFormats/DTRecHit/interface/DTRecHitCollection.h"
0096 #include "Geometry/DTGeometry/interface/DTLayer.h"
0097 #include "Geometry/DTGeometry/interface/DTGeometry.h"
0098 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0099 //#include "Validation/GlobalRecHits/interface/DTHitQualityUtils.h"
0100 #include "Validation/DTRecHits/interface/DTHitQualityUtils.h"
0101 
0102 // muon CSC info
0103 #include "DataFormats/CSCDigi/interface/CSCStripDigi.h"
0104 #include "DataFormats/CSCDigi/interface/CSCStripDigiCollection.h"
0105 #include "DataFormats/CSCDigi/interface/CSCWireDigi.h"
0106 #include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h"
0107 #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
0108 #include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h"
0109 #include "DataFormats/CSCRecHit/interface/CSCRecHit2D.h"
0110 #include "Geometry/CSCGeometry/interface/CSCLayer.h"
0111 
0112 // muon RPC info
0113 #include "Geometry/RPCGeometry/interface/RPCGeometry.h"
0114 #include "DataFormats/RPCDigi/interface/RPCDigiCollection.h"
0115 #include "DataFormats/MuonDetId/interface/RPCDetId.h"
0116 #include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h"
0117 #include "Geometry/RPCGeometry/interface/RPCRoll.h"
0118 
0119 // event info
0120 #include "SimDataFormats/ValidationFormats/interface/PValidationFormats.h"
0121 #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
0122 #include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
0123 #include "SimDataFormats/CaloHit/interface/PCaloHit.h"
0124 #include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
0125 #include "SimDataFormats/TrackingHit/interface/PSimHit.h"
0126 
0127 // general info
0128 #include "DataFormats/DetId/interface/DetId.h"
0129 #include "Geometry/CommonDetUnit/interface/GeomDetType.h"
0130 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
0131 
0132 // helper files
0133 //#include <CLHEP/Vector/LorentzVector.h>
0134 //#include <CLHEP/Units/SystemOfUnits.h>
0135 
0136 #include <iostream>
0137 #include <cstdlib>
0138 #include <string>
0139 #include <memory>
0140 #include <vector>
0141 #include <map>
0142 #include <cmath>
0143 
0144 #include "TString.h"
0145 
0146 class PGlobalRecHit;
0147 class CaloGeometryRecord;
0148 class TrackerTopology;
0149 class GlobalRecHitsProducer : public edm::one::EDProducer<> {
0150 public:
0151   typedef std::vector<float> FloatVector;
0152   typedef std::vector<double> DoubleVector;
0153   typedef std::vector<int> IntVector;
0154   typedef std::map<uint32_t, float, std::less<uint32_t>> MapType;
0155 
0156   explicit GlobalRecHitsProducer(const edm::ParameterSet&);
0157   ~GlobalRecHitsProducer() override;
0158   void beginJob() override;
0159   void endJob() override;
0160   void produce(edm::Event&, const edm::EventSetup&) override;
0161 
0162 private:
0163   // production related methods
0164   void fillECal(edm::Event&, const edm::EventSetup&);
0165   void storeECal(PGlobalRecHit&);
0166   void fillHCal(edm::Event&, const edm::EventSetup&);
0167   void storeHCal(PGlobalRecHit&);
0168   void fillTrk(edm::Event&, const edm::EventSetup&);
0169   void storeTrk(PGlobalRecHit&);
0170   void fillMuon(edm::Event&, const edm::EventSetup&);
0171   void storeMuon(PGlobalRecHit&);
0172 
0173   void clear();
0174 
0175 private:
0176   //  parameter information
0177   std::string fName;
0178   int verbosity;
0179   int frequency;
0180   std::string label;
0181   bool getAllProvenances;
0182   bool printProvenanceInfo;
0183 
0184   // Electromagnetic info
0185   // ECal info
0186 
0187   FloatVector EBRE;
0188   FloatVector EBSHE;
0189 
0190   FloatVector EERE;
0191   FloatVector EESHE;
0192 
0193   FloatVector ESRE;
0194   FloatVector ESSHE;
0195 
0196   edm::InputTag ECalEBSrc_;
0197   edm::InputTag ECalUncalEBSrc_;
0198   edm::InputTag ECalEESrc_;
0199   edm::InputTag ECalUncalEESrc_;
0200   edm::InputTag ECalESSrc_;
0201   edm::EDGetTokenT<EBRecHitCollection> ECalEBSrc_Token_;
0202   edm::EDGetTokenT<EERecHitCollection> ECalEESrc_Token_;
0203   edm::EDGetTokenT<ESRecHitCollection> ECalESSrc_Token_;
0204   edm::EDGetTokenT<EBUncalibratedRecHitCollection> ECalUncalEBSrc_Token_;
0205   edm::EDGetTokenT<EEUncalibratedRecHitCollection> ECalUncalEESrc_Token_;
0206   edm::EDGetTokenT<CrossingFrame<PCaloHit>> EBHits_Token_;
0207   edm::EDGetTokenT<CrossingFrame<PCaloHit>> EEHits_Token_;
0208   edm::EDGetTokenT<CrossingFrame<PCaloHit>> ESHits_Token_;
0209 
0210   // HCal info
0211 
0212   FloatVector HBCalREC;
0213   FloatVector HBCalR;
0214   FloatVector HBCalSHE;
0215 
0216   FloatVector HECalREC;
0217   FloatVector HECalR;
0218   FloatVector HECalSHE;
0219 
0220   FloatVector HOCalREC;
0221   FloatVector HOCalR;
0222   FloatVector HOCalSHE;
0223 
0224   FloatVector HFCalREC;
0225   FloatVector HFCalR;
0226   FloatVector HFCalSHE;
0227 
0228   edm::InputTag HCalSrc_;
0229   edm::EDGetTokenT<edm::PCaloHitContainer> HCalSrc_Token_;
0230 
0231   // Tracker info
0232   // SiStrip
0233 
0234   FloatVector TIBL1RX, TIBL2RX, TIBL3RX, TIBL4RX;
0235   FloatVector TIBL1RY, TIBL2RY, TIBL3RY, TIBL4RY;
0236   FloatVector TIBL1SX, TIBL2SX, TIBL3SX, TIBL4SX;
0237   FloatVector TIBL1SY, TIBL2SY, TIBL3SY, TIBL4SY;
0238 
0239   FloatVector TOBL1RX, TOBL2RX, TOBL3RX, TOBL4RX;
0240   FloatVector TOBL1RY, TOBL2RY, TOBL3RY, TOBL4RY;
0241   FloatVector TOBL1SX, TOBL2SX, TOBL3SX, TOBL4SX;
0242   FloatVector TOBL1SY, TOBL2SY, TOBL3SY, TOBL4SY;
0243 
0244   FloatVector TIDW1RX, TIDW2RX, TIDW3RX;
0245   FloatVector TIDW1RY, TIDW2RY, TIDW3RY;
0246   FloatVector TIDW1SX, TIDW2SX, TIDW3SX;
0247   FloatVector TIDW1SY, TIDW2SY, TIDW3SY;
0248 
0249   FloatVector TECW1RX, TECW2RX, TECW3RX, TECW4RX, TECW5RX, TECW6RX, TECW7RX, TECW8RX;
0250   FloatVector TECW1RY, TECW2RY, TECW3RY, TECW4RY, TECW5RY, TECW6RY, TECW7RY, TECW8RY;
0251   FloatVector TECW1SX, TECW2SX, TECW3SX, TECW4SX, TECW5SX, TECW6SX, TECW7SX, TECW8SX;
0252   FloatVector TECW1SY, TECW2SY, TECW3SY, TECW4SY, TECW5SY, TECW6SY, TECW7SY, TECW8SY;
0253 
0254   edm::InputTag SiStripSrc_;
0255   edm::EDGetTokenT<SiStripMatchedRecHit2DCollection> SiStripSrc_Token_;
0256 
0257   std::vector<PSimHit> matched;
0258   std::pair<LocalPoint, LocalVector> projectHit(const PSimHit& hit,
0259                                                 const StripGeomDetUnit* stripDet,
0260                                                 const BoundPlane& plane);
0261   TrackerHitAssociator::Config trackerHitAssociatorConfig_;
0262 
0263   // SiPxl
0264 
0265   FloatVector BRL1RX, BRL2RX, BRL3RX;
0266   FloatVector BRL1RY, BRL2RY, BRL3RY;
0267   FloatVector BRL1SX, BRL2SX, BRL3SX;
0268   FloatVector BRL1SY, BRL2SY, BRL3SY;
0269 
0270   FloatVector FWD1pRX, FWD1nRX, FWD2pRX, FWD2nRX;
0271   FloatVector FWD1pRY, FWD1nRY, FWD2pRY, FWD2nRY;
0272   FloatVector FWD1pSX, FWD1nSX, FWD2pSX, FWD2nSX;
0273   FloatVector FWD1pSY, FWD1nSY, FWD2pSY, FWD2nSY;
0274 
0275   edm::InputTag SiPxlSrc_;
0276   edm::EDGetTokenT<SiPixelRecHitCollection> SiPxlSrc_Token_;
0277 
0278   // Muon info
0279   // DT
0280 
0281   FloatVector DTRHD;
0282   FloatVector DTSHD;
0283 
0284   edm::InputTag MuDTSrc_;
0285   edm::InputTag MuDTSimSrc_;
0286   edm::EDGetTokenT<DTRecHitCollection> MuDTSrc_Token_;
0287   edm::EDGetTokenT<edm::PSimHitContainer> MuDTSimSrc_Token_;
0288 
0289   // Return a map between DTRecHit1DPair and wireId
0290   std::map<DTWireId, std::vector<DTRecHit1DPair>> map1DRecHitsPerWire(const DTRecHitCollection* dt1DRecHitPairs);
0291 
0292   // Compute SimHit distance from wire (cm)
0293   float simHitDistFromWire(const DTLayer* layer, DTWireId wireId, const PSimHit& hit);
0294 
0295   // Find the RecHit closest to the muon SimHit
0296   template <typename type>
0297   const type* findBestRecHit(const DTLayer* layer,
0298                              DTWireId wireId,
0299                              const std::vector<type>& recHits,
0300                              const float simHitDist);
0301 
0302   // Compute the distance from wire (cm) of a hits in a DTRecHit1DPair
0303   float recHitDistFromWire(const DTRecHit1DPair& hitPair, const DTLayer* layer);
0304   // Compute the distance from wire (cm) of a hits in a DTRecHit1D
0305   float recHitDistFromWire(const DTRecHit1D& recHit, const DTLayer* layer);
0306 
0307   // Does the real job
0308   template <typename type>
0309   int compute(const DTGeometry* dtGeom,
0310               const std::map<DTWireId, std::vector<PSimHit>>& simHitsPerWire,
0311               const std::map<DTWireId, std::vector<type>>& recHitsPerWire,
0312               int step);
0313 
0314   // CSC
0315 
0316   FloatVector CSCRHPHI;
0317   FloatVector CSCRHPERP;
0318   FloatVector CSCSHPHI;
0319 
0320   edm::InputTag MuCSCSrc_;
0321   edm::EDGetTokenT<CSCRecHit2DCollection> MuCSCSrc_Token_;
0322   edm::EDGetTokenT<CrossingFrame<PSimHit>> MuCSCHits_Token_;
0323 
0324   std::map<int, edm::PSimHitContainer> theMap;
0325   void plotResolution(const PSimHit& simHit, const CSCRecHit2D& recHit, const CSCLayer* layer, int chamberType);
0326 
0327   // RPC
0328 
0329   FloatVector RPCRHX;
0330   FloatVector RPCSHX;
0331 
0332   edm::InputTag MuRPCSrc_;
0333   edm::InputTag MuRPCSimSrc_;
0334   edm::EDGetTokenT<RPCRecHitCollection> MuRPCSrc_Token_;
0335   edm::EDGetTokenT<edm::PSimHitContainer> MuRPCSimSrc_Token_;
0336 
0337   edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeomToken_;
0338   edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoToken_;
0339   edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> tGeomToken_;
0340   edm::ESGetToken<DTGeometry, MuonGeometryRecord> dtGeomToken_;
0341   edm::ESGetToken<CSCGeometry, MuonGeometryRecord> cscGeomToken_;
0342   edm::ESGetToken<RPCGeometry, MuonGeometryRecord> rpcGeomToken_;
0343 
0344   // private statistics information
0345   unsigned int count;
0346 
0347 };  // end class declaration
0348 
0349 #endif
0350 
0351 #ifndef GlobalHitMap
0352 #define GlobalHitMap
0353 
0354 // geometry mapping
0355 static const int dTrk = 1;
0356 static const int sdPxlBrl = 1;
0357 static const int sdPxlFwd = 2;
0358 static const int sdSiTIB = 3;
0359 static const int sdSiTID = 4;
0360 static const int sdSiTOB = 5;
0361 static const int sdSiTEC = 6;
0362 
0363 static const int dMuon = 2;
0364 static const int sdMuonDT = 1;
0365 static const int sdMuonCSC = 2;
0366 static const int sdMuonRPC = 3;
0367 static const int sdMuonRPCRgnBrl = 0;
0368 static const int sdMuonRPCRgnFwdp = 1;
0369 static const int sdMuonRPCRgnFwdn = -1;
0370 
0371 static const int dEcal = 3;
0372 static const int sdEcalBrl = 1;
0373 static const int sdEcalFwd = 2;
0374 static const int sdEcalPS = 3;
0375 static const int sdEcalTT = 4;
0376 static const int sdEcalLPnD = 5;
0377 
0378 static const int dHcal = 4;
0379 static const int sdHcalEmpty = 0;
0380 static const int sdHcalBrl = 1;
0381 static const int sdHcalEC = 2;
0382 static const int sdHcalOut = 3;
0383 static const int sdHcalFwd = 4;
0384 static const int sdHcalTT = 5;
0385 static const int sdHcalCalib = 6;
0386 static const int sdHcalCompst = 7;
0387 
0388 #endif  //PGlobalRecHitsProducer_h