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::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

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
 
ESProxyIndex const * getTokenIndices (unsigned int iIndex) const
 
ESRecordIndex const * getTokenRecordIndices (unsigned int iIndex) const
 
bool hasMayConsumes () const noexcept
 
size_t numberOfTokenIndices (unsigned int iIndex) const
 
ESProducer const & operator= (const ESProducer &)=delete
 
SerialTaskQueueChainqueue ()
 
template<typename Record >
std::optional< std::vector< ESProxyIndex > > updateFromMayConsumes (unsigned int iIndex, const Record &iRecord) const
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &) final
 
 ~ESProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
 ESProxyFactoryProducer (const ESProxyFactoryProducer &)=delete
 
const ESProxyFactoryProduceroperator= (const ESProxyFactoryProducer &)=delete
 
 ~ESProxyFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
void createKeyedProxies (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
 DataProxyProvider ()
 
 DataProxyProvider (const DataProxyProvider &)=delete
 
const ComponentDescriptiondescription () const
 
void fillRecordsNotAllowingConcurrentIOVs (std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
 
virtual void initConcurrentIOVs (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
bool isUsingRecord (const EventSetupRecordKey &key) const
 
KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey, unsigned int iovIndex=0)
 
const DataProxyProvideroperator= (const DataProxyProvider &)=delete
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~DataProxyProvider () 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::DataProxyProvider
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::ESProxyFactoryProducer
using EventSetupRecordKey = eventsetup::EventSetupRecordKey
 
- Protected Types inherited from edm::eventsetup::DataProxyProvider
using KeyedProxiesVector = std::vector< std::pair< DataKey, std::shared_ptr< DataProxy > >>
 
- Protected Member Functions inherited from edm::ESProducer
template<typename T >
auto setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
auto setWhatProduced (T *iThis, const es::Label &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 TArg >
ESConsumesCollectorT< TRecord > setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel={})
 
void usesResources (std::vector< std::string > const &)
 
- Protected Member Functions inherited from edm::ESProxyFactoryProducer
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::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
 
KeyedProxiesVector registerProxies (const EventSetupRecordKey &, unsigned int iovIndex) override
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
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.

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 }

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

◆ ~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.

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 }

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

Referenced by produceDBGasGainCorrection().

◆ produceDBGasGainCorrection()

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

Definition at line 29 of file CSCGasGainCorrectionDBConditions.cc.

30  {
31  // need a new object so to not be deleted at exit
33 }

References dataCorrFileName, isForMC, and prefillDBGasGainCorrection().

Referenced by CSCGasGainCorrectionDBConditions().

◆ setIntervalFor()

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

Member Data Documentation

◆ dataCorrFileName

std::string CSCGasGainCorrectionDBConditions::dataCorrFileName
private

◆ isForMC

bool CSCGasGainCorrectionDBConditions::isForMC
private
mps_fire.i
i
Definition: mps_fire.py:428
SiStripPI::mean
Definition: SiStripPayloadInspectorHelper.h:169
relativeConstraints.station
station
Definition: relativeConstraints.py:67
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
cms::cuda::assert
assert(be >=bs)
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
makeMuonMisalignmentScenario.endcap
endcap
Definition: makeMuonMisalignmentScenario.py:320
CSCDBGasGainCorrection::GasGainContainer
std::vector< Item > GasGainContainer
Definition: CSCDBGasGainCorrection.h:20
CSCDBGasGainCorrection
Definition: CSCDBGasGainCorrection.h:9
RPCNoise_example.check
check
Definition: RPCNoise_example.py:71
submitPVValidationJobs.isMC
list isMC
Definition: submitPVValidationJobs.py:658
groupFilesInBlocks.fin
fin
Definition: groupFilesInBlocks.py:94
pixelgpudetails::MAX_SIZE
constexpr unsigned int MAX_SIZE
Definition: SiPixelROCsStatusAndMapping.h:10
CSCIndexer
Definition: CSCIndexer.h:44
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
edm::IOVSyncValue::endOfTime
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
CSCGasGainCorrectionDBConditions::isForMC
bool isForMC
Definition: CSCGasGainCorrectionDBConditions.h:39
CSCGasGainCorrectionDBConditions::prefillDBGasGainCorrection
static CSCDBGasGainCorrection * prefillDBGasGainCorrection(bool isForMC, std::string dataCorrFileName)
Definition: CSCGasGainCorrectionDBConditions.h:53
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CSCGasGainCorrectionDBConditions::ReturnType
std::unique_ptr< CSCDBGasGainCorrection > ReturnType
Definition: CSCGasGainCorrectionDBConditions.h:28
cond::ValidityInterval
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
CSCDBGasGainCorrection::gasGainCorr
GasGainContainer gasGainCorr
Definition: CSCDBGasGainCorrection.h:21
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
edm::IOVSyncValue::beginOfTime
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
CSCGasGainCorrectionDBConditions::produceDBGasGainCorrection
ReturnType produceDBGasGainCorrection(const CSCDBGasGainCorrectionRcd &)
Definition: CSCGasGainCorrectionDBConditions.cc:29
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
CSCGasGainCorrectionDBConditions::dataCorrFileName
std::string dataCorrFileName
Definition: CSCGasGainCorrectionDBConditions.h:41