1 #ifndef _CSCGASGAINCORRECTIONDBCONDITIONS_H 2 #define _CSCGASGAINCORRECTIONDBCONDITIONS_H 28 typedef std::unique_ptr<CSCDBGasGainCorrection>
ReturnType;
56 printf(
"\n Generating fake DB constants for MC\n");
58 printf(
"\n Reading gas gain corrections from file %s \n", filename.data());
63 const int MAX_SIZE = 55944;
68 itemvector.resize(MAX_SIZE);
72 for (
int i = 0;
i < MAX_SIZE;
i++) {
73 itemvector[
i].gainCorr = 1.;
75 return cndbGasGainCorr;
90 float gas_gain_correction;
93 for (
int j = 0; j < MAX_SIZE; j++) {
94 gains[j].gas_gain_index = -999;
95 gains[j].endcap = -999;
96 gains[j].station = -999;
98 gains[j].chamber = -999;
99 gains[j].layer = -999;
100 gains[j].hvsegment = -999;
101 gains[j].cfeb = -999;
102 gains[j].nentries = -999;
103 gains[j].mean = -999.;
104 gains[j].truncated_mean = -999.;
105 gains[j].gas_gain_correction = -999.;
108 FILE *
fin = fopen(filename.data(),
"r");
114 int check = fscanf(fin,
115 "%d %d %d %d %d %d %d %d %d %f %f %f \n",
116 &gains[linecounter].gas_gain_index,
117 &gains[linecounter].
endcap,
119 &gains[linecounter].
ring,
121 &gains[linecounter].layer,
122 &gains[linecounter].hvsegment,
123 &gains[linecounter].cfeb,
124 &gains[linecounter].nentries,
125 &gains[linecounter].
mean,
126 &gains[linecounter].truncated_mean,
127 &gains[linecounter].gas_gain_correction);
130 printf(
"The input file format is not as expected\n");
139 if (linecounter == MAX_SIZE) {
140 std::cout <<
"Total number of gas gains read in = " << linecounter << std::endl;
142 std::cout <<
"ERROR: Total number of gas-gains read in = " << linecounter
143 <<
" while total number expected = " << MAX_SIZE << std::endl;
147 for (
int i = 0;
i < MAX_SIZE;
i++) {
148 itemvector[
i].gainCorr = 0.;
150 if (gains[
i].gas_gain_correction > 0.) {
151 itemvector[
i].gainCorr = gains[
i].gas_gain_correction;
154 std::cout <<
"ERROR: gas_gain_correction < 0 for index " << gains[
i].gas_gain_index << std::endl;
158 return cndbGasGainCorr;
~CSCGasGainCorrectionDBConditions() override
std::string dataCorrFileName
GasGainContainer gasGainCorr
CSCGasGainCorrectionDBConditions(const edm::ParameterSet &)
std::unique_ptr< CSCDBGasGainCorrection > ReturnType
static CSCDBGasGainCorrection * prefillDBGasGainCorrection(bool isForMC, std::string dataCorrFileName)
ReturnType produceDBGasGainCorrection(const CSCDBGasGainCorrectionRcd &)
std::vector< Item > GasGainContainer
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override