CMS 3D CMS Logo

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

Public Member Functions

 PhotonRegressionValueMapProducer (const edm::ParameterSet &)
 
 ~PhotonRegressionValueMapProducer ()
 
- 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 (const std::string &iProcessName, std::vector< const char * > &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 ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &) override
 
template<typename T >
void writeValueMap (edm::Event &iEvent, const edm::Handle< edm::View< reco::Photon > > &handle, const std::vector< T > &values, const std::string &label) const
 

Private Attributes

edm::EDGetTokenT
< EcalRecHitCollection
ebReducedRecHitCollection_
 
edm::EDGetTokenT
< EcalRecHitCollection
ebReducedRecHitCollectionMiniAOD_
 
edm::EDGetTokenT
< EcalRecHitCollection
eeReducedRecHitCollection_
 
edm::EDGetTokenT
< EcalRecHitCollection
eeReducedRecHitCollectionMiniAOD_
 
edm::EDGetTokenT
< EcalRecHitCollection
esReducedRecHitCollection_
 
edm::EDGetTokenT
< EcalRecHitCollection
esReducedRecHitCollectionMiniAOD_
 
std::unique_ptr
< EcalClusterLazyToolsBase
lazyTools
 
edm::EDGetToken src_
 
edm::EDGetToken srcMiniAOD_
 
const bool use_full5x5_
 

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
 
- 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 88 of file PhotonRegressionValueMapProducer.cc.

Constructor & Destructor Documentation

PhotonRegressionValueMapProducer::PhotonRegressionValueMapProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 125 of file PhotonRegressionValueMapProducer.cc.

References ebReducedRecHitCollection_, ebReducedRecHitCollectionMiniAOD_, eeReducedRecHitCollection_, eeReducedRecHitCollectionMiniAOD_, esReducedRecHitCollection_, esReducedRecHitCollectionMiniAOD_, edm::ParameterSet::getParameter(), mergeVDriftHistosByStation::name, src_, srcMiniAOD_, and AlCaHLTBitMon_QueryRunRegistry::string.

125  :
126  use_full5x5_(iConfig.getParameter<bool>("useFull5x5")) {
127 
128  //
129  // Declare consummables, handle both AOD and miniAOD case
130  //
131  ebReducedRecHitCollection_ = mayConsume<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>
132  ("ebReducedRecHitCollection"));
133  ebReducedRecHitCollectionMiniAOD_ = mayConsume<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>
134  ("ebReducedRecHitCollectionMiniAOD"));
135 
136  eeReducedRecHitCollection_ = mayConsume<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>
137  ("eeReducedRecHitCollection"));
138  eeReducedRecHitCollectionMiniAOD_ = mayConsume<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>
139  ("eeReducedRecHitCollectionMiniAOD"));
140 
141  esReducedRecHitCollection_ = mayConsume<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>
142  ("esReducedRecHitCollection"));
143  esReducedRecHitCollectionMiniAOD_ = mayConsume<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>
144  ("esReducedRecHitCollectionMiniAOD"));
145 
146  // reco photons are castable into pat photons, so no need to handle reco/pat seprately
147  src_ = mayConsume<edm::View<reco::Photon> >(iConfig.getParameter<edm::InputTag>("src"));
148  srcMiniAOD_ = mayConsume<edm::View<reco::Photon> >(iConfig.getParameter<edm::InputTag>("srcMiniAOD"));
149 
150  //
151  // Declare producibles
152  //
153  // Cluster shapes
154  for( const std::string& name : float_var_names ) {
155  produces<edm::ValueMap<float> >(name);
156  }
157 
158  for( const std::string& name : integer_var_names ) {
159  produces<edm::ValueMap<int> >(name);
160  }
161 }
T getParameter(std::string const &) const
edm::EDGetTokenT< EcalRecHitCollection > ebReducedRecHitCollectionMiniAOD_
edm::EDGetTokenT< EcalRecHitCollection > esReducedRecHitCollectionMiniAOD_
edm::EDGetTokenT< EcalRecHitCollection > eeReducedRecHitCollection_
edm::EDGetTokenT< EcalRecHitCollection > ebReducedRecHitCollection_
edm::EDGetTokenT< EcalRecHitCollection > esReducedRecHitCollection_
edm::EDGetTokenT< EcalRecHitCollection > eeReducedRecHitCollectionMiniAOD_
PhotonRegressionValueMapProducer::~PhotonRegressionValueMapProducer ( )

