CMS 3D CMS Logo

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::stream::EDProducer<>

Public Member Functions

 CentralityBinProducer (const edm::ParameterSet &)
 
 ~CentralityBinProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

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,
  ZDChitsPlus = 12, ZDChitsMinus = 13, PFhf = 14, PFhfPlus = 15,
  PFhfMinus = 16, Missing = 17
}
 

Private Member Functions

void beginRun (edm::Run const &run, const edm::EventSetup &iSetup) override
 
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_
 
edm::ESGetToken< CentralityTable, HeavyIonRcdinputDBToken_
 
unsigned int pPbRunFlip_
 
unsigned int prevRun_
 
edm::EDGetTokenT< reco::Centralitytag_
 
VariableType varType_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 46 of file CentralityBinProducer.cc.

Member Enumeration Documentation

◆ VariableType

Enumerator
HFtowers 
HFtowersPlus 
HFtowersMinus 
HFtowersTrunc 
HFtowersPlusTrunc 
HFtowersMinusTrunc 
HFhits 
PixelHits 
PixelTracks 
Tracks 
EB 
EE 
ZDChitsPlus 
ZDChitsMinus 
PFhf 
PFhfPlus 
PFhfMinus 
Missing 

Definition at line 47 of file CentralityBinProducer.cc.

47  {
48  HFtowers = 0,
49  HFtowersPlus = 1,
50  HFtowersMinus = 2,
51  HFtowersTrunc = 3,
54  HFhits = 6,
55  PixelHits = 7,
56  PixelTracks = 8,
57  Tracks = 9,
58  EB = 10,
59  EE = 11,
60  ZDChitsPlus = 12,
61  ZDChitsMinus = 13,
62  PFhf = 14,
63  PFhfPlus = 15,
64  PFhfMinus = 16,
65  Missing = 17
66  };

Constructor & Destructor Documentation

◆ CentralityBinProducer()

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

Definition at line 103 of file CentralityBinProducer.cc.

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

103  : prevRun_(0), varType_(Missing) {
104  using namespace edm;
105  tag_ = consumes<reco::Centrality>(iConfig.getParameter<edm::InputTag>("Centrality"));
106  centralityVariable_ = iConfig.getParameter<std::string>("centralityVariable");
107  pPbRunFlip_ = iConfig.getParameter<unsigned int>("pPbRunFlip");
108 
109  if (centralityVariable_ == "HFtowers")
110  varType_ = HFtowers;
111  if (centralityVariable_ == "HFtowersPlus")
113  if (centralityVariable_ == "HFtowersMinus")
115  if (centralityVariable_ == "HFtowersTrunc")
117  if (centralityVariable_ == "HFtowersPlusTrunc")
119  if (centralityVariable_ == "HFtowersMinusTrunc")
121  if (centralityVariable_ == "HFhits")
122  varType_ = HFhits;
123  if (centralityVariable_ == "PixelHits")
125  if (centralityVariable_ == "PixelTracks")
127  if (centralityVariable_ == "Tracks")
128  varType_ = Tracks;
129  if (centralityVariable_ == "EB")
130  varType_ = EB;
131  if (centralityVariable_ == "EE")
132  varType_ = EE;
133  if (centralityVariable_ == "ZDChitsPlus")
135  if (centralityVariable_ == "ZDChitsMinus")
137  if (centralityVariable_ == "PFhf")
138  varType_ = PFhf;
139  if (centralityVariable_ == "PFhfPlus")
140  varType_ = PFhfPlus;
141  if (centralityVariable_ == "PFhfMinus")
143  if (varType_ == Missing) {
144  std::string errorMessage =
145  "Requested Centrality variable does not exist : " + centralityVariable_ + "\n" + "Supported variables are: \n" +
146  "HFtowers HFtowersPlus HFtowersMinus HFtowersTrunc HFtowersPlusTrunc HFtowersMinusTrunc "
147  "HFhits PixelHits PixelTracks Tracks EB EE ZDChitsPlus ZDChitsMinus PFhf PFhfPlus PFhfMinus" +
148  "\n";
149  throw cms::Exception("Configuration", errorMessage);
150  }
151 
152  if (iConfig.exists("nonDefaultGlauberModel")) {
153  centralityMC_ = iConfig.getParameter<std::string>("nonDefaultGlauberModel");
154  }
156  inputDBToken_ =
157  esConsumes<CentralityTable, HeavyIonRcd, edm::Transition::BeginRun>(edm::ESInputTag("", centralityLabel_));
158 
159  produces<int>(centralityVariable_);
160 }
edm::ESGetToken< CentralityTable, HeavyIonRcd > inputDBToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
bool exists(std::string const &parameterName) const
checks if a parameter exists
HLT enums.
edm::EDGetTokenT< reco::Centrality > tag_

◆ ~CentralityBinProducer()

CentralityBinProducer::~CentralityBinProducer ( )
override

Definition at line 162 of file CentralityBinProducer.cc.

162  {
163  // do anything here that needs to be done at desctruction time
164  // (e.g. close files, deallocate resources etc.)
165 }

Member Function Documentation

◆ beginRun()

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

Definition at line 243 of file CentralityBinProducer.cc.

References centralityVariable_, edm::EventSetup::getHandle(), HFtowersMinus, HFtowersMinusTrunc, HFtowersPlus, HFtowersPlusTrunc, inputDB_, inputDBToken_, PFhfMinus, PFhfPlus, pPbRunFlip_, prevRun_, edm::RunBase::run(), varType_, ZDChitsMinus, and ZDChitsPlus.

243  {
244  if (prevRun_ < pPbRunFlip_ && iRun.run() >= pPbRunFlip_) {
245  if (centralityVariable_ == "HFtowersPlus")
247  if (centralityVariable_ == "HFtowersMinus")
249  if (centralityVariable_ == "HFtowersPlusTrunc")
251  if (centralityVariable_ == "HFtowersMinusTrunc")
253  if (centralityVariable_ == "ZDChitsPlus")
255  if (centralityVariable_ == "ZDChitsMinus")
257  if (centralityVariable_ == "PFhfPlus")
259  if (centralityVariable_ == "PFhfMinus")
260  varType_ = PFhfPlus;
261  }
262  prevRun_ = iRun.run();
263 
264  inputDB_ = iSetup.getHandle(inputDBToken_);
265 }
edm::ESGetToken< CentralityTable, HeavyIonRcd > inputDBToken_
edm::ESHandle< CentralityTable > inputDB_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130

◆ produce()

void CentralityBinProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 172 of file CentralityBinProducer.cc.

References newFWLiteAna::bin, centralityVariable_, chandle_, EB, EE, reco::Centrality::EtEBSum(), reco::Centrality::EtEESum(), reco::Centrality::EtHFhitSum(), reco::Centrality::EtHFtowerSum(), reco::Centrality::EtHFtowerSumMinus(), reco::Centrality::EtHFtowerSumPlus(), reco::Centrality::EtHFtruncated(), reco::Centrality::EtHFtruncatedMinus(), reco::Centrality::EtHFtruncatedPlus(), reco::Centrality::EtPFhfSum(), reco::Centrality::EtPFhfSumMinus(), reco::Centrality::EtPFhfSumPlus(), Exception, HFhits, HFtowers, HFtowersMinus, HFtowersMinusTrunc, HFtowersPlus, HFtowersPlusTrunc, HFtowersTrunc, mps_fire::i, iEvent, inputDB_, CentralityTable::m_table, reco::Centrality::multiplicityPixel(), reco::Centrality::NpixelTracks(), reco::Centrality::Ntracks(), PFhf, PFhfMinus, PFhfPlus, PixelHits, PixelTracks, tag_, Tracks, varType_, ZDChitsMinus, ZDChitsPlus, reco::Centrality::zdcSumMinus(), and reco::Centrality::zdcSumPlus().

