CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

ESTrivialConditionRetriever Class Reference

#include <ESTrivialConditionRetriever.h>

Inheritance diagram for ESTrivialConditionRetriever:
edm::ESProducer edm::EventSetupRecordIntervalFinder edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

List of all members.

Public Member Functions

 ESTrivialConditionRetriever (const edm::ParameterSet &pset)
virtual std::auto_ptr
< ESChannelStatus
getChannelStatusFromConfiguration (const ESChannelStatusRcd &)
virtual std::auto_ptr
< ESADCToGeVConstant
produceESADCToGeVConstant (const ESADCToGeVConstantRcd &)
virtual std::auto_ptr
< ESChannelStatus
produceESChannelStatus (const ESChannelStatusRcd &)
virtual std::auto_ptr
< ESIntercalibConstants
produceESIntercalibConstants (const ESIntercalibConstantsRcd &)
virtual std::auto_ptr
< ESPedestals
produceESPedestals (const ESPedestalsRcd &)
virtual std::auto_ptr
< ESTBWeights
produceESTBWeights (const ESTBWeightsRcd &)
virtual std::auto_ptr
< ESWeightStripGroups
produceESWeightStripGroups (const ESWeightStripGroupsRcd &)
virtual ~ESTrivialConditionRetriever ()

Protected Member Functions

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

Private Member Functions

 ESTrivialConditionRetriever (const ESTrivialConditionRetriever &)
void getWeightsFromConfiguration (const edm::ParameterSet &ps)
const ESTrivialConditionRetrieveroperator= (const ESTrivialConditionRetriever &)

Private Attributes

double adcToGeVHighConstant_
double adcToGeVLowConstant_
ESWeightSet amplWeights_
std::string amplWeightsFile_
std::string channelStatusFile_
double ESpedMean_
double ESpedRMS_
bool getWeightsFromFile_
double intercalibConstantMean_
std::string intercalibConstantsFile_
double intercalibConstantSigma_
bool producedESADCToGeVConstant_
bool producedESChannelStatus_
bool producedESIntercalibConstants_
bool producedESPedestals_
bool producedESWeights_
int verbose_

Detailed Description

Definition at line 40 of file ESTrivialConditionRetriever.h.


Constructor & Destructor Documentation

ESTrivialConditionRetriever::ESTrivialConditionRetriever ( const edm::ParameterSet pset)

Definition at line 19 of file ESTrivialConditionRetriever.cc.

References getChannelStatusFromConfiguration(), edm::ParameterSet::getUntrackedParameter(), getHLTPrescaleColumns::path, produceESADCToGeVConstant(), produceESChannelStatus(), produceESIntercalibConstants(), produceESPedestals(), produceESTBWeights(), produceESWeightStripGroups(), and AlCaHLTBitMon_QueryRunRegistry::string.

