CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
CentralityBinProducer Class Reference

#include <RecoHI/CentralityBinProducer/src/CentralityBinProducer.cc>

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

Public Member Functions

 CentralityBinProducer (const edm::ParameterSet &)
 
 ~CentralityBinProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- 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 (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &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 ()
 

Private Types

enum  VariableType {
  HFtowers = 0, HFtowersPlus = 1, HFtowersMinus = 2, HFtowersTrunc = 3,
  HFtowersPlusTrunc = 4, HFtowersMinusTrunc = 5, HFhits = 6, PixelHits = 7,
  PixelTracks = 8, Tracks = 9, EB = 10, EE = 11,
  Missing = 12
}
 

Private Member Functions

virtual void beginRun (edm::Run const &run, const edm::EventSetup &iSetup) override
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::string centralityLabel_
 
std::string centralityMC_
 
std::string centralityVariable_
 
edm::Handle< reco::Centralitychandle_
 
edm::ESHandle< CentralityTableinputDB_
 
unsigned int pPbRunFlip_
 
unsigned int prevRun_
 
edm::EDGetTokenT
< reco::Centrality
tag_
 
VariableType varType_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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 47 of file CentralityBinProducer.cc.

Member Enumeration Documentation

Constructor & Destructor Documentation

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

Definition at line 86 of file CentralityBinProducer.cc.

References centralityLabel_, centralityMC_, centralityVariable_, EB, EE, Exception, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), HFhits, HFtowers, HFtowersMinus, HFtowersMinusTrunc, HFtowersPlus, HFtowersPlusTrunc, HFtowersTrunc, Missing, PixelHits, PixelTracks, pPbRunFlip_, AlCaHLTBitMon_QueryRunRegistry::string, tag_, Tracks, and varType_.

