1 #ifndef _CSCCHIPSPEEDCORRECTIONDBCONDITIONS_H
2 #define _CSCCHIPSPEEDCORRECTIONDBCONDITIONS_H
59 printf(
"\n Generating fake DB constants for MC\n");
61 printf(
"\n Reading chip corrections from file %s \n",filename.data());
62 printf(
"my data offset value is %f \n",dataOffset);
67 const int CHIP_FACTOR=100;
68 const int MAX_SIZE = 15768;
69 const int MAX_SHORT= 32767;
73 itemvector.resize(MAX_SIZE);
78 for (
int i=0;
i<MAX_SIZE;
i++){
79 itemvector[
i].speedCorr = 0;
85 FILE *
fin = fopen(filename.data(),
"r");
91 std::vector<int> new_index_id;
92 std::vector<float> new_chipPulse;
93 double runningTotal = 0;
98 int check = fscanf(fin,
"%d %d %d %d %d %d %f %f %d \n",&serialChamber,&endcap,&station,&ring,&chamber,&chip,&t,&dt,&nPulses);
100 printf(
"The input file format is not as expected\n");
104 int serialChamber_safecopy = serialChamber;
117 if (serialChamber >=235 && serialChamber <=270)
118 serialChamber += 234;
120 if (serialChamber >=271 && serialChamber <=504)
128 int layer = (chip)/5+1;
132 CSCDetId cscId_doubleCheck(endcap,station,ring,chamber,layer);
133 if (cscId != cscId_doubleCheck){
134 printf(
"Why doesn't chamberSerial %d map to e: %d s: %d r: %d c: %d ? \n",serialChamber_safecopy, endcap, station, ring, chamber);
143 if (endcap == 2 && station ==1 && ring==1 && chip <5){
148 new_index_id.push_back(indexer.
chipIndex(cscId,chip));
149 new_chipPulse.push_back(t);
159 for (
int i=0;
i<MAX_SIZE;
i++){
160 itemvector[
i].speedCorr = 0;
163 for (
unsigned int i=0;
i<new_index_id.size();
i++){
164 if((
short int) (fabs((dataOffset-new_chipPulse[
i])*CHIP_FACTOR+0.5))<MAX_SHORT)
165 itemvector[new_index_id[
i]-1].speedCorr = (
short int) ((dataOffset-new_chipPulse[i])*CHIP_FACTOR+0.5*(dataOffset>=new_chipPulse[
i])-0.5*(dataOffset<new_chipPulse[i]));
174 float ave = runningTotal/numNonZero;
175 for (
int i=0;
i<MAX_SIZE;
i++){
176 if( itemvector[
i].speedCorr == 0 ||itemvector[
i].speedCorr == (
short int)(dataOffset*CHIP_FACTOR+0.5) )
177 itemvector[
i].speedCorr = (
short int) ((dataOffset-ave)*CHIP_FACTOR+0.5*(dataOffset>=ave)-0.5*(dataOffset<ave));
ChipSpeedContainer chipSpeedCorr
~CSCChipSpeedCorrectionDBConditions()
ReturnType produceDBChipSpeedCorrection(const CSCDBChipSpeedCorrectionRcd &)
bool check(const std::string &)
CSCDetId detIdFromChamberIndex(IndexType ici) const
const CSCDBChipSpeedCorrection * ReturnType
std::string dataCorrFileName
IndexType chipIndex(IndexType ie, IndexType is, IndexType ir, IndexType ic, IndexType il, IndexType ichip) const
static CSCDBChipSpeedCorrection * prefillDBChipSpeedCorrection(bool isForMC, std::string dataCorrFileName, float dataOffse)
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &)
std::vector< Item > ChipSpeedContainer
CSCChipSpeedCorrectionDBConditions(const edm::ParameterSet &)
CSCDBChipSpeedCorrection * cndbChipCorr