{

  // initilize parameters used to produce cond DB objects
  adcToGeVLowConstant_ = ps.getUntrackedParameter<double>("adcToGeVLowConstant",1.0);
  adcToGeVHighConstant_ = ps.getUntrackedParameter<double>("adcToGeVHighConstant",1.0);

  intercalibConstantMean_ = ps.getUntrackedParameter<double>("intercalibConstantMean",1.0);
  intercalibConstantSigma_ = ps.getUntrackedParameter<double>("intercalibConstantSigma",0.0);

  //  intercalibErrorMean_ = ps.getUntrackedParameter<double>("IntercalibErrorMean",0.0);

  ESpedMean_ = ps.getUntrackedParameter<double>("ESpedMean", 200.);
  ESpedRMS_  = ps.getUntrackedParameter<double>("ESpedRMS",  1.00);

  getWeightsFromFile_ = ps.getUntrackedParameter<bool>("getWeightsFromFile",false);


  std::string path="CalibCalorimetry/EcalTrivialCondModules/data/";
  std::string weightType;
  std::ostringstream str;

  weightType = str.str();

  amplWeightsFile_ = ps.getUntrackedParameter<std::string>("amplWeightsFile",path+"ampWeightsES"+weightType);

  // default weights for MGPA shape after pedestal subtraction
  getWeightsFromConfiguration(ps);

  producedESPedestals_ = ps.getUntrackedParameter<bool>("producedESPedestals",true);
  producedESWeights_ = ps.getUntrackedParameter<bool>("producedESWeights",true);

  producedESADCToGeVConstant_ = ps.getUntrackedParameter<bool>("producedESADCToGeVConstant",true);

  verbose_ = ps.getUntrackedParameter<int>("verbose", 0);

  //Tell Producer what we produce
  //setWhatproduce(this);
  if (producedESPedestals_)
    setWhatProduced(this, &ESTrivialConditionRetriever::produceESPedestals );

  if (producedESWeights_) {
      setWhatProduced(this, &ESTrivialConditionRetriever::produceESWeightStripGroups );
      setWhatProduced(this, &ESTrivialConditionRetriever::produceESTBWeights );
    }

  if (producedESADCToGeVConstant_)
    setWhatProduced(this, &ESTrivialConditionRetriever::produceESADCToGeVConstant );

  // intercalibration constants
  producedESIntercalibConstants_ = ps.getUntrackedParameter<bool>("producedESIntercalibConstants",true);
  intercalibConstantsFile_ = ps.getUntrackedParameter<std::string>("intercalibConstantsFile","") ;

  if (producedESIntercalibConstants_) { // user asks to produce constants
    if(intercalibConstantsFile_ == "") {  // if file provided read constants
      //    setWhatProduced (this, &ESTrivialConditionRetriever::getIntercalibConstantsFromConfiguration ) ;
      //  } else { // set all constants to 1. or smear as specified by user
        setWhatProduced (this, &ESTrivialConditionRetriever::produceESIntercalibConstants ) ;
    }
    findingRecord<ESIntercalibConstantsRcd> () ;
  }

  // intercalibration constants errors
  /*  producedESIntercalibErrors_ = ps.getUntrackedParameter<bool>("producedESIntercalibErrors",true);
      intercalibErrorsFile_ = ps.getUntrackedParameter<std::string>("intercalibErrorsFile","") ;
      
      if (producedESIntercalibErrors_) { // user asks to produce constants
      if(intercalibErrorsFile_ != "") {  // if file provided read constants
      setWhatProduced (this, &ESTrivialConditionRetriever::getIntercalibErrorsFromConfiguration ) ;
      } else { // set all constants to 1. or smear as specified by user
      setWhatProduced (this, &ESTrivialConditionRetriever::produceESIntercalibErrors ) ;
      }
      findingRecord<ESIntercalibErrorsRcd> () ;
      }
  */

  // channel status
  producedESChannelStatus_ = ps.getUntrackedParameter<bool>("producedESChannelStatus",true);
  channelStatusFile_ = ps.getUntrackedParameter<std::string>("channelStatusFile","");

  if ( producedESChannelStatus_ ) {
          if ( channelStatusFile_ != "" ) { // if file provided read channel map
                  setWhatProduced( this, &ESTrivialConditionRetriever::getChannelStatusFromConfiguration );
          } else { // set all channels to working -- FIXME might be changed
                  setWhatProduced( this, &ESTrivialConditionRetriever::produceESChannelStatus );
          }
          findingRecord<ESChannelStatusRcd>();
  }

  //Tell Finder what records we find
  if (producedESPedestals_)  findingRecord<ESPedestalsRcd>();

  if (producedESWeights_) {
      findingRecord<ESWeightStripGroupsRcd>();
      findingRecord<ESTBWeightsRcd>();
    }

  if (producedESADCToGeVConstant_)  findingRecord<ESADCToGeVConstantRcd>();

}
ESTrivialConditionRetriever::~ESTrivialConditionRetriever ( ) [virtual]