172  {
173  iEvent.getByToken(tag_, chandle_);
174 
175  double value = 0;
176  switch (varType_) {
177  case HFtowers:
179  break;
180  case HFtowersPlus:
182  break;
183  case HFtowersMinus:
185  break;
186  case HFhits:
188  break;
189  case HFtowersTrunc:
191  break;
192  case HFtowersPlusTrunc:
194  break;
195  case HFtowersMinusTrunc:
197  break;
198  case PixelHits:
200  break;
201  case PixelTracks:
203  break;
204  case Tracks:
205  value = chandle_->Ntracks();
206  break;
207  case EB:
208  value = chandle_->EtEBSum();
209  break;
210  case EE:
211  value = chandle_->EtEESum();
212  break;
213  case ZDChitsPlus:
215  break;
216  case ZDChitsMinus:
218  break;
219  case PFhf:
220  value = chandle_->EtPFhfSum();
221  break;
222  case PFhfPlus:
224  break;
225  case PFhfMinus:
227  break;
228  default:
229  throw cms::Exception("CentralityBinProducer", "Centrality variable not recognized.");
230  }
231 
232  int bin = inputDB_->m_table.size() - 1;
233  for (unsigned int i = 0; i < inputDB_->m_table.size(); ++i) {
234  if (value >= inputDB_->m_table[i].bin_edge && value) {
235  bin = i;
236  break;
237  }
238  }
239 
240  iEvent.put(std::make_unique<int>(bin), centralityVariable_);
241 }
std::vector< CBin > m_table
double EtHFtruncatedPlus() const
Definition: Centrality.h:31
double EtHFtowerSum() const
Definition: Centrality.h:24
double EtHFtruncated() const
Definition: Centrality.h:30
double zdcSumMinus() const
Definition: Centrality.h:56
double EtPFhfSumMinus() const
Definition: Centrality.h:60
double multiplicityPixel() const
Definition: Centrality.h:43
double EtPFhfSum() const
Definition: Centrality.h:58
edm::ESHandle< CentralityTable > inputDB_
int iEvent
Definition: GenABIO.cc:224
double Ntracks() const
Definition: Centrality.h:46
double EtPFhfSumPlus() const
Definition: Centrality.h:59
double EtHFtowerSumMinus() const
Definition: Centrality.h:26
Definition: value.py:1
double EtEESum() const
Definition: Centrality.h:33
edm::Handle< reco::Centrality > chandle_
double EtEBSum() const
Definition: Centrality.h:39
double EtHFhitSum() const
Definition: Centrality.h:21
edm::EDGetTokenT< reco::Centrality > tag_
double EtHFtowerSumPlus() const
Definition: Centrality.h:25
double NpixelTracks() const
Definition: Centrality.h:50
double zdcSumPlus() const
Definition: Centrality.h:55
double EtHFtruncatedMinus() const
Definition: Centrality.h:32

Member Data Documentation

◆ centralityLabel_

std::string CentralityBinProducer::centralityLabel_
private

Definition at line 84 of file CentralityBinProducer.cc.

Referenced by CentralityBinProducer().

◆ centralityMC_

std::string CentralityBinProducer::centralityMC_
private

Definition at line 85 of file CentralityBinProducer.cc.

Referenced by CentralityBinProducer().

◆ centralityVariable_

std::string CentralityBinProducer::centralityVariable_
private

Definition at line 83 of file CentralityBinProducer.cc.

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

◆ chandle_

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

Definition at line 78 of file CentralityBinProducer.cc.

Referenced by produce().

◆ inputDB_

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

Definition at line 80 of file CentralityBinProducer.cc.

Referenced by beginRun(), and produce().

◆ inputDBToken_

edm::ESGetToken<CentralityTable, HeavyIonRcd> CentralityBinProducer::inputDBToken_
private

Definition at line 81 of file CentralityBinProducer.cc.

Referenced by beginRun(), and CentralityBinProducer().

◆ pPbRunFlip_

unsigned int CentralityBinProducer::pPbRunFlip_
private

Definition at line 89 of file CentralityBinProducer.cc.

Referenced by beginRun(), and CentralityBinProducer().

◆ prevRun_

unsigned int CentralityBinProducer::prevRun_
private

Definition at line 86 of file CentralityBinProducer.cc.

Referenced by beginRun().

◆ tag_

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

Definition at line 79 of file CentralityBinProducer.cc.

Referenced by CentralityBinProducer(), and produce().

◆ varType_

VariableType CentralityBinProducer::varType_
private

Definition at line 88 of file CentralityBinProducer.cc.

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