CMS 3D CMS Logo

CSCCrosstalkDBConditions Class Reference

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

Inheritance diagram for CSCCrosstalkDBConditions:

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

List of all members.

Public Types

typedef const CSCDBCrosstalkReturnType

Public Member Functions

 CSCCrosstalkDBConditions (const edm::ParameterSet &)
ReturnType produceDBCrosstalk (const CSCDBCrosstalkRcd &)
 ~CSCCrosstalkDBConditions ()

Static Public Member Functions

static CSCDBCrosstalkprefillDBCrosstalk ()

Private Member Functions

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

Private Attributes

CSCDBCrosstalkcndbCrosstalk


Detailed Description

Definition at line 20 of file CSCCrosstalkDBConditions.h.


Member Typedef Documentation

typedef const CSCDBCrosstalk* CSCCrosstalkDBConditions::ReturnType

Definition at line 28 of file CSCCrosstalkDBConditions.h.


Constructor & Destructor Documentation

CSCCrosstalkDBConditions::CSCCrosstalkDBConditions ( const edm::ParameterSet iConfig  ) 

Definition at line 10 of file CSCCrosstalkDBConditions.cc.

References cndbCrosstalk, prefillDBCrosstalk(), produceDBCrosstalk(), and edm::ESProducer::setWhatProduced().

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

CSCCrosstalkDBConditions::~CSCCrosstalkDBConditions (  ) 

Definition at line 22 of file CSCCrosstalkDBConditions.cc.

References cndbCrosstalk.

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


Member Function Documentation

CSCDBCrosstalk * CSCCrosstalkDBConditions::prefillDBCrosstalk (  )  [inline, static]

Definition at line 46 of file CSCCrosstalkDBConditions.h.

References TestMuL1L2Filter_cff::cerr, counter(), CSCDBCrosstalk::crosstalk, lat::endl(), cmsRelvalreport::exit, CSCDBCrosstalk::factor_intercept, CSCDBCrosstalk::factor_slope, i, in, int, and k.

Referenced by CSCCrosstalkDBConditions().

