CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
SiStripApvGainRescaler Class Reference

#include <CondTools/SiStrip/plugins/SiStripApvGainRescaler.cc>

Inheritance diagram for SiStripApvGainRescaler:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 SiStripApvGainRescaler (const edm::ParameterSet &)
 
 ~SiStripApvGainRescaler () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
std::unique_ptr< SiStripApvGaingetNewObject (const std::map< std::pair< uint32_t, int >, float > &theMap)
 

Private Attributes

const edm::ESGetToken< SiStripGain, SiStripGainRcdg1g2Token_
 
const edm::ESGetToken< SiStripApvGain, SiStripApvGain3Rcdg3Token_
 
const uint32_t m_printdebug
 
const std::string m_Record
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Description: Utility class to rescale the values of SiStrip G2 by the ratio of G1_old/G1_new: this is useful in the case in which a Gain2 payload needs to recycled after a G1 update to keep the G1*G2 product constant

Implementation: [Notes on implementation]

Definition at line 45 of file SiStripApvGainRescaler.cc.

Constructor & Destructor Documentation

◆ SiStripApvGainRescaler()

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

Definition at line 69 of file SiStripApvGainRescaler.cc.

References edm::ParameterSet::getUntrackedParameter().

70  : m_printdebug{iConfig.getUntrackedParameter<uint32_t>("printDebug", 1)},
71  m_Record(iConfig.getParameter<std::string>("Record")),
73  g3Token_(esConsumes()) {}
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
T getUntrackedParameter(std::string const &, T const &) const
const edm::ESGetToken< SiStripApvGain, SiStripApvGain3Rcd > g3Token_
const edm::ESGetToken< SiStripGain, SiStripGainRcd > g1g2Token_

◆ ~SiStripApvGainRescaler()

SiStripApvGainRescaler::~SiStripApvGainRescaler ( )
overridedefault

Member Function Documentation

◆ analyze()

void SiStripApvGainRescaler::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 81 of file SiStripApvGainRescaler.cc.

