CMS 3D CMS Logo

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

#include <CSCGainsConditions.h>

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

Public Types

typedef std::unique_ptr< CSCGainsReturnType
 

Public Member Functions

 CSCGainsConditions (const edm::ParameterSet &)
 
ReturnType produceGains (const CSCGainsRcd &)
 
 ~CSCGainsConditions () 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 CSCGainsprefillGains ()
 
- 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

CSCGainscnGains
 

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 19 of file CSCGainsConditions.h.

Member Typedef Documentation

◆ ReturnType

typedef std::unique_ptr<CSCGains> CSCGainsConditions::ReturnType

Definition at line 26 of file CSCGainsConditions.h.

Constructor & Destructor Documentation

◆ CSCGainsConditions()

CSCGainsConditions::CSCGainsConditions ( const edm::ParameterSet iConfig)

Definition at line 207 of file CSCGainsConditions.cc.

References produceGains(), and edm::ESProducer::setWhatProduced().

207  {
208  // the following line is needed to tell the framework what
209  // added by Zhen (changed since 1_2_0)
211  findingRecord<CSCGainsRcd>();
212  // now do what ever other initialization is needed
213 }
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:166
ReturnType produceGains(const CSCGainsRcd &)

◆ ~CSCGainsConditions()

CSCGainsConditions::~CSCGainsConditions ( )
override

Definition at line 215 of file CSCGainsConditions.cc.

215  {
216  // do anything here that needs to be done at desctruction time
217  // (e.g. close files, deallocate resources etc.)
218 }

Member Function Documentation

◆ prefillGains()

CSCGains * CSCGainsConditions::prefillGains ( )
static

Definition at line 6 of file CSCGainsConditions.cc.

References DMR_cfg::cerr, hcalRecHitTable_cff::detId, beamvalidation::exit(), CSCGains::gains, recoMuon::in, SiStripPI::mean, SiStripPI::min, and fileCollector::seed.

Referenced by produceGains().