Definition at line 163 of file PhotonRegressionValueMapProducer.cc.

164 {}

Member Function Documentation

void PhotonRegressionValueMapProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 282 of file PhotonRegressionValueMapProducer.cc.

References edm::ConfigurationDescriptions::addDefault(), and edm::ParameterSetDescription::setUnknown().

282  {
283  //The following says we do not know what parameters are allowed so do no validation
284  // Please change this to state exactly what you do use, even if it is no parameters
286  desc.setUnknown();
287  descriptions.addDefault(desc);
288 }
void addDefault(ParameterSetDescription const &psetDescription)
void PhotonRegressionValueMapProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::stream::EDProducerBase.

Definition at line 166 of file PhotonRegressionValueMapProducer.cc.

References ebReducedRecHitCollection_, ebReducedRecHitCollectionMiniAOD_, eeReducedRecHitCollection_, eeReducedRecHitCollectionMiniAOD_, esReducedRecHitCollection_, esReducedRecHitCollectionMiniAOD_, Exception, edm::Event::getByToken(), i, iEvent, lazyTools, alcazmumu_cfi::src, src_, srcMiniAOD_, run_regression::test, use_full5x5_, and writeValueMap().

166  {
167 
168  using namespace edm;
169 
171 
172  bool isAOD = true;
173  iEvent.getByToken(src_, src);
174  if(!src.isValid() ){
175  isAOD = false;
176  iEvent.getByToken(srcMiniAOD_, src);
177  }
178 
179  if( !src.isValid() ) {
180  throw cms::Exception("IllDefinedDataTier")
181  << "DataFormat does not contain a photon source!";
182  }
183 
184  // configure lazy tools
186 
187  if( isAOD ) {
191  } else {
195  }
196 
197  if( use_full5x5_ ) {
198  lazyTools = std::make_unique<noZS::EcalClusterLazyTools>( iEvent, iSetup,
199  ebrh, eerh, esrh );
200  } else {
201  lazyTools = std::make_unique<EcalClusterLazyTools>( iEvent, iSetup,
202  ebrh, eerh, esrh );
203  }
204 
205  if( !isAOD && src->size() ) {
206  edm::Ptr<pat::Photon> test(src->ptrAt(0));
207  if( test.isNull() || !test.isAvailable() ) {
208  throw cms::Exception("InvalidConfiguration")
209  <<"DataFormat is detected as miniAOD but cannot cast to pat::Photon!";
210  }
211  }
212 
213  std::vector<std::vector<float> > float_vars(k_NFloatVars);
214  std::vector<std::vector<int> > int_vars(k_NIntVars);
215 
216  std::unordered_map<std::string,float> float_vars_map;
217  std::unordered_map<std::string,int> int_vars_map;
218 
219  // reco::Photon::superCluster() is virtual so we can exploit polymorphism
220  for (unsigned idxpho = 0; idxpho < src->size(); ++idxpho) {
221  const auto& iPho = src->ptrAt(idxpho);
222 
223  //
224  // Compute full 5x5 quantities
225  //
226  const auto& theseed = *(iPho->superCluster()->seed());
227 
228  if( use_full5x5_ ) {
229  calculateValues<noZS::EcalClusterLazyTools>(lazyTools.get(),
230  theseed,
231  float_vars_map,
232  int_vars_map);
233  } else {
234  calculateValues<EcalClusterLazyTools>(lazyTools.get(),
235  theseed,
236  float_vars_map,
237  int_vars_map);
238  }
239 
240  check_map(float_vars_map, k_NFloatVars);
241  check_map(int_vars_map, k_NIntVars);
242 
243  for( unsigned i = 0; i < float_vars.size(); ++i ) {
244  float_vars[i].emplace_back(float_vars_map.at(float_var_names[i]));
245  }
246 
247 
248  for( unsigned i = 0; i < int_vars.size(); ++i ) {
249  int_vars[i].emplace_back(int_vars_map.at(integer_var_names[i]));
250  }
251 
252  }
253 
254  for( unsigned i = 0; i < float_vars.size(); ++i ) {
255  writeValueMap(iEvent, src, float_vars[i], float_var_names[i]);
256  }
257 
258  for( unsigned i = 0; i < int_vars.size(); ++i ) {
259  writeValueMap(iEvent, src, int_vars[i], integer_var_names[i]);
260  }
261 
262  lazyTools.reset(nullptr);
263 }
int i
Definition: DBlmapReader.cc:9
std::unique_ptr< EcalClusterLazyToolsBase > lazyTools
edm::EDGetTokenT< EcalRecHitCollection > ebReducedRecHitCollectionMiniAOD_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
edm::EDGetTokenT< EcalRecHitCollection > esReducedRecHitCollectionMiniAOD_
edm::EDGetTokenT< EcalRecHitCollection > eeReducedRecHitCollection_
edm::EDGetTokenT< EcalRecHitCollection > ebReducedRecHitCollection_
int iEvent
Definition: GenABIO.cc:230
void writeValueMap(edm::Event &iEvent, const edm::Handle< edm::View< reco::Photon > > &handle, const std::vector< T > &values, const std::string &label) const
edm::EDGetTokenT< EcalRecHitCollection > esReducedRecHitCollection_
edm::EDGetTokenT< EcalRecHitCollection > eeReducedRecHitCollectionMiniAOD_
template<typename T >
void PhotonRegressionValueMapProducer::writeValueMap ( edm::Event iEvent,
const edm::Handle< edm::View< reco::Photon > > &  handle,
const std::vector< T > &  values,
const std::string &  label 
) const
private

