CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
PhotonGSCrysSimpleFixer Class Reference
Inheritance diagram for PhotonGSCrysSimpleFixer:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) override
 
template<typename T >
void getToken (edm::EDGetTokenT< T > &token, const edm::ParameterSet &pset, const std::string &label)
 
 PhotonGSCrysSimpleFixer (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
virtual ~PhotonGSCrysSimpleFixer ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

edm::EDGetTokenT
< EcalRecHitCollection
ebMultiAndWeightsRecHitsToken_
 
edm::EDGetTokenT
< EcalRecHitCollection
ebMultiRecHitsToken_
 
const reco::Photon::P4type energyTypeForP4_
 
const std::vector< int > energyTypesToFix_
 
const CaloGeometrygeometry_
 
edm::EDGetTokenT
< reco::PhotonCollection
oldPhosToken_
 
const CaloTopologytopology_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 39 of file PhotonGSCrysSimpleFixer.cc.

Constructor & Destructor Documentation

PhotonGSCrysSimpleFixer::PhotonGSCrysSimpleFixer ( const edm::ParameterSet pset)
explicit

Definition at line 76 of file PhotonGSCrysSimpleFixer.cc.

References ebMultiAndWeightsRecHitsToken_, ebMultiRecHitsToken_, getToken(), and oldPhosToken_.

76  :
77  energyTypesToFix_(StringToEnumValue<reco::Photon::P4type>(pset.getParameter<std::vector<std::string> >("energyTypesToFix"))),
78  energyTypeForP4_(static_cast<reco::Photon::P4type>(StringToEnumValue<reco::Photon::P4type>(pset.getParameter<std::string>("energyTypeForP4"))))
79 {
80  getToken(oldPhosToken_,pset,"oldPhos");
81  getToken(ebMultiAndWeightsRecHitsToken_,pset,"ebMultiAndWeightsRecHits");
82  getToken(ebMultiRecHitsToken_,pset,"ebMultiRecHits");
83 
84 
85  produces<reco::PhotonCollection >();
86 }
T getParameter(std::string const &) const
void getToken(edm::EDGetTokenT< T > &token, const edm::ParameterSet &pset, const std::string &label)
const std::vector< int > energyTypesToFix_
edm::EDGetTokenT< reco::PhotonCollection > oldPhosToken_
edm::EDGetTokenT< EcalRecHitCollection > ebMultiAndWeightsRecHitsToken_
const reco::Photon::P4type energyTypeForP4_
edm::EDGetTokenT< EcalRecHitCollection > ebMultiRecHitsToken_
virtual PhotonGSCrysSimpleFixer::~PhotonGSCrysSimpleFixer ( )
inlinevirtual

Definition at line 42 of file PhotonGSCrysSimpleFixer.cc.

42 {}

Member Function Documentation

void PhotonGSCrysSimpleFixer::beginLuminosityBlock ( edm::LuminosityBlock const &  lb,
edm::EventSetup const &  es 
)
overridevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 141 of file PhotonGSCrysSimpleFixer.cc.

References geometry_, edm::EventSetup::get(), edm::ESHandle< class >::product(), and topology_.

142  {
143  edm::ESHandle<CaloGeometry> caloGeom ;
144  edm::ESHandle<CaloTopology> caloTopo ;
145  es.get<CaloGeometryRecord>().get(caloGeom);
146  es.get<CaloTopologyRecord>().get(caloTopo);
147  geometry_ = caloGeom.product();
148  topology_ = caloTopo.product();
149 }
const CaloTopology * topology_
const CaloGeometry * geometry_
T const * product() const
Definition: ESHandle.h:86
template<typename T >
void PhotonGSCrysSimpleFixer::getToken ( edm::EDGetTokenT< T > &  token,
const edm::ParameterSet pset,
const std::string &  label 
)
inline

Definition at line 50 of file PhotonGSCrysSimpleFixer.cc.

References edm::ParameterSet::getParameter(), and diffTwoXMLs::label.

Referenced by PhotonGSCrysSimpleFixer().

50  {
51  token=consumes<T>(pset.getParameter<edm::InputTag>(label));
52  }
T getParameter(std::string const &) const
void PhotonGSCrysSimpleFixer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::stream::EDProducerBase.

Definition at line 88 of file PhotonGSCrysSimpleFixer.cc.

References GainSwitchTools::correctHadem(), ebMultiAndWeightsRecHitsToken_, ebMultiRecHitsToken_, energyTypeForP4_, energyTypesToFix_, reco::Photon::full5x5_setShowerShapeVariables(), reco::Photon::full5x5_showerShapeVariables(), GainSwitchTools::gainSwitchedIdsIn5x5(), geometry_, reco::Photon::getCorrectedEnergy(), reco::Photon::getCorrectedEnergyError(), GainSwitchTools::hasEBGainSwitchIn5x5(), eostools::move(), GainSwitchTools::newRawEnergyNoFracs(), oldPhosToken_, edm::Event::put(), reco::Photon::setCorrectedEnergy(), reco::Photon::setShowerShapeVariables(), reco::Photon::showerShapeVariables(), reco::Photon::superCluster(), and topology_.

89 {
90  auto outPhos = std::make_unique<reco::PhotonCollection>();
91 
92 
93  auto phosHandle = getHandle(iEvent,oldPhosToken_);
94  auto& ebMultiRecHits = *getHandle(iEvent,ebMultiRecHitsToken_);
95  auto& ebMultiAndWeightsRecHits = *getHandle(iEvent,ebMultiAndWeightsRecHitsToken_);
96 
97 
98  for(size_t phoNr=0;phoNr<phosHandle->size();phoNr++){
99  reco::PhotonRef phoRef(phosHandle,phoNr);
100  if(GainSwitchTools::hasEBGainSwitchIn5x5(*phoRef->superCluster(),&ebMultiRecHits,topology_)){
101 
102  reco::Photon newPho(*phoRef);
103 
104  std::vector<DetId> gsIds = GainSwitchTools::gainSwitchedIdsIn5x5(phoRef->superCluster()->seed()->seed(),
105  &ebMultiRecHits,topology_);
106  float newRawEnergy = GainSwitchTools::newRawEnergyNoFracs(*phoRef->superCluster(),gsIds,
107  &ebMultiRecHits,&ebMultiAndWeightsRecHits);
108  float energyCorr = newRawEnergy / phoRef->superCluster()->rawEnergy();
109 
110  reco::Photon::ShowerShape full5x5ShowerShape = GainSwitchTools::redoEcalShowerShape<true>(newPho.full5x5_showerShapeVariables(),newPho.superCluster(),&ebMultiAndWeightsRecHits,topology_,geometry_);
111  reco::Photon::ShowerShape showerShape = GainSwitchTools::redoEcalShowerShape<false>(newPho.showerShapeVariables(),newPho.superCluster(),&ebMultiAndWeightsRecHits,topology_,geometry_);
112 
113 
114  GainSwitchTools::correctHadem(showerShape,energyCorr);
115  GainSwitchTools::correctHadem(full5x5ShowerShape,energyCorr);
116 
117  newPho.full5x5_setShowerShapeVariables(full5x5ShowerShape);
118  newPho.setShowerShapeVariables(showerShape);
119 
120  for(int typeAsInt : energyTypesToFix_){
121  auto type = static_cast<reco::Photon::P4type>(typeAsInt);
122  float oldEnergy = newPho.getCorrectedEnergy(type);
123  float oldEnergyErr = newPho.getCorrectedEnergyError(type);
124  newPho.setCorrectedEnergy(type,oldEnergy*energyCorr,oldEnergyErr*energyCorr,false);
125  }
126 
127  //now we set the P4 of the object as appropriate
128  newPho.setCorrectedEnergy(energyTypeForP4_,newPho.getCorrectedEnergy(energyTypeForP4_),
129  newPho.getCorrectedEnergyError(energyTypeForP4_),true);
130 
131 
132  outPhos->push_back(newPho);
133  }else{
134  outPhos->push_back(*phoRef);
135  }
136  }
137 
138  iEvent.put(std::move(outPhos));
139 }
type
Definition: HCALResponse.h:21
const CaloTopology * topology_
const CaloGeometry * geometry_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
const std::vector< int > energyTypesToFix_
def move
Definition: eostools.py:510
edm::EDGetTokenT< reco::PhotonCollection > oldPhosToken_
static void correctHadem(reco::GsfElectron::ShowerShape &showerShape, float eNewOverEOld, const GainSwitchTools::ShowerShapeType ssType)
static float newRawEnergyNoFracs(const reco::SuperCluster &superClus, const std::vector< DetId > gainSwitchedHitIds, const EcalRecHitCollection *oldRecHits, const EcalRecHitCollection *newRecHits)
static std::vector< DetId > gainSwitchedIdsIn5x5(const DetId &id, const EcalRecHitCollection *recHits, const CaloTopology *topology)
edm::EDGetTokenT< EcalRecHitCollection > ebMultiAndWeightsRecHitsToken_
const reco::Photon::P4type energyTypeForP4_
static bool hasEBGainSwitchIn5x5(const reco::SuperCluster &superClus, const EcalRecHitCollection *recHits, const CaloTopology *topology)
edm::EDGetTokenT< EcalRecHitCollection > ebMultiRecHitsToken_

Member Data Documentation

edm::EDGetTokenT<EcalRecHitCollection> PhotonGSCrysSimpleFixer::ebMultiAndWeightsRecHitsToken_
private

Definition at line 55 of file PhotonGSCrysSimpleFixer.cc.

Referenced by PhotonGSCrysSimpleFixer(), and produce().

edm::EDGetTokenT<EcalRecHitCollection> PhotonGSCrysSimpleFixer::ebMultiRecHitsToken_
private

Definition at line 56 of file PhotonGSCrysSimpleFixer.cc.

Referenced by PhotonGSCrysSimpleFixer(), and produce().

const reco::Photon::P4type PhotonGSCrysSimpleFixer::energyTypeForP4_
private

Definition at line 59 of file PhotonGSCrysSimpleFixer.cc.

Referenced by produce().

const std::vector<int> PhotonGSCrysSimpleFixer::energyTypesToFix_
private

Definition at line 58 of file PhotonGSCrysSimpleFixer.cc.

Referenced by produce().

const CaloGeometry* PhotonGSCrysSimpleFixer::geometry_
private

Definition at line 62 of file PhotonGSCrysSimpleFixer.cc.

Referenced by beginLuminosityBlock(), and produce().

edm::EDGetTokenT<reco::PhotonCollection> PhotonGSCrysSimpleFixer::oldPhosToken_
private

Definition at line 54 of file PhotonGSCrysSimpleFixer.cc.

Referenced by PhotonGSCrysSimpleFixer(), and produce().

const CaloTopology* PhotonGSCrysSimpleFixer::topology_
private

Definition at line 61 of file PhotonGSCrysSimpleFixer.cc.

Referenced by beginLuminosityBlock(), and produce().