6  {
7  float mean, min, minchi;
8  int seed;
9  int old_chamber_id, old_strip, new_chamber_id, new_strip;
10  float old_gainslope, old_intercpt, old_chisq;
11  std::vector<int> old_cham_id;
12  std::vector<int> old_strips;
13  std::vector<float> old_slope;
14  std::vector<float> old_intercept;
15  std::vector<float> old_chi2;
16  float new_gainslope, new_intercpt, new_chisq;
17  std::vector<int> new_cham_id;
18  std::vector<int> new_strips;
19  std::vector<float> new_slope;
20  std::vector<float> new_intercept;
21  std::vector<float> new_chi2;
22 
23  const CSCDetId &detId = CSCDetId();
24  CSCGains *cngains = new CSCGains();
25 
26  int max_istrip, id_layer, max_ring, max_cham;
27  unsigned int old_nrlines = 0;
28  unsigned int new_nrlines = 0;
29  seed = 10000;
30  srand(seed);
31  mean = 6.8, min = -10.0, minchi = 1.0;
32 
33  std::ifstream olddata;
34  olddata.open("old_gains.dat", std::ios::in);
35  if (!olddata) {
36  std::cerr << "Error: old_gains.dat -> no such file!" << std::endl;
37  exit(1);
38  }
39 
40  while (!olddata.eof()) {
41  olddata >> old_chamber_id >> old_strip >> old_gainslope >> old_intercpt >> old_chisq;
42  old_cham_id.push_back(old_chamber_id);
43  old_strips.push_back(old_strip);
44  old_slope.push_back(old_gainslope);
45  old_intercept.push_back(old_intercpt);
46  old_chi2.push_back(old_chisq);
47  old_nrlines++;
48  }
49  olddata.close();
50 
51  std::ifstream newdata;
52  newdata.open("new_gains.txt", std::ios::in);
53  if (!newdata) {
54  std::cerr << "Error: new_gains.txt -> no such file!" << std::endl;
55  exit(1);
56  }
57 
58  while (!newdata.eof()) {
59  newdata >> new_chamber_id >> new_strip >> new_gainslope >> new_intercpt >> new_chisq;
60  new_cham_id.push_back(new_chamber_id);
61  new_strips.push_back(new_strip);
62  new_slope.push_back(new_gainslope);
63  new_intercept.push_back(new_intercpt);
64  new_chi2.push_back(new_chisq);
65  new_nrlines++;
66  }
67  newdata.close();
68 
69  // endcap=1 to 2,station=1 to 4, ring=1 to 4,chamber=1 to 36,layer=1 to 6
70  for (int iendcap = detId.minEndcapId(); iendcap <= detId.maxEndcapId(); iendcap++) {
71  for (int istation = detId.minStationId(); istation <= detId.maxStationId(); istation++) {
72  max_ring = detId.maxRingId();
73  // station 4 ring 4 not there(36 chambers*2 missing)
74  // 3 rings max this way of counting (ME1a & b)
75  if (istation == 1)
76  max_ring = 3;
77  if (istation == 2)
78  max_ring = 2;
79  if (istation == 3)
80  max_ring = 2;
81  if (istation == 4)
82  max_ring = 1;
83 
84  for (int iring = detId.minRingId(); iring <= max_ring; iring++) {
85  max_istrip = 80;
86  max_cham = detId.maxChamberId();
87  if (istation == 1 && iring == 1)
88  max_cham = 36;
89  if (istation == 1 && iring == 2)
90  max_cham = 36;
91  if (istation == 1 && iring == 3)
92  max_cham = 36;
93  if (istation == 2 && iring == 1)
94  max_cham = 18;
95  if (istation == 2 && iring == 2)
96  max_cham = 36;
97  if (istation == 3 && iring == 1)
98  max_cham = 18;
99  if (istation == 3 && iring == 2)
100  max_cham = 36;
101  if (istation == 4 && iring == 1)
102  max_cham = 18;
103 
104  for (int ichamber = detId.minChamberId(); ichamber <= max_cham; ichamber++) {
105  for (int ilayer = detId.minLayerId(); ilayer <= detId.maxLayerId(); ilayer++) {
106  // station 1 ring 3 has 64 strips per layer instead of 80
107  if (istation == 1 && iring == 3)
108  max_istrip = 64;
109 
110  std::vector<CSCGains::Item> itemvector;
111  itemvector.resize(max_istrip);
112  id_layer = 100000 * iendcap + 10000 * istation + 1000 * iring + 10 * ichamber + ilayer;
113 
114  for (int istrip = 0; istrip < max_istrip; istrip++) {
115  itemvector[istrip].gain_slope = ((double)rand() / ((double)(RAND_MAX) + (double)(1))) + mean;
116  itemvector[istrip].gain_intercept = ((double)rand() / ((double)(RAND_MAX) + (double)(1))) + min;
117  itemvector[istrip].gain_chi2 = ((double)rand() / ((double)(RAND_MAX) + (double)(1))) + minchi;
118  cngains->gains[id_layer] = itemvector;
119  }
120  }
121  }
122  }
123  }
124  }
125 
126  // overwrite fakes with old values from DB
127  int istrip = 0;
128  std::vector<CSCGains::Item> itemvector;
129  itemvector.resize(80);
130 
131  for (unsigned int mystrip = 0; mystrip < old_nrlines - 1; mystrip++) {
132  if (old_strips[mystrip] == 0)
133  istrip = 0;
134  itemvector[istrip].gain_slope = old_slope[mystrip];
135  itemvector[istrip].gain_intercept = old_intercept[mystrip];
136  itemvector[istrip].gain_chi2 = old_chi2[mystrip];
137  cngains->gains[old_cham_id[mystrip]] = itemvector;
138  istrip++;
139  }
140 
141  itemvector.resize(64);
142  for (unsigned int mystrip = 0; mystrip < old_nrlines - 1; mystrip++) {
143  if (old_strips[mystrip] == 0)
144  istrip = 0;
145  if (old_cham_id[mystrip] >= 113000 && old_cham_id[mystrip] <= 113999) {
146  itemvector[istrip].gain_slope = old_slope[mystrip];
147  itemvector[istrip].gain_intercept = old_intercept[mystrip];
148  itemvector[istrip].gain_chi2 = old_chi2[mystrip];
149  cngains->gains[old_cham_id[mystrip]] = itemvector;
150  istrip++;
151  }
152  }
153 
154  itemvector.resize(64);
155  for (unsigned int mystrip = 0; mystrip < old_nrlines - 1; mystrip++) {
156  if (old_strips[mystrip] == 0)
157  istrip = 0;
158  if (old_cham_id[mystrip] >= 213000 && old_cham_id[mystrip] <= 213999) {
159  itemvector[istrip].gain_slope = old_slope[mystrip];
160  itemvector[istrip].gain_intercept = old_intercept[mystrip];
161  itemvector[istrip].gain_chi2 = old_chi2[mystrip];
162  cngains->gains[old_cham_id[mystrip]] = itemvector;
163  istrip++;
164  }
165  }
166 
167  // overwrite old values with ones from new runs
168  itemvector.resize(80);
169  for (unsigned int mystrip = 0; mystrip < new_nrlines - 1; mystrip++) {
170  if (new_strips[mystrip] == 0)
171  istrip = 0;
172  itemvector[istrip].gain_slope = new_slope[mystrip];
173  itemvector[istrip].gain_intercept = new_intercept[mystrip];
174  itemvector[istrip].gain_chi2 = new_chi2[mystrip];
175  cngains->gains[new_cham_id[mystrip]] = itemvector;
176  istrip++;
177  }
178 
179  itemvector.resize(64);
180  for (unsigned int mystrip = 0; mystrip < new_nrlines - 1; mystrip++) {
181  if (new_strips[mystrip] == 0)
182  istrip = 0;
183  if (new_cham_id[mystrip] >= 113000 && new_cham_id[mystrip] <= 113999) {
184  itemvector[istrip].gain_slope = new_slope[mystrip];
185  itemvector[istrip].gain_intercept = new_intercept[mystrip];
186  itemvector[istrip].gain_chi2 = new_chi2[mystrip];
187  cngains->gains[new_cham_id[mystrip]] = itemvector;
188  istrip++;
189  }
190  }
191 
192  itemvector.resize(64);
193  for (unsigned int mystrip = 0; mystrip < new_nrlines - 1; mystrip++) {
194  if (new_strips[mystrip] == 0)
195  istrip = 0;
196  if (new_cham_id[mystrip] >= 213000 && new_cham_id[mystrip] <= 213999) {
197  itemvector[istrip].gain_slope = new_slope[mystrip];
198  itemvector[istrip].gain_intercept = new_intercept[mystrip];
199  itemvector[istrip].gain_chi2 = new_chi2[mystrip];
200  cngains->gains[new_cham_id[mystrip]] = itemvector;
201  istrip++;
202  }
203  }
204  return cngains;
205 }
GainsMap gains
Definition: CSCGains.h:26
def exit(msg="")

◆ produceGains()

CSCGainsConditions::ReturnType CSCGainsConditions::produceGains ( const CSCGainsRcd iRecord)

Definition at line 225 of file CSCGainsConditions.cc.

References prefillGains().

Referenced by CSCGainsConditions().

225  {
226  // Added by Zhen, need a new object so to not be deleted at exit
228 }
std::unique_ptr< CSCGains > ReturnType
static CSCGains * prefillGains()

◆ setIntervalFor()

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

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 230 of file CSCGainsConditions.cc.

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

232  {
234 }
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

◆ cnGains

CSCGains* CSCGainsConditions::cnGains
private

Definition at line 35 of file CSCGainsConditions.h.