CMS 3D CMS Logo

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 std::unique_ptr< CSCcrosstalkReturnType
 
- 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

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

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::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 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 253 of file CSCCrosstalkConditions.cc.

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

254 {
255  //the following line is needed to tell the framework what
256  // 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
CSCCrosstalkConditions::~CSCCrosstalkConditions ( )
override

Definition at line 264 of file CSCCrosstalkConditions.cc.

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

Member Function Documentation

CSCcrosstalk * CSCCrosstalkConditions::prefillCrosstalk ( )
static

Definition at line 6 of file CSCCrosstalkConditions.cc.

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

Referenced by produceCrosstalk().

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

Definition at line 278 of file CSCCrosstalkConditions.cc.

References prefillCrosstalk().

Referenced by CSCCrosstalkConditions().

279 {
280  // Added by Zhen, need a new object so to not be deleted at exit
282 
283 }
std::unique_ptr< CSCcrosstalk > ReturnType
static CSCcrosstalk * prefillCrosstalk()
void CSCCrosstalkConditions::setIntervalFor ( const edm::eventsetup::EventSetupRecordKey ,
const edm::IOVSyncValue ,
edm::ValidityInterval oValidity 
)
overrideprivatevirtual

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 285 of file CSCCrosstalkConditions.cc.

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

287  {
289 
290  }
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

Definition at line 34 of file CSCCrosstalkConditions.h.