CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Public Types

typedef const CSCGainsReturnType
 
- Public Types inherited from edm::eventsetup::DataProxyProvider
typedef std::vector< std::pair
< DataKey,
edm::propagate_const
< std::shared_ptr< DataProxy > > > > 
KeyedProxies
 
typedef std::vector
< EventSetupRecordKey
Keys
 
typedef std::map
< EventSetupRecordKey,
KeyedProxies
RecordProxies
 

Public Member Functions

 CSCGainsConditions (const edm::ParameterSet &)
 
ReturnType produceGains (const CSCGainsRcd &)
 
 ~CSCGainsConditions ()
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
virtual ~ESProducer ()
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
virtual void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval)
 overrides DataProxyProvider method More...
 
virtual ~ESProxyFactoryProducer ()
 
- 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 ()
 
- Public Member Functions inherited from edm::EventSetupRecordIntervalFinder
const
eventsetup::ComponentDescription
descriptionForFinder () const
 
 EventSetupRecordIntervalFinder ()
 
std::set
< eventsetup::EventSetupRecordKey
findingForRecords () const
 
const ValidityIntervalfindIntervalFor (const eventsetup::EventSetupRecordKey &, const IOVSyncValue &)
 
void setDescriptionForFinder (const eventsetup::ComponentDescription &iDescription)
 
virtual ~EventSetupRecordIntervalFinder ()
 

Static Public Member Functions

static CSCGainsprefillGains ()
 
- 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 &)
 

Private Attributes

CSCGainscnGains
 

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::auto_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const eventsetup::EventSetupRecordKey &iRecord, std::auto_ptr< eventsetup::ProxyFactoryBase > &iFactory, const std::string &iLabel=std::string())
 
virtual void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList)
 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 19 of file CSCGainsConditions.h.

Member Typedef Documentation

Definition at line 26 of file CSCGainsConditions.h.

Constructor & Destructor Documentation

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

Definition at line 192 of file CSCGainsConditions.cc.

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

193 {
194  //the following line is needed to tell the framework what
195  // data is being produced
196  cnGains = prefillGains();
197  // added by Zhen (changed since 1_2_0)
199  findingRecord<CSCGainsRcd>();
200  //now do what ever other initialization is needed
201 }
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
static CSCGains * prefillGains()
ReturnType produceGains(const CSCGainsRcd &)
CSCGainsConditions::~CSCGainsConditions ( )

Definition at line 204 of file CSCGainsConditions.cc.

References cnGains.

205 {
206 
207  // do anything here that needs to be done at desctruction time
208  // (e.g. close files, deallocate resources etc.)
209  delete cnGains;
210 }

Member Function Documentation

CSCGains * CSCGainsConditions::prefillGains ( )
static

Definition at line 6 of file CSCGainsConditions.cc.

References ecal_dqm_sourceclient-live_cfg::cerr, CSCDetId, cmsRelvalreport::exit, CSCGains::gains, recoMuon::in, CSCDetId::maxChamberId(), CSCDetId::maxEndcapId(), CSCDetId::maxLayerId(), CSCDetId::maxRingId(), CSCDetId::maxStationId(), timingPdfMaker::mean, min(), CSCDetId::minChamberId(), CSCDetId::minEndcapId(), CSCDetId::minLayerId(), CSCDetId::minRingId(), CSCDetId::minStationId(), rand(), and fileCollector::seed.

Referenced by CSCGainsConditions().

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

Definition at line 219 of file CSCGainsConditions.cc.

References cnGains.

Referenced by CSCGainsConditions().

220 {
221  // Added by Zhen, need a new object so to not be deleted at exit
222  CSCGains* mydata=new CSCGains( *cnGains );
223 
224  return mydata;
225 
226 }
void CSCGainsConditions::setIntervalFor ( const edm::eventsetup::EventSetupRecordKey ,
const edm::IOVSyncValue ,
edm::ValidityInterval oValidity 
)
privatevirtual

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 228 of file CSCGainsConditions.cc.

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

230  {
232 
233  }
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

CSCGains* CSCGainsConditions::cnGains
private

Definition at line 33 of file CSCGainsConditions.h.

Referenced by CSCGainsConditions(), produceGains(), and ~CSCGainsConditions().