CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
RawPCCProducer Class Reference
Inheritance diagram for RawPCCProducer:
edm::global::EDProducer< edm::EndLuminosityBlockProducer > edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 RawPCCProducer (const edm::ParameterSet &)
 
 ~RawPCCProducer () override
 
- Public Member Functions inherited from edm::global::EDProducer< edm::EndLuminosityBlockProducer >
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () 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
 
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::vector< ModuleDescription const * > &modules, 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)
 

Private Member Functions

void globalEndLuminosityBlockProduce (edm::LuminosityBlock &lumiSeg, const edm::EventSetup &iSetup) const final
 
void produce (edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const final
 

Private Attributes

const bool applyCorr_
 
const std::string csvOutLabel_
 
std::mutex fileLock_
 
const std::vector< int > modVeto_
 
edm::EDGetTokenT< reco::PixelClusterCountspccToken_
 
const edm::EDPutTokenT< LumiInfoputToken_
 
const bool saveCSVFile_
 
const std::string takeAverageValue_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase 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
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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>
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<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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


class: RawPCCProducer.cc

description: Creates a LumiInfo object that will contain the luminosity per bunch crossing, along with the total luminosity and the statistical error.

authors:Sam Higginbotham (shigg.nosp@m.inb@.nosp@m.cern..nosp@m.ch) and Chris Palmer (capal.nosp@m.mer@.nosp@m.cern..nosp@m.ch)


Definition at line 34 of file RawPCCProducer.cc.

Constructor & Destructor Documentation

◆ RawPCCProducer()

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

Definition at line 57 of file RawPCCProducer.cc.

58  : putToken_{produces<LumiInfo, edm::Transition::EndLuminosityBlock>(
59  iConfig.getParameter<edm::ParameterSet>("RawPCCProducerParameters")
60  .getUntrackedParameter<std::string>("outputProductName", "alcaLumi"))},
61  takeAverageValue_{iConfig.getParameter<edm::ParameterSet>("RawPCCProducerParameters")
62  .getUntrackedParameter<std::string>("OutputValue", std::string("Totals"))},
63  modVeto_{
64  iConfig.getParameter<edm::ParameterSet>("RawPCCProducerParameters").getParameter<std::vector<int>>("modVeto")},
65  csvOutLabel_{iConfig.getParameter<edm::ParameterSet>("RawPCCProducerParameters")
66  .getUntrackedParameter<std::string>("label", std::string("rawPCC.csv"))},
67  saveCSVFile_{iConfig.getParameter<edm::ParameterSet>("RawPCCProducerParameters")
68  .getUntrackedParameter<bool>("saveCSVFile", false)},
69  applyCorr_{iConfig.getParameter<edm::ParameterSet>("RawPCCProducerParameters")
70  .getUntrackedParameter<bool>("ApplyCorrections", false)} {
71  auto pccSource =
72  iConfig.getParameter<edm::ParameterSet>("RawPCCProducerParameters").getParameter<std::string>("inputPccLabel");
73  auto prodInst =
74  iConfig.getParameter<edm::ParameterSet>("RawPCCProducerParameters").getParameter<std::string>("ProdInst");
75 
76  pccToken_ = consumes<reco::PixelClusterCounts, edm::InLumi>(edm::InputTag(pccSource, prodInst));
77 }

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ~RawPCCProducer()

RawPCCProducer::~RawPCCProducer ( )
override

Definition at line 80 of file RawPCCProducer.cc.

80 {}

Member Function Documentation

◆ globalEndLuminosityBlockProduce()

void RawPCCProducer::globalEndLuminosityBlockProduce ( edm::LuminosityBlock lumiSeg,
const edm::EventSetup iSetup 
) const
finalprivate

Definition at line 86 of file RawPCCProducer.cc.

87  {
88  float totalLumi = 0.0; //The total raw luminosity from the pixel clusters - not scaled
89  float statErrOnLumi = 0.0; //the statistical error on the lumi - large num ie sqrt(N)
90 
91  //new vector containing clusters per bxid
92  std::vector<int> clustersPerBXOutput(LumiConstants::numBX, 0);
93  //new vector containing clusters per bxid with afterglow corrections
94  std::vector<float> corrClustersPerBXOutput(LumiConstants::numBX, 0);
95 
96  //The indicies of all the good modules - not vetoed
97  std::vector<int> goodMods;
98 
100  lumiSeg.getByToken(pccToken_, pccHandle);
101 
102  const reco::PixelClusterCounts& inputPcc = *(pccHandle.product());
103 
104  //vector with Module IDs 1-1 map to bunch x-ing in clusers
105  auto modID = inputPcc.readModID();
106  //vector with total events at each bxid.
107  auto events = inputPcc.readEvents();
108  auto clustersPerBXInput = inputPcc.readCounts();
109 
110  //making list of modules to sum over
111  for (unsigned int i = 0; i < modID.size(); i++) {
112  if (std::find(modVeto_.begin(), modVeto_.end(), modID.at(i)) == modVeto_.end()) {
113  goodMods.push_back(i);
114  }
115  }
116 
117  //summing over good modules only
118  for (int bx = 0; bx < int(LumiConstants::numBX); bx++) {
119  for (unsigned int i = 0; i < goodMods.size(); i++) {
120  clustersPerBXOutput.at(bx) += clustersPerBXInput.at(goodMods.at(i) * int(LumiConstants::numBX) + bx);
121  }
122  }
123 
124  std::vector<float> correctionScaleFactors;
125  if (applyCorr_) {
127  iSetup.get<LumiCorrectionsRcd>().get(corrHandle);
128  const LumiCorrections* pccCorrections = corrHandle.product();
129  correctionScaleFactors = pccCorrections->getCorrectionsBX();
130  } else {
131  correctionScaleFactors.resize(LumiConstants::numBX, 1.0);
132  }
133 
134  for (unsigned int i = 0; i < clustersPerBXOutput.size(); i++) {
135  if (events.at(i) != 0) {
136  corrClustersPerBXOutput[i] = clustersPerBXOutput[i] * correctionScaleFactors[i];
137  } else {
138  corrClustersPerBXOutput[i] = 0.0;
139  }
140  totalLumi += corrClustersPerBXOutput[i];
141  statErrOnLumi += float(events[i]);
142  }
143 
144  std::vector<float> errorPerBX; //Stat error (or number of events)
145  errorPerBX.assign(events.begin(), events.end());
146 
147  if (takeAverageValue_ == "Average") {
148  unsigned int NActiveBX = 0;
149  for (int bx = 0; bx < int(LumiConstants::numBX); bx++) {
150  if (events[bx] > 0) {
151  NActiveBX++;
152  // Counting where events are will only work
153  // for ZeroBias or AlwaysTrue triggers.
154  // Random triggers will get all BXs.
155  corrClustersPerBXOutput[bx] /= float(events[bx]);
156  errorPerBX[bx] = 1 / sqrt(float(events[bx]));
157  }
158  }
159  if (statErrOnLumi != 0) {
160  totalLumi = totalLumi / statErrOnLumi * float(NActiveBX);
161  statErrOnLumi = 1 / sqrt(statErrOnLumi) * totalLumi;
162  }
163  }
164 
165  LumiInfo outputLumiInfo;
166 
167  outputLumiInfo.setTotalInstLumi(totalLumi);
168  outputLumiInfo.setTotalInstStatError(statErrOnLumi);
169 
170  outputLumiInfo.setErrorLumiAllBX(errorPerBX);
171  outputLumiInfo.setInstLumiAllBX(corrClustersPerBXOutput);
172 
173  if (saveCSVFile_) {
174  std::lock_guard<std::mutex> lock(fileLock_);
175  std::ofstream csfile(csvOutLabel_, std::ios_base::app);
176  csfile << std::to_string(lumiSeg.run()) << ",";
177  csfile << std::to_string(lumiSeg.luminosityBlock()) << ",";
178  csfile << std::to_string(totalLumi);
179 
180  if (totalLumi > 0) {
181  for (unsigned int bx = 0; bx < LumiConstants::numBX; bx++) {
182  csfile << "," << std::to_string(corrClustersPerBXOutput[bx]);
183  }
184  csfile << std::endl;
185  } else if (totalLumi < 0) {
186  edm::LogInfo("WARNING") << "WHY IS LUMI NEGATIVE?!?!?!? " << totalLumi;
187  }
188 
189  csfile.close();
190  }
191  lumiSeg.emplace(putToken_, std::move(outputLumiInfo));
192 }

References applyCorr_, simKBmtfDigis_cfi::bx, csvOutLabel_, edm::LuminosityBlock::emplace(), patZpeak::events, fileLock_, spr::find(), dqmMemoryStats::float, edm::EventSetup::get(), get, edm::LuminosityBlock::getByToken(), LumiCorrections::getCorrectionsBX(), mps_fire::i, createfilelist::int, CommonMethods::lock(), edm::LuminosityBlockBase::luminosityBlock(), modVeto_, eostools::move(), LumiConstants::numBX, pccToken_, edm::Handle< T >::product(), edm::ESHandle< T >::product(), putToken_, reco::PixelClusterCounts::readCounts(), reco::PixelClusterCounts::readEvents(), reco::PixelClusterCounts::readModID(), edm::LuminosityBlockBase::run(), saveCSVFile_, LumiInfo::setErrorLumiAllBX(), LumiInfo::setInstLumiAllBX(), LumiInfo::setTotalInstLumi(), LumiInfo::setTotalInstStatError(), mathSSE::sqrt(), and takeAverageValue_.

◆ produce()

void RawPCCProducer::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
finalprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 83 of file RawPCCProducer.cc.

83 {}

Member Data Documentation

◆ applyCorr_

const bool RawPCCProducer::applyCorr_
private

Definition at line 53 of file RawPCCProducer.cc.

Referenced by globalEndLuminosityBlockProduce().

◆ csvOutLabel_

const std::string RawPCCProducer::csvOutLabel_
private

Definition at line 49 of file RawPCCProducer.cc.

Referenced by globalEndLuminosityBlockProduce().

◆ fileLock_

std::mutex RawPCCProducer::fileLock_
mutableprivate

Definition at line 50 of file RawPCCProducer.cc.

Referenced by globalEndLuminosityBlockProduce().

◆ modVeto_

const std::vector<int> RawPCCProducer::modVeto_
private

Definition at line 47 of file RawPCCProducer.cc.

Referenced by globalEndLuminosityBlockProduce().

◆ pccToken_

edm::EDGetTokenT<reco::PixelClusterCounts> RawPCCProducer::pccToken_
private

Definition at line 43 of file RawPCCProducer.cc.

Referenced by globalEndLuminosityBlockProduce().

◆ putToken_

const edm::EDPutTokenT<LumiInfo> RawPCCProducer::putToken_
private

Definition at line 44 of file RawPCCProducer.cc.

Referenced by globalEndLuminosityBlockProduce().

◆ saveCSVFile_

const bool RawPCCProducer::saveCSVFile_
private

Definition at line 51 of file RawPCCProducer.cc.

Referenced by globalEndLuminosityBlockProduce().

◆ takeAverageValue_

const std::string RawPCCProducer::takeAverageValue_
private

Definition at line 45 of file RawPCCProducer.cc.

Referenced by globalEndLuminosityBlockProduce().

edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
mps_fire.i
i
Definition: mps_fire.py:355
LumiInfo
Definition: LumiInfo.h:28
reco::PixelClusterCounts::readEvents
std::vector< int > const & readEvents() const
Definition: PixelClusterCounts.h:48
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
edm::Handle::product
T const * product() const
Definition: Handle.h:70
LumiConstants::numBX
static const unsigned int numBX
Definition: LumiConstants.h:8
reco::PixelClusterCounts::readCounts
std::vector< int > const & readCounts() const
Definition: PixelClusterCounts.h:47
edm::LogInfo
Definition: MessageLogger.h:254
RawPCCProducer::takeAverageValue_
const std::string takeAverageValue_
Definition: RawPCCProducer.cc:45
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::LuminosityBlockBase::run
RunNumber_t run() const
Definition: LuminosityBlockBase.h:42
patZpeak.events
events
Definition: patZpeak.py:20
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
reco::PixelClusterCounts
Definition: PixelClusterCounts.h:23
reco::PixelClusterCounts::readModID
std::vector< int > const & readModID() const
Definition: PixelClusterCounts.h:49
edm::Handle
Definition: AssociativeIterator.h:50
edm::LuminosityBlock::emplace
void emplace(EDPutTokenT< PROD > token, Args &&... args)
puts a new product
Definition: LuminosityBlock.h:246
simKBmtfDigis_cfi.bx
bx
Definition: simKBmtfDigis_cfi.py:55
RawPCCProducer::pccToken_
edm::EDGetTokenT< reco::PixelClusterCounts > pccToken_
Definition: RawPCCProducer.cc:43
LumiInfo::setTotalInstLumi
void setTotalInstLumi(float totalLumi)
Definition: LumiInfo.h:122
edm::LuminosityBlock::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: LuminosityBlock.h:318
LumiCorrectionsRcd
Definition: LumiCorrectionsRcd.h:23
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
LumiInfo::setInstLumiAllBX
void setInstLumiAllBX(std::vector< float > &instLumiByBX)
Definition: LumiInfo.cc:31
edm::LuminosityBlockBase::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: LuminosityBlockBase.h:40
LumiCorrections::getCorrectionsBX
const std::vector< float > & getCorrectionsBX() const
Definition: LumiCorrections.h:34
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
edm::ESHandle
Definition: DTSurvey.h:22
RawPCCProducer::modVeto_
const std::vector< int > modVeto_
Definition: RawPCCProducer.cc:47
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:36
CommonMethods.lock
def lock()
Definition: CommonMethods.py:82
createfilelist.int
int
Definition: createfilelist.py:10
RawPCCProducer::applyCorr_
const bool applyCorr_
Definition: RawPCCProducer.cc:53
LumiCorrections
Definition: LumiCorrections.h:22
LumiInfo::setTotalInstStatError
void setTotalInstStatError(float statError)
Definition: LumiInfo.h:126
get
#define get
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
RawPCCProducer::putToken_
const edm::EDPutTokenT< LumiInfo > putToken_
Definition: RawPCCProducer.cc:44
RawPCCProducer::saveCSVFile_
const bool saveCSVFile_
Definition: RawPCCProducer.cc:51
RawPCCProducer::fileLock_
std::mutex fileLock_
Definition: RawPCCProducer.cc:50
LumiInfo::setErrorLumiAllBX
void setErrorLumiAllBX(std::vector< float > &errLumiByBX)
Definition: LumiInfo.cc:35
RawPCCProducer::csvOutLabel_
const std::string csvOutLabel_
Definition: RawPCCProducer.cc:49
edm::InputTag
Definition: InputTag.h:15