CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
 
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::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
 
bool registeredToConsumeMany (TypeID const &, 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::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

const edm::ESGetToken
< SiStripGain, SiStripGainRcd
g1g2Token_
 
const edm::ESGetToken
< SiStripApvGain,
SiStripApvGain3Rcd
g3Token_
 
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< B > consumes (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 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)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
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...
 
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 ( const edm::ParameterSet iConfig)
explicit

Definition at line 70 of file SiStripApvGainRescaler.cc.

72  //now do what ever initialization is needed
73 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::ESGetToken< SiStripApvGain, SiStripApvGain3Rcd > g3Token_
const edm::ESGetToken< SiStripGain, SiStripGainRcd > g1g2Token_
SiStripApvGainRescaler::~SiStripApvGainRescaler ( )
overridedefault

Member Function Documentation

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 ztail::d, g1g2Token_, g3Token_, edm::EventSetup::getData(), getNewObject(), 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)
bool getData(T &iHolder) const
Definition: EventSetup.h:128
tuple d
Definition: ztail.py:151
std::pair< ContainerIterator, ContainerIterator > Range
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
const edm::ESGetToken< SiStripApvGain, SiStripApvGain3Rcd > g3Token_
const edm::ESGetToken< SiStripGain, SiStripGainRcd > g1g2Token_
void SiStripApvGainRescaler::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 133 of file SiStripApvGainRescaler.cc.

133 {}
void SiStripApvGainRescaler::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 136 of file SiStripApvGainRescaler.cc.

136 {}
void SiStripApvGainRescaler::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 172 of file SiStripApvGainRescaler.cc.

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

172  {
174 
175  desc.setComment(
176  " Utility class to rescale the values of SiStrip G2 by the ratio of G1_old/G1_new: this is useful in the case in "
177  "which a Gain2 payload needs to recycled after a G1 update to keep the G1*G2 product constant."
178  "PoolDBOutputService must be set up for 'SiStripApvGainRcd'.");
179 
180  desc.add<std::string>("Record", "SiStripApvGainRcd");
181  descriptions.add("rescaleGain2byGain1", desc);
182 }
void setComment(std::string const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::unique_ptr< SiStripApvGain > SiStripApvGainRescaler::getNewObject ( const std::map< std::pair< uint32_t, int >, float > &  theMap)
private

Definition at line 139 of file SiStripApvGainRescaler.cc.

References getGTfromDQMFile::obj, gpuVertexFinder::printf(), and sistrip::SpyUtilities::range().

Referenced by analyze().

140  {
141  std::unique_ptr<SiStripApvGain> obj = std::make_unique<SiStripApvGain>();
142 
143  std::vector<float> theSiStripVector;
144  uint32_t PreviousDetId = 0;
145  for (const auto& element : theMap) {
146  uint32_t DetId = element.first.first;
147  if (DetId != PreviousDetId) {
148  if (!theSiStripVector.empty()) {
149  SiStripApvGain::Range range(theSiStripVector.begin(), theSiStripVector.end());
150  if (!obj->put(PreviousDetId, range))
151  printf("Bug to put detId = %i\n", PreviousDetId);
152  }
153  theSiStripVector.clear();
154  PreviousDetId = DetId;
155  }
156  theSiStripVector.push_back(element.second);
157 
158  edm::LogInfo("SiStripApvGainRescaler")
159  << " DetId: " << DetId << " APV: " << element.first.second << " Gain: " << element.second << std::endl;
160  }
161 
162  if (!theSiStripVector.empty()) {
163  SiStripApvGain::Range range(theSiStripVector.begin(), theSiStripVector.end());
164  if (!obj->put(PreviousDetId, range))
165  printf("Bug to put detId = %i\n", PreviousDetId);
166  }
167 
168  return obj;
169 }
const uint16_t range(const Frame &aFrame)
printf("params %d %f %f %f\n", minT, eps, errmax, chi2max)
std::pair< ContainerIterator, ContainerIterator > Range
Log< level::Info, false > LogInfo
Definition: DetId.h:17

Member Data Documentation

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

Definition at line 62 of file SiStripApvGainRescaler.cc.

Referenced by analyze().

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

Definition at line 64 of file SiStripApvGainRescaler.cc.

Referenced by analyze().

const std::string SiStripApvGainRescaler::m_Record
private

Definition at line 59 of file SiStripApvGainRescaler.cc.

Referenced by analyze().