CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
EgammaSCCorrectionMaker Class Reference

#include <EgammaSCCorrectionMaker/EgammaSCCorrectionMaker/src/EgammaSCCorrectionMaker.cc>

Inheritance diagram for EgammaSCCorrectionMaker:
edm::stream::EDProducer<>

Public Member Functions

 EgammaSCCorrectionMaker (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~EgammaSCCorrectionMaker () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Attributes

bool applyCrackCorrection_
 
bool applyEnergyCorrection_
 
bool applyLocalContCorrection_
 
std::unique_ptr< EcalClusterFunctionBaseClasscrackCorrectionFunction_
 
std::string crackCorrectorName_
 
std::unique_ptr< EcalClusterFunctionBaseClassenergyCorrectionFunction_
 
std::unique_ptr< EgammaSCEnergyCorrectionAlgoenergyCorrector_
 
std::string energyCorrectorName_
 
double etThresh_
 
std::unique_ptr< EcalClusterFunctionBaseClasslocalContCorrectionFunction_
 
std::string localContCorrectorName_
 
int modeEB_
 
int modeEE_
 
std::string outputCollection_
 
edm::EDGetTokenT< EcalRecHitCollectionrHInputProducer_
 
edm::InputTag rHTag_
 
reco::CaloCluster::AlgoId sCAlgo_
 
edm::EDGetTokenT< reco::SuperClusterCollectionsCInputProducer_
 
double sigmaElectronicNoise_
 

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, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Description: Producer of corrected SuperClusters

Definition at line 37 of file EgammaSCCorrectionMaker.h.

Constructor & Destructor Documentation

EgammaSCCorrectionMaker::EgammaSCCorrectionMaker ( const edm::ParameterSet ps)
explicit

Definition at line 22 of file EgammaSCCorrectionMaker.cc.

References applyCrackCorrection_, applyEnergyCorrection_, applyLocalContCorrection_, crackCorrectionFunction_, crackCorrectorName_, reco::CaloCluster::dynamicHybrid, energyCorrectionFunction_, energyCorrector_, energyCorrectorName_, etThresh_, edm::ParameterSet::existsAs(), timingPdfMaker::get, edm::ParameterSet::getParameter(), reco::CaloCluster::hybrid, reco::CaloCluster::island, localContCorrectionFunction_, localContCorrectorName_, modeEB_, modeEE_, reco::CaloCluster::multi5x5, outputCollection_, rHInputProducer_, rHTag_, sCAlgo_, sCInputProducer_, sigmaElectronicNoise_, AlCaHLTBitMon_QueryRunRegistry::string, and ~EgammaSCCorrectionMaker().

22  {
23  // the input producers
24  rHTag_ = ps.getParameter<edm::InputTag>("recHitProducer");
25  rHInputProducer_ = consumes<EcalRecHitCollection>(rHTag_);
26  sCInputProducer_ = consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("rawSuperClusterProducer"));
27  std::string sCAlgo_str = ps.getParameter<std::string>("superClusterAlgo");
28 
29  // determine which BasicCluster algo we are correcting for
30  //And obtain forrection parameters form cfg file
31  edm::ParameterSet fCorrPset;
32  if (sCAlgo_str == "Hybrid") {
34  fCorrPset = ps.getParameter<edm::ParameterSet>("hyb_fCorrPset");
35  } else if (sCAlgo_str == "Island") {
37  fCorrPset = ps.getParameter<edm::ParameterSet>("isl_fCorrPset");
38  } else if (sCAlgo_str == "DynamicHybrid") {
40  fCorrPset = ps.getParameter<edm::ParameterSet>("dyn_fCorrPset");
41  } else if (sCAlgo_str == "Multi5x5") {
43  fCorrPset = ps.getParameter<edm::ParameterSet>("fix_fCorrPset");
44  } else {
45  edm::LogError("EgammaSCCorrectionMakerError")
46  << "Error! SuperClusterAlgo in config file must be Hybrid or Island: " << sCAlgo_str
47  << " Using Hybrid by default";
49  }
50 
51  // set correction algo parameters
52  applyEnergyCorrection_ = ps.getParameter<bool>("applyEnergyCorrection");
53  applyCrackCorrection_ = ps.getParameter<bool>("applyCrackCorrection");
55  ps.existsAs<bool>("applyLocalContCorrection") ? ps.getParameter<bool>("applyLocalContCorrection") : false;
56 
57  energyCorrectorName_ = ps.getParameter<std::string>("energyCorrectorName");
58  crackCorrectorName_ = ps.existsAs<std::string>("crackCorrectorName")
59  ? ps.getParameter<std::string>("crackCorrectorName")
60  : std::string("EcalClusterCrackCorrection");
61  localContCorrectorName_ = ps.existsAs<std::string>("localContCorrectorName")
62  ? ps.getParameter<std::string>("localContCorrectorName")
63  : std::string("EcalBasicClusterLocalContCorrection");
64 
65  modeEB_ = ps.getParameter<int>("modeEB");
66  modeEE_ = ps.getParameter<int>("modeEE");
67 
68  sigmaElectronicNoise_ = ps.getParameter<double>("sigmaElectronicNoise");
69 
70  etThresh_ = ps.getParameter<double>("etThresh");
71 
72  // set the producer parameters
73  outputCollection_ = ps.getParameter<std::string>("corectedSuperClusterCollection");
74  produces<reco::SuperClusterCollection>(outputCollection_);
75 
76  // instanciate the correction algo object
77  energyCorrector_ = std::make_unique<EgammaSCEnergyCorrectionAlgo>(sigmaElectronicNoise_, sCAlgo_, fCorrPset);
78 
79  // energy correction class
82  //energyCorrectionFunction_ = EcalClusterFunctionFactory::get()->create("EcalClusterEnergyCorrection", ps);
83 
84  if (applyCrackCorrection_)
85  crackCorrectionFunction_ = EcalClusterFunctionFactory::get()->create(crackCorrectorName_, ps);
86 
87  if (applyLocalContCorrection_)
89 }
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:160
edm::EDGetTokenT< EcalRecHitCollection > rHInputProducer_
reco::CaloCluster::AlgoId sCAlgo_
edm::EDGetTokenT< reco::SuperClusterCollection > sCInputProducer_
std::unique_ptr< EcalClusterFunctionBaseClass > energyCorrectionFunction_
std::unique_ptr< EcalClusterFunctionBaseClass > crackCorrectionFunction_
std::unique_ptr< EcalClusterFunctionBaseClass > localContCorrectionFunction_
std::unique_ptr< EgammaSCEnergyCorrectionAlgo > energyCorrector_
EgammaSCCorrectionMaker::~EgammaSCCorrectionMaker ( )
overridedefault

