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
CSCCrosstalkConditions Class Reference

#include <CSCCrosstalkConditions.h>

Inheritance diagram for CSCCrosstalkConditions:
edm::ESProducer edm::EventSetupRecordIntervalFinder edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Public Types

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

Public Member Functions

 CSCCrosstalkConditions (const edm::ParameterSet &)
 
ReturnType produceCrosstalk (const CSCcrosstalkRcd &)
 
 ~CSCCrosstalkConditions ()
 
- 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 CSCcrosstalkprefillCrosstalk ()
 

Private Member Functions

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

Private Attributes

CSCcrosstalkcnCrosstalk
 

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 CSCCrosstalkConditions.h.

Member Typedef Documentation

Definition at line 27 of file CSCCrosstalkConditions.h.

Constructor & Destructor Documentation

CSCCrosstalkConditions::CSCCrosstalkConditions ( const edm::ParameterSet iConfig)

Definition at line 252 of file CSCCrosstalkConditions.cc.

References cnCrosstalk, prefillCrosstalk(), produceCrosstalk(), and edm::ESProducer::setWhatProduced().

253 {
254  //the following line is needed to tell the framework what
255  // data is being produced
257  // added by Zhen (changed since 1_2_0)
259  findingRecord<CSCcrosstalkRcd>();
260  //now do what ever other initialization is needed
261 }
ReturnType produceCrosstalk(const CSCcrosstalkRcd &)
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
static CSCcrosstalk * prefillCrosstalk()
CSCCrosstalkConditions::~CSCCrosstalkConditions ( )

Definition at line 264 of file CSCCrosstalkConditions.cc.

References cnCrosstalk.

265 {
266 
267  // do anything here that needs to be done at desctruction time
268  // (e.g. close files, deallocate resources etc.)
269  delete cnCrosstalk;
270 }

Member Function Documentation

CSCcrosstalk * CSCCrosstalkConditions::prefillCrosstalk ( )
static

Definition at line 5 of file CSCCrosstalkConditions.cc.

References benchmark_cfg::cerr, CSCcrosstalk::crosstalk, CSCDetId, cmsRelvalreport::exit, recoMuon::in, CSCDetId::maxChamberId(), CSCDetId::maxEndcapId(), CSCDetId::maxLayerId(), CSCDetId::maxRingId(), CSCDetId::maxStationId(), plotscripts::mean(), min, CSCDetId::minChamberId(), CSCDetId::minEndcapId(), CSCDetId::minLayerId(), CSCDetId::minRingId(), CSCDetId::minStationId(), and rand().

Referenced by CSCCrosstalkConditions().