Definition at line 120 of file ESTrivialConditionRetriever.cc.

{
}
ESTrivialConditionRetriever::ESTrivialConditionRetriever ( const ESTrivialConditionRetriever ) [private]

Member Function Documentation

std::auto_ptr< ESChannelStatus > ESTrivialConditionRetriever::getChannelStatusFromConfiguration ( const ESChannelStatusRcd ) [virtual]

Definition at line 301 of file ESTrivialConditionRetriever.cc.

References alignCSCRings::e, Exception, edm::FileInPath::fullPath(), ESDetId::ISTRIP_MAX, ESDetId::ISTRIP_MIN, ESDetId::IX_MAX, ESDetId::IX_MIN, ESDetId::IY_MAX, ESDetId::IY_MIN, ntuplemaker::status, AlCaHLTBitMon_QueryRunRegistry::string, and ESDetId::unhashIndex().

Referenced by ESTrivialConditionRetriever().

{
  std::auto_ptr<ESChannelStatus> ecalStatus = std::auto_ptr<ESChannelStatus>( new ESChannelStatus() );
  

  // start by setting all statuses to 0
  

  for (int istrip=ESDetId::ISTRIP_MIN;istrip<=ESDetId::ISTRIP_MAX;istrip++) {
    for (int ix=ESDetId::IX_MIN;ix<=ESDetId::IX_MAX;ix++){
      for (int iy=ESDetId::IY_MIN;iy<=ESDetId::IY_MAX;iy++){
        for ( int iplane=1; iplane<=2; iplane++){
          for(int izeta=-1; izeta<=1 ;++izeta) {
            if(izeta==0) continue;
            try {
              //ESDetId Plane iplane Zside izeta 
              ESDetId anESId(istrip,ix,iy,iplane,izeta);
              //          xtalGroups->setValue(ebid.rawId(), ESStripGroupId(ieta) ); // define rings in eta
              ecalStatus->setValue( anESId, 0 );
            }
            catch ( cms::Exception &e ) 
              { 
              }
          }
        }
      }
    }
  }
  
  // overwrite the statuses which are in the file
  
  edm::LogInfo("ESTrivialConditionRetriever") << "Reading channel statuses from file " << edm::FileInPath(channelStatusFile_).fullPath().c_str() ;
  std::ifstream statusFile(edm::FileInPath(channelStatusFile_).fullPath().c_str());
  if ( !statusFile.good() ) {
    edm::LogError ("ESTrivialConditionRetriever") 
      << "*** Problems opening file: " << channelStatusFile_ ;
    throw cms::Exception ("Cannot open ECAL channel status file") ;
  }
  
  std::string ESSubDet;
  std::string str;
  int hashIndex(0);
  int status(0);
  
  while (!statusFile.eof()) 
    {
      statusFile >> ESSubDet;
      if (ESSubDet!=std::string("ES") )
        {
          std::getline(statusFile,str);
          continue;
        }
      else
        {
          statusFile>> hashIndex >> status;
        }
      // std::cout << ESSubDet << " " << hashIndex << " " << status;
      
      if(ESSubDet==std::string("ES"))
        {
          ESDetId esid = ESDetId::unhashIndex(hashIndex);
          ecalStatus->setValue( esid, status );
        }
      else
        {
          edm::LogError ("ESTrivialConditionRetriever") 
            << " *** " << ESSubDet << " is not ES ";
        }
    }
  // the file is supposed to be in the form 
  // ES hashed_index status 
  // ES 132332 1  --> higher than 0  means bad 
  
  statusFile.close();
  return ecalStatus;
}
void ESTrivialConditionRetriever::getWeightsFromConfiguration ( const edm::ParameterSet ps) [private]

Definition at line 257 of file ESTrivialConditionRetriever.cc.

References Exception, edm::FileInPath::fullPath(), j, and gen::k.

