CMS 3D CMS Logo

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

#include <CSCGasGainCorrectionDBConditions.h>

Inheritance diagram for CSCGasGainCorrectionDBConditions:
edm::ESProducer edm::EventSetupRecordIntervalFinder edm::ESProductResolverFactoryProducer edm::eventsetup::ESProductResolverProvider

Public Types

typedef std::unique_ptr< CSCDBGasGainCorrectionReturnType
 

Public Member Functions

 CSCGasGainCorrectionDBConditions (const edm::ParameterSet &)
 
ReturnType produceDBGasGainCorrection (const CSCDBGasGainCorrectionRcd &)
 
 ~CSCGasGainCorrectionDBConditions () override
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
 ESProducer (const ESProducer &)=delete
 
 ESProducer (ESProducer &&)=delete
 
ESResolverIndex const * getTokenIndices (unsigned int iIndex) const
 
ESRecordIndex const * getTokenRecordIndices (unsigned int iIndex) const
 
bool hasMayConsumes () const noexcept
 
size_t numberOfTokenIndices (unsigned int iIndex) const
 
ESProduceroperator= (const ESProducer &)=delete
 
ESProduceroperator= (ESProducer &&)=delete
 
SerialTaskQueueChainqueue ()
 
template<typename Record >
std::optional< std::vector< ESResolverIndex > > updateFromMayConsumes (unsigned int iIndex, const Record &iRecord) const
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &) final
 
 ~ESProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::ESProductResolverFactoryProducer
 ESProductResolverFactoryProducer ()
 
 ESProductResolverFactoryProducer (const ESProductResolverFactoryProducer &)=delete
 
const ESProductResolverFactoryProduceroperator= (const ESProductResolverFactoryProducer &)=delete
 
 ~ESProductResolverFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::ESProductResolverProvider