Definition at line 266 of file PhotonRegressionValueMapProducer.cc.

References patZpeak::handle, and edm::Event::put().

Referenced by produce().

270 {
271  using namespace edm;
272  using namespace std;
273  typedef ValueMap<T> TValueMap;
274 
275  auto_ptr<TValueMap> valMap(new TValueMap());
276  typename TValueMap::Filler filler(*valMap);
277  filler.insert(handle, values.begin(), values.end());
278  filler.fill();
279  iEvent.put(valMap, label);
280 }
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:115

Member Data Documentation

edm::EDGetTokenT<EcalRecHitCollection> PhotonRegressionValueMapProducer::ebReducedRecHitCollection_
private
edm::EDGetTokenT<EcalRecHitCollection> PhotonRegressionValueMapProducer::ebReducedRecHitCollectionMiniAOD_
private
edm::EDGetTokenT<EcalRecHitCollection> PhotonRegressionValueMapProducer::eeReducedRecHitCollection_
private
edm::EDGetTokenT<EcalRecHitCollection> PhotonRegressionValueMapProducer::eeReducedRecHitCollectionMiniAOD_
private
edm::EDGetTokenT<EcalRecHitCollection> PhotonRegressionValueMapProducer::esReducedRecHitCollection_
private
edm::EDGetTokenT<EcalRecHitCollection> PhotonRegressionValueMapProducer::esReducedRecHitCollectionMiniAOD_
private
std::unique_ptr<EcalClusterLazyToolsBase> PhotonRegressionValueMapProducer::lazyTools
private

Definition at line 108 of file PhotonRegressionValueMapProducer.cc.

Referenced by produce().

edm::EDGetToken PhotonRegressionValueMapProducer::src_
private
edm::EDGetToken PhotonRegressionValueMapProducer::srcMiniAOD_
private
const bool PhotonRegressionValueMapProducer::use_full5x5_
private

Definition at line 122 of file PhotonRegressionValueMapProducer.cc.

Referenced by produce().