{

  ESWeightSet::ESWeightMatrix vampl;

  if (!getWeightsFromFile_ )
    {
      
      //      vampl.set(1.);

      // amplwgtv[0]= ps.getUntrackedParameter< std::vector<double> >("amplWeights", vampl);
    }
  else if (getWeightsFromFile_)
    {
      edm::LogInfo("ESTrivialConditionRetriever") << "Reading amplitude weights from file " << edm::FileInPath(amplWeightsFile_).fullPath().c_str() ;
      std::ifstream amplFile(edm::FileInPath(amplWeightsFile_).fullPath().c_str());
      while (!amplFile.eof() ) 
        {
          for(int j = 0; j < 2; ++j) {
            std::vector<float> vec(3) ;
            for(int k = 0; k < 3; ++k) {
              float ww;
              amplFile >> ww;
                    vec[k]=ww;
            }
            // vampl.putRow(vec);
          }
        }
    }
  else
    {
      //Not supported
      edm::LogError("ESTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
      throw cms::Exception("WrongConfig");
    }

  
  amplWeights_=ESWeightSet(vampl);

}
const ESTrivialConditionRetriever& ESTrivialConditionRetriever::operator= ( const ESTrivialConditionRetriever ) [private]
std::auto_ptr< ESADCToGeVConstant > ESTrivialConditionRetriever::produceESADCToGeVConstant ( const ESADCToGeVConstantRcd ) [virtual]

Definition at line 234 of file ESTrivialConditionRetriever.cc.

Referenced by ESTrivialConditionRetriever().

{
  return std::auto_ptr<ESADCToGeVConstant>( new ESADCToGeVConstant(adcToGeVLowConstant_,adcToGeVHighConstant_) );
}
std::auto_ptr< ESChannelStatus > ESTrivialConditionRetriever::produceESChannelStatus ( const ESChannelStatusRcd ) [virtual]

Definition at line 381 of file ESTrivialConditionRetriever.cc.

References alignCSCRings::e, ESDetId::ISTRIP_MAX, ESDetId::ISTRIP_MIN, ESDetId::IX_MAX, ESDetId::IX_MIN, ESDetId::IY_MAX, and ESDetId::IY_MIN.

Referenced by ESTrivialConditionRetriever().

{

  std::auto_ptr<ESChannelStatus>  ical = std::auto_ptr<ESChannelStatus>( new ESChannelStatus() );
  for (int istrip=ESDetId::ISTRIP_MIN;istrip<=ESDetId::ISTRIP_MAX;istrip++) {
    for (int ix=ESDetId::IX_MIN;ix<=ESDetId::IX_MAX;ix++){
      for (int iy=ESDetId::IY_MIN;iy<=ESDetId::IY_MAX;iy++){
        for ( int iplane=1; iplane<=2; iplane++){
          for(int izeta=-1; izeta<=1 ;++izeta) {
            if(izeta==0) continue;
            try {
              //ESDetId Plane iplane Zside izeta 
              ESDetId anESId(istrip,ix,iy,iplane,izeta);
              //          xtalGroups->setValue(ebid.rawId(), ESStripGroupId(ieta) ); // define rings in eta
              ical->setValue( anESId, 0 );
            }
            catch ( cms::Exception &e ) 
              { 
              }
          }
        }
      }
    }
  }
  
  return ical;
}
std::auto_ptr< ESIntercalibConstants > ESTrivialConditionRetriever::produceESIntercalibConstants ( const ESIntercalibConstantsRcd ) [virtual]

Definition at line 202 of file ESTrivialConditionRetriever.cc.

References gather_cfg::cout, alignCSCRings::e, ESDetId::ISTRIP_MAX, ESDetId::ISTRIP_MIN, ESDetId::IX_MAX, ESDetId::IX_MIN, ESDetId::IY_MAX, ESDetId::IY_MIN, alignCSCRings::r, and DetId::rawId().

Referenced by ESTrivialConditionRetriever().

{
  std::auto_ptr<ESIntercalibConstants>  ical = std::auto_ptr<ESIntercalibConstants>( new ESIntercalibConstants() );
  std::cout << "entring produce intercalib "<< std::endl;

  for (int istrip=ESDetId::ISTRIP_MIN;istrip<=ESDetId::ISTRIP_MAX;istrip++) {
    for (int ix=ESDetId::IX_MIN;ix<=ESDetId::IX_MAX;ix++){
      for (int iy=ESDetId::IY_MIN;iy<=ESDetId::IY_MAX;iy++){
        for ( int iplane=1; iplane<=2; iplane++){
          for(int izeta=-1; izeta<=1 ;++izeta) {
            if(izeta==0) continue;
            try {
              //ESDetId Plane iplane Zside izeta 
              ESDetId anESId(istrip,ix,iy,iplane,izeta);
              double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
              ical->setValue( anESId.rawId(), intercalibConstantMean_ + r*intercalibConstantSigma_ );
            }
            catch ( cms::Exception &e )
              {
              }
          }
        }
      }
    }
  }
  std::cout << "done produce intercalib"<< std::endl;

  return ical;
}
std::auto_ptr< ESPedestals > ESTrivialConditionRetriever::produceESPedestals ( const ESPedestalsRcd ) [virtual]

Definition at line 139 of file ESTrivialConditionRetriever.cc.

References gather_cfg::cout, alignCSCRings::e, ESDetId::ISTRIP_MAX, ESDetId::ISTRIP_MIN, ESDetId::IX_MAX, ESDetId::IX_MIN, ESDetId::IY_MAX, ESDetId::IY_MIN, and DetId::rawId().

Referenced by ESTrivialConditionRetriever().

                                                                       {
  std::cout<< " producing pedestals"<< std::endl;
  std::auto_ptr<ESPedestals>  peds = std::auto_ptr<ESPedestals>( new ESPedestals() );
  ESPedestals::Item ESitem;
  ESitem.mean  = ESpedMean_;
  ESitem.rms   = ESpedRMS_;
  
  for (int istrip=ESDetId::ISTRIP_MIN;istrip<=ESDetId::ISTRIP_MAX;istrip++) {
    for (int ix=ESDetId::IX_MIN;ix<=ESDetId::IX_MAX;ix++){
      for (int iy=ESDetId::IY_MIN;iy<=ESDetId::IY_MAX;iy++){
        for ( int iplane=1; iplane<=2; iplane++){
          for(int izeta=-1; izeta<=1 ;++izeta) {
            if(izeta==0) continue;
            try {
              //ESDetId Plane iplane Zside izeta 
              ESDetId aPositiveId(istrip,ix,iy,iplane,izeta);
              peds->insert(std::make_pair(aPositiveId.rawId(),ESitem));
            }
            catch ( cms::Exception &e ) 
              { 
              }
          }
        }
      }
    }
  }
  //return std::auto_ptr<ESPedestals>( peds );
  std::cout<< " produced pedestals"<< std::endl;
  return peds;
}
std::auto_ptr< ESTBWeights > ESTrivialConditionRetriever::produceESTBWeights ( const ESTBWeightsRcd ) [virtual]

Definition at line 240 of file ESTrivialConditionRetriever.cc.

Referenced by ESTrivialConditionRetriever().

{
  // create weights for the test-beam
  std::auto_ptr<ESTBWeights> tbwgt = std::auto_ptr<ESTBWeights>( new ESTBWeights() );

  int igrp=1;
  ESWeightSet wgt = ESWeightSet(amplWeights_);
  //  ESWeightSet::ESWeightMatrix& mat1 = wgt.getWeights();
  
  tbwgt->setValue(igrp,wgt);


  return tbwgt;
}
std::auto_ptr< ESWeightStripGroups > ESTrivialConditionRetriever::produceESWeightStripGroups ( const ESWeightStripGroupsRcd ) [virtual]

Definition at line 171 of file ESTrivialConditionRetriever.cc.

References gather_cfg::cout, alignCSCRings::e, ESDetId::ISTRIP_MAX, ESDetId::ISTRIP_MIN, ESDetId::IX_MAX, ESDetId::IX_MIN, ESDetId::IY_MAX, ESDetId::IY_MIN, and DetId::rawId().

Referenced by ESTrivialConditionRetriever().

{
  std::auto_ptr<ESWeightStripGroups> xtalGroups = std::auto_ptr<ESWeightStripGroups>( new ESWeightStripGroups() );
  ESStripGroupId defaultGroupId(1);
  std::cout << "entering produce weight groups"<< std::endl;
  for (int istrip=ESDetId::ISTRIP_MIN;istrip<=ESDetId::ISTRIP_MAX;istrip++) {
    for (int ix=ESDetId::IX_MIN;ix<=ESDetId::IX_MAX;ix++){
      for (int iy=ESDetId::IY_MIN;iy<=ESDetId::IY_MAX;iy++){
        for ( int iplane=1; iplane<=2; iplane++){
          for(int izeta=-1; izeta<=1 ;++izeta) {
            if(izeta==0) continue;
            try {
              //ESDetId Plane iplane Zside izeta 
              ESDetId anESId(istrip,ix,iy,iplane,izeta);
              //          xtalGroups->setValue(ebid.rawId(), ESStripGroupId(ieta) ); // define rings in eta
              xtalGroups->setValue(anESId.rawId(), defaultGroupId ); // define rings in eta
            }
            catch ( cms::Exception &e ) 
              { 
              }
          }
        }
      }
    }
  }
  std::cout << "done with produce weight groups"<< std::endl;

  return xtalGroups;
}
void ESTrivialConditionRetriever::setIntervalFor ( const edm::eventsetup::EventSetupRecordKey rk,
const edm::IOVSyncValue iTime,
edm::ValidityInterval oValidity 
) [protected, virtual]

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 128 of file ESTrivialConditionRetriever.cc.

References edm::IOVSyncValue::beginOfTime(), gather_cfg::cout, edm::IOVSyncValue::endOfTime(), edm::eventsetup::EventSetupRecordKey::name(), edm::IOVSyncValue::time(), and edm::Timestamp::value().

{
  if(verbose_>=1) std::cout << "ESTrivialConditionRetriever::setIntervalFor(): record key = " << rk.name() << "\ttime: " << iTime.time().value() << std::endl;
  //For right now, we will just use an infinite interval of validity
  oValidity = edm::ValidityInterval( edm::IOVSyncValue::beginOfTime(),edm::IOVSyncValue::endOfTime() );
}

Member Data Documentation

Definition at line 76 of file ESTrivialConditionRetriever.h.

Definition at line 75 of file ESTrivialConditionRetriever.h.

Definition at line 87 of file ESTrivialConditionRetriever.h.

Definition at line 89 of file ESTrivialConditionRetriever.h.

Definition at line 91 of file ESTrivialConditionRetriever.h.

Definition at line 84 of file ESTrivialConditionRetriever.h.

Definition at line 85 of file ESTrivialConditionRetriever.h.

Definition at line 93 of file ESTrivialConditionRetriever.h.

Definition at line 78 of file ESTrivialConditionRetriever.h.

Definition at line 90 of file ESTrivialConditionRetriever.h.

Definition at line 79 of file ESTrivialConditionRetriever.h.

Definition at line 97 of file ESTrivialConditionRetriever.h.

Definition at line 98 of file ESTrivialConditionRetriever.h.

Definition at line 96 of file ESTrivialConditionRetriever.h.

Definition at line 94 of file ESTrivialConditionRetriever.h.

Definition at line 95 of file ESTrivialConditionRetriever.h.

Definition at line 100 of file ESTrivialConditionRetriever.h.