void createKeyedResolvers (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
const ComponentDescriptiondescription () const
 
 ESProductResolverProvider ()
 
 ESProductResolverProvider (const ESProductResolverProvider &)=delete
 
void fillRecordsNotAllowingConcurrentIOVs (std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
 
virtual void initConcurrentIOVs (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
bool isUsingRecord (const EventSetupRecordKey &key) const
 
KeyedResolverskeyedResolvers (const EventSetupRecordKey &iRecordKey, unsigned int iovIndex=0)
 
const ESProductResolverProvideroperator= (const ESProductResolverProvider &)=delete
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~ESProductResolverProvider () noexcept(false)
 
- Public Member Functions inherited from edm::EventSetupRecordIntervalFinder
bool concurrentFinder () const
 
const eventsetup::ComponentDescriptiondescriptionForFinder () const
 
 EventSetupRecordIntervalFinder ()
 
 EventSetupRecordIntervalFinder (const EventSetupRecordIntervalFinder &)=delete
 
std::set< eventsetup::EventSetupRecordKeyfindingForRecords () const
 
const ValidityIntervalfindIntervalFor (const eventsetup::EventSetupRecordKey &, const IOVSyncValue &)
 
bool nonconcurrentAndIOVNeedsUpdate (const eventsetup::EventSetupRecordKey &key, const IOVSyncValue &syncValue) const
 
const EventSetupRecordIntervalFinderoperator= (const EventSetupRecordIntervalFinder &)=delete
 
void resetInterval (const eventsetup::EventSetupRecordKey &)
 
void setDescriptionForFinder (const eventsetup::ComponentDescription &iDescription)
 
virtual ~EventSetupRecordIntervalFinder () noexcept(false)
 

Static Public Member Functions

static CSCDBGasGainCorrectionprefillDBGasGainCorrection (bool isForMC, std::string dataCorrFileName)
 
- Static Public Member Functions inherited from edm::eventsetup::ESProductResolverProvider
static void prevalidate (ConfigurationDescriptions &)
 

Private Member Functions

void setIntervalFor (const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
 

Private Attributes

std::string dataCorrFileName
 
bool isForMC
 

Additional Inherited Members

- Protected Types inherited from edm::ESProductResolverFactoryProducer
using EventSetupRecordKey = eventsetup::EventSetupRecordKey
 
- Protected Types inherited from edm::eventsetup::ESProductResolverProvider
using KeyedResolversVector = std::vector< std::pair< DataKey, std::shared_ptr< ESProductResolver > >>
 
- Protected Member Functions inherited from edm::ESProducer
ESConsumesInfoconsumesInfoPushBackNew ()
 
unsigned int consumesInfoSize () const
 
template<typename CallbackT , typename TList , typename TRecord >
void registerProducts (std::shared_ptr< std::pair< unsigned int, std::shared_ptr< CallbackT >>> iCallback, const TList *, const TRecord *iRecord, const es::Label &iLabel)
 
template<typename CallbackT , typename TRecord >
void registerProducts (std::shared_ptr< std::pair< unsigned int, std::shared_ptr< CallbackT >>>, const eventsetup::produce::Null *, const TRecord *, const es::Label &)
 
template<typename T >
auto setWhatProduced (T *iThis, const es::Label &iLabel={})
 
template<typename T >
auto setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
auto setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
auto setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord >
auto setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord , typename TDecorator >
auto setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const TDecorator &iDec, const es::Label &iLabel={})
 
template<typename TFunc >
auto setWhatProduced (TFunc &&func, const es::Label &iLabel={})
 
template<typename TReturn , typename TRecord , typename TFunc , typename TDecorator >
ESConsumesCollectorT< TRecord > setWhatProduced (TFunc &&func, TDecorator &&iDec, const es::Label &iLabel={})
 
void usesResources (std::vector< std::string > const &)
 
- Protected Member Functions inherited from edm::ESProductResolverFactoryProducer
template<class TFactory >
void registerFactory (std::unique_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ESProductResolverFactoryBase > iFactory, const std::string &iLabel=std::string())
 
KeyedResolversVector registerResolvers (const EventSetupRecordKey &, unsigned int iovIndex) override
 
- Protected Member Functions inherited from edm::eventsetup::ESProductResolverProvider
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &key)
 
- Protected Member Functions inherited from edm::EventSetupRecordIntervalFinder
template<class T >
void findingRecord ()
 
void findingRecordWithKey (const eventsetup::EventSetupRecordKey &)
 

Detailed Description

Definition at line 21 of file CSCGasGainCorrectionDBConditions.h.

Member Typedef Documentation

◆ ReturnType

Definition at line 28 of file CSCGasGainCorrectionDBConditions.h.

Constructor & Destructor Documentation

◆ CSCGasGainCorrectionDBConditions()

CSCGasGainCorrectionDBConditions::CSCGasGainCorrectionDBConditions ( const edm::ParameterSet iConfig)

Definition at line 8 of file CSCGasGainCorrectionDBConditions.cc.

References dataCorrFileName, edm::ParameterSet::getUntrackedParameter(), isForMC, produceDBGasGainCorrection(), edm::ESProducer::setWhatProduced(), and AlCaHLTBitMon_QueryRunRegistry::string.

8  {
9  // the following line is needed to tell the framework what
10  // data is being produced
11  isForMC = iConfig.getUntrackedParameter<bool>("isForMC", true);
12  dataCorrFileName = iConfig.getUntrackedParameter<std::string>("dataCorrFileName", "empty.txt");
13  // added by Zhen (changed since 1_2_0)
15  findingRecord<CSCDBGasGainCorrectionRcd>();
16  // now do what ever other initialization is needed
17 }
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:166
T getUntrackedParameter(std::string const &, T const &) const
ReturnType produceDBGasGainCorrection(const CSCDBGasGainCorrectionRcd &)

◆ ~CSCGasGainCorrectionDBConditions()

CSCGasGainCorrectionDBConditions::~CSCGasGainCorrectionDBConditions ( )
override

Definition at line 19 of file CSCGasGainCorrectionDBConditions.cc.

19  {
20  // do anything here that needs to be done at desctruction time
21  // (e.g. close files, deallocate resources etc.)
22 }

Member Function Documentation

◆ prefillDBGasGainCorrection()

CSCDBGasGainCorrection * CSCGasGainCorrectionDBConditions::prefillDBGasGainCorrection ( bool  isForMC,
std::string  dataCorrFileName 
)
inlinestatic

Definition at line 53 of file CSCGasGainCorrectionDBConditions.h.

References cms::cuda::assert(), relativeConstraints::chamber, RPCNoise_example::check, gather_cfg::cout, makeMuonMisalignmentScenario::endcap, corrVsCorr::filename, groupFilesInBlocks::fin, ecalph2::gains, CSCDBGasGainCorrection::gasGainCorr, mps_fire::i, DiMuonV_cfg::isMC, dqmiolumiharvest::j, nano_mu_digi_cff::layer, pixelgpudetails::MAX_SIZE, SiStripPI::mean, relativeConstraints::ring, and relativeConstraints::station.

Referenced by produceDBGasGainCorrection().

54  {
55  if (isMC)
56  printf("\n Generating fake DB constants for MC\n");
57  else {
58  printf("\n Reading gas gain corrections from file %s \n", filename.data());
59  }
60 
61  CSCIndexer indexer;
62 
63  const int MAX_SIZE = 55944;
64 
65  CSCDBGasGainCorrection *cndbGasGainCorr = new CSCDBGasGainCorrection();
66 
67  CSCDBGasGainCorrection::GasGainContainer &itemvector = cndbGasGainCorr->gasGainCorr;
68  itemvector.resize(MAX_SIZE);
69 
70  // Filling corrections for MC is very simple
71  if (isMC) {
72  for (int i = 0; i < MAX_SIZE; i++) {
73  itemvector[i].gainCorr = 1.;
74  }
75  return cndbGasGainCorr;
76  }
77 
78  struct gain_info {
79  int gas_gain_index;
80  int endcap;
81  int station;
82  int ring;
83  int chamber;
84  int layer;
85  int hvsegment;
86  int cfeb;
87  int nentries;
88  float mean;
89  float truncated_mean;
90  float gas_gain_correction;
91  } gains[MAX_SIZE];
92 
93  for (int j = 0; j < MAX_SIZE; j++) {
94  gains[j].gas_gain_index = -999;
95  gains[j].endcap = -999;
96  gains[j].station = -999;
97  gains[j].ring = -999;
98  gains[j].chamber = -999;
99  gains[j].layer = -999;
100  gains[j].hvsegment = -999;
101  gains[j].cfeb = -999;
102  gains[j].nentries = -999;
103  gains[j].mean = -999.;
104  gains[j].truncated_mean = -999.;
105  gains[j].gas_gain_correction = -999.;
106  }
107 
108  FILE *fin = fopen(filename.data(), "r");
109 
110  int linecounter = 0; // set the line counter to the first serial number in the file....
111 
112  while (!feof(fin)) {
113  // note space at end of format string to convert last \n
114  int check = fscanf(fin,
115  "%d %d %d %d %d %d %d %d %d %f %f %f \n",
116  &gains[linecounter].gas_gain_index,
117  &gains[linecounter].endcap,
118  &gains[linecounter].station,
119  &gains[linecounter].ring,
120  &gains[linecounter].chamber,
121  &gains[linecounter].layer,
122  &gains[linecounter].hvsegment,
123  &gains[linecounter].cfeb,
124  &gains[linecounter].nentries,
125  &gains[linecounter].mean,
126  &gains[linecounter].truncated_mean,
127  &gains[linecounter].gas_gain_correction);
128 
129  if (check != 12) {
130  printf("The input file format is not as expected\n");
131  assert(0);
132  }
133 
134  linecounter++;
135  }
136 
137  fclose(fin);
138 
139  if (linecounter == MAX_SIZE) {
140  std::cout << "Total number of gas gains read in = " << linecounter << std::endl;
141  } else {
142  std::cout << "ERROR: Total number of gas-gains read in = " << linecounter
143  << " while total number expected = " << MAX_SIZE << std::endl;
144  }
145 
146  // Fill the chip corrections with values from the file
147  for (int i = 0; i < MAX_SIZE; i++) {
148  itemvector[i].gainCorr = 0.;
149 
150  if (gains[i].gas_gain_correction > 0.) {
151  itemvector[i].gainCorr = gains[i].gas_gain_correction;
152  } else {
153  // if there is no value, this should be fixed...
154  std::cout << "ERROR: gas_gain_correction < 0 for index " << gains[i].gas_gain_index << std::endl;
155  }
156  }
157 
158  return cndbGasGainCorr;
159 }
assert(be >=bs)
constexpr float gains[NGAINS]
Definition: EcalConstants.h:20
dictionary isMC
Definition: DiMuonV_cfg.py:36
std::vector< Item > GasGainContainer
constexpr unsigned int MAX_SIZE

◆ produceDBGasGainCorrection()

CSCGasGainCorrectionDBConditions::ReturnType CSCGasGainCorrectionDBConditions::produceDBGasGainCorrection ( const CSCDBGasGainCorrectionRcd iRecord)

Definition at line 29 of file CSCGasGainCorrectionDBConditions.cc.

References dataCorrFileName, isForMC, and prefillDBGasGainCorrection().

Referenced by CSCGasGainCorrectionDBConditions().

30  {
31  // need a new object so to not be deleted at exit
33 }
std::unique_ptr< CSCDBGasGainCorrection > ReturnType
static CSCDBGasGainCorrection * prefillDBGasGainCorrection(bool isForMC, std::string dataCorrFileName)

◆ setIntervalFor()

void CSCGasGainCorrectionDBConditions::setIntervalFor ( const edm::eventsetup::EventSetupRecordKey ,
const edm::IOVSyncValue ,
edm::ValidityInterval oValidity 
)
overrideprivatevirtual

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 35 of file CSCGasGainCorrectionDBConditions.cc.

References edm::IOVSyncValue::beginOfTime(), and edm::IOVSyncValue::endOfTime().

37  {
39 }
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88

Member Data Documentation

◆ dataCorrFileName

std::string CSCGasGainCorrectionDBConditions::dataCorrFileName
private

◆ isForMC

bool CSCGasGainCorrectionDBConditions::isForMC
private