1 #ifndef _CSCCCHAMBERTIMECORRECTIONSVALUES_H
2 #define _CSCCCHAMBERTIMECORRECTIONSVALUES_H
56 printf(
"\n Generating fake DB constants for MC\n");
58 printf(
"\n Getting chamber corrections from the cable data base and possibly other files \n");
61 const int MAX_SIZE = 540;
69 float cfeb_length=0, alct_length=0, cfeb_tmb_skew_delay=0, cfeb_timing_corr=0;
77 for(i=1;i<=MAX_SIZE;++
i){
93 for(i=1;i<=MAX_SIZE;++
i){
94 if (i<= 36 || (i>= 235 && i<=270)) { OffsetByType=172.; anodeOffset=6.18; }
95 else if (i<= 72 || (i>= 271 && i<=306)) { OffsetByType=168.; anodeOffset=6.22; }
96 else if (i<= 108 || (i>= 307 && i<=342)) { OffsetByType=177.; anodeOffset=6.19; }
97 else if (i<= 126 || (i>= 343 && i<=360)) { OffsetByType=171.; anodeOffset=6.25; }
98 else if (i<= 162 || (i>= 361 && i<=396)) { OffsetByType=175.; anodeOffset=6.21; }
99 else if (i<= 180 || (i>= 397 && i<=414)) { OffsetByType=171.; anodeOffset=6.25; }
100 else if (i<= 216 || (i>= 415 && i<=450)) { OffsetByType=175.; anodeOffset=6.20; }
101 else if (i<= 234 || (i>= 451 && i<=468)) { OffsetByType=172.; anodeOffset=6.19; }
102 else {OffsetByType=175; anodeOffset=6.21; }
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));
116 for(i=1;i<=MAX_SIZE;++
i){
120 if (i<= 36 || (i>= 235 && i<=270)) { anodeOffset=8.20; }
121 else if (i<= 72 || (i>= 271 && i<=306)) { anodeOffset=8.20; }
122 else if (i<= 108 || (i>= 307 && i<=342)) { anodeOffset=8.20; }
123 else if (i<= 126 || (i>= 343 && i<=360)) { anodeOffset=8.15; }
124 else if (i<= 162 || (i>= 361 && i<=396)) { anodeOffset=8.20; }
125 else if (i<= 180 || (i>= 397 && i<=414)) { anodeOffset=8.15; }
126 else if (i<= 216 || (i>= 415 && i<=450)) { anodeOffset=8.20; }
127 else if (i<= 234 || (i>= 451 && i<=468)) { anodeOffset=8.15; }
128 else {anodeOffset=8.20; }
131 cable->
cable_read(i, &chamber_label, &cfeb_length, &cfeb_rev, &alct_length,
132 &alct_rev, &cfeb_tmb_skew_delay, &cfeb_timing_corr);
135 if(!chamber_label.empty() && !(cfeb_length==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);
143 chamberObj->
chamberCorrections[i-1].anode_bx_offset=(
short int)(anodeOffset*FACTOR+0.5);
149 FILE *
fin = fopen(
"/afs/cern.ch/user/d/deisher/public/TimingCorrections2009/ttcrx_delay_effects_23April_2010.txt",
"r");
154 int check = fscanf(fin,
"%d %f \n",&chamber,&corr);
156 printf(
"cfeb timing corr file has an unexpected format \n");
160 chamberObj->
chamberCorrections[chamber-1].cfeb_timing_corr= (
short int)(corr*FACTOR+0.5*(corr>=0)-0.5*(corr<0));
165 for(i=1;i<=MAX_SIZE;++
i){
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));
170 chamberObj->
chamberCorrections[i-1].cfeb_timing_corr=(
short int)((temp-1*nonME11offset)*FACTOR+0.5*(temp>=nonME11offset)-0.5*(temp<nonME11offset));
174 FILE *fdelay = fopen(
"/afs/cern.ch/user/d/deisher/public/TimingCorrections2009/cfeb_cable_delay_20100423_both.txt",
"r");
178 while (!feof(fdelay)){
180 int check = fscanf(fdelay,
"%1024s %d \n",label,&delay);
182 printf(
"cfeb cable delay file has an unexpected format \n");
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)
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);
199 FILE *foffset = fopen(
"/afs/cern.ch/user/d/deisher/public/TimingCorrections2009/offset_26July2010_codeOverhaul_slope012.txt",
"r");
202 while (!feof(foffset)){
204 int check = fscanf(foffset,
"%d %d %d %d %f \n",&iE,&iS,&iR,&iC,&offset);
206 printf(
"offset file has an unexpected format \n");
209 int chamberSerial = 0;
210 if (iS ==1 && iR ==4)
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);
221 FILE *foffsetAgain = fopen(
"/afs/cern.ch/user/d/deisher/public/TimingCorrections2009/CathodeTimingCorrection_DB_12082010.txt",
"r");
222 while (!feof(foffsetAgain)){
224 int check = fscanf(foffsetAgain,
"%d %d %d %d %f \n",&iE,&iS,&iR,&iC,&offset);
226 printf(
"offsetAgain file has an unexpected format \n");
229 int chamberSerial = 0;
230 if (iS ==1 && iR ==4)
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);
238 fclose(foffsetAgain);
IndexType chamberIndex(const CSCDetId &id) const
static CSCChamberTimeCorrections * prefill(bool isMC, float ME11offset, float nonME11offset)
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)
const CSCChamberTimeCorrections * ReturnType
CSCChamberTimeCorrectionsValues(const edm::ParameterSet &)
bool check(const std::string &)
ReturnType produceChamberTimeCorrections(const CSCChamberTimeCorrectionsRcd &)
ChamberContainer chamberCorrections
CSCChamberTimeCorrections * chamberObj
~CSCChamberTimeCorrectionsValues()
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &)