CMS 3D CMS Logo

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

#include <CSCChamberTimeCorrectionsValues.h>

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

Public Types

typedef std::unique_ptr< CSCChamberTimeCorrectionsReturnType
 
- 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

 CSCChamberTimeCorrectionsValues (const edm::ParameterSet &)
 
ReturnType produceChamberTimeCorrections (const CSCChamberTimeCorrectionsRcd &)
 
 ~CSCChamberTimeCorrectionsValues () 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 CSCChamberTimeCorrectionsprefill (bool isMC, float ME11offset, float nonME11offset)
 
- 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

bool isForMC
 
float ME11offsetData
 
float ME11offsetMC
 
float nonME11offsetData
 
float nonME11offsetMC
 

Additional Inherited Members

- Protected Member Functions inherited from edm::ESProducer
 ESProducer (const ESProducer &)=delete
 
ESProducer const & operator= (const ESProducer &)=delete
 
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 23 of file CSCChamberTimeCorrectionsValues.h.

Member Typedef Documentation

Definition at line 28 of file CSCChamberTimeCorrectionsValues.h.

Constructor & Destructor Documentation

CSCChamberTimeCorrectionsValues::CSCChamberTimeCorrectionsValues ( const edm::ParameterSet iConfig)

Definition at line 10 of file CSCChamberTimeCorrectionsValues.cc.

References edm::ParameterSet::getUntrackedParameter(), isForMC, ME11offsetData, ME11offsetMC, nonME11offsetData, nonME11offsetMC, produceChamberTimeCorrections(), and edm::ESProducer::setWhatProduced().

11 {
12  //the following line is needed to tell the framework what
13  // data is being produced
14  isForMC = iConfig.getUntrackedParameter<bool>("isForMC",true);
15  ME11offsetMC = 184;
16  ME11offsetData = 205;
17  nonME11offsetMC = 174;
18  nonME11offsetData = 216;
20  findingRecord<CSCChamberTimeCorrectionsRcd>();
21  //now do what ever other initialization is needed
22 }
T getUntrackedParameter(std::string const &, T const &) const
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
ReturnType produceChamberTimeCorrections(const CSCChamberTimeCorrectionsRcd &)
CSCChamberTimeCorrectionsValues::~CSCChamberTimeCorrectionsValues ( )
override

Definition at line 25 of file CSCChamberTimeCorrectionsValues.cc.

26 {
27 
28  // do anything here that needs to be done at desctruction time
29  // (e.g. close files, deallocate resources etc.)
30 }

Member Function Documentation

CSCChamberTimeCorrections * CSCChamberTimeCorrectionsValues::prefill ( bool  isMC,
float  ME11offset,
float  nonME11offset 
)
inlinestatic

Definition at line 52 of file CSCChamberTimeCorrectionsValues.h.

References csccableread::cable_read(), relativeConstraints::chamber, CSCChamberTimeCorrections::chamberCorrections, CSCIndexer::chamberIndex(), trackerTree::check(), corr, KineDebug3::count(), CSCChamberTimeCorrections::factor_precision, groupFilesInBlocks::fin, objects.autophobj::float, mps_fire::i, createfilelist::int, diffTwoXMLs::label, PFRecoTauDiscriminationByIsolation_cfi::offset, AlCaHLTBitMon_QueryRunRegistry::string, and groupFilesInBlocks::temp.

Referenced by produceChamberTimeCorrections().

