CMS 3D CMS Logo

CSCGainsDBConditions Class Reference

#include <CalibMuon/CSCCalibration/interface/CSCGainsDBConditions.h>

Inheritance diagram for CSCGainsDBConditions:

edm::ESProducer edm::EventSetupRecordIntervalFinder edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

List of all members.

Public Types

typedef const CSCDBGainsReturnType

Public Member Functions

 CSCGainsDBConditions (const edm::ParameterSet &)
ReturnType produceDBGains (const CSCDBGainsRcd &)
 ~CSCGainsDBConditions ()

Static Public Member Functions

static CSCDBGainsprefillDBGains ()

Private Member Functions

void setIntervalFor (const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &)

Private Attributes

CSCDBGainscndbGains


Detailed Description

Definition at line 20 of file CSCGainsDBConditions.h.


Member Typedef Documentation

typedef const CSCDBGains* CSCGainsDBConditions::ReturnType

Definition at line 28 of file CSCGainsDBConditions.h.


Constructor & Destructor Documentation

CSCGainsDBConditions::CSCGainsDBConditions ( const edm::ParameterSet iConfig  ) 

Definition at line 10 of file CSCGainsDBConditions.cc.

References cndbGains, prefillDBGains(), produceDBGains(), and edm::ESProducer::setWhatProduced().

00011 {
00012   //the following line is needed to tell the framework what
00013   // data is being produced
00014   cndbGains = prefillDBGains();
00015   // added by Zhen (changed since 1_2_0)
00016   setWhatProduced(this,&CSCGainsDBConditions::produceDBGains);
00017   findingRecord<CSCDBGainsRcd>();
00018   //now do what ever other initialization is needed
00019 }

CSCGainsDBConditions::~CSCGainsDBConditions (  ) 

Definition at line 22 of file CSCGainsDBConditions.cc.

References cndbGains.

00023 {
00024  
00025    // do anything here that needs to be done at desctruction time
00026    // (e.g. close files, deallocate resources etc.)
00027   delete cndbGains;
00028 }


Member Function Documentation

CSCDBGains * CSCGainsDBConditions::prefillDBGains (  )  [inline, static]

Definition at line 44 of file CSCGainsDBConditions.h.

References TestMuL1L2Filter_cff::cerr, counter(), GenMuonPlsPt100GeV_cfg::cout, lat::endl(), cmsRelvalreport::exit, CSCDBGains::factor_gain, CSCDBGains::gains, i, in, int, and k.

Referenced by CSCGainsDBConditions().

00045 {
00046   const int MAX_SIZE = 217728;
00047   const int FACTOR = 1000;
00048   const int MAX_SHORT = 32767;
00049   CSCDBGains * cndbgains = new CSCDBGains();
00050     
00051   int db_index;
00052   float db_gainslope,db_intercpt, db_chisq;
00053   std::vector<int> db_index_id;
00054   std::vector<float> db_slope;
00055   std::vector<float> db_intercept;
00056   std::vector<float> db_chi2;
00057   int new_index;
00058   float new_gainslope,new_intercpt, new_chisq;
00059   std::vector<int> new_cham_id;
00060   std::vector<int> new_index_id;
00061   std::vector<int> new_strips;
00062   std::vector<float> new_slope;
00063   std::vector<float> new_intercept;
00064   std::vector<float> new_chi2;
00065 
00066   int counter;
00067   int db_nrlines=0;
00068   int new_nrlines=0;
00069   
00070   std::ifstream dbdata; 
00071   dbdata.open("old_dbgains.dat",std::ios::in); 
00072   if(!dbdata) {
00073     std::cerr <<"Error: old_dbgains.dat -> no such file!"<< std::endl;
00074     exit(1);
00075   }
00076   
00077   while (!dbdata.eof() ) { 
00078     dbdata >> db_index >> db_gainslope >> db_intercpt >> db_chisq ; 
00079     db_index_id.push_back(db_index);
00080     db_slope.push_back(db_gainslope);
00081     db_intercept.push_back(db_intercpt);
00082     db_chi2.push_back(db_chisq);
00083     db_nrlines++;
00084   }
00085   dbdata.close();
00086 
00087   std::ifstream newdata;
00088   newdata.open("gains.dat",std::ios::in); 
00089   if(!newdata) {
00090     std::cerr <<"Error: gains.dat -> no such file!"<< std::endl;
00091     exit(1);
00092   }
00093   
00094   while (!newdata.eof() ) { 
00095     newdata >> new_index >> new_gainslope >> new_intercpt >> new_chisq ; 
00096     new_index_id.push_back(new_index);
00097     new_slope.push_back(new_gainslope);
00098     new_intercept.push_back(new_intercpt);
00099     new_chi2.push_back(new_chisq);
00100     new_nrlines++;
00101   }
00102   newdata.close();
00103 
00104   CSCDBGains::GainContainer & itemvector = cndbgains->gains;
00105   itemvector.resize(MAX_SIZE);
00106   cndbgains->factor_gain = (short int) (FACTOR);
00107   std::cout<<" myfactor "<<cndbgains->factor_gain<<std::endl;
00108 
00109   for(int i=0; i<MAX_SIZE;++i){
00110     itemvector[i].gain_slope= int (db_slope[i]*FACTOR+0.5);
00111   }
00112 
00113    for(int i=0; i<MAX_SIZE;++i){
00114      counter=db_index_id[i];  
00115      for (unsigned int k=0;k<new_index_id.size()-1;k++){
00116        if(counter==new_index_id[k]){
00117          if ((short int) (fabs(new_slope[k]*FACTOR+0.5))<MAX_SHORT) itemvector[counter].gain_slope= int (new_slope[k]*FACTOR+0.5);
00118          itemvector[i] = itemvector[counter];
00119         //std::cout<<"counter "<<counter<<" new_index_id[k] "<<new_index_id[k]<<" new_slope[k] "<<new_slope[k]<<" db_slope[k] "<<db_slope[k]<<std::endl;
00120        }  
00121      }
00122    }
00123      return cndbgains;
00124 }

CSCGainsDBConditions::ReturnType CSCGainsDBConditions::produceDBGains ( const CSCDBGainsRcd iRecord  ) 

Definition at line 37 of file CSCGainsDBConditions.cc.

References cndbGains.

Referenced by CSCGainsDBConditions().

00038 {
00039   //need a new object so to not be deleted at exit
00040   CSCDBGains* mydata=new CSCDBGains( *cndbGains );
00041   return mydata;
00042   
00043 }

void CSCGainsDBConditions::setIntervalFor ( const edm::eventsetup::EventSetupRecordKey ,
const edm::IOVSyncValue ,
edm::ValidityInterval oValidity 
) [private, virtual]

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 45 of file CSCGainsDBConditions.cc.

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


Member Data Documentation

CSCDBGains* CSCGainsDBConditions::cndbGains [private]

Definition at line 35 of file CSCGainsDBConditions.h.

Referenced by CSCGainsDBConditions(), produceDBGains(), and ~CSCGainsDBConditions().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:17:19 2009 for CMSSW by  doxygen 1.5.4