00047 {
00048   const int MAX_SIZE = 217728;
00049   const int SLOPE_FACTOR=10000000;
00050   const int INTERCEPT_FACTOR=100000;
00051   const int MAX_SHORT= 32767;
00052   CSCDBCrosstalk * cndbcrosstalk = new CSCDBCrosstalk();
00053 
00054   int db_index,new_index;
00055   float db_slope_right,db_slope_left,db_intercept_right;
00056   float db_intercept_left, db_chi2_right,db_chi2_left;
00057   std::vector<int> db_index_id;
00058   std::vector<float> db_slope_r;
00059   std::vector<float> db_intercept_r;
00060   std::vector<float> db_chi2_r;
00061   std::vector<float> db_slope_l;
00062   std::vector<float> db_intercept_l;
00063   std::vector<float> db_chi2_l;
00064   float new_slope_right,new_slope_left,new_intercept_right;
00065   float new_intercept_left, new_chi2_right,new_chi2_left;
00066   std::vector<int> new_cham_id;
00067   std::vector<int> new_index_id;
00068   std::vector<int> new_strips;
00069   std::vector<float> new_slope_r;
00070   std::vector<float> new_intercept_r;
00071   std::vector<float> new_chi2_r;
00072   std::vector<float> new_slope_l;
00073   std::vector<float> new_intercept_l;
00074   std::vector<float> new_chi2_l;
00075     
00076   int counter;
00077   int db_nrlines=0;
00078   int new_nrlines=0;
00079     
00080   std::ifstream dbdata; 
00081   dbdata.open("old_dbxtalk.dat",std::ios::in); 
00082   if(!dbdata) {
00083     std::cerr <<"Error: old_dbxtalk.dat -> no such file!"<< std::endl;
00084     exit(1);
00085   }
00086   
00087   while (!dbdata.eof() ) { 
00088     dbdata >> db_index >> db_slope_right >> db_intercept_right >> db_chi2_right >> db_slope_left >> db_intercept_left >> db_chi2_left ;
00089     db_index_id.push_back(db_index);
00090     db_slope_r.push_back(db_slope_right);
00091     db_slope_l.push_back(db_slope_left);
00092     db_intercept_r.push_back(db_intercept_right);
00093     db_intercept_l.push_back(db_intercept_left);
00094     db_chi2_r.push_back(db_chi2_right);
00095     db_chi2_l.push_back(db_chi2_left); 
00096     db_nrlines++;
00097   }
00098   dbdata.close();
00099 
00100   std::ifstream newdata;
00101   newdata.open("xtalk.dat",std::ios::in); 
00102   if(!newdata) {
00103     std::cerr <<"Error: xtalk.dat -> no such file!"<< std::endl;
00104     exit(1);
00105   }
00106   
00107   while (!newdata.eof() ) { 
00108     newdata >> new_index >> new_slope_right >> new_intercept_right >> new_chi2_right >> new_slope_left >> new_intercept_left >> new_chi2_left ; 
00109     new_index_id.push_back(new_index);
00110     new_slope_r.push_back(new_slope_right);
00111     new_slope_l.push_back(new_slope_left);
00112     new_intercept_r.push_back(new_intercept_right);
00113     new_intercept_l.push_back(new_intercept_left);
00114     new_chi2_r.push_back(new_chi2_right);
00115     new_chi2_l.push_back(new_chi2_left);
00116     new_nrlines++;
00117   }
00118   newdata.close();
00119   
00120   CSCDBCrosstalk::CrosstalkContainer & itemvector = cndbcrosstalk->crosstalk;
00121   itemvector.resize(MAX_SIZE);
00122   cndbcrosstalk->factor_slope = int (SLOPE_FACTOR);
00123   cndbcrosstalk->factor_intercept = int (INTERCEPT_FACTOR);
00124 
00125   for(int i=0; i<MAX_SIZE;++i){
00126     itemvector[i].xtalk_slope_right=(short int) (db_slope_r[i]*SLOPE_FACTOR+0.5);
00127     itemvector[i].xtalk_intercept_right= (short int) (db_intercept_r[i]*INTERCEPT_FACTOR+0.5); 
00128     itemvector[i].xtalk_slope_left= (short int) (db_slope_l[i]*SLOPE_FACTOR+0.5);  
00129     itemvector[i].xtalk_intercept_left= (short int) (db_intercept_l[i]*INTERCEPT_FACTOR+0.5);  
00130   }
00131 
00132   for(int i=0; i<MAX_SIZE;++i){
00133     counter=db_index_id[i];  
00134     for (unsigned int k=0;k<new_index_id.size()-1;k++){
00135       if(counter==new_index_id[k]){
00136         if ((short int) (fabs(new_slope_r[k]*SLOPE_FACTOR+0.5))<MAX_SHORT)         itemvector[counter].xtalk_slope_right= int (new_slope_r[k]*SLOPE_FACTOR+0.5);
00137         if ((short int) (fabs(new_intercept_r[k]*INTERCEPT_FACTOR+0.5))<MAX_SHORT) itemvector[counter].xtalk_intercept_right= int (new_intercept_r[k]*INTERCEPT_FACTOR+0.5); 
00138         if ((short int) (fabs(new_slope_l[k]*SLOPE_FACTOR+0.5))<MAX_SHORT)         itemvector[counter].xtalk_slope_left= int (new_slope_l[k]*SLOPE_FACTOR+0.5);  
00139         if ((short int) (fabs(new_intercept_l[k]*INTERCEPT_FACTOR+0.5))<MAX_SHORT) itemvector[counter].xtalk_intercept_left= int (new_intercept_l[k]*INTERCEPT_FACTOR+0.5);  
00140         itemvector[i] = itemvector[counter];
00141         //std::cout<<" counter "<<counter <<" dbindex "<<new_index_id[k]<<" dbslope " <<db_slope_r[k]<<" new slope "<<new_slope_r[k]<<std::endl;
00142       }  
00143     }
00144   }
00145   
00146   return cndbcrosstalk;
00147 
00148 }

CSCCrosstalkDBConditions::ReturnType CSCCrosstalkDBConditions::produceDBCrosstalk ( const CSCDBCrosstalkRcd iRecord  ) 

Definition at line 37 of file CSCCrosstalkDBConditions.cc.

References cndbCrosstalk.

Referenced by CSCCrosstalkDBConditions().

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

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

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 45 of file CSCCrosstalkDBConditions.cc.

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


Member Data Documentation

CSCDBCrosstalk* CSCCrosstalkDBConditions::cndbCrosstalk [private]

Definition at line 37 of file CSCCrosstalkDBConditions.h.

Referenced by CSCCrosstalkDBConditions(), produceDBCrosstalk(), and ~CSCCrosstalkDBConditions().


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