CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
ValueMapTraslator Class Reference

#include <Calibration/ValueMapTraslator/src/ValueMapTraslator.cc>

Inheritance diagram for ValueMapTraslator:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 ValueMapTraslator (const edm::ParameterSet &)
 
 ~ValueMapTraslator () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 

Private Types

typedef edm::ValueMap< value_tMap_t
 
typedef double value_t
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

edm::InputTag inputCollectionTAG
 
edm::EDGetTokenT< Map_tinputToken_
 
edm::InputTag oldreferenceCollectionTAG
 
edm::EDGetTokenT< reco::GsfElectronCollectionoldreferenceToken_
 
std::string outputCollectionName
 
edm::InputTag referenceCollectionTAG
 
edm::EDGetTokenT< reco::GsfElectronCollectionreferenceToken_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
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

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 42 of file ValueMapTraslator.cc.

Member Typedef Documentation

Definition at line 44 of file ValueMapTraslator.cc.

typedef double ValueMapTraslator::value_t
private

Definition at line 43 of file ValueMapTraslator.cc.

Constructor & Destructor Documentation

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

Definition at line 77 of file ValueMapTraslator.cc.

References inputCollectionTAG, inputToken_, oldreferenceCollectionTAG, oldreferenceToken_, outputCollectionName, referenceCollectionTAG, and referenceToken_.

77  :
78  referenceCollectionTAG(iConfig.getParameter<edm::InputTag>("referenceCollection")),
79  oldreferenceCollectionTAG(iConfig.getParameter<edm::InputTag>("oldreferenceCollection")),
80  inputCollectionTAG(iConfig.getParameter<edm::InputTag>("inputCollection")),
81  outputCollectionName(iConfig.getParameter<std::string>("outputCollection"))
82 {
83  //now do what ever other initialization is needed
84  referenceToken_ = consumes<reco::GsfElectronCollection>(referenceCollectionTAG);
85  oldreferenceToken_ = consumes<reco::GsfElectronCollection>(oldreferenceCollectionTAG);
86  inputToken_ = consumes< Map_t >(inputCollectionTAG);
88  produces< Map_t >(outputCollectionName);
89 
90 }
T getParameter(std::string const &) const
std::string outputCollectionName
edm::InputTag inputCollectionTAG
edm::InputTag oldreferenceCollectionTAG
edm::EDGetTokenT< reco::GsfElectronCollection > referenceToken_
edm::EDGetTokenT< reco::GsfElectronCollection > oldreferenceToken_
edm::EDGetTokenT< Map_t > inputToken_
edm::InputTag referenceCollectionTAG
ValueMapTraslator::~ValueMapTraslator ( )
override

Definition at line 93 of file ValueMapTraslator.cc.

94 {
95 
96  // do anything here that needs to be done at desctruction time
97  // (e.g. close files, deallocate resources etc.)
98 
99 }

Member Function Documentation

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

Definition at line 175 of file ValueMapTraslator.cc.

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

175  {
176  //The following says we do not know what parameters are allowed so do no validation
177  // Please change this to state exactly what you do use, even if it is no parameters
179  desc.setUnknown();
180  descriptions.addDefault(desc);
181 }
void addDefault(ParameterSetDescription const &psetDescription)
void ValueMapTraslator::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

< requires that the track is the same, so I'm sure the electron object is the same. This to avoid the case when two electrons have the same eta and phi at the vtx

Definition at line 108 of file ValueMapTraslator.cc.

References gather_cfg::cout, metsig::electron, edm::helper::Filler< Map >::fill(), objects.autophobj::filler, edm::Event::getByToken(), mps_fire::i, inputToken_, edm::helper::Filler< Map >::insert(), eostools::move(), oldreferenceToken_, edm::Event::put(), referenceToken_, and valueVector().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

