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 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 ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 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::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Types

typedef edm::ValueMap< value_tMap_t
 
typedef double value_t
 

Private Member Functions

virtual void beginJob ()
 
virtual void beginLuminosityBlock (edm::LuminosityBlock &, edm::EventSetup const &)
 
virtual void beginRun (edm::Run &, edm::EventSetup const &)
 
virtual void endJob ()
 
virtual void endLuminosityBlock (edm::LuminosityBlock &, edm::EventSetup const &)
 
virtual void endRun (edm::Run &, edm::EventSetup const &)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 

Private Attributes

edm::InputTag inputCollectionTAG
 
edm::EDGetTokenT< Map_tinputToken_
 
edm::InputTag oldreferenceCollectionTAG
 
edm::EDGetTokenT
< reco::GsfElectronCollection
oldreferenceToken_
 
std::string outputCollectionName
 
edm::InputTag referenceCollectionTAG
 
edm::EDGetTokenT
< reco::GsfElectronCollection
referenceToken_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 84 of file ValueMapTraslator.cc.

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

84  :
85  referenceCollectionTAG(iConfig.getParameter<edm::InputTag>("referenceCollection")),
86  oldreferenceCollectionTAG(iConfig.getParameter<edm::InputTag>("oldreferenceCollection")),
87  inputCollectionTAG(iConfig.getParameter<edm::InputTag>("inputCollection")),
88  outputCollectionName(iConfig.getParameter<std::string>("outputCollection"))
89 {
90  //now do what ever other initialization is needed
91  referenceToken_ = consumes<reco::GsfElectronCollection>(referenceCollectionTAG);
92  oldreferenceToken_ = consumes<reco::GsfElectronCollection>(oldreferenceCollectionTAG);
93  inputToken_ = consumes< Map_t >(inputCollectionTAG);
95  produces< Map_t >(outputCollectionName);
96 
97 }
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 ( )

Definition at line 100 of file ValueMapTraslator.cc.

101 {
102 
103  // do anything here that needs to be done at desctruction time
104  // (e.g. close files, deallocate resources etc.)
105 
106 }

Member Function Documentation

void ValueMapTraslator::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 182 of file ValueMapTraslator.cc.

183 {
184 }
void ValueMapTraslator::beginLuminosityBlock ( edm::LuminosityBlock ,
edm::EventSetup const &   
)
privatevirtual

Definition at line 205 of file ValueMapTraslator.cc.

206 {
207 }
void ValueMapTraslator::beginRun ( edm::Run ,
edm::EventSetup const &   
)
privatevirtual

Definition at line 193 of file ValueMapTraslator.cc.

194 {
195 }
void ValueMapTraslator::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 188 of file ValueMapTraslator.cc.

188  {
189 }
void ValueMapTraslator::endLuminosityBlock ( edm::LuminosityBlock ,
edm::EventSetup const &   
)
privatevirtual

Definition at line 211 of file ValueMapTraslator.cc.

212 {
213 }
void ValueMapTraslator::endRun ( edm::Run ,
edm::EventSetup const &   
)
privatevirtual

Definition at line 199 of file ValueMapTraslator.cc.

200 {
201 }
void ValueMapTraslator::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 217 of file ValueMapTraslator.cc.

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

217  {
218  //The following says we do not know what parameters are allowed so do no validation
219  // Please change this to state exactly what you do use, even if it is no parameters
221  desc.setUnknown();
222  descriptions.addDefault(desc);
223 }
void addDefault(ParameterSetDescription const &psetDescription)
void ValueMapTraslator::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

< 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 115 of file ValueMapTraslator.cc.

References edm::ValueMap< T >::const_iterator::begin(), gather_cfg::cout, metsig::electron, edm::helper::Filler< Map >::fill(), edm::Event::getByToken(), i, inputToken_, edm::helper::Filler< Map >::insert(), oldreferenceToken_, edm::Event::put(), referenceToken_, and valueVector().

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

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

Member Data Documentation

edm::InputTag ValueMapTraslator::inputCollectionTAG
private

Definition at line 64 of file ValueMapTraslator.cc.

Referenced by ValueMapTraslator().

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

Definition at line 69 of file ValueMapTraslator.cc.

Referenced by produce(), and ValueMapTraslator().

edm::InputTag ValueMapTraslator::oldreferenceCollectionTAG
private

Definition at line 63 of file ValueMapTraslator.cc.

Referenced by ValueMapTraslator().

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

Definition at line 68 of file ValueMapTraslator.cc.

Referenced by produce(), and ValueMapTraslator().

std::string ValueMapTraslator::outputCollectionName
private

Definition at line 65 of file ValueMapTraslator.cc.

Referenced by ValueMapTraslator().

edm::InputTag ValueMapTraslator::referenceCollectionTAG
private

Definition at line 63 of file ValueMapTraslator.cc.

Referenced by ValueMapTraslator().

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

Definition at line 67 of file ValueMapTraslator.cc.

Referenced by produce(), and ValueMapTraslator().