5  {
6 
7  float mean,min,minchi;
8  int seed;long int M;
9  int old_chamber_id,old_strip,new_chamber_id,new_strip;
10  float old_slope_right,old_slope_left,old_intercept_right;
11  float old_intercept_left, old_chi2_right,old_chi2_left;
12  std::vector<int> old_cham_id;
13  std::vector<int> old_strips;
14  std::vector<float> old_slope_r;
15  std::vector<float> old_intercept_r;
16  std::vector<float> old_chi2_r;
17  std::vector<float> old_slope_l;
18  std::vector<float> old_intercept_l;
19  std::vector<float> old_chi2_l;
20  float new_slope_right,new_slope_left,new_intercept_right;
21  float new_intercept_left, new_chi2_right,new_chi2_left;
22  std::vector<int> new_cham_id;
23  std::vector<int> new_strips;
24  std::vector<float> new_slope_r;
25  std::vector<float> new_intercept_r;
26  std::vector<float> new_chi2_r;
27  std::vector<float> new_slope_l;
28  std::vector<float> new_intercept_l;
29  std::vector<float> new_chi2_l;
30 
31 
32 
33  const CSCDetId& detId = CSCDetId();
34  CSCcrosstalk * cncrosstalk = new CSCcrosstalk();
35 
36  int max_istrip,id_layer,max_ring,max_cham;
37  unsigned int old_nrlines=0;
38  unsigned int new_nrlines=0;
39  seed = 10000;
40  srand(seed);
41  mean=-0.0009, min=0.035, minchi=1.5, M=1000;
42 
43  //endcap=1 to 2,station=1 to 4, ring=1 to 4,chamber=1 to 36,layer=1 to 6
44  std::ifstream olddata;
45  olddata.open("old_xtalk.dat",std::ios::in);
46  if(!olddata) {
47  std::cerr <<"Error: old_xtalk.dat -> no such file!"<< std::endl;
48  exit(1);
49  }
50 
51  while (!olddata.eof() ) {
52  olddata >> old_chamber_id >> old_strip >> old_slope_right >> old_intercept_right >> old_chi2_right >> old_slope_left >> old_intercept_left >> old_chi2_left ;
53  old_cham_id.push_back(old_chamber_id);
54  old_strips.push_back(old_strip);
55  old_slope_r.push_back(old_slope_right);
56  old_slope_l.push_back(old_slope_left);
57  old_intercept_r.push_back(old_intercept_right);
58  old_intercept_l.push_back(old_intercept_left);
59  old_chi2_r.push_back(old_chi2_right);
60  old_chi2_l.push_back(old_chi2_left);
61  old_nrlines++;
62  }
63  olddata.close();
64 
65  std::ifstream newdata;
66  newdata.open("new_xtalk.txt",std::ios::in);
67  if(!newdata) {
68  std::cerr <<"Error: new_xtalk.dat -> no such file!"<< std::endl;
69  exit(1);
70  }
71 
72  while (!newdata.eof() ) {
73  newdata >> new_chamber_id >> new_strip >> new_slope_right >> new_intercept_right >> new_chi2_right >> new_slope_left >> new_intercept_left >> new_chi2_left ;
74  new_cham_id.push_back(new_chamber_id);
75  new_strips.push_back(new_strip);
76  new_slope_r.push_back(new_slope_right);
77  new_slope_l.push_back(new_slope_left);
78  new_intercept_r.push_back(new_intercept_right);
79  new_intercept_l.push_back(new_intercept_left);
80  new_chi2_r.push_back(new_chi2_right);
81  new_chi2_l.push_back(new_chi2_left);
82  new_nrlines++;
83  }
84  newdata.close();
85 
86  for(int iendcap=detId.minEndcapId(); iendcap<=detId.maxEndcapId(); iendcap++){
87  for(int istation=detId.minStationId() ; istation<=detId.maxStationId(); istation++){
88  max_ring=detId.maxRingId();
89  //station 4 ring 4 not there(36 chambers*2 missing)
90  //3 rings max this way of counting (ME1a & b)
91  if(istation==1) max_ring=3;
92  if(istation==2) max_ring=2;
93  if(istation==3) max_ring=2;
94  if(istation==4) max_ring=1;
95 
96  for(int iring=detId.minRingId(); iring<=max_ring; iring++){
97  max_istrip=80;
98  max_cham=detId.maxChamberId();
99  if(istation==1 && iring==1) max_cham=36;
100  if(istation==1 && iring==2) max_cham=36;
101  if(istation==1 && iring==3) max_cham=36;
102  if(istation==2 && iring==1) max_cham=18;
103  if(istation==2 && iring==2) max_cham=36;
104  if(istation==3 && iring==1) max_cham=18;
105  if(istation==3 && iring==2) max_cham=36;
106  if(istation==4 && iring==1) max_cham=18;
107  //station 1 ring 3 has 64 strips per layer instead of 80(minus & plus side!!!)
108 
109  for(int ichamber=detId.minChamberId(); ichamber<=max_cham; ichamber++){
110 
111  for(int ilayer=detId.minLayerId(); ilayer<=detId.maxLayerId(); ilayer++){
112  //station 1 ring 3 has 64 strips per layer instead of 80
113  if(istation==1 && iring==3) max_istrip=64;
114 
115  std::vector<CSCcrosstalk::Item> itemvector;
116  itemvector.resize(max_istrip);
117  id_layer = 100000*iendcap + 10000*istation + 1000*iring + 10*ichamber + ilayer;
118 
119  for(int istrip=0;istrip<max_istrip;istrip++){
120  //create fake values
121  itemvector[istrip].xtalk_slope_right=-((double)rand()/((double)(RAND_MAX)+(double)(1)))/10000+mean;
122  itemvector[istrip].xtalk_intercept_right=((double)rand()/((double)(RAND_MAX)+(double)(1)))/100+min;
123  itemvector[istrip].xtalk_chi2_right=((double)rand()/((double)(RAND_MAX)+(double)(1)))+minchi;
124  itemvector[istrip].xtalk_slope_left=-((double)rand()/((double)(RAND_MAX)+(double)(1)))/10000+mean;
125  itemvector[istrip].xtalk_intercept_left=((double)rand()/((double)(RAND_MAX)+(double)(1)))/100+min;
126  itemvector[istrip].xtalk_chi2_left=((double)rand()/((double)(RAND_MAX)+(double)(1)))+minchi;
127  cncrosstalk->crosstalk[id_layer]=itemvector;
128 
129  if(istrip==0){
130  itemvector[istrip].xtalk_slope_right=-((double)rand()/((double)(RAND_MAX)+(double)(1)))/10000+mean;
131  itemvector[istrip].xtalk_intercept_right=((double)rand()/((double)(RAND_MAX)+(double)(1)))/100+min;
132  itemvector[istrip].xtalk_chi2_right=((double)rand()/((double)(RAND_MAX)+(double)(1)))+minchi;
133  itemvector[istrip].xtalk_slope_left=0.0;
134  itemvector[istrip].xtalk_intercept_left=0.0;
135  itemvector[istrip].xtalk_chi2_left=0.0;
136  cncrosstalk->crosstalk[id_layer]=itemvector;
137  }
138 
139  if(istrip==79){
140  itemvector[istrip].xtalk_slope_right=0.0;
141  itemvector[istrip].xtalk_intercept_right=0.0;
142  itemvector[istrip].xtalk_chi2_right=0.0;
143  itemvector[istrip].xtalk_slope_left=-((double)rand()/((double)(RAND_MAX)+(double)(1)))/10000+mean;
144  itemvector[istrip].xtalk_intercept_left=((double)rand()/((double)(RAND_MAX)+(double)(1)))/100+min;
145  itemvector[istrip].xtalk_chi2_left=((double)rand()/((double)(RAND_MAX)+(double)(1)))+minchi;
146  cncrosstalk->crosstalk[id_layer]=itemvector;
147  }
148  }
149  }
150  }
151  }
152  }
153 
154  //overwrite fakes with old values from DB
155  int istrip = 0;
156  std::vector<CSCcrosstalk::Item> itemvector;
157  itemvector.resize(80);
158 
159  for(unsigned int mystrip=0; mystrip<old_nrlines-1; mystrip++){
160  if(old_strips[mystrip]==0) istrip = 0;
161  itemvector[istrip].xtalk_slope_right=old_slope_r[mystrip];
162  itemvector[istrip].xtalk_intercept_right=old_intercept_r[mystrip];
163  itemvector[istrip].xtalk_chi2_right=old_chi2_r[mystrip];
164  itemvector[istrip].xtalk_slope_left=old_slope_l[mystrip];
165  itemvector[istrip].xtalk_intercept_left=old_intercept_l[mystrip];
166  itemvector[istrip].xtalk_chi2_left=old_chi2_l[mystrip];
167  cncrosstalk->crosstalk[old_cham_id[mystrip]]=itemvector;
168  istrip++;
169  }
170 
171 
172  itemvector.resize(64);
173  for(unsigned int mystrip=0; mystrip<old_nrlines-1; mystrip++){
174  if(old_strips[mystrip]==0) istrip = 0;
175  if(old_cham_id[mystrip] >= 113000 && old_cham_id[mystrip] <= 113999){
176  itemvector[istrip].xtalk_slope_right=old_slope_r[mystrip];
177  itemvector[istrip].xtalk_intercept_right=old_intercept_r[mystrip];
178  itemvector[istrip].xtalk_chi2_right=old_chi2_r[mystrip];
179  itemvector[istrip].xtalk_slope_left=old_slope_l[mystrip];
180  itemvector[istrip].xtalk_intercept_left=old_intercept_l[mystrip];
181  itemvector[istrip].xtalk_chi2_left=old_chi2_l[mystrip];
182  cncrosstalk->crosstalk[old_cham_id[mystrip]]=itemvector;
183  istrip++;
184  }
185  }
186 
187  itemvector.resize(64);
188  for(unsigned int mystrip=0; mystrip<old_nrlines-1; mystrip++){
189  if(old_strips[mystrip]==0) istrip = 0;
190  if(old_cham_id[mystrip] >= 213000 && old_cham_id[mystrip] <= 213999){
191  itemvector[istrip].xtalk_slope_right=old_slope_r[mystrip];
192  itemvector[istrip].xtalk_intercept_right=old_intercept_r[mystrip];
193  itemvector[istrip].xtalk_chi2_right=old_chi2_r[mystrip];
194  itemvector[istrip].xtalk_slope_left=old_slope_l[mystrip];
195  itemvector[istrip].xtalk_intercept_left=old_intercept_l[mystrip];
196  itemvector[istrip].xtalk_chi2_left=old_chi2_l[mystrip];
197  cncrosstalk->crosstalk[old_cham_id[mystrip]]=itemvector;
198  istrip++;
199  }
200  }
201 
202  //overwrite old values with ones from new runs
203  itemvector.resize(80);
204  for(unsigned int mystrip=0; mystrip<new_nrlines-1; mystrip++){
205  if(new_strips[mystrip]==0) istrip = 0;
206  itemvector[istrip].xtalk_slope_right=new_slope_r[mystrip];
207  itemvector[istrip].xtalk_intercept_right=new_intercept_r[mystrip];
208  itemvector[istrip].xtalk_chi2_right=new_chi2_r[mystrip];
209  itemvector[istrip].xtalk_slope_left=new_slope_l[mystrip];
210  itemvector[istrip].xtalk_intercept_left=new_intercept_l[mystrip];
211  itemvector[istrip].xtalk_chi2_left=new_chi2_l[mystrip];
212  cncrosstalk->crosstalk[new_cham_id[mystrip]]=itemvector;
213  istrip++;
214  }
215 
216  itemvector.resize(64);
217  for(unsigned int mystrip=0; mystrip<new_nrlines-1; mystrip++){
218  if(new_strips[mystrip]==0) istrip = 0;
219  if(new_cham_id[mystrip] >= 113000 && new_cham_id[mystrip] <= 113999){
220  itemvector[istrip].xtalk_slope_right=new_slope_r[mystrip];
221  itemvector[istrip].xtalk_intercept_right=new_intercept_r[mystrip];
222  itemvector[istrip].xtalk_chi2_right=new_chi2_r[mystrip];
223  itemvector[istrip].xtalk_slope_left=new_slope_l[mystrip];
224  itemvector[istrip].xtalk_intercept_left=new_intercept_l[mystrip];
225  itemvector[istrip].xtalk_chi2_left=new_chi2_l[mystrip];
226  cncrosstalk->crosstalk[new_cham_id[mystrip]]=itemvector;
227  istrip++;
228  }
229  }
230 
231  itemvector.resize(64);
232  for(unsigned int mystrip=0; mystrip<new_nrlines-1; mystrip++){
233  if(new_strips[mystrip]==0) istrip = 0;
234  if(new_cham_id[mystrip] >= 213000 && new_cham_id[mystrip] <= 213999){
235  itemvector[istrip].xtalk_slope_right=new_slope_r[mystrip];
236  itemvector[istrip].xtalk_intercept_right=new_intercept_r[mystrip];
237  itemvector[istrip].xtalk_chi2_right=new_chi2_r[mystrip];
238  itemvector[istrip].xtalk_slope_left=new_slope_l[mystrip];
239  itemvector[istrip].xtalk_intercept_left=new_intercept_l[mystrip];
240  itemvector[istrip].xtalk_chi2_left=new_chi2_l[mystrip];
241  cncrosstalk->crosstalk[new_cham_id[mystrip]]=itemvector;
242  istrip++;
243  }
244  }
245  }
246 
247  return cncrosstalk;
248 
249 }
static int minRingId()
Definition: CSCDetId.h:242
static int minEndcapId()
Definition: CSCDetId.h:238
#define min(a, b)
Definition: mlp_lapack.h:161
static int maxStationId()
Definition: CSCDetId.h:241
static int maxRingId()
Definition: CSCDetId.h:243
CrosstalkMap crosstalk
Definition: CSCcrosstalk.h:26
static int minChamberId()
Definition: CSCDetId.h:244
static int minStationId()
Definition: CSCDetId.h:240
static int maxEndcapId()
Definition: CSCDetId.h:239
static int minLayerId()
Definition: CSCDetId.h:246
static int maxChamberId()
Definition: CSCDetId.h:245
Signal rand(Signal arg)
Definition: vlib.cc:442
static int maxLayerId()
Definition: CSCDetId.h:247
CSCCrosstalkConditions::ReturnType CSCCrosstalkConditions::produceCrosstalk ( const CSCcrosstalkRcd iRecord)

Definition at line 279 of file CSCCrosstalkConditions.cc.

References cnCrosstalk.

Referenced by CSCCrosstalkConditions().

280 {
281  // Added by Zhen, need a new object so to not be deleted at exit
282  CSCcrosstalk* mydata=new CSCcrosstalk( *cnCrosstalk );
283 
284  return mydata;
285 
286 }
void CSCCrosstalkConditions::setIntervalFor ( const edm::eventsetup::EventSetupRecordKey ,
const edm::IOVSyncValue ,
edm::ValidityInterval oValidity 
)
privatevirtual

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 288 of file CSCCrosstalkConditions.cc.

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

290  {
292 
293  }
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

CSCcrosstalk* CSCCrosstalkConditions::cnCrosstalk
private