#include <CSCGasGainCorrectionDBConditions.h>
Public Types | |
typedef const CSCDBGasGainCorrection * | ReturnType |
Public Member Functions | |
CSCGasGainCorrectionDBConditions (const edm::ParameterSet &) | |
ReturnType | produceDBGasGainCorrection (const CSCDBGasGainCorrectionRcd &) |
~CSCGasGainCorrectionDBConditions () | |
Static Public Member Functions | |
static CSCDBGasGainCorrection * | prefillDBGasGainCorrection (bool isForMC, std::string dataCorrFileName) |
Private Member Functions | |
void | setIntervalFor (const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) |
Private Attributes | |
CSCDBGasGainCorrection * | cndbGasGainCorr |
std::string | dataCorrFileName |
bool | isForMC |
Definition at line 21 of file CSCGasGainCorrectionDBConditions.h.
Definition at line 28 of file CSCGasGainCorrectionDBConditions.h.
CSCGasGainCorrectionDBConditions::CSCGasGainCorrectionDBConditions | ( | const edm::ParameterSet & | iConfig | ) |
Definition at line 10 of file CSCGasGainCorrectionDBConditions.cc.
References cndbGasGainCorr, dataCorrFileName, edm::ParameterSet::getUntrackedParameter(), isForMC, prefillDBGasGainCorrection(), produceDBGasGainCorrection(), and edm::ESProducer::setWhatProduced().
{ //the following line is needed to tell the framework what // data is being produced isForMC = iConfig.getUntrackedParameter<bool>("isForMC",true); dataCorrFileName= iConfig.getUntrackedParameter<std::string>("dataCorrFileName","empty.txt"); cndbGasGainCorr = prefillDBGasGainCorrection(isForMC,dataCorrFileName); // added by Zhen (changed since 1_2_0) setWhatProduced(this,&CSCGasGainCorrectionDBConditions::produceDBGasGainCorrection); findingRecord<CSCDBGasGainCorrectionRcd>(); //now do what ever other initialization is needed }
CSCGasGainCorrectionDBConditions::~CSCGasGainCorrectionDBConditions | ( | ) |
Definition at line 25 of file CSCGasGainCorrectionDBConditions.cc.
References cndbGasGainCorr.
{ // do anything here that needs to be done at desctruction time // (e.g. close files, deallocate resources etc.) delete cndbGasGainCorr; }
CSCDBGasGainCorrection * CSCGasGainCorrectionDBConditions::prefillDBGasGainCorrection | ( | bool | isForMC, |
std::string | dataCorrFileName | ||
) | [inline, static] |
Definition at line 55 of file CSCGasGainCorrectionDBConditions.h.
References CastorDataFrameFilter_impl::check(), cndbGasGainCorr, gather_cfg::cout, Reference_intrackfit_cff::endcap, groupFilesInBlocks::fin, CSCDBGasGainCorrection::gasGainCorr, i, j, timingPdfMaker::mean, relativeConstraints::ring, and relativeConstraints::station.
Referenced by CSCGasGainCorrectionDBConditions().
{ if (isMC) printf("\n Generating fake DB constants for MC\n"); else { printf("\n Reading gas gain corrections from file %s \n",filename.data()); } CSCIndexer indexer; const int MAX_SIZE = 55944; CSCDBGasGainCorrection * cndbGasGainCorr = new CSCDBGasGainCorrection(); CSCDBGasGainCorrection::GasGainContainer & itemvector = cndbGasGainCorr->gasGainCorr; itemvector.resize(MAX_SIZE); //Filling corrections for MC is very simple if (isMC){ for (int i=0;i<MAX_SIZE;i++){ itemvector[i].gainCorr = 1.; } return cndbGasGainCorr; } struct gain_info { int gas_gain_index ; int endcap ; int station ; int ring ; int chamber ; int layer ; int hvsegment ; int cfeb ; int nentries ; float mean ; float truncated_mean ; float gas_gain_correction; } gains[MAX_SIZE]; for (int j=0; j<MAX_SIZE; j++) { gains[j].gas_gain_index = -999; gains[j].endcap = -999; gains[j].station = -999; gains[j].ring = -999; gains[j].chamber = -999; gains[j].layer = -999; gains[j].hvsegment = -999; gains[j].cfeb = -999; gains[j].nentries = -999; gains[j].mean = -999.; gains[j].truncated_mean = -999.; gains[j].gas_gain_correction= -999.; } FILE *fin = fopen(filename.data(),"r"); int linecounter = 0; // set the line counter to the first serial number in the file.... while (!feof(fin)){ //note space at end of format string to convert last \n int check = fscanf(fin,"%d %d %d %d %d %d %d %d %d %f %f %f \n", &gains[linecounter].gas_gain_index , &gains[linecounter].endcap , &gains[linecounter].station , &gains[linecounter].ring , &gains[linecounter].chamber , &gains[linecounter].layer , &gains[linecounter].hvsegment , &gains[linecounter].cfeb , &gains[linecounter].nentries , &gains[linecounter].mean , &gains[linecounter].truncated_mean , &gains[linecounter].gas_gain_correction); if (check != 12){ printf("The input file format is not as expected\n"); assert(0); } linecounter++; } fclose(fin); if (linecounter == MAX_SIZE) { std::cout << "Total number of gas gains read in = " << linecounter << std::endl; } else { std::cout << "ERROR: Total number of gas-gains read in = " << linecounter << " while total number expected = " << MAX_SIZE << std::endl; } // Fill the chip corrections with values from the file for (int i=0;i<MAX_SIZE;i++){ itemvector[i].gainCorr = 0.; if (gains[i].gas_gain_correction > 0.) { itemvector[i].gainCorr = gains[i].gas_gain_correction; } else { // if there is no value, this should be fixed... std::cout << "ERROR: gas_gain_correction < 0 for index " << gains[i].gas_gain_index << std::endl; } } return cndbGasGainCorr; }
CSCGasGainCorrectionDBConditions::ReturnType CSCGasGainCorrectionDBConditions::produceDBGasGainCorrection | ( | const CSCDBGasGainCorrectionRcd & | iRecord | ) |
Definition at line 40 of file CSCGasGainCorrectionDBConditions.cc.
References cndbGasGainCorr.
Referenced by CSCGasGainCorrectionDBConditions().
{ //need a new object so to not be deleted at exit CSCDBGasGainCorrection* mydata=new CSCDBGasGainCorrection( *cndbGasGainCorr ); return mydata; }
void CSCGasGainCorrectionDBConditions::setIntervalFor | ( | const edm::eventsetup::EventSetupRecordKey & | , |
const edm::IOVSyncValue & | , | ||
edm::ValidityInterval & | oValidity | ||
) | [private, virtual] |
Implements edm::EventSetupRecordIntervalFinder.
Definition at line 48 of file CSCGasGainCorrectionDBConditions.cc.
References edm::IOVSyncValue::beginOfTime(), and edm::IOVSyncValue::endOfTime().
{ oValidity = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(),edm::IOVSyncValue::endOfTime()); }
Definition at line 35 of file CSCGasGainCorrectionDBConditions.h.
Referenced by CSCGasGainCorrectionDBConditions(), prefillDBGasGainCorrection(), produceDBGasGainCorrection(), and ~CSCGasGainCorrectionDBConditions().
std::string CSCGasGainCorrectionDBConditions::dataCorrFileName [private] |
Definition at line 40 of file CSCGasGainCorrectionDBConditions.h.
Referenced by CSCGasGainCorrectionDBConditions().
bool CSCGasGainCorrectionDBConditions::isForMC [private] |
Definition at line 38 of file CSCGasGainCorrectionDBConditions.h.
Referenced by CSCGasGainCorrectionDBConditions().