CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 std::unique_ptr
< CSCcrosstalk
ReturnType
 

Public Member Functions

 CSCCrosstalkConditions (const edm::ParameterSet &)
 
ReturnType produceCrosstalk (const CSCcrosstalkRcd &)
 
 ~CSCCrosstalkConditions () override
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
 ESProducer (const ESProducer &)=delete
 
ESProxyIndex const * getTokenIndices (unsigned int iIndex) const
 
ESRecordIndex const * getTokenRecordIndices (unsigned int iIndex) const
 
bool hasMayConsumes () const noexcept
 
size_t numberOfTokenIndices (unsigned int iIndex) const
 
ESProducer const & operator= (const ESProducer &)=delete
 
SerialTaskQueueChainqueue ()
 
template<typename Record >
std::optional< std::vector
< ESProxyIndex > > 
updateFromMayConsumes (unsigned int iIndex, const Record &iRecord) const
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &) final
 
 ~ESProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
 ESProxyFactoryProducer (const ESProxyFactoryProducer &)=delete
 
const ESProxyFactoryProduceroperator= (const ESProxyFactoryProducer &)=delete
 
 ~ESProxyFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
void createKeyedProxies (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
 DataProxyProvider ()
 
 DataProxyProvider (const DataProxyProvider &)=delete
 
const ComponentDescriptiondescription () const
 
void fillRecordsNotAllowingConcurrentIOVs (std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
 
virtual void initConcurrentIOVs (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
bool isUsingRecord (const EventSetupRecordKey &key) const
 
KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey, unsigned int iovIndex=0)
 
const DataProxyProvideroperator= (const DataProxyProvider &)=delete
 
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
bool concurrentFinder () const
 
const
eventsetup::ComponentDescription
descriptionForFinder () const
 
 EventSetupRecordIntervalFinder ()
 
 EventSetupRecordIntervalFinder (const EventSetupRecordIntervalFinder &)=delete
 
std::set
< eventsetup::EventSetupRecordKey
findingForRecords () const
 
const ValidityIntervalfindIntervalFor (const eventsetup::EventSetupRecordKey &, const IOVSyncValue &)
 
bool nonconcurrentAndIOVNeedsUpdate (const eventsetup::EventSetupRecordKey &key, const IOVSyncValue &syncValue) const
 
const
EventSetupRecordIntervalFinder
operator= (const EventSetupRecordIntervalFinder &)=delete
 
void resetInterval (const eventsetup::EventSetupRecordKey &)
 
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 Types inherited from edm::ESProxyFactoryProducer
using EventSetupRecordKey = eventsetup::EventSetupRecordKey
 
- Protected Types inherited from edm::eventsetup::DataProxyProvider
using KeyedProxiesVector = std::vector< std::pair< DataKey, std::shared_ptr< DataProxy >>>
 
- Protected Member Functions inherited from edm::ESProducer
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 TArg >
ESConsumesCollectorT< TRecord > setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel={})
 
void usesResources (std::vector< std::string > const &)
 
- 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 EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
 
KeyedProxiesVector registerProxies (const EventSetupRecordKey &, unsigned int iovIndex) override
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
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 CSCCrosstalkConditions.h.

Member Typedef Documentation

Definition at line 26 of file CSCCrosstalkConditions.h.

Constructor & Destructor Documentation

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

Definition at line 276 of file CSCCrosstalkConditions.cc.

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

276  {
277  // the following line is needed to tell the framework what
278  // data is being produced
279  // added by Zhen (changed since 1_2_0)
281  findingRecord<CSCcrosstalkRcd>();
282  // now do what ever other initialization is needed
283 }
ReturnType produceCrosstalk(const CSCcrosstalkRcd &)
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
CSCCrosstalkConditions::~CSCCrosstalkConditions ( )
override

Definition at line 285 of file CSCCrosstalkConditions.cc.

285  {
286  // do anything here that needs to be done at desctruction time
287  // (e.g. close files, deallocate resources etc.)
288 }

Member Function Documentation

CSCcrosstalk * CSCCrosstalkConditions::prefillCrosstalk ( )
static

Definition at line 6 of file CSCCrosstalkConditions.cc.

References EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, CSCcrosstalk::crosstalk, CSCDetId, beamvalidation::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(), and fileCollector::seed.

Referenced by produceCrosstalk().

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

Definition at line 295 of file CSCCrosstalkConditions.cc.

References prefillCrosstalk().

Referenced by CSCCrosstalkConditions().

295  {
296  // Added by Zhen, need a new object so to not be deleted at exit
298 }
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 300 of file CSCCrosstalkConditions.cc.

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

302  {
304 }
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

CSCcrosstalk* CSCCrosstalkConditions::cnCrosstalk
private

Definition at line 35 of file CSCCrosstalkConditions.h.