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

Constructor & Destructor Documentation

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

Definition at line 97 of file PhotonRegressionValueMapProducer.cc.

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

97  :
98  use_full5x5_(iConfig.getParameter<bool>("useFull5x5")) {
99 
100  //
101  // Declare consummables, handle both AOD and miniAOD case
102  //
103  ebReducedRecHitCollection_ = mayConsume<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>
104  ("ebReducedRecHitCollection"));
105  ebReducedRecHitCollectionMiniAOD_ = mayConsume<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>
106  ("ebReducedRecHitCollectionMiniAOD"));
107 
108  eeReducedRecHitCollection_ = mayConsume<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>
109  ("eeReducedRecHitCollection"));
110  eeReducedRecHitCollectionMiniAOD_ = mayConsume<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>
111  ("eeReducedRecHitCollectionMiniAOD"));
112 
113  esReducedRecHitCollection_ = mayConsume<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>
114  ("esReducedRecHitCollection"));
115  esReducedRecHitCollectionMiniAOD_ = mayConsume<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>
116  ("esReducedRecHitCollectionMiniAOD"));
117 
118  // reco photons are castable into pat photons, so no need to handle reco/pat seprately
119  src_ = mayConsume<edm::View<reco::Photon> >(iConfig.getParameter<edm::InputTag>("src"));
120  srcMiniAOD_ = mayConsume<edm::View<reco::Photon> >(iConfig.getParameter<edm::InputTag>("srcMiniAOD"));
121 
122  //
123  // Declare producibles
124  //
125  // Cluster shapes
126  for( const std::string& name : float_var_names ) {
127  produces<edm::ValueMap<float> >(name);
128  }
129 
130  for( const std::string& name : integer_var_names ) {
131  produces<edm::ValueMap<int> >(name);
132  }
133 }
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 135 of file PhotonRegressionValueMapProducer.cc.

136 {}

Member Function Documentation

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

Definition at line 254 of file PhotonRegressionValueMapProducer.cc.

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

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

Implements edm::stream::EDProducerBase.

Definition at line 138 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().

138  {
139 
140  using namespace edm;
141 
143 
144  bool isAOD = true;
145  iEvent.getByToken(src_, src);
146  if(!src.isValid() ){
147  isAOD = false;
148  iEvent.getByToken(srcMiniAOD_, src);
149  }
150 
151  if( !src.isValid() ) {
152  throw cms::Exception("IllDefinedDataTier")
153  << "DataFormat does not contain a photon source!";
154  }
155 
156  // configure lazy tools
158 
159  if( isAOD ) {
163  } else {
167  }
168 
169  if( use_full5x5_ ) {
170  lazyTools = std::make_unique<noZS::EcalClusterLazyTools>( iEvent, iSetup,
171  ebrh, eerh, esrh );
172  } else {
173  lazyTools = std::make_unique<EcalClusterLazyTools>( iEvent, iSetup,
174  ebrh, eerh, esrh );
175  }
176 
177  if( !isAOD && src->size() ) {
178  edm::Ptr<pat::Photon> test(src->ptrAt(0));
179  if( test.isNull() || !test.isAvailable() ) {
180  throw cms::Exception("InvalidConfiguration")
181  <<"DataFormat is detected as miniAOD but cannot cast to pat::Photon!";
182  }
183  }
184 
185  std::vector<std::vector<float> > float_vars(k_NFloatVars);
186  std::vector<std::vector<int> > int_vars(k_NIntVars);
187 
188  std::unordered_map<std::string,float> float_vars_map;
189  std::unordered_map<std::string,int> int_vars_map;
190 
191  // reco::Photon::superCluster() is virtual so we can exploit polymorphism
192  for (unsigned idxpho = 0; idxpho < src->size(); ++idxpho) {
193  const auto& iPho = src->ptrAt(idxpho);
194 
195  //
196  // Compute full 5x5 quantities
197  //
198  const auto& theseed = *(iPho->superCluster()->seed());
199 
200  if( use_full5x5_ ) {
201  calculateValues<noZS::EcalClusterLazyTools>(lazyTools.get(),
202  theseed,
203  float_vars_map,
204  int_vars_map);
205  } else {
206  calculateValues<EcalClusterLazyTools>(lazyTools.get(),
207  theseed,
208  float_vars_map,
209  int_vars_map);
210  }
211 
212  check_map(float_vars_map, k_NFloatVars);
213  check_map(int_vars_map, k_NIntVars);
214 
215  for( unsigned i = 0; i < float_vars.size(); ++i ) {
216  float_vars[i].emplace_back(float_vars_map.at(float_var_names[i]));
217  }
218 
219 
220  for( unsigned i = 0; i < int_vars.size(); ++i ) {
221  int_vars[i].emplace_back(int_vars_map.at(integer_var_names[i]));
222  }
223 
224  }
225 
226  for( unsigned i = 0; i < float_vars.size(); ++i ) {
227  writeValueMap(iEvent, src, float_vars[i], float_var_names[i]);
228  }
229 
230  for( unsigned i = 0; i < int_vars.size(); ++i ) {
231  writeValueMap(iEvent, src, int_vars[i], integer_var_names[i]);
232  }
233 
234  lazyTools.reset(nullptr);
235 }
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:464
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 238 of file PhotonRegressionValueMapProducer.cc.

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

Referenced by produce().

242 {
243  using namespace edm;
244  using namespace std;
245  typedef ValueMap<T> TValueMap;
246 
247  auto_ptr<TValueMap> valMap(new TValueMap());
248  typename TValueMap::Filler filler(*valMap);
249  filler.insert(handle, values.begin(), values.end());
250  filler.fill();
251  iEvent.put(valMap, label);
252 }
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120

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

Referenced by produce().