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 Types inherited from edm::eventsetup::DataProxyProvider
typedef std::vector< std::pair< DataKey, edm::propagate_const< std::shared_ptr< DataProxy > > > > KeyedProxies
 
typedef std::vector< EventSetupRecordKeyKeys
 
typedef std::map< EventSetupRecordKey, KeyedProxiesRecordProxies
 

Public Member Functions

 CSCGasGainCorrectionDBConditions (const edm::ParameterSet &)
 
ReturnType produceDBGasGainCorrection (const CSCDBGasGainCorrectionRcd &)
 
 ~CSCGasGainCorrectionDBConditions () override
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
 ~ESProducer ()(false) override
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval) override
 overrides DataProxyProvider method More...
 
 ~ESProxyFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
 DataProxyProvider ()
 
const ComponentDescriptiondescription () const
 
bool isUsingRecord (const EventSetupRecordKey &) const
 
const KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey) const
 
void resetProxies (const EventSetupRecordKey &iRecordType)
 
void resetProxiesIfTransient (const EventSetupRecordKey &iRecordType)
 
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
const eventsetup::ComponentDescriptiondescriptionForFinder () const
 
 EventSetupRecordIntervalFinder ()
 
std::set< eventsetup::EventSetupRecordKeyfindingForRecords () const
 
const ValidityIntervalfindIntervalFor (const eventsetup::EventSetupRecordKey &, const IOVSyncValue &)
 
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 Member Functions inherited from edm::ESProducer
template<typename T >
void setWhatProduced (T *iThis, const es::Label &iLabel=es::Label())
 
template<typename T >
void setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
void setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
void setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord , typename TArg >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel=es::Label())
 
- 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 eventsetup::EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
 
void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList) override
 override DataProxyProvider method More...
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
void eraseAll (const EventSetupRecordKey &iRecordKey)
 deletes all the Proxies in aStream More...
 
void invalidateProxies (const EventSetupRecordKey &iRecordKey)
 
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &)
 
- 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

Definition at line 28 of file CSCGasGainCorrectionDBConditions.h.

Constructor & Destructor Documentation

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

Definition at line 9 of file CSCGasGainCorrectionDBConditions.cc.

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

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

Definition at line 23 of file CSCGasGainCorrectionDBConditions.cc.

24 {
25 
26  // do anything here that needs to be done at desctruction time
27  // (e.g. close files, deallocate resources etc.)
28 }

Member Function Documentation

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

Definition at line 54 of file CSCGasGainCorrectionDBConditions.h.

References relativeConstraints::chamber, trackerTree::check(), gather_cfg::cout, makeMuonMisalignmentScenario::endcap, groupFilesInBlocks::fin, CSCDBGasGainCorrection::gasGainCorr, mps_fire::i, SiStripPI::mean, relativeConstraints::ring, and relativeConstraints::station.

Referenced by produceDBGasGainCorrection().

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

Definition at line 37 of file CSCGasGainCorrectionDBConditions.cc.

References dataCorrFileName, isForMC, and prefillDBGasGainCorrection().

Referenced by CSCGasGainCorrectionDBConditions().

38 {
39  //need a new object so to not be deleted at exit
41 
42 }
std::unique_ptr< CSCDBGasGainCorrection > ReturnType
static CSCDBGasGainCorrection * prefillDBGasGainCorrection(bool isForMC, std::string dataCorrFileName)
void CSCGasGainCorrectionDBConditions::setIntervalFor ( const edm::eventsetup::EventSetupRecordKey ,
const edm::IOVSyncValue ,
edm::ValidityInterval oValidity 
)
overrideprivatevirtual

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 44 of file CSCGasGainCorrectionDBConditions.cc.

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

46 {
48 
49 }
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:97
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:19
static const IOVSyncValue & beginOfTime()

Member Data Documentation

std::string CSCGasGainCorrectionDBConditions::dataCorrFileName
private
bool CSCGasGainCorrectionDBConditions::isForMC
private