86  :
87  prevRun_(0),
89 {
90  using namespace edm;
91  tag_ = consumes<reco::Centrality>(iConfig.getParameter<edm::InputTag>("Centrality"));
92  centralityVariable_ = iConfig.getParameter<std::string>("centralityVariable");
93  pPbRunFlip_ = iConfig.getParameter<unsigned int>("pPbRunFlip");
94 
95  if(centralityVariable_.compare("HFtowers") == 0) varType_ = HFtowers;
96  if(centralityVariable_.compare("HFtowersPlus") == 0) varType_ = HFtowersPlus;
97  if(centralityVariable_.compare("HFtowersMinus") == 0) varType_ = HFtowersMinus;
98  if(centralityVariable_.compare("HFtowersTrunc") == 0) varType_ = HFtowersTrunc;
99  if(centralityVariable_.compare("HFtowersPlusTrunc") == 0) varType_ = HFtowersPlusTrunc;
100  if(centralityVariable_.compare("HFtowersMinusTrunc") == 0) varType_ = HFtowersMinusTrunc;
101  if(centralityVariable_.compare("HFhits") == 0) varType_ = HFhits;
102  if(centralityVariable_.compare("PixelHits") == 0) varType_ = PixelHits;
103  if(centralityVariable_.compare("PixelTracks") == 0) varType_ = PixelTracks;
104  if(centralityVariable_.compare("Tracks") == 0) varType_ = Tracks;
105  if(centralityVariable_.compare("EB") == 0) varType_ = EB;
106  if(centralityVariable_.compare("EE") == 0) varType_ = EE;
107  if(varType_ == Missing){
108  std::string errorMessage="Requested Centrality variable does not exist : "+centralityVariable_+"\n" +
109  "Supported variables are: \n" + "HFtowers HFtowersPlus HFtowersMinus HFtowersTrunc HFtowersPlusTrunc HFtowersMinusTrunc HFhits PixelHits PixelTracks Tracks EB EE" + "\n";
110  throw cms::Exception("Configuration",errorMessage);
111  }
112 
113  if(iConfig.exists("nonDefaultGlauberModel")){
114  centralityMC_ = iConfig.getParameter<std::string>("nonDefaultGlauberModel");
115  }
117 
118  produces<int>(centralityVariable_.data());
119 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< reco::Centrality > tag_
CentralityBinProducer::~CentralityBinProducer ( )

Definition at line 122 of file CentralityBinProducer.cc.

123 {
124 
125  // do anything here that needs to be done at desctruction time
126  // (e.g. close files, deallocate resources etc.)
127 
128 }

Member Function Documentation

void CentralityBinProducer::beginRun ( edm::Run const &  run,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 176 of file CentralityBinProducer.cc.

References centralityLabel_, centralityVariable_, edm::EventSetup::get(), HFtowersMinus, HFtowersMinusTrunc, HFtowersPlus, HFtowersPlusTrunc, inputDB_, pPbRunFlip_, prevRun_, edm::RunBase::run(), and varType_.

177 {
178 
179  if(prevRun_ < pPbRunFlip_ && iRun.run() >= pPbRunFlip_){
180  if(centralityVariable_.compare("HFtowersPlus") == 0) varType_ = HFtowersMinus;
181  if(centralityVariable_.compare("HFtowersMinus") == 0) varType_ = HFtowersPlus;
182  if(centralityVariable_.compare("HFtowersPlusTrunc") == 0) varType_ = HFtowersMinusTrunc;
183  if(centralityVariable_.compare("HFtowersMinusTrunc") == 0) varType_ = HFtowersPlusTrunc;
184  }
185  prevRun_ = iRun.run();
186 
187  iSetup.get<HeavyIonRcd>().get(centralityLabel_,inputDB_);
188 
189 }
edm::ESHandle< CentralityTable > inputDB_
const T & get() const
Definition: EventSetup.h:56
void CentralityBinProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 137 of file CentralityBinProducer.cc.

References newFWLiteAna::bin, centralityVariable_, chandle_, EB, EE, Exception, edm::Event::getByToken(), HFhits, HFtowers, HFtowersMinus, HFtowersMinusTrunc, HFtowersPlus, HFtowersPlusTrunc, HFtowersTrunc, i, inputDB_, PixelHits, PixelTracks, edm::Event::put(), tag_, Tracks, relativeConstraints::value, and varType_.

138 {
139 
140  iEvent.getByToken(tag_,chandle_);
141 
142  double value = 0;
143  switch(varType_){
144  case HFtowers : value = chandle_->EtHFtowerSum();break;
145  case HFtowersPlus : value = chandle_->EtHFtowerSumPlus();break;
146  case HFtowersMinus : value = chandle_->EtHFtowerSumMinus();break;
147  case HFhits : value = chandle_->EtHFhitSum();break;
148  case HFtowersTrunc : value = chandle_->EtHFtruncated();break;
149  case HFtowersPlusTrunc : value = chandle_->EtHFtruncatedPlus();break;
150  case HFtowersMinusTrunc : value = chandle_->EtHFtruncatedMinus();break;
151  case PixelHits : value = chandle_->multiplicityPixel();break;
152  case PixelTracks : value = chandle_->NpixelTracks();break;
153  case Tracks : value = chandle_->Ntracks();break;
154  case EB : value = chandle_->EtEBSum();break;
155  case EE : value = chandle_->EtEESum();break;
156  default:
157  throw cms::Exception("CentralityBinProducer","Centrality variable not recognized.");
158  }
159 
160  int bin = inputDB_->m_table.size() - 1;
161  for(unsigned int i = 0; i < inputDB_->m_table.size(); ++i){
162 
163  if(value >= inputDB_->m_table[i].bin_edge && value){
164  bin = i; break;
165  }
166 
167  }
168 
169  std::auto_ptr<int> binp(new int(bin));
170  iEvent.put(binp,centralityVariable_.data());
171 
172 }
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
edm::ESHandle< CentralityTable > inputDB_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
edm::Handle< reco::Centrality > chandle_
edm::EDGetTokenT< reco::Centrality > tag_

Member Data Documentation

std::string CentralityBinProducer::centralityLabel_
private

Definition at line 65 of file CentralityBinProducer.cc.

Referenced by beginRun(), and CentralityBinProducer().

std::string CentralityBinProducer::centralityMC_
private

Definition at line 66 of file CentralityBinProducer.cc.

Referenced by CentralityBinProducer().

std::string CentralityBinProducer::centralityVariable_
private

Definition at line 64 of file CentralityBinProducer.cc.

Referenced by beginRun(), CentralityBinProducer(), and produce().

edm::Handle<reco::Centrality> CentralityBinProducer::chandle_
private

Definition at line 60 of file CentralityBinProducer.cc.

Referenced by produce().

edm::ESHandle<CentralityTable> CentralityBinProducer::inputDB_
private

Definition at line 62 of file CentralityBinProducer.cc.

Referenced by beginRun(), and produce().

unsigned int CentralityBinProducer::pPbRunFlip_
private

Definition at line 70 of file CentralityBinProducer.cc.

Referenced by beginRun(), and CentralityBinProducer().

unsigned int CentralityBinProducer::prevRun_
private

Definition at line 67 of file CentralityBinProducer.cc.

Referenced by beginRun().

edm::EDGetTokenT<reco::Centrality> CentralityBinProducer::tag_
private

Definition at line 61 of file CentralityBinProducer.cc.

Referenced by CentralityBinProducer(), and produce().

VariableType CentralityBinProducer::varType_
private

Definition at line 69 of file CentralityBinProducer.cc.

Referenced by beginRun(), CentralityBinProducer(), and produce().