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
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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::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)
 

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
 
void beginJob () override
 
void endJob () override
 
std::unique_ptr< SiStripApvGaingetNewObject (const std::map< std::pair< uint32_t, int >, float > &theMap)
 

Private Attributes

edm::ESGetToken< SiStripGain, SiStripGainRcdg1g2Token_
 
edm::ESGetToken< SiStripApvGain, SiStripApvGain3Rcdg3Token_
 
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
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 = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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

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 70 of file SiStripApvGainRescaler.cc.

72  //now do what ever initialization is needed
73 }

◆ ~SiStripApvGainRescaler()

SiStripApvGainRescaler::~SiStripApvGainRescaler ( )
override

Definition at line 75 of file SiStripApvGainRescaler.cc.

75  {
76  // do anything here that needs to be done at desctruction time
77  // (e.g. close files, deallocate resources etc.)
78 }

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 85 of file SiStripApvGainRescaler.cc.

85  {
86  using namespace edm;
87 
88  const auto& g1g2 = iSetup.getData(g1g2Token_);
89  const auto& g3 = iSetup.getData(g3Token_);
90 
91  std::map<std::pair<uint32_t, int>, float> theMap;
92 
93  std::vector<uint32_t> detid;
94  g1g2.getDetIds(detid);
95  for (const auto& d : detid) {
96  SiStripApvGain::Range rangeG1_old = g1g2.getRange(d, 0);
97  SiStripApvGain::Range rangeG2_old = g1g2.getRange(d, 1);
98  SiStripApvGain::Range rangeG1_new = g3.getRange(d);
99 
100  int nAPV = 0;
101  for (int it = 0; it < rangeG1_old.second - rangeG1_old.first; it++) {
102  nAPV++;
103 
104  std::pair<uint32_t, int> index = std::make_pair(d, nAPV);
105 
106  float G1_old = g1g2.getApvGain(it, rangeG1_old);
107  float G2_old = g1g2.getApvGain(it, rangeG2_old);
108  float G1G2_old = G1_old * G2_old;
109  float G1_new = g3.getApvGain(it, rangeG1_new);
110 
111  // this is based on G1_old*G2_old = G1_new * G2_new ==> G2_new = (G1_old*G2_old)/G1_new
112 
113  float NewGain = G1G2_old / G1_new;
114 
115  // DO NOT RESCALE APVs set to the default value
116  if (G2_old != 1.) {
117  theMap[index] = NewGain;
118  } else {
119  theMap[index] = 1.;
120  }
121 
122  } // loop over APVs
123  } // loop over DetIds
124 
125  std::unique_ptr<SiStripApvGain> theAPVGains = this->getNewObject(theMap);
126 
127  // write out the APVGains record
129 
130  if (poolDbService.isAvailable())
131  poolDbService->writeOne(theAPVGains.get(), poolDbService->currentTime(), m_Record);
132  else
133  throw std::runtime_error("PoolDBService required.");
134 }

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

◆ beginJob()

void SiStripApvGainRescaler::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 137 of file SiStripApvGainRescaler.cc.

137 {}

◆ endJob()

void SiStripApvGainRescaler::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 140 of file SiStripApvGainRescaler.cc.

140 {}

◆ fillDescriptions()

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

Definition at line 176 of file SiStripApvGainRescaler.cc.

176  {
178 
179  desc.setComment(
180  " Utility class to rescale the values of SiStrip G2 by the ratio of G1_old/G1_new: this is useful in the case in "
181  "which a Gain2 payload needs to recycled after a G1 update to keep the G1*G2 product constant."
182  "PoolDBOutputService must be set up for 'SiStripApvGainRcd'.");
183 
184  desc.add<std::string>("Record", "SiStripApvGainRcd");
185  descriptions.add("rescaleGain2byGain1", desc);
186 }

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

◆ getNewObject()

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

Definition at line 143 of file SiStripApvGainRescaler.cc.

144  {
145  std::unique_ptr<SiStripApvGain> obj = std::make_unique<SiStripApvGain>();
146 
147  std::vector<float> theSiStripVector;
148  uint32_t PreviousDetId = 0;
149  for (const auto& element : theMap) {
150  uint32_t DetId = element.first.first;
151  if (DetId != PreviousDetId) {
152  if (!theSiStripVector.empty()) {
153  SiStripApvGain::Range range(theSiStripVector.begin(), theSiStripVector.end());
154  if (!obj->put(PreviousDetId, range))
155  printf("Bug to put detId = %i\n", PreviousDetId);
156  }
157  theSiStripVector.clear();
158  PreviousDetId = DetId;
159  }
160  theSiStripVector.push_back(element.second);
161 
162  edm::LogInfo("SiStripApvGainRescaler")
163  << " DetId: " << DetId << " APV: " << element.first.second << " Gain: " << element.second << std::endl;
164  }
165 
166  if (!theSiStripVector.empty()) {
167  SiStripApvGain::Range range(theSiStripVector.begin(), theSiStripVector.end());
168  if (!obj->put(PreviousDetId, range))
169  printf("Bug to put detId = %i\n", PreviousDetId);
170  }
171 
172  return obj;
173 }

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

Referenced by analyze().

Member Data Documentation

◆ g1g2Token_

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

Definition at line 62 of file SiStripApvGainRescaler.cc.

Referenced by analyze().

◆ g3Token_

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

Definition at line 64 of file SiStripApvGainRescaler.cc.

Referenced by analyze().

◆ m_Record

const std::string SiStripApvGainRescaler::m_Record
private

Definition at line 59 of file SiStripApvGainRescaler.cc.

Referenced by analyze().

FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
SiStripApvGainRescaler::g1g2Token_
edm::ESGetToken< SiStripGain, SiStripGainRcd > g1g2Token_
Definition: SiStripApvGainRescaler.cc:62
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
DetId
Definition: DetId.h:17
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
SiStripApvGainRescaler::getNewObject
std::unique_ptr< SiStripApvGain > getNewObject(const std::map< std::pair< uint32_t, int >, float > &theMap)
Definition: SiStripApvGainRescaler.cc:143
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::Service< cond::service::PoolDBOutputService >
SiStripApvGainRescaler::m_Record
const std::string m_Record
Definition: SiStripApvGainRescaler.cc:59
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:120
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
SiStripApvGain::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripApvGain.h:28
cond::service::PoolDBOutputService::writeOne
Hash writeOne(const T *payload, Time_t time, const std::string &recordName)
Definition: PoolDBOutputService.h:63
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
edm::EDConsumerBase::esConsumes
auto esConsumes()
Definition: EDConsumerBase.h:200
ztail.d
d
Definition: ztail.py:151
SiStripApvGainRescaler::g3Token_
edm::ESGetToken< SiStripApvGain, SiStripApvGain3Rcd > g3Token_
Definition: SiStripApvGainRescaler.cc:64
cond::service::PoolDBOutputService::currentTime
cond::Time_t currentTime() const
Definition: PoolDBOutputService.cc:217