CMS 3D CMS Logo

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

Public Member Functions

 RawPCCProducer (const edm::ParameterSet &)
 
 ~RawPCCProducer () override
 
- Public Member Functions inherited from edm::one::EDProducer< edm::EndLuminosityBlockProducer, edm::one::WatchLuminosityBlocks >
 EDProducer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () 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
 
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)
 
 ~ProducerBase () 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void beginLuminosityBlock (edm::LuminosityBlock const &lumiSeg, const edm::EventSetup &iSetup) final
 
void endLuminosityBlock (edm::LuminosityBlock const &lumiSeg, const edm::EventSetup &iSetup) final
 
void endLuminosityBlockProduce (edm::LuminosityBlock &lumiSeg, const edm::EventSetup &iSetup) final
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) final
 

Private Attributes

bool applyCorr_
 
std::vector< int > clustersPerBXInput_
 
std::vector< int > clustersPerBXOutput_
 
std::vector< float > corrClustersPerBXOutput_
 
std::vector< float > correctionScaleFactors_
 
std::ofstream csvfile
 
std::string csvOutLabel_
 
std::vector< float > errorPerBX_
 
std::vector< int > events_
 
std::vector< int > goodMods_
 
std::vector< int > modID_
 
std::vector< int > modVeto_
 
std::unique_ptr< LumiInfooutputLumiInfo
 
std::string outputProductName_
 
std::string pccSource_
 
edm::EDGetTokenT< reco::PixelClusterCountspccToken
 
std::string prodInst_
 
bool saveCSVFile_
 
float statErrOnLumi_
 
std::string takeAverageValue_
 
float totalLumi_
 

Additional Inherited Members

- Public Types inherited from edm::one::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::one::EDProducerBase
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


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 33 of file RawPCCProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 75 of file RawPCCProducer.cc.

References applyCorr_, clustersPerBXOutput_, corrClustersPerBXOutput_, correctionScaleFactors_, csvOutLabel_, edm::ParameterSet::getParameter(), modVeto_, LumiConstants::numBX, outputProductName_, pccSource_, pccToken, prodInst_, saveCSVFile_, AlCaHLTBitMon_QueryRunRegistry::string, and takeAverageValue_.

76 {
77  pccSource_ = iConfig.getParameter<edm::ParameterSet>("RawPCCProducerParameters").getParameter<std::string>("inputPccLabel");
78  prodInst_ = iConfig.getParameter<edm::ParameterSet>("RawPCCProducerParameters").getParameter<std::string>("ProdInst");
79  takeAverageValue_ = iConfig.getParameter<edm::ParameterSet>("RawPCCProducerParameters").getUntrackedParameter<std::string>("OutputValue",std::string("Totals"));
80  outputProductName_ = iConfig.getParameter<edm::ParameterSet>("RawPCCProducerParameters").getUntrackedParameter<std::string>("outputProductName","alcaLumi");
81  modVeto_ = iConfig.getParameter<edm::ParameterSet>("RawPCCProducerParameters").getParameter<std::vector<int>>("modVeto");
82  applyCorr_ = iConfig.getParameter<edm::ParameterSet>("RawPCCProducerParameters").getUntrackedParameter<bool>("ApplyCorrections",false);
83  saveCSVFile_ = iConfig.getParameter<edm::ParameterSet>("RawPCCProducerParameters").getUntrackedParameter<bool>("saveCSVFile",false);
84  csvOutLabel_ = iConfig.getParameter<edm::ParameterSet>("RawPCCProducerParameters").getUntrackedParameter<std::string>("label",std::string("rawPCC.csv"));
85 
86  edm::InputTag PCCInputTag_(pccSource_, prodInst_);
87  clustersPerBXOutput_.resize(LumiConstants::numBX,0);//vector containing clusters per bxid
88  corrClustersPerBXOutput_.resize(LumiConstants::numBX,0);//vector containing clusters per bxid
89  pccToken=consumes<reco::PixelClusterCounts, edm::InLumi>(PCCInputTag_);
90  produces<LumiInfo, edm::Transition::EndLuminosityBlock>(outputProductName_);
91 
92  if(!applyCorr_){
94  }
95 }
T getParameter(std::string const &) const
std::vector< int > modVeto_
std::vector< float > correctionScaleFactors_
static const unsigned int numBX
Definition: LumiConstants.h:9
std::string prodInst_
std::string outputProductName_
std::string takeAverageValue_
std::vector< int > clustersPerBXOutput_
std::string csvOutLabel_
std::string pccSource_
edm::EDGetTokenT< reco::PixelClusterCounts > pccToken
std::vector< float > corrClustersPerBXOutput_
RawPCCProducer::~RawPCCProducer ( )
override

Definition at line 98 of file RawPCCProducer.cc.

98  {
99 }

Member Function Documentation

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

Definition at line 108 of file RawPCCProducer.cc.

