test
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
CSCChamberTimeCorrectionsValues Class Reference

#include <CSCChamberTimeCorrectionsValues.h>

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

Public Types

typedef const
CSCChamberTimeCorrections
ReturnType
 
- 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

 CSCChamberTimeCorrectionsValues (const edm::ParameterSet &)
 
ReturnType produceChamberTimeCorrections (const CSCChamberTimeCorrectionsRcd &)
 
 ~CSCChamberTimeCorrectionsValues ()
 
- 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 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 &)
 

Private Attributes

CSCChamberTimeCorrectionschamberObj
 
bool isForMC
 
float ME11offsetData
 
float ME11offsetMC
 
float nonME11offsetData
 
float nonME11offsetMC
 

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 23 of file CSCChamberTimeCorrectionsValues.h.

Member Typedef Documentation

Definition at line 30 of file CSCChamberTimeCorrectionsValues.h.

Constructor & Destructor Documentation

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

Definition at line 10 of file CSCChamberTimeCorrectionsValues.cc.

References chamberObj, edm::ParameterSet::getUntrackedParameter(), isForMC, ME11offsetData, ME11offsetMC, nonME11offsetData, nonME11offsetMC, prefill(), 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;
21  findingRecord<CSCChamberTimeCorrectionsRcd>();
22  //now do what ever other initialization is needed
23 }
T getUntrackedParameter(std::string const &, T const &) const
static CSCChamberTimeCorrections * prefill(bool isMC, float ME11offset, float nonME11offset)
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
ReturnType produceChamberTimeCorrections(const CSCChamberTimeCorrectionsRcd &)
CSCChamberTimeCorrectionsValues::~CSCChamberTimeCorrectionsValues ( )

Definition at line 26 of file CSCChamberTimeCorrectionsValues.cc.

References chamberObj.

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

Member Function Documentation

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

Definition at line 53 of file CSCChamberTimeCorrectionsValues.h.

References assert(), csccableread::cable_read(), CSCChamberTimeCorrections::chamberCorrections, CSCIndexer::chamberIndex(), chamberObj, trackerTree::check(), corr, KineDebug3::count(), CSCChamberTimeCorrections::factor_precision, groupFilesInBlocks::fin, i, diffTwoXMLs::label, hltrates_dqm_sourceclient-live_cfg::offset, AlCaHLTBitMon_QueryRunRegistry::string, and groupFilesInBlocks::temp.

Referenced by CSCChamberTimeCorrectionsValues().

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

Definition at line 41 of file CSCChamberTimeCorrectionsValues.cc.

References chamberObj.

Referenced by CSCChamberTimeCorrectionsValues().

42 {
43  //need a new object so to not be deleted at exit
45  return mydata;
46 
47 }
void CSCChamberTimeCorrectionsValues::setIntervalFor ( const edm::eventsetup::EventSetupRecordKey ,
const edm::IOVSyncValue ,
edm::ValidityInterval oValidity 
)
privatevirtual

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 49 of file CSCChamberTimeCorrectionsValues.cc.

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

51  {
53 
54  }
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

CSCChamberTimeCorrections* CSCChamberTimeCorrectionsValues::chamberObj
private
bool CSCChamberTimeCorrectionsValues::isForMC
private

Definition at line 40 of file CSCChamberTimeCorrectionsValues.h.

Referenced by CSCChamberTimeCorrectionsValues().

float CSCChamberTimeCorrectionsValues::ME11offsetData
private

Definition at line 42 of file CSCChamberTimeCorrectionsValues.h.

Referenced by CSCChamberTimeCorrectionsValues().

float CSCChamberTimeCorrectionsValues::ME11offsetMC
private

Definition at line 41 of file CSCChamberTimeCorrectionsValues.h.

Referenced by CSCChamberTimeCorrectionsValues().

float CSCChamberTimeCorrectionsValues::nonME11offsetData
private

Definition at line 44 of file CSCChamberTimeCorrectionsValues.h.

Referenced by CSCChamberTimeCorrectionsValues().

float CSCChamberTimeCorrectionsValues::nonME11offsetMC
private

Definition at line 43 of file CSCChamberTimeCorrectionsValues.h.

Referenced by CSCChamberTimeCorrectionsValues().