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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
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 wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
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::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 41 of file ValueMapTraslator.cc.

Member Typedef Documentation

◆ Map_t

Definition at line 43 of file ValueMapTraslator.cc.

◆ value_t

typedef double ValueMapTraslator::value_t
private

Definition at line 42 of file ValueMapTraslator.cc.

Constructor & Destructor Documentation

◆ ValueMapTraslator()

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

Definition at line 75 of file ValueMapTraslator.cc.

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

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

◆ ~ValueMapTraslator()

ValueMapTraslator::~ValueMapTraslator ( )
override

Definition at line 88 of file ValueMapTraslator.cc.

88  {
89  // do anything here that needs to be done at desctruction time
90  // (e.g. close files, deallocate resources etc.)
91 }

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 158 of file ValueMapTraslator.cc.

158  {
159  //The following says we do not know what parameters are allowed so do no validation
160  // Please change this to state exactly what you do use, even if it is no parameters
162  desc.setUnknown();
163  descriptions.addDefault(desc);
164 }

References edm::ConfigurationDescriptions::addDefault(), and submitPVResolutionJobs::desc.

◆ produce()

void ValueMapTraslator::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

< 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

Implements edm::EDProducer.

Definition at line 98 of file ValueMapTraslator.cc.

98  {
99  using namespace edm;
100  std::vector<value_t> valueVector;
101  auto valueVectorPtr = std::make_unique<Map_t>();
102 
103  //------------------------------
104  Handle<reco::GsfElectronCollection> referenceHandle;
105  Handle<reco::GsfElectronCollection> oldreferenceHandle;
106  Handle<Map_t> inputHandle;
107 
108  iEvent.getByToken(referenceToken_, referenceHandle);
109  iEvent.getByToken(oldreferenceToken_, oldreferenceHandle);
110  iEvent.getByToken(inputToken_, inputHandle);
111 
112  for (Map_t::const_iterator valueMap_itr = inputHandle->begin(); valueMap_itr != inputHandle->end(); valueMap_itr++) {
113  for (unsigned int i = 0; i < valueMap_itr.size(); i++) {
114 #ifdef DEBUG
115  std::cout << valueMap_itr[i] << std::endl;
116 #endif
117  // valueVector.push_back((valueMap_itr[i])); //valueMap_itr-inputHandle->begin()]));
118  }
119  break;
120  }
121 
122 #ifdef DEBUG
123  std::cout << "Size: " << referenceHandle->size() << "\t" << oldreferenceHandle->size() << "\t" << inputHandle->size()
124  << "\t" << valueVector.size() << std::endl;
125 #endif
126  for (reco::GsfElectronCollection::const_iterator electronNew = referenceHandle->begin();
127  electronNew != referenceHandle->end();
128  electronNew++) {
129  for (reco::GsfElectronCollection::const_iterator electron = oldreferenceHandle->begin();
130  electron != oldreferenceHandle->end();
131  electron++) {
132  //if(electronNew->GsfTrackF
133  if (electron->gsfTrack() != electronNew->gsfTrack())
134  continue;
135  //if(fabs(electronNew->eta() - electron->eta())>0.0001) continue;
136  //if(fabs(electronNew->phi() - electron->phi())>0.0001) continue;
137 
138  reco::GsfElectronRef eleRef(oldreferenceHandle, electron - oldreferenceHandle->begin());
139  reco::GsfElectronRef eleRef2(referenceHandle, electronNew - referenceHandle->begin());
140 
141 #ifdef DEBUG
142  std::cout << eleRef->eta() << "\t" << eleRef2->eta() << "\t" << eleRef->phi() << "\t" << eleRef2->phi() << "\t"
143  << eleRef->energy() << "\t" << eleRef2->energy() << "\t" << (eleRef->gsfTrack() == eleRef2->gsfTrack())
144  << "\t" << (eleRef == eleRef2) << "\t" << (*inputHandle)[eleRef] << std::endl;
145 #endif
146  valueVector.push_back((*inputHandle)[eleRef]); //valueMap_itr-inputHandle->begin()]));
147  }
148  }
149  //#endif
150  Map_t::Filler filler(*valueVectorPtr);
151  filler.insert(referenceHandle, valueVector.begin(), valueVector.end());
152  filler.fill();
153 
154  iEvent.put(std::move(valueVectorPtr));
155 }

References gather_cfg::cout, metsig::electron, trigObjTnPSource_cfi::filler, mps_fire::i, iEvent, inputToken_, eostools::move(), oldreferenceToken_, and referenceToken_.

Member Data Documentation

◆ inputCollectionTAG

edm::InputTag ValueMapTraslator::inputCollectionTAG
private

Definition at line 56 of file ValueMapTraslator.cc.

Referenced by ValueMapTraslator().

◆ inputToken_

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

Definition at line 61 of file ValueMapTraslator.cc.

Referenced by produce(), and ValueMapTraslator().

◆ oldreferenceCollectionTAG

edm::InputTag ValueMapTraslator::oldreferenceCollectionTAG
private

Definition at line 55 of file ValueMapTraslator.cc.

Referenced by ValueMapTraslator().

◆ oldreferenceToken_

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

Definition at line 60 of file ValueMapTraslator.cc.

Referenced by produce(), and ValueMapTraslator().

◆ outputCollectionName

std::string ValueMapTraslator::outputCollectionName
private

Definition at line 57 of file ValueMapTraslator.cc.

Referenced by ValueMapTraslator().

◆ referenceCollectionTAG

edm::InputTag ValueMapTraslator::referenceCollectionTAG
private

Definition at line 55 of file ValueMapTraslator.cc.

Referenced by ValueMapTraslator().

◆ referenceToken_

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

Definition at line 59 of file ValueMapTraslator.cc.

Referenced by produce(), and ValueMapTraslator().

ValueMapTraslator::referenceCollectionTAG
edm::InputTag referenceCollectionTAG
Definition: ValueMapTraslator.cc:55
mps_fire.i
i
Definition: mps_fire.py:428
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::Handle< reco::GsfElectronCollection >
edm::Ref
Definition: AssociativeIterator.h:58
metsig::electron
Definition: SignAlgoResolutions.h:48
ValueMapTraslator::outputCollectionName
std::string outputCollectionName
Definition: ValueMapTraslator.cc:57
ValueMapTraslator::inputCollectionTAG
edm::InputTag inputCollectionTAG
Definition: ValueMapTraslator.cc:56
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
iEvent
int iEvent
Definition: GenABIO.cc:224
ValueMapTraslator::oldreferenceToken_
edm::EDGetTokenT< reco::GsfElectronCollection > oldreferenceToken_
Definition: ValueMapTraslator.cc:60
ValueMapTraslator::referenceToken_
edm::EDGetTokenT< reco::GsfElectronCollection > referenceToken_
Definition: ValueMapTraslator.cc:59
edm::ValueMap::Filler
helper::Filler< ValueMap< T > > Filler
Definition: ValueMap.h:168
ValueMapTraslator::oldreferenceCollectionTAG
edm::InputTag oldreferenceCollectionTAG
Definition: ValueMapTraslator.cc:55
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
ValueMapTraslator::inputToken_
edm::EDGetTokenT< Map_t > inputToken_
Definition: ValueMapTraslator.cc:61
edm::InputTag
Definition: InputTag.h:15