References csvfile, csvOutLabel_, edm::LuminosityBlockBase::luminosityBlock(), outputLumiInfo, edm::LuminosityBlockBase::run(), and saveCSVFile_.

108  {
109 
110  outputLumiInfo = std::make_unique<LumiInfo>();
111 
112  if(saveCSVFile_){
113  csvfile.open(csvOutLabel_, std::ios_base::app);
114  csvfile<<std::to_string(lumiSeg.run())<<",";
115  csvfile<<std::to_string(lumiSeg.luminosityBlock())<<",";
116  }
117 }
std::unique_ptr< LumiInfo > outputLumiInfo
std::string csvOutLabel_
std::ofstream csvfile
void RawPCCProducer::endLuminosityBlock ( edm::LuminosityBlock const &  lumiSeg,
const edm::EventSetup iSetup 
)
finalprivate

Definition at line 120 of file RawPCCProducer.cc.

References applyCorr_, clustersPerBXInput_, clustersPerBXOutput_, corrClustersPerBXOutput_, correctionScaleFactors_, csvfile, errorPerBX_, events_, lumiContext::fill, spr::find(), objects.autophobj::float, edm::EventSetup::get(), edm::LuminosityBlock::getByToken(), LumiCorrections::getCorrectionsBX(), goodMods_, mps_fire::i, createfilelist::int, modID_, modVeto_, LumiConstants::numBX, outputLumiInfo, pccToken, edm::Handle< T >::product(), edm::ESHandle< T >::product(), reco::PixelClusterCounts::readCounts(), reco::PixelClusterCounts::readEvents(), reco::PixelClusterCounts::readModID(), saveCSVFile_, statErrOnLumi_, takeAverageValue_, and totalLumi_.

120  {
121  totalLumi_=0.0;
122  statErrOnLumi_=0.0;
123 
126 
127  goodMods_.clear();
128 
130  lumiSeg.getByToken(pccToken,pccHandle);
131 
132  const reco::PixelClusterCounts& inputPcc = *(pccHandle.product());
133 
134  modID_ = inputPcc.readModID();
135  events_= inputPcc.readEvents();
136  clustersPerBXInput_ = inputPcc.readCounts();
137 
138  //making list of modules to sum over
139  for (unsigned int i=0;i<modID_.size();i++){
140  if (std::find(modVeto_.begin(),modVeto_.end(), modID_.at(i)) == modVeto_.end()){
141  goodMods_.push_back(i);
142  }
143  }
144 
145  //summing over good modules only
146  for (int bx=0;bx<int(LumiConstants::numBX);bx++){
147  for (unsigned int i=0;i<goodMods_.size();i++){
149 
150  }
151  }
152 
153  if(applyCorr_){
155  iSetup.get<LumiCorrectionsRcd>().get(corrHandle);
156  const LumiCorrections *pccCorrections = corrHandle.product();
157  correctionScaleFactors_ = pccCorrections->getCorrectionsBX();
158  }
159 
160  for (unsigned int i=0;i<clustersPerBXOutput_.size();i++){
161  if (events_.at(i)!=0){
163  }else{
165  }
168  }
169 
170  errorPerBX_.clear();
171  errorPerBX_.assign(events_.begin(),events_.end());
172 
173  if(takeAverageValue_=="Average"){
174  unsigned int NActiveBX=0;
175  for (int bx=0;bx<int(LumiConstants::numBX);bx++){
176  if(events_[bx]>0){
177  NActiveBX++;
178  // Counting where events are will only work
179  // for ZeroBias or AlwaysTrue triggers.
180  // Random triggers will get all BXs.
182  errorPerBX_[bx]=1/TMath::Sqrt(float(events_[bx]));
183  }
184  }
185  if (statErrOnLumi_!=0) {
188  }
189  }
190 
191 
192  outputLumiInfo->setTotalInstLumi(totalLumi_);
193  outputLumiInfo->setTotalInstStatError(statErrOnLumi_);
194 
195  outputLumiInfo->setErrorLumiAllBX(errorPerBX_);
196  outputLumiInfo->setInstLumiAllBX(corrClustersPerBXOutput_);
197 
198  if(saveCSVFile_){
199  csvfile<<std::to_string(totalLumi_);
200 
201  if(totalLumi_>0){
202  for(unsigned int bx=0;bx<LumiConstants::numBX;bx++){
203  csvfile<<","<<std::to_string(corrClustersPerBXOutput_[bx]);
204  }
205  csvfile<<std::endl;
206  } else if (totalLumi_<0) {
207  edm::LogInfo("WARNING")<<"WHY IS LUMI NEGATIVE?!?!?!? "<<totalLumi_;
208  }
209 
210  csvfile.close();
211  }
212 }
std::vector< int > modVeto_
std::vector< float > correctionScaleFactors_
std::unique_ptr< LumiInfo > outputLumiInfo
static const unsigned int numBX
Definition: LumiConstants.h:9
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::vector< int > clustersPerBXInput_
std::vector< int > const & readCounts() const
std::vector< int > goodMods_
std::vector< int > const & readModID() const
std::string takeAverageValue_
std::vector< int > modID_
std::vector< int > clustersPerBXOutput_
T const * product() const
Definition: Handle.h:81
const std::vector< float > & getCorrectionsBX() const
const T & get() const
Definition: EventSetup.h:59
edm::EDGetTokenT< reco::PixelClusterCounts > pccToken
std::vector< float > errorPerBX_
T const * product() const
Definition: ESHandle.h:86
std::ofstream csvfile
std::vector< int > events_
std::vector< int > const & readEvents() const
std::vector< float > corrClustersPerBXOutput_
void RawPCCProducer::endLuminosityBlockProduce ( edm::LuminosityBlock lumiSeg,
const edm::EventSetup iSetup 
)
finalprivate