Referenced by EgammaSCCorrectionMaker().

Member Function Documentation

void EgammaSCCorrectionMaker::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 93 of file EgammaSCCorrectionMaker.cc.

References applyCrackCorrection_, applyEnergyCorrection_, applyLocalContCorrection_, crackCorrectionFunction_, DetId::Ecal, EcalBarrel, EcalEndcap, EcalPreshower, reco::CaloCluster::energy(), energyCorrectionFunction_, energyCorrector_, energyCorrectorName_, etThresh_, edm::EventSetup::get(), edm::Event::getByToken(), CaloGeometry::getSubdetectorGeometry(), egammaRechitFilter_cfi::hitCollection, mps_fire::i, edm::InputTag::instance(), localContCorrectionFunction_, modeEB_, modeEE_, eostools::move(), outputCollection_, reco::CaloCluster::position(), edm::Handle< T >::product(), edm::Event::put(), rHInputProducer_, rHTag_, sCAlgo_, sCInputProducer_, funct::sin(), str, and AlCaHLTBitMon_QueryRunRegistry::string.

93  {
94  using namespace edm;
95 
96  // initialize energy correction class
98  energyCorrectionFunction_->init(es);
99 
100  // initialize energy correction class
102  crackCorrectionFunction_->init(es);
103 
104  // initialize containemnt correction class
107 
108  // get the collection geometry:
109  edm::ESHandle<CaloGeometry> geoHandle;
110  es.get<CaloGeometryRecord>().get(geoHandle);
111  const CaloGeometry& geometry = *geoHandle;
112  const CaloSubdetectorGeometry* geometry_p;
113 
114  std::string rHInputCollection = rHTag_.instance();
115  if (rHInputCollection == "EcalRecHitsEB") {
116  geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
117  } else if (rHInputCollection == "EcalRecHitsEE") {
118  geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
119  } else if (rHInputCollection == "EcalRecHitsPS") {
120  geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
121  } else {
122  std::string str =
123  "\n\nSCCorrectionMaker encountered invalied ecalhitcollection type: " + rHInputCollection + ".\n\n";
124  throw(std::runtime_error(str.c_str()));
125  }
126 
127  // Get raw SuperClusters from the event
128  Handle<reco::SuperClusterCollection> pRawSuperClusters;
129  evt.getByToken(sCInputProducer_, pRawSuperClusters);
130 
131  // Get the RecHits from the event
133  evt.getByToken(rHInputProducer_, pRecHits);
134 
135  // Create a pointer to the RecHits and raw SuperClusters
136  const EcalRecHitCollection* hitCollection = pRecHits.product();
137  const reco::SuperClusterCollection* rawClusters = pRawSuperClusters.product();
138 
139  // Define a collection of corrected SuperClusters to put back into the event
140  auto corrClusters = std::make_unique<reco::SuperClusterCollection>();
141 
142  // Loop over raw clusters and make corrected ones
143  reco::SuperClusterCollection::const_iterator aClus;
144  int i = 0;
145  for (aClus = rawClusters->begin(); aClus != rawClusters->end(); aClus++) {
146  reco::SuperCluster enecorrClus, crackcorrClus, localContCorrClus;
147 
148  i++;
149 
151  enecorrClus = energyCorrector_->applyCorrection(*aClus,
152  *hitCollection,
153  sCAlgo_,
154  geometry_p,
157  modeEB_,
158  modeEE_);
159  else
160  enecorrClus = *aClus;
161 
163  crackcorrClus = energyCorrector_->applyCrackCorrection(enecorrClus, crackCorrectionFunction_.get());
164  else
165  crackcorrClus = enecorrClus;
166 
168  localContCorrClus = energyCorrector_->applyLocalContCorrection(crackcorrClus, localContCorrectionFunction_.get());
169  else
170  localContCorrClus = crackcorrClus;
171 
172  if (localContCorrClus.energy() * sin(localContCorrClus.position().theta()) > etThresh_) {
173  corrClusters->push_back(localContCorrClus);
174  }
175  }
176 
177  // Put collection of corrected SuperClusters into the event
178  evt.put(std::move(corrClusters), outputCollection_);
179 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:153
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
edm::EDGetTokenT< EcalRecHitCollection > rHInputProducer_
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
reco::CaloCluster::AlgoId sCAlgo_
edm::EDGetTokenT< reco::SuperClusterCollection > sCInputProducer_
double energy() const
cluster energy
Definition: CaloCluster.h:148
std::unique_ptr< EcalClusterFunctionBaseClass > energyCorrectionFunction_
T const * product() const
Definition: Handle.h:69
std::unique_ptr< EcalClusterFunctionBaseClass > crackCorrectionFunction_
std::unique_ptr< EcalClusterFunctionBaseClass > localContCorrectionFunction_
HLT enums.
T get() const
Definition: EventSetup.h:73
#define str(s)
std::string const & instance() const
Definition: InputTag.h:37
std::unique_ptr< EgammaSCEnergyCorrectionAlgo > energyCorrector_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

bool EgammaSCCorrectionMaker::applyCrackCorrection_
private

Definition at line 53 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

bool EgammaSCCorrectionMaker::applyEnergyCorrection_
private

Definition at line 52 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

bool EgammaSCCorrectionMaker::applyLocalContCorrection_
private

Definition at line 54 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

std::unique_ptr<EcalClusterFunctionBaseClass> EgammaSCCorrectionMaker::crackCorrectionFunction_
private

Definition at line 45 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

std::string EgammaSCCorrectionMaker::crackCorrectorName_
private

Definition at line 57 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker().

std::unique_ptr<EcalClusterFunctionBaseClass> EgammaSCCorrectionMaker::energyCorrectionFunction_
private

Definition at line 44 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

std::unique_ptr<EgammaSCEnergyCorrectionAlgo> EgammaSCCorrectionMaker::energyCorrector_
private

Definition at line 49 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

std::string EgammaSCCorrectionMaker::energyCorrectorName_
private

Definition at line 56 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

double EgammaSCCorrectionMaker::etThresh_
private

Definition at line 65 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

std::unique_ptr<EcalClusterFunctionBaseClass> EgammaSCCorrectionMaker::localContCorrectionFunction_
private

Definition at line 46 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

std::string EgammaSCCorrectionMaker::localContCorrectorName_
private

Definition at line 58 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker().

int EgammaSCCorrectionMaker::modeEB_
private

Definition at line 60 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

int EgammaSCCorrectionMaker::modeEE_
private

Definition at line 61 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

std::string EgammaSCCorrectionMaker::outputCollection_
private

Definition at line 73 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

edm::EDGetTokenT<EcalRecHitCollection> EgammaSCCorrectionMaker::rHInputProducer_
private

Definition at line 68 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

edm::InputTag EgammaSCCorrectionMaker::rHTag_
private

Definition at line 70 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

reco::CaloCluster::AlgoId EgammaSCCorrectionMaker::sCAlgo_
private

Definition at line 72 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

edm::EDGetTokenT<reco::SuperClusterCollection> EgammaSCCorrectionMaker::sCInputProducer_
private

Definition at line 69 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker(), and produce().

double EgammaSCCorrectionMaker::sigmaElectronicNoise_
private

Definition at line 64 of file EgammaSCCorrectionMaker.h.

Referenced by EgammaSCCorrectionMaker().