53 {
54  if (isMC)
55  printf("\n Generating fake DB constants for MC\n");
56  else
57  printf("\n Getting chamber corrections from the cable data base and possibly other files \n");
58 
59  const int FACTOR=100;
60  const int MAX_SIZE = 540;
61  //const int MAX_SHORT= 32767;
62 
64 
65  int i; //i - chamber index.
66  int count=0;
67  std::string chamber_label, cfeb_rev, alct_rev;
68  float cfeb_length=0, alct_length=0, cfeb_tmb_skew_delay=0, cfeb_timing_corr=0;
69 
70  // Only the first 481 chambers have interesting cable lengths at present
71  // The rest of the chambers will be filled with zeros
72  chamberObj->factor_precision = FACTOR;
73 
74  chamberObj->chamberCorrections.resize(MAX_SIZE);
75  // fill the database with dummy values
76  for(i=1;i<=MAX_SIZE;++i){
77  chamberObj->chamberCorrections[i-1].cfeb_length=0;
78  chamberObj->chamberCorrections[i-1].cfeb_rev='X';
79  chamberObj->chamberCorrections[i-1].alct_length=0;
80  chamberObj->chamberCorrections[i-1].alct_rev='X';
81  chamberObj->chamberCorrections[i-1].cfeb_tmb_skew_delay=0;
82  chamberObj->chamberCorrections[i-1].cfeb_timing_corr=0;
83  chamberObj->chamberCorrections[i-1].cfeb_cable_delay=0;
84  chamberObj->chamberCorrections[i-1].anode_bx_offset=0;
85  }
86 
87 
88  // for MC there will is a different correction for each chamber type
89  if (isMC){
90  float OffsetByType;
91  float anodeOffset;
92  for(i=1;i<=MAX_SIZE;++i){
93  if (i<= 36 || (i>= 235 && i<=270)) { OffsetByType=172.; anodeOffset=6.18; }// 1/1
94  else if (i<= 72 || (i>= 271 && i<=306)) { OffsetByType=168.; anodeOffset=6.22; }// 1/2
95  else if (i<= 108 || (i>= 307 && i<=342)) { OffsetByType=177.; anodeOffset=6.19; }// 1/3
96  else if (i<= 126 || (i>= 343 && i<=360)) { OffsetByType=171.; anodeOffset=6.25; }// 2/1
97  else if (i<= 162 || (i>= 361 && i<=396)) { OffsetByType=175.; anodeOffset=6.21; }// 2/2
98  else if (i<= 180 || (i>= 397 && i<=414)) { OffsetByType=171.; anodeOffset=6.25; }// 3/1
99  else if (i<= 216 || (i>= 415 && i<=450)) { OffsetByType=175.; anodeOffset=6.20; }// 3/2
100  else if (i<= 234 || (i>= 451 && i<=468)) { OffsetByType=172.; anodeOffset=6.19; }// 4/1
101  else {OffsetByType=175; anodeOffset=6.21; }// 4/2
102 
103  chamberObj->chamberCorrections[i-1].cfeb_timing_corr=(short int)(-1*OffsetByType*FACTOR+0.5*(-1*OffsetByType>=0)-0.5*(-1*OffsetByType<0));
104  chamberObj->chamberCorrections[i-1].anode_bx_offset =(short int)(anodeOffset *FACTOR+0.5*(anodeOffset >=0)-0.5*(anodeOffset <0));
105  }
106 
107  return chamberObj;
108  }
109 
110  // ***************************************************************************
111  // Everything below this point is for setting the chamber corrections for data
112  // ***************************************************************************
113 
114  csccableread cable;
115  for(i=1;i<=MAX_SIZE;++i){
116  // the anode bx offset is 8.15 bx for chambers in 2/1, 3/1, and 4/1
117  // and 8.18 bx for all other chambers for early runs (8.20 for runs> 149357)
118  float anodeOffset;
119  if (i<= 36 || (i>= 235 && i<=270)) { anodeOffset=8.20; }// 1/1
120  else if (i<= 72 || (i>= 271 && i<=306)) { anodeOffset=8.20; }// 1/2
121  else if (i<= 108 || (i>= 307 && i<=342)) { anodeOffset=8.20; }// 1/3
122  else if (i<= 126 || (i>= 343 && i<=360)) { anodeOffset=8.15; }// 2/1
123  else if (i<= 162 || (i>= 361 && i<=396)) { anodeOffset=8.20; }// 2/2
124  else if (i<= 180 || (i>= 397 && i<=414)) { anodeOffset=8.15; }// 3/1
125  else if (i<= 216 || (i>= 415 && i<=450)) { anodeOffset=8.20; }// 3/2
126  else if (i<= 234 || (i>= 451 && i<=468)) { anodeOffset=8.15; }// 4/1
127  else {anodeOffset=8.20; }// 4/2
128 
129  // for data we will read in from Igor's database
130  cable.cable_read(i, &chamber_label, &cfeb_length, &cfeb_rev, &alct_length,
131  &alct_rev, &cfeb_tmb_skew_delay, &cfeb_timing_corr);
132  // If the read of the cable database is useful (if there is information for the chamber there)
133  // re-enter the information the cable object
134  if(!chamber_label.empty() && !(cfeb_length==0)){
135  chamberObj->chamberCorrections[i-1].cfeb_length=(short int)(cfeb_length*FACTOR+0.5);
136  chamberObj->chamberCorrections[i-1].cfeb_rev=cfeb_rev[0];
137  chamberObj->chamberCorrections[i-1].alct_length=(short int)(alct_length*FACTOR+0.5);
138  chamberObj->chamberCorrections[i-1].alct_rev=alct_rev[0];
139  chamberObj->chamberCorrections[i-1].cfeb_tmb_skew_delay=(short int)(cfeb_tmb_skew_delay*FACTOR+0.5);
140  chamberObj->chamberCorrections[i-1].cfeb_timing_corr=(short int)(cfeb_timing_corr*FACTOR+0.5);
141  chamberObj->chamberCorrections[i-1].cfeb_cable_delay=0;
142  chamberObj->chamberCorrections[i-1].anode_bx_offset=(short int)(anodeOffset*FACTOR+0.5);
143  }
144  count=count+1;
145  }
146 
147  //Read in the changes you want to make in the extra chamber variable cfeb_timing_corr
148  FILE *fin = fopen("/afs/cern.ch/user/d/deisher/public/TimingCorrections2009/ttcrx_delay_effects_23April_2010.txt","r");
149  int chamber;
150  float corr;
151  while (!feof(fin)){
152  //note space at end of format string to convert last \n
153  int check = fscanf(fin,"%d %f \n",&chamber,&corr);
154  if (check != 2){
155  printf("cfeb timing corr file has an unexpected format \n");
156  assert(0);
157  }
158  //printf("chamber %d corr %f \n",chamber,corr);
159  chamberObj->chamberCorrections[chamber-1].cfeb_timing_corr= (short int)(corr*FACTOR+0.5*(corr>=0)-0.5*(corr<0));
160  }
161  fclose(fin);
162 
163  // Remove the offsets inherent to ME11 and non ME11 chambers
164  for(i=1;i<=MAX_SIZE;++i){
165  float temp= float(chamberObj->chamberCorrections[i-1].cfeb_timing_corr)/FACTOR;
166  if (i<= 36 || (i>= 235 && i<=270))
167  chamberObj->chamberCorrections[i-1].cfeb_timing_corr=(short int)((temp-1*ME11offset)*FACTOR+0.5*(temp>=ME11offset)-0.5*(temp<ME11offset));
168  else
169  chamberObj->chamberCorrections[i-1].cfeb_timing_corr=(short int)((temp-1*nonME11offset)*FACTOR+0.5*(temp>=nonME11offset)-0.5*(temp<nonME11offset));
170  }
171 
172  //Read in the cfeb_cable_delay values (0 or 1) and don't use a precision correction factor
173  FILE *fdelay = fopen("/afs/cern.ch/user/d/deisher/public/TimingCorrections2009/cfeb_cable_delay_20100423_both.txt","r");
174  char label[1024];
175  int delay;
176  CSCIndexer indexer;
177  while (!feof(fdelay)){
178  //note space at end of format string to convert last \n
179  int check = fscanf(fdelay,"%1024s %d \n",label,&delay);
180  if (check != 2){
181  printf("cfeb cable delay file has an unexpected format \n");
182  assert(0);
183  }
184  int chamberSerial = 0;
185  int c_endcap = (label[2]=='+' ? 1 : 2);
186  int c_station = atoi(&label[3]);
187  int c_ring = atoi(&label[5]);
188  if (c_station ==1 && c_ring ==4)
189  c_ring =1;
190  int c_chamber = (label[7]=='0' ? atoi(&label[8]) : atoi(&label[7]));
191  chamberSerial = indexer.chamberIndex(c_endcap, c_station, c_ring, c_chamber);
192  //printf("chamberLabel %s (%d %d %d %d) chamberSerial %d delay %d \n",label,c_endcap,c_station, c_ring, c_chamber, chamberSerial,delay);
193  chamberObj->chamberCorrections[chamberSerial-1].cfeb_cable_delay= (short int)delay;
194  }
195  fclose(fdelay);
196 
197  //Read in a 2nd order correction for chamber offsets derived from data
198  FILE *foffset = fopen("/afs/cern.ch/user/d/deisher/public/TimingCorrections2009/offset_26July2010_codeOverhaul_slope012.txt","r");
199  float offset;
200  int iE,iS,iR,iC;
201  while (!feof(foffset)){
202  //note space at end of format string to convert last \n
203  int check = fscanf(foffset,"%d %d %d %d %f \n",&iE,&iS,&iR,&iC,&offset);
204  if (check != 5){
205  printf("offset file has an unexpected format \n");
206  assert(0);
207  }
208  int chamberSerial = 0;
209  if (iS ==1 && iR ==4)
210  iR =1;
211  chamberSerial = indexer.chamberIndex(iE,iS,iR,iC);
212  //printf("chamberLabel %s (%d %d %d %d) chamberSerial %d delay %d \n",label,c_endcap,c_station, c_ring, c_chamber, chamberSerial,delay);
213  float temp= float(chamberObj->chamberCorrections[chamberSerial-1].cfeb_timing_corr)/FACTOR;
214  chamberObj->chamberCorrections[chamberSerial-1].cfeb_timing_corr= (short int)((temp-offset)*FACTOR+0.5*(temp>=offset)-0.5*(temp<offset));
215  printf("Serial %d old corr %f change %f newcorr %f \n",chamberSerial,temp,offset,(float)chamberObj->chamberCorrections[chamberSerial-1].cfeb_timing_corr/FACTOR);
216  }
217  fclose(foffset);
218 
219  //Read in a 3rd order correction for chamber offsets derived from data
220  FILE *foffsetAgain = fopen("/afs/cern.ch/user/d/deisher/public/TimingCorrections2009/CathodeTimingCorrection_DB_12082010.txt","r");
221  while (!feof(foffsetAgain)){
222  //note space at end of format string to convert last \n
223  int check = fscanf(foffsetAgain,"%d %d %d %d %f \n",&iE,&iS,&iR,&iC,&offset);
224  if (check != 5){
225  printf("offsetAgain file has an unexpected format \n");
226  assert(0);
227  }
228  int chamberSerial = 0;
229  if (iS ==1 && iR ==4)
230  iR =1;
231  chamberSerial = indexer.chamberIndex(iE,iS,iR,iC);
232  //printf("chamberLabel %s (%d %d %d %d) chamberSerial %d delay %d \n",label,c_endcap,c_station, c_ring, c_chamber, chamberSerial,delay);
233  float temp= float(chamberObj->chamberCorrections[chamberSerial-1].cfeb_timing_corr)/FACTOR;
234  chamberObj->chamberCorrections[chamberSerial-1].cfeb_timing_corr= (short int)((temp-offset)*FACTOR+0.5*(temp>=offset)-0.5*(temp<offset));
235  printf("Serial %d old corr %f change %f newcorr %f \n",chamberSerial,temp,offset,(float)chamberObj->chamberCorrections[chamberSerial-1].cfeb_timing_corr/FACTOR);
236  }
237  fclose(foffsetAgain);
238 
239 
240 
241  return chamberObj;
242 }
IndexType chamberIndex(const CSCDetId &id) const
Definition: CSCIndexer.h:66
void cable_read(int chamber_index, std::string *chamber_label, float *cfeb_length, std::string *cfeb_rev, float *alct_length, std::string *alct_rev, float *cfeb_tmb_skew_delay, float *cfeb_timing_corr)
Definition: CSCCableRead.cc:28
JetCorrectorParameters corr
Definition: classes.h:5
def check(config)
Definition: trackerTree.py:14
CSCChamberTimeCorrectionsValues::ReturnType CSCChamberTimeCorrectionsValues::produceChamberTimeCorrections ( const CSCChamberTimeCorrectionsRcd iRecord)
void CSCChamberTimeCorrectionsValues::setIntervalFor ( const edm::eventsetup::EventSetupRecordKey ,
const edm::IOVSyncValue ,
edm::ValidityInterval oValidity 
)
overrideprivatevirtual

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 47 of file CSCChamberTimeCorrectionsValues.cc.

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

49  {
51 
52  }
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

bool CSCChamberTimeCorrectionsValues::isForMC
private
float CSCChamberTimeCorrectionsValues::ME11offsetData
private
float CSCChamberTimeCorrectionsValues::ME11offsetMC
private
float CSCChamberTimeCorrectionsValues::nonME11offsetData
private
float CSCChamberTimeCorrectionsValues::nonME11offsetMC
private