Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-03 22:27:55

0001 #ifndef Calibration_EcalAlCaRecoProducers_SelectedElectronFEDListProducer_h
0002 #define Calibration_EcalAlCaRecoProducers_SelectedElectronFEDListProducer_h
0003 
0004 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0005 // egamma objects
0006 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
0007 
0008 #include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"
0009 // Geometry
0010 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0011 #include "Geometry/EcalMapping/interface/EcalMappingRcd.h"
0012 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0013 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0014 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0015 // strip geometry
0016 #include "CalibFormats/SiStripObjects/interface/SiStripRegionCabling.h"
0017 #include "CalibTracker/Records/interface/SiStripDetCablingRcd.h"
0018 #include "CalibTracker/Records/interface/SiStripRegionCablingRcd.h"
0019 // Strip and pixel
0020 #include "CondFormats/DataRecord/interface/SiPixelFedCablingMapRcd.h"
0021 #include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h"
0022 // Hcal objects
0023 #include "CalibFormats/HcalObjects/interface/HcalDbService.h"
0024 #include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
0025 
0026 // Math
0027 #include "DataFormats/Math/interface/normalizedPhi.h"
0028 
0029 #include "FWCore/Framework/interface/stream/EDProducer.h"
0030 #include "FWCore/Framework/interface/EventSetup.h"
0031 // Message logger
0032 #include "FWCore/ServiceRegistry/interface/Service.h"
0033 
0034 class InputTag;
0035 
0036 class FEDRawDataCollection;
0037 
0038 class SiPixelFedCablingTree;
0039 class SiStripFedCabling;
0040 
0041 class CaloSubdetectorGeometry;
0042 class HcalElectronicsMap;
0043 
0044 // Hcal rec hit: this is a Fwd file defining typedefs
0045 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
0046 
0047 // Pixel region class
0048 class PixelRegion {
0049 public:
0050   PixelRegion(math::XYZVector& momentum, float dphi = 0.5, float deta = 0.5, float maxz = 24.0) {
0051     vector = momentum;
0052     dPhi = dphi;
0053     dEta = deta;
0054     maxZ = maxz;
0055     cosphi = vector.x() / vector.rho();
0056     sinphi = vector.y() / vector.rho();
0057     atantheta = vector.z() / vector.rho();
0058   }
0059 
0060   math::XYZVector vector;
0061   float dPhi, dEta, maxZ;
0062   float cosphi, sinphi, atantheta;
0063 };
0064 
0065 // Pixel module class
0066 class PixelModule {
0067 public:
0068   PixelModule() {}
0069   PixelModule(float phi, float eta) : Phi(phi), Eta(eta), x(0.), y(0.), z(0.), DetId(0), Fed(0) {}
0070   bool operator<(const PixelModule& m) const {
0071     if (Phi < m.Phi)
0072       return true;
0073     if (Phi == m.Phi && Eta < m.Eta)
0074       return true;
0075     if (Phi == m.Phi && Eta == m.Eta && DetId < m.DetId)
0076       return true;
0077     return false;
0078   }
0079 
0080   float Phi, Eta;
0081   float x, y, z;
0082   unsigned int DetId;
0083   unsigned int Fed;
0084 };
0085 
0086 // main class
0087 template <typename TEle, typename TCand>
0088 class SelectedElectronFEDListProducer : public edm::stream::EDProducer<> {
0089 public:
0090   explicit SelectedElectronFEDListProducer(const edm::ParameterSet&);
0091   ~SelectedElectronFEDListProducer() override;
0092 
0093   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0094 
0095 protected:
0096   virtual void beginJob();
0097   virtual void endJob();
0098   void produce(edm::Event&, const edm::EventSetup&) override;
0099 
0100 private:
0101   typedef std::vector<TEle> TEleColl;
0102   typedef std::vector<TCand> TCandColl;
0103 
0104 public:
0105   void pixelFedDump(std::vector<PixelModule>::const_iterator& itDn,
0106                     std::vector<PixelModule>::const_iterator& itUp,
0107                     const PixelRegion& region);
0108 
0109 private:
0110   // input parameter of the producer
0111   std::vector<edm::InputTag> recoEcalCandidateTags_;
0112   std::vector<edm::InputTag> electronTags_;
0113   edm::InputTag beamSpotTag_;
0114   edm::InputTag rawDataTag_;
0115 
0116   edm::InputTag HBHERecHitTag_;
0117 
0118   std::vector<int> isGsfElectronCollection_;
0119   std::vector<int> addThisSelectedFEDs_;
0120 
0121   edm::FileInPath ESLookupTable_;
0122 
0123   bool dumpSelectedEcalFed_;
0124   bool dumpSelectedSiStripFed_;
0125   bool dumpSelectedSiPixelFed_;
0126   bool dumpSelectedHCALFed_;
0127   bool dumpAllEcalFed_;
0128   bool dumpAllTrackerFed_;
0129   bool dumpAllHCALFed_;
0130 
0131   double dRStripRegion_;
0132   double dPhiPixelRegion_;
0133   double dEtaPixelRegion_;
0134   double maxZPixelRegion_;
0135   double dRHcalRegion_;
0136 
0137   std::string outputLabelModule_;
0138 
0139   // Token for the input collection
0140   edm::EDGetTokenT<FEDRawDataCollection> rawDataToken_;
0141   edm::EDGetTokenT<reco::BeamSpot> beamSpotToken_;
0142   edm::EDGetTokenT<HBHERecHitCollection> hbheRecHitToken_;
0143   std::vector<edm::EDGetTokenT<trigger::TriggerFilterObjectWithRefs> > recoEcalCandidateToken_;
0144   std::vector<edm::EDGetTokenT<TEleColl> > electronToken_;
0145 
0146   // Token for the input collection
0147   const edm::ESGetToken<HcalDbService, HcalDbRecord> hcalDbToken_;
0148   const edm::ESGetToken<EcalElectronicsMapping, EcalMappingRcd> ecalMappingToken_;
0149   const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeometryToken_;
0150   const edm::ESGetToken<SiPixelFedCablingMap, SiPixelFedCablingMapRcd> siPixelFedCablingMapToken_;
0151   const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> trackerGeometryToken_;
0152   const edm::ESGetToken<SiStripRegionCabling, SiStripRegionCablingRcd> siStripRegionCablingToken_;
0153 
0154   // used inside the producer
0155   math::XYZVector beamSpotPosition_;
0156 
0157   // internal info for ES geometry
0158   int ES_fedId_[2][2][40][40];
0159 
0160   // fed list and output raw data
0161   std::vector<uint32_t> fedList_;
0162 
0163   // get calo geomentry and electronic map
0164   const EcalElectronicsMapping* EcalMapping_;
0165   const CaloGeometry* GeometryCalo_;
0166   const CaloSubdetectorGeometry* GeometryES_;
0167   const SiStripRegionCabling* StripRegionCabling_;
0168   const HcalElectronicsMap* HcalReadoutMap_;
0169 
0170   // get pixel geometry and electronic map
0171   std::unique_ptr<SiPixelFedCablingTree> PixelCabling_;
0172   std::vector<PixelModule> pixelModuleVector_;
0173 
0174   // get strip geometry and electronic map
0175   std::pair<double, double> regionDimension_;
0176 };
0177 
0178 #endif  // SelectedElectronFEDListProducer_h