CMS 3D CMS Logo

CentralityBinProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CentralityBinProducer
4 // Class: CentralityBinProducer
5 //
13 //
14 // Original Author: Yetkin Yilmaz
15 // Created: Thu Aug 12 05:34:11 EDT 2010
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 #include <string>
22 
23 // user include files
26 
31 
33 
35 
41 
42 //
43 // class declaration
44 //
45 
47  enum VariableType {
48  HFtowers = 0,
54  HFhits = 6,
55  PixelHits = 7,
57  Tracks = 9,
58  EB = 10,
59  EE = 11,
62  Missing = 14
63  };
64 
65 public:
67  ~CentralityBinProducer() override;
68 
69 private:
70  void beginRun(edm::Run const& run, const edm::EventSetup& iSetup) override;
71  void produce(edm::Event&, const edm::EventSetup&) override;
72 
73  // ----------member data ---------------------------
74 
78 
82  unsigned int prevRun_;
83 
85  unsigned int pPbRunFlip_;
86 };
87 
88 //
89 // constants, enums and typedefs
90 //
91 
92 //
93 // static data member definitions
94 //
95 
96 //
97 // constructors and destructor
98 //
99 CentralityBinProducer::CentralityBinProducer(const edm::ParameterSet& iConfig) : prevRun_(0), varType_(Missing) {
100  using namespace edm;
101  tag_ = consumes<reco::Centrality>(iConfig.getParameter<edm::InputTag>("Centrality"));
102  centralityVariable_ = iConfig.getParameter<std::string>("centralityVariable");
103  pPbRunFlip_ = iConfig.getParameter<unsigned int>("pPbRunFlip");
104 
105  if (centralityVariable_ == "HFtowers")
106  varType_ = HFtowers;
107  if (centralityVariable_ == "HFtowersPlus")
109  if (centralityVariable_ == "HFtowersMinus")
111  if (centralityVariable_ == "HFtowersTrunc")
113  if (centralityVariable_ == "HFtowersPlusTrunc")
115  if (centralityVariable_ == "HFtowersMinusTrunc")
117  if (centralityVariable_ == "HFhits")
118  varType_ = HFhits;
119  if (centralityVariable_ == "PixelHits")
121  if (centralityVariable_ == "PixelTracks")
123  if (centralityVariable_ == "Tracks")
124  varType_ = Tracks;
125  if (centralityVariable_ == "EB")
126  varType_ = EB;
127  if (centralityVariable_ == "EE")
128  varType_ = EE;
129  if (centralityVariable_ == "ZDChitsPlus")
131  if (centralityVariable_ == "ZDChitsMinus")
133  if (varType_ == Missing) {
134  std::string errorMessage = "Requested Centrality variable does not exist : " + centralityVariable_ + "\n" +
135  "Supported variables are: \n" +
136  "HFtowers HFtowersPlus HFtowersMinus HFtowersTrunc HFtowersPlusTrunc HFtowersMinusTrunc "
137  "HFhits PixelHits PixelTracks Tracks EB EE" +
138  "\n";
139  throw cms::Exception("Configuration", errorMessage);
140  }
141 
142  if (iConfig.exists("nonDefaultGlauberModel")) {
143  centralityMC_ = iConfig.getParameter<std::string>("nonDefaultGlauberModel");
144  }
146 
147  produces<int>(centralityVariable_);
148 }
149 
151  // do anything here that needs to be done at desctruction time
152  // (e.g. close files, deallocate resources etc.)
153 }
154 
155 //
156 // member functions
157 //
158 
159 // ------------ method called to produce the data ------------
161  iEvent.getByToken(tag_, chandle_);
162 
163  double value = 0;
164  switch (varType_) {
165  case HFtowers:
167  break;
168  case HFtowersPlus:
170  break;
171  case HFtowersMinus:
173  break;
174  case HFhits:
176  break;
177  case HFtowersTrunc:
179  break;
180  case HFtowersPlusTrunc:
182  break;
183  case HFtowersMinusTrunc:
185  break;
186  case PixelHits:
188  break;
189  case PixelTracks:
191  break;
192  case Tracks:
193  value = chandle_->Ntracks();
194  break;
195  case EB:
196  value = chandle_->EtEBSum();
197  break;
198  case EE:
199  value = chandle_->EtEESum();
200  break;
201  case ZDChitsPlus:
203  break;
204  case ZDChitsMinus:
206  break;
207  default:
208  throw cms::Exception("CentralityBinProducer", "Centrality variable not recognized.");
209  }
210 
211  int bin = inputDB_->m_table.size() - 1;
212  for (unsigned int i = 0; i < inputDB_->m_table.size(); ++i) {
213  if (value >= inputDB_->m_table[i].bin_edge && value) {
214  bin = i;
215  break;
216  }
217  }
218 
219  iEvent.put(std::make_unique<int>(bin), centralityVariable_);
220 }
221 
222 void CentralityBinProducer::beginRun(edm::Run const& iRun, const edm::EventSetup& iSetup) {
223  if (prevRun_ < pPbRunFlip_ && iRun.run() >= pPbRunFlip_) {
224  if (centralityVariable_ == "HFtowersPlus")
226  if (centralityVariable_ == "HFtowersMinus")
228  if (centralityVariable_ == "HFtowersPlusTrunc")
230  if (centralityVariable_ == "HFtowersMinusTrunc")
232  if (centralityVariable_ == "ZDChitsPlus")
234  if (centralityVariable_ == "ZDChitsMinus")
236  }
237  prevRun_ = iRun.run();
238 
240 }
241 
242 //define this as a plug-in
CentralityBinProducer::HFtowersPlus
Definition: CentralityBinProducer.cc:49
CentralityBinProducer::beginRun
void beginRun(edm::Run const &run, const edm::EventSetup &iSetup) override
Definition: CentralityBinProducer.cc:222
mps_fire.i
i
Definition: mps_fire.py:355
EDProducer.h
ESHandle.h
CentralityBinProducer::centralityLabel_
std::string centralityLabel_
Definition: CentralityBinProducer.cc:80
edm::Run
Definition: Run.h:45
edm::EDGetTokenT< reco::Centrality >
CentralityBinProducer::chandle_
edm::Handle< reco::Centrality > chandle_
Definition: CentralityBinProducer.cc:75
reco::Centrality::EtHFhitSum
double EtHFhitSum() const
Definition: Centrality.h:21
edm
HLT enums.
Definition: AlignableModifier.h:19
CentralityTable.h
CentralityBinProducer::EB
Definition: CentralityBinProducer.cc:58
CentralityBinProducer::centralityMC_
std::string centralityMC_
Definition: CentralityBinProducer.cc:81
edm::Handle< reco::Centrality >
edm::RunBase::run
RunNumber_t run() const
Definition: RunBase.h:40
CentralityBinProducer::PixelTracks
Definition: CentralityBinProducer.cc:56
CentralityBinProducer::HFtowersMinus
Definition: CentralityBinProducer.cc:50
CentralityBinProducer::ZDChitsMinus
Definition: CentralityBinProducer.cc:61
CentralityBinProducer::CentralityBinProducer
CentralityBinProducer(const edm::ParameterSet &)
Definition: CentralityBinProducer.cc:99
CentralityBinProducer::HFtowersMinusTrunc
Definition: CentralityBinProducer.cc:53
CentralityBinProducer::Missing
Definition: CentralityBinProducer.cc:62
HeavyIonRcd.h
CentralityBinProducer::HFtowersPlusTrunc
Definition: CentralityBinProducer.cc:52
MakerMacros.h
CentralityBinProducer::PixelHits
Definition: CentralityBinProducer.cc:55
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
reco::Centrality::EtHFtruncated
double EtHFtruncated() const
Definition: Centrality.h:30
reco::Centrality::EtEBSum
double EtEBSum() const
Definition: Centrality.h:39
Centrality.h
reco::Centrality::EtHFtowerSumPlus
double EtHFtowerSumPlus() const
Definition: Centrality.h:25
CentralityBinProducer::VariableType
VariableType
Definition: CentralityBinProducer.cc:47
CentralityBinProducer::varType_
VariableType varType_
Definition: CentralityBinProducer.cc:84
reco::Centrality::EtHFtruncatedMinus
double EtHFtruncatedMinus() const
Definition: Centrality.h:32
CentralityTable::m_table
std::vector< CBin > m_table
Definition: CentralityTable.h:39
Run.h
edm::ESHandle< CentralityTable >
reco::Centrality::EtEESum
double EtEESum() const
Definition: Centrality.h:33
reco::Centrality::zdcSumPlus
double zdcSumPlus() const
Definition: Centrality.h:55
CentralityBinProducer::inputDB_
edm::ESHandle< CentralityTable > inputDB_
Definition: CentralityBinProducer.cc:77
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:674
CentralityBinProducer::tag_
edm::EDGetTokenT< reco::Centrality > tag_
Definition: CentralityBinProducer.cc:76
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
iEvent
int iEvent
Definition: GenABIO.cc:224
CentralityBinProducer::prevRun_
unsigned int prevRun_
Definition: CentralityBinProducer.cc:82
value
Definition: value.py:1
reco::Centrality::EtHFtruncatedPlus
double EtHFtruncatedPlus() const
Definition: Centrality.h:31
edm::EventSetup
Definition: EventSetup.h:57
CentralityBinProducer::~CentralityBinProducer
~CentralityBinProducer() override
Definition: CentralityBinProducer.cc:150
CentralityBinProducer::pPbRunFlip_
unsigned int pPbRunFlip_
Definition: CentralityBinProducer.cc:85
get
#define get
CentralityBinProducer::Tracks
Definition: CentralityBinProducer.cc:57
CentralityBinProducer::HFtowersTrunc
Definition: CentralityBinProducer.cc:51
InputTag.h
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
CentralityBinProducer::centralityVariable_
std::string centralityVariable_
Definition: CentralityBinProducer.cc:79
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
CentralityBinProducer::ZDChitsPlus
Definition: CentralityBinProducer.cc:60
reco::Centrality::NpixelTracks
double NpixelTracks() const
Definition: Centrality.h:50
writedatasetfile.run
run
Definition: writedatasetfile.py:27
CentralityBinProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: CentralityBinProducer.cc:160
Frameworkfwd.h
Exception
Definition: hltDiff.cc:246
reco::Centrality::zdcSumMinus
double zdcSumMinus() const
Definition: Centrality.h:56
reco::Centrality::multiplicityPixel
double multiplicityPixel() const
Definition: Centrality.h:43
EventSetup.h
edm::EDProducer
Definition: EDProducer.h:36
CentralityBinProducer::HFhits
Definition: CentralityBinProducer.cc:54
ConsumesCollector.h
HeavyIonRcd
Definition: HeavyIonRcd.h:24
ParameterSet.h
reco::Centrality::EtHFtowerSum
double EtHFtowerSum() const
Definition: Centrality.h:24
edm::Event
Definition: Event.h:73
CentralityBinProducer::EE
Definition: CentralityBinProducer.cc:59
CentralityBinProducer
Definition: CentralityBinProducer.cc:46
reco::Centrality::Ntracks
double Ntracks() const
Definition: Centrality.h:46
edm::InputTag
Definition: InputTag.h:15
CentralityBinProducer::HFtowers
Definition: CentralityBinProducer.cc:48
reco::Centrality::EtHFtowerSumMinus
double EtHFtowerSumMinus() const
Definition: Centrality.h:26