References cond::service::PoolDBOutputService::currentTime(), ztail::d, g1g2Token_, g3Token_, edm::EventSetup::getData(), getNewObject(), edm::Service< T >::isAvailable(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, m_Record, and cond::service::PoolDBOutputService::writeOneIOV().

81  {
82  using namespace edm;
83 
84  const auto& g1g2 = iSetup.getData(g1g2Token_);
85  const auto& g3 = iSetup.getData(g3Token_);
86 
87  std::map<std::pair<uint32_t, int>, float> theMap;
88 
89  std::vector<uint32_t> detid;
90  g1g2.getDetIds(detid);
91  for (const auto& d : detid) {
92  SiStripApvGain::Range rangeG1_old = g1g2.getRange(d, 0);
93  SiStripApvGain::Range rangeG2_old = g1g2.getRange(d, 1);
94  SiStripApvGain::Range rangeG1_new = g3.getRange(d);
95 
96  int nAPV = 0;
97  for (int it = 0; it < rangeG1_old.second - rangeG1_old.first; it++) {
98  nAPV++;
99 
100  std::pair<uint32_t, int> index = std::make_pair(d, nAPV);
101 
102  float G1_old = g1g2.getApvGain(it, rangeG1_old);
103  float G2_old = g1g2.getApvGain(it, rangeG2_old);
104  float G1G2_old = G1_old * G2_old;
105  float G1_new = g3.getApvGain(it, rangeG1_new);
106 
107  // this is based on G1_old*G2_old = G1_new * G2_new ==> G2_new = (G1_old*G2_old)/G1_new
108 
109  float NewGain = G1G2_old / G1_new;
110 
111  // DO NOT RESCALE APVs set to the default value
112  if (G2_old != 1.) {
113  theMap[index] = NewGain;
114  } else {
115  theMap[index] = 1.;
116  }
117 
118  } // loop over APVs
119  } // loop over DetIds
120 
121  std::unique_ptr<SiStripApvGain> theAPVGains = this->getNewObject(theMap);
122 
123  // write out the APVGains record
125 
126  if (poolDbService.isAvailable())
127  poolDbService->writeOneIOV(*theAPVGains, poolDbService->currentTime(), m_Record);
128  else
129  throw std::runtime_error("PoolDBService required.");
130 }
std::unique_ptr< SiStripApvGain > getNewObject(const std::map< std::pair< uint32_t, int >, float > &theMap)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
std::pair< ContainerIterator, ContainerIterator > Range
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
d
Definition: ztail.py:151
const edm::ESGetToken< SiStripApvGain, SiStripApvGain3Rcd > g3Token_
HLT enums.
bool isAvailable() const
Definition: Service.h:40
const edm::ESGetToken< SiStripGain, SiStripGainRcd > g1g2Token_

◆ fillDescriptions()

void SiStripApvGainRescaler::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 170 of file SiStripApvGainRescaler.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

170  {
172 
173  desc.setComment(
174  " Utility class to rescale the values of SiStrip G2 by the ratio of G1_old/G1_new: this is useful in the case in "
175  "which a Gain2 payload needs to recycled after a G1 update to keep the G1*G2 product constant."
176  "PoolDBOutputService must be set up for 'SiStripApvGainRcd'.");
177 
178  desc.add<std::string>("Record", "SiStripApvGainRcd");
179  desc.addUntracked<unsigned int>("printDebug", 1);
180  descriptions.add("rescaleGain2byGain1", desc);
181 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ getNewObject()

std::unique_ptr< SiStripApvGain > SiStripApvGainRescaler::getNewObject ( const std::map< std::pair< uint32_t, int >, float > &  theMap)
private

Definition at line 133 of file SiStripApvGainRescaler.cc.

References m_printdebug, getGTfromDQMFile::obj, and FastTimerService_cff::range.

Referenced by analyze().

134  {
135  std::unique_ptr<SiStripApvGain> obj = std::make_unique<SiStripApvGain>();
136 
137  std::vector<float> theSiStripVector;
138  uint32_t PreviousDetId = 0;
139  unsigned int countDetIds(0); // count DetIds to print
140  for (const auto& element : theMap) {
141  uint32_t DetId = element.first.first;
142  if (DetId != PreviousDetId) {
143  if (!theSiStripVector.empty()) {
144  SiStripApvGain::Range range(theSiStripVector.begin(), theSiStripVector.end());
145  if (!obj->put(PreviousDetId, range))
146  edm::LogError("SiStripApvGainRescaler") << "Bug to put detId = " << PreviousDetId << "\n";
147  }
148  theSiStripVector.clear();
149  PreviousDetId = DetId;
150  countDetIds++;
151  }
152  theSiStripVector.push_back(element.second);
153 
154  if (countDetIds <= m_printdebug) {
155  edm::LogInfo("SiStripApvGainRescaler")
156  << __FUNCTION__ << " DetId: " << DetId << " APV: " << element.first.second << " Gain: " << element.second;
157  }
158  }
159 
160  if (!theSiStripVector.empty()) {
161  SiStripApvGain::Range range(theSiStripVector.begin(), theSiStripVector.end());
162  if (!obj->put(PreviousDetId, range))
163  edm::LogError("SiStripApvGainRescaler") << "Bug to put detId = " << PreviousDetId << "\n";
164  }
165 
166  return obj;
167 }
std::pair< ContainerIterator, ContainerIterator > Range
Log< level::Info, false > LogInfo
Definition: DetId.h:17

Member Data Documentation

◆ g1g2Token_

const edm::ESGetToken<SiStripGain, SiStripGainRcd> SiStripApvGainRescaler::g1g2Token_
private

Definition at line 61 of file SiStripApvGainRescaler.cc.

Referenced by analyze().

◆ g3Token_

const edm::ESGetToken<SiStripApvGain, SiStripApvGain3Rcd> SiStripApvGainRescaler::g3Token_
private

Definition at line 63 of file SiStripApvGainRescaler.cc.

Referenced by analyze().

◆ m_printdebug

const uint32_t SiStripApvGainRescaler::m_printdebug
private

Definition at line 57 of file SiStripApvGainRescaler.cc.

Referenced by getNewObject().

◆ m_Record

const std::string SiStripApvGainRescaler::m_Record
private

Definition at line 58 of file SiStripApvGainRescaler.cc.

Referenced by analyze().