Definition at line 215 of file RawPCCProducer.cc.

References DEFINE_FWK_MODULE, eostools::move(), outputLumiInfo, outputProductName_, edm::LuminosityBlock::put(), and AlCaHLTBitMon_QueryRunRegistry::string.

215  {
217 
218 }
std::unique_ptr< LumiInfo > outputLumiInfo
void put(std::unique_ptr< PROD > product)
Put a new product.
std::string outputProductName_
def move(src, dest)
Definition: eostools.py:510
void RawPCCProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
finalprivate

Definition at line 102 of file RawPCCProducer.cc.

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

102  {
103 
104 
105 }

Member Data Documentation

bool RawPCCProducer::applyCorr_
private

Definition at line 66 of file RawPCCProducer.cc.

Referenced by endLuminosityBlock(), and RawPCCProducer().

std::vector<int> RawPCCProducer::clustersPerBXInput_
private

Definition at line 53 of file RawPCCProducer.cc.

Referenced by endLuminosityBlock().

std::vector<int> RawPCCProducer::clustersPerBXOutput_
private

Definition at line 56 of file RawPCCProducer.cc.

Referenced by endLuminosityBlock(), and RawPCCProducer().

std::vector<float> RawPCCProducer::corrClustersPerBXOutput_
private

Definition at line 57 of file RawPCCProducer.cc.

Referenced by endLuminosityBlock(), and RawPCCProducer().

std::vector<float> RawPCCProducer::correctionScaleFactors_
private

Definition at line 67 of file RawPCCProducer.cc.

Referenced by endLuminosityBlock(), and RawPCCProducer().

std::ofstream RawPCCProducer::csvfile
private

Definition at line 71 of file RawPCCProducer.cc.

Referenced by beginLuminosityBlock(), and endLuminosityBlock().

std::string RawPCCProducer::csvOutLabel_
private

Definition at line 63 of file RawPCCProducer.cc.

Referenced by beginLuminosityBlock(), and RawPCCProducer().

std::vector<float> RawPCCProducer::errorPerBX_
private

Definition at line 58 of file RawPCCProducer.cc.

Referenced by endLuminosityBlock().

std::vector<int> RawPCCProducer::events_
private

Definition at line 55 of file RawPCCProducer.cc.

Referenced by endLuminosityBlock().

std::vector<int> RawPCCProducer::goodMods_
private

Definition at line 59 of file RawPCCProducer.cc.

Referenced by endLuminosityBlock().

std::vector<int> RawPCCProducer::modID_
private

Definition at line 54 of file RawPCCProducer.cc.

Referenced by endLuminosityBlock().

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

Definition at line 51 of file RawPCCProducer.cc.

Referenced by endLuminosityBlock(), and RawPCCProducer().

std::unique_ptr<LumiInfo> RawPCCProducer::outputLumiInfo
private
std::string RawPCCProducer::outputProductName_
private

Definition at line 52 of file RawPCCProducer.cc.

Referenced by endLuminosityBlockProduce(), and RawPCCProducer().

std::string RawPCCProducer::pccSource_
private

Definition at line 47 of file RawPCCProducer.cc.

Referenced by RawPCCProducer().

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

Definition at line 46 of file RawPCCProducer.cc.

Referenced by endLuminosityBlock(), and RawPCCProducer().

std::string RawPCCProducer::prodInst_
private

Definition at line 48 of file RawPCCProducer.cc.

Referenced by RawPCCProducer().

bool RawPCCProducer::saveCSVFile_
private

Definition at line 64 of file RawPCCProducer.cc.

Referenced by beginLuminosityBlock(), endLuminosityBlock(), and RawPCCProducer().

float RawPCCProducer::statErrOnLumi_
private

Definition at line 61 of file RawPCCProducer.cc.

Referenced by endLuminosityBlock().

std::string RawPCCProducer::takeAverageValue_
private

Definition at line 49 of file RawPCCProducer.cc.

Referenced by endLuminosityBlock(), and RawPCCProducer().

float RawPCCProducer::totalLumi_
private

Definition at line 60 of file RawPCCProducer.cc.

Referenced by endLuminosityBlock().