109 {
110  using namespace edm;
111  std::vector<value_t> valueVector;
112  auto valueVectorPtr = std::make_unique<Map_t>();
113 
114  //------------------------------
116  Handle< reco::GsfElectronCollection > oldreferenceHandle;
117  Handle< Map_t > inputHandle;
118 
119  iEvent.getByToken( referenceToken_, referenceHandle);
120  iEvent.getByToken( oldreferenceToken_, oldreferenceHandle);
121  iEvent.getByToken( inputToken_, inputHandle);
122 
123  for(Map_t::const_iterator valueMap_itr = inputHandle->begin();
124  valueMap_itr != inputHandle->end();
125  valueMap_itr++){
126  for(unsigned int i = 0; i < valueMap_itr.size(); i++){
127 #ifdef DEBUG
128  std::cout << valueMap_itr[i] << std::endl;
129 #endif
130  // valueVector.push_back((valueMap_itr[i])); //valueMap_itr-inputHandle->begin()]));
131  }
132  break;
133  }
134 
135 #ifdef DEBUG
136  std::cout << "Size: " << referenceHandle->size() << "\t" << oldreferenceHandle->size() << "\t" << inputHandle->size() << "\t" << valueVector.size() << std::endl;
137 #endif
138  for(reco::GsfElectronCollection::const_iterator electronNew = referenceHandle->begin();
139  electronNew!= referenceHandle->end();
140  electronNew++){
141 
142  for(reco::GsfElectronCollection::const_iterator electron = oldreferenceHandle->begin();
143  electron!= oldreferenceHandle->end();
144  electron++){
145  //if(electronNew->GsfTrackF
146  if(electron->gsfTrack() != electronNew->gsfTrack()) continue;
147  //if(fabs(electronNew->eta() - electron->eta())>0.0001) continue;
148  //if(fabs(electronNew->phi() - electron->phi())>0.0001) continue;
149 
150  reco::GsfElectronRef eleRef(oldreferenceHandle, electron-oldreferenceHandle->begin());
151  reco::GsfElectronRef eleRef2(referenceHandle, electronNew-referenceHandle->begin());
152 
153 #ifdef DEBUG
154  std::cout << eleRef->eta() << "\t" << eleRef2->eta() << "\t"
155  << eleRef->phi() << "\t" << eleRef2->phi() << "\t"
156  << eleRef->energy() << "\t" << eleRef2->energy() << "\t"
157  << (eleRef->gsfTrack() == eleRef2->gsfTrack()) << "\t"
158  << (eleRef == eleRef2) << "\t"
159  << (*inputHandle)[eleRef] << std::endl;
160 #endif
161  valueVector.push_back((*inputHandle)[eleRef]); //valueMap_itr-inputHandle->begin()]));
162  }
163  }
164  //#endif
165  Map_t::Filler filler(*valueVectorPtr);
166  filler.insert(referenceHandle, valueVector.begin(), valueVector.end());
167  filler.fill();
168 
169  iEvent.put(std::move(valueVectorPtr));
170 
171 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
void valueVector(const std::map< K, V > &extract, std::vector< V > &output)
Definition: Operators.h:43
edm::EDGetTokenT< reco::GsfElectronCollection > referenceToken_
edm::EDGetTokenT< reco::GsfElectronCollection > oldreferenceToken_
helper::Filler< ValueMap< T > > Filler
Definition: ValueMap.h:169
edm::EDGetTokenT< Map_t > inputToken_
HLT enums.
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

edm::InputTag ValueMapTraslator::inputCollectionTAG
private

Definition at line 57 of file ValueMapTraslator.cc.

Referenced by ValueMapTraslator().

edm::EDGetTokenT<Map_t> ValueMapTraslator::inputToken_
private

Definition at line 62 of file ValueMapTraslator.cc.

Referenced by produce(), and ValueMapTraslator().

edm::InputTag ValueMapTraslator::oldreferenceCollectionTAG
private

Definition at line 56 of file ValueMapTraslator.cc.

Referenced by ValueMapTraslator().

edm::EDGetTokenT<reco::GsfElectronCollection> ValueMapTraslator::oldreferenceToken_
private

Definition at line 61 of file ValueMapTraslator.cc.

Referenced by produce(), and ValueMapTraslator().

std::string ValueMapTraslator::outputCollectionName
private

Definition at line 58 of file ValueMapTraslator.cc.

Referenced by ValueMapTraslator().

edm::InputTag ValueMapTraslator::referenceCollectionTAG
private

Definition at line 56 of file ValueMapTraslator.cc.

Referenced by ValueMapTraslator().

edm::EDGetTokenT<reco::GsfElectronCollection> ValueMapTraslator::referenceToken_
private

Definition at line 60 of file ValueMapTraslator.cc.

Referenced by produce(), and ValueMapTraslator().