CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes | Friends

pos::PixelCalibConfiguration Class Reference

This class implements the steps that are used in a scan over Threshold and CalDelay. More...

#include <interface/PixelCalibConfiguration.h>

Inheritance diagram for pos::PixelCalibConfiguration:
pos::PixelCalibBase pos::PixelConfigBase

List of all members.

Public Member Functions

void buildROCAndModuleLists (const PixelNameTranslation *translation, const PixelDetectorConfig *detconfig)
const std::set< PixelChannel > & channelList () const
const std::vector< std::vector
< unsigned int > > & 
columnList () const
bool containsScan (std::string name) const
std::vector< std::pair
< unsigned int, std::vector
< unsigned int > > > & 
fedCardsAndChannels (unsigned int crate, PixelNameTranslation *translation, PixelFEDConfig *fedconfig, PixelDetectorConfig *detconfig) const
std::set< unsigned int > getFECCrates (const PixelNameTranslation *translation, const PixelFECConfig *fecconfig) const
std::set< unsigned int > getFEDCrates (const PixelNameTranslation *translation, const PixelFEDConfig *fedconfig) const
std::map< unsigned int,
std::set< unsigned int > > 
getFEDsAndChannels (PixelNameTranslation *translation)
std::string getStreamedContent (void) const
std::set< unsigned int > getTKFECCrates (const PixelPortcardMap *portcardmap, const std::map< std::string, PixelPortCardConfig * > &mapNamePortCard, const PixelTKFECConfig *tkfecconfig) const
unsigned int iScan (std::string dac) const
unsigned int maxNumHitsPerROC () const
std::string mode () const
const std::set< PixelModuleName > & moduleList () const
unsigned int nConfigurations () const
void nextFECState (std::map< unsigned int, PixelFECConfigInterface * > &pixelFECs, PixelDetectorConfig *detconfig, PixelNameTranslation *trans, std::map< pos::PixelModuleName, pos::PixelMaskBase * > *masks, std::map< pos::PixelModuleName, pos::PixelTrimBase * > *trims, std::map< pos::PixelModuleName, pos::PixelDACSettings * > *dacss, unsigned int state) const
bool noHits () const
unsigned int nParameters () const
unsigned int nPixelPatterns () const
unsigned int nROC () const
unsigned int nScanPoints (std::string dac) const
unsigned int nScanPoints () const
unsigned int nTriggersPerPattern () const
unsigned int nTriggersTotal () const
unsigned int numberOfScanVariables () const
std::map< std::string,
std::string > 
parametersList () const
std::string parameterValue (std::string parameterName) const
 PixelCalibConfiguration (std::vector< std::vector< std::string > > &)
 PixelCalibConfiguration (std::string filename="")
std::set< std::pair< unsigned
int, unsigned int > > 
pixelsWithHits (unsigned int state) const
const std::vector< PixelROCName > & rocList () const
const std::vector< std::vector
< unsigned int > > & 
rowList () const
unsigned int scanCounter (std::string dac, unsigned int state) const
std::string scanName (unsigned int iscan) const
bool scanningROCForState (PixelROCName roc, unsigned int state) const
unsigned int scanValue (std::string dac, unsigned int state, PixelROCName roc) const
unsigned int scanValue (std::string dac, unsigned int state) const
double scanValueMax (std::string dac) const
double scanValueMin (std::string dac) const
std::vector< unsigned int > scanValues (std::string dac) const
bool scanValuesMixedAcrossROCs (std::string dac) const
double scanValueStep (std::string dac) const
bool singleROC () const
virtual void writeASCII (std::string dir="") const
void writeXML (pos::PixelConfigKey key, int version, std::string path) const
virtual void writeXML (std::ofstream *out, std::ofstream *out1=NULL, std::ofstream *out2=NULL) const
virtual void writeXMLHeader (pos::PixelConfigKey key, int version, std::string path, std::ofstream *out, std::ofstream *out1=NULL, std::ofstream *out2=NULL) const
virtual void writeXMLTrailer (std::ofstream *out, std::ofstream *out1=NULL, std::ofstream *out2=NULL) const
virtual ~PixelCalibConfiguration ()

Private Member Functions

void buildObjectsDependingOnTheNameTranslation (const PixelNameTranslation *aNameTranslation)
void buildROCAndModuleListsFromROCSet (const std::set< PixelROCName > &rocSet)
unsigned int colCounter (unsigned int state) const
void disablePixels (PixelFECConfigInterface *pixelFEC, unsigned int irows, unsigned int icols, pos::PixelROCTrimBits *trims, PixelHdwAddress theROC) const
void disablePixels (PixelFECConfigInterface *pixelFEC, pos::PixelROCTrimBits *trims, PixelHdwAddress theROC) const
void enablePixels (PixelFECConfigInterface *pixelFEC, unsigned int irows, unsigned int icols, pos::PixelROCMaskBits *masks, pos::PixelROCTrimBits *trims, PixelHdwAddress theROC) const
unsigned int nScanPoints (unsigned int iscan) const
unsigned int numROCsCalibratedOnChannel (PixelROCName roc) const
unsigned int ROCNumberOnChannelAmongThoseCalibrated (PixelROCName roc) const
unsigned int rowCounter (unsigned int state) const
unsigned int scanCounter (unsigned int iscan, unsigned int state) const
unsigned int scanROC (unsigned int state) const
unsigned int scanValue (unsigned int iscan, unsigned int state, unsigned int ROCNumber, unsigned int ROCsOnChannel) const
unsigned int scanValue (unsigned int iscan, unsigned int state, PixelROCName roc) const
double scanValueMax (unsigned int iscan) const
double scanValueMin (unsigned int iscan) const
std::vector< unsigned int > scanValues (unsigned int iscan) const
bool scanValuesMixedAcrossROCs (unsigned int iscan) const
double scanValueStep (unsigned int iscan) const

Private Attributes

bool _bufferData
std::string calibFileContent_
std::set< PixelChannelchannels_
std::vector< std::vector
< unsigned int > > 
cols_
std::vector< PixelDACScanRangedacs_
std::vector< std::pair
< unsigned int, std::vector
< unsigned int > > > 
fedCardsAndChannels_
bool highVCalRange_
std::set< PixelModuleNamemodules_
unsigned int nROC_
unsigned int ntrigger_
std::map< PixelROCName,
unsigned int > 
numROCsCalibratedOnChannel_
bool objectsDependingOnTheNameTranslationBuilt_
std::vector< int > old_icols
std::vector< int > old_irows
std::map< std::string,
std::string > 
parameters_
bool rocAndModuleListsBuilt_
std::vector< PixelROCInforocInfo_
std::vector< std::string > rocListInstructions_
std::map< PixelROCName,
unsigned int > 
ROCNumberOnChannelAmongThoseCalibrated_
std::vector< PixelROCNamerocs_
std::vector< std::vector
< unsigned int > > 
rows_
bool singleROC_
bool usesROCList_

Friends

std::ostream & pos::operator<< (std::ostream &s, const PixelCalibConfiguration &calib)

Detailed Description

This class implements the steps that are used in a scan over Threshold and CalDelay.

" " " " It features a double inheritance, both from ConfigurationObjects and CalibrationObjects

A longer explanation will be placed here later

Definition at line 64 of file PixelCalibConfiguration.h.


Constructor & Destructor Documentation

PixelCalibConfiguration::PixelCalibConfiguration ( std::string  filename = "")

Definition at line 300 of file PixelCalibConfiguration.cc.

References _bufferData, abs, buildROCAndModuleListsFromROCSet(), calibFileContent_, cols_, gather_cfg::cout, dacs_, first, highVCalRange_, recoMuon::in, getHLTprescales::index, pos::k_DACName_Vcal, prof2calltree::last, reco_application_tbsim_DetSim-Digi_cfg::mix, pos::PixelCalibBase::mode_, AlCaRecoCosmics_cfg::name, ntrigger_, objectsDependingOnTheNameTranslationBuilt_, parameters_, rocAndModuleListsBuilt_, rocListInstructions_, tablePrinter::rows, rows_, pos::PixelDACScanRange::setNegative(), pos::PixelDACScanRange::setRelative(), singleROC_, ExpressReco_HICollisions_FallBack::step, tmp, usesROCList_, and makeHLTPrescaleTable::values.

                                                                  :
  PixelCalibBase(), PixelConfigBase("","","") {

  std::string mthn = "[PixelCalibConfiguration::PixelCalibConfiguration()]\t    " ;

  _bufferData=true; 
  
    std::ifstream in(filename.c_str());

    if (!in.good()){
        std::cout << __LINE__ << "]\t" << mthn << "Could not open:"<<filename<<std::endl;
        assert(0);
    }
    else {
        std::cout << __LINE__ << "]\t" << mthn << "Opened:"<<filename<<std::endl;
    }

    std::string tmp;

    in >> tmp;

    if (tmp=="Mode:"){
      in >> mode_;
      std::cout << __LINE__ << "]\t" << mthn << "PixelCalibConfiguration mode="<<mode_<< std::endl;
      in >>tmp;
    } else {
      mode_="FEDChannelOffsetPixel";
      std::cout << __LINE__ << "]\t" << mthn << "PixelCalibConfiguration mode not set, is this an old file? "
                << __LINE__ << "]\t" << std::endl;
      assert(0);
    }

    singleROC_=false;
      
    if (tmp=="SingleROC") {
      singleROC_=true;
      in >> tmp;
    }

        // Read in parameters, if any.
        if (tmp=="Parameters:") {
                in >> tmp;
                while (tmp!="Rows:")
                {
                        assert( !in.eof() );
                        std::string paramName = tmp;
                        in >> tmp; // tmp contains the parameter value
                        parameters_[paramName] = tmp;
                        in >> tmp; // tmp contains the next parameter's name, or "Rows:"
                }
        }

    assert(tmp=="Rows:");

    in >> tmp;

    std::vector <unsigned int> rows;
    while (tmp!="Cols:"){
        if (tmp=="|") {
            rows_.push_back(rows);
            rows.clear();
        }
        else{
          if (tmp!="*"){
            rows.push_back(atoi(tmp.c_str()));
          }
        }
        in >> tmp;
    }
    rows_.push_back(rows);
    rows.clear();
    
    in >> tmp;

    std::vector <unsigned int> cols;
    while ((tmp!="VcalLow:")&&(tmp!="VcalHigh:")&&
           (tmp!="Vcal:")&&(tmp!="VcalHigh")&&(tmp!="VcalLow")){
        if (tmp=="|") {
            cols_.push_back(cols);
            cols.clear();
        }
        else{
          if (tmp!="*"){
            cols.push_back(atoi(tmp.c_str()));
          }
        }
        in >> tmp;
    }
    cols_.push_back(cols);
    cols.clear();

    highVCalRange_=true;

    if (tmp=="VcalLow") {
      highVCalRange_=false;
      in >> tmp;
    }

    if (tmp=="VcalHigh") {
      highVCalRange_=true;
      in >> tmp;
    }

    if (tmp=="VcalLow:") {
        highVCalRange_=false;
    }

    if ((tmp=="VcalLow:")||(tmp=="VcalHigh:")||(tmp=="Vcal:")){
      unsigned int  first,last,step;
      in >> first >> last >> step;
      unsigned int index=1;
      if (dacs_.size()>0) {
        index=dacs_.back().index()*dacs_.back().getNPoints();
      }
      in >> tmp;
      bool mix = false;
      if ( tmp=="mix" )
      {
        mix = true;
        in >> tmp;
      }
      PixelDACScanRange dacrange(pos::k_DACName_Vcal,first,last,step,index,mix);
      dacs_.push_back(dacrange);
    }
    else{

      //in >> tmp;
      while(tmp=="Scan:"||tmp=="ScanValues:"){
        if (tmp=="ScanValues:"){
          std::string dacname;
          in >> dacname;
          vector<unsigned int> values;
          int val;  
          in >> val;
          while (val!=-1) {
            values.push_back(val);
            in >> val;
          }
          unsigned int index=1;
          if (dacs_.size()>0) {
            index=dacs_.back().index()*dacs_.back().getNPoints();
          }
          PixelDACScanRange dacrange(dacname,values,index,false);
          dacs_.push_back(dacrange);
          in >> tmp;
        }
        else {
          std::string dacname;
          in >> dacname;
          unsigned int  first,last,step;
          in >> first >> last >> step;
          unsigned int index=1;
          if (dacs_.size()>0) {
            index=dacs_.back().index()*dacs_.back().getNPoints();
          }
          in >> tmp;
          bool mix = false;
          if ( tmp=="mix" )
            {
              mix = true;
              in >> tmp;
            }
          PixelDACScanRange dacrange(dacname,first,last,step,index,mix);
          dacs_.push_back(dacrange);
        }
      }
      
      while ((tmp=="Set:")||(tmp=="SetRelative:")){
        string name;
        in >> name;
        int val;
        in >> val;
        unsigned int absval=std::abs(val);
        unsigned int index=1;
        if (dacs_.size()>0) index=dacs_.back().index()*dacs_.back().getNPoints();
        PixelDACScanRange dacrange(name,absval,absval,1,index,false);
        if (tmp=="SetRelative:") {
          dacrange.setRelative();
          if (val<0) {
            dacrange.setNegative();
          }
        }
        dacs_.push_back(dacrange);
        in >> tmp;
      }
    }

    assert(tmp=="Repeat:");

    in >> ntrigger_;

    in >> tmp;

    usesROCList_=false;
    bool buildROCListNow = false;
    if ( tmp=="Rocs:" ) {
      buildROCListNow = true;
      usesROCList_=true;
    }
    else { assert(tmp=="ToCalibrate:"); buildROCListNow = false; }

    while (!in.eof())
    {
       tmp = "";
       in >> tmp;

       // added by F.Blekman to be able to deal with POS245 style calib.dat files in CMSSW
       // these files use the syntax: 
       // Rocs:
       // all

       if( tmp=="all" || tmp=="+" || tmp=="-" ){
         buildROCListNow=false;
       }
       // end of addition by F.B.
         
       if ( tmp=="" ) continue;
       rocListInstructions_.push_back(tmp);
    }

    in.close();
    
    rocAndModuleListsBuilt_ = false;
    if ( buildROCListNow )
    {
       std::set<PixelROCName> rocSet;
       for(std::vector<std::string>::iterator rocListInstructions_itr = rocListInstructions_.begin(); rocListInstructions_itr != rocListInstructions_.end(); rocListInstructions_itr++)
       {
          PixelROCName rocname(*rocListInstructions_itr);
          rocSet.insert(rocname);
       }
       buildROCAndModuleListsFromROCSet(rocSet);
    }
    
    objectsDependingOnTheNameTranslationBuilt_ = false;
    
    // Added by Dario as a temporary patch for Debbie (this will disappear in the future)
    std::ifstream inTmp(filename.c_str());
    calibFileContent_ = "" ;
    while(!inTmp.eof())
    {
     std::string tmpString ;
     getline (inTmp, tmpString);
     calibFileContent_ += tmpString + "\n";
     //cout << __LINE__ << "]\t" << "[PixelCalibConfiguration::~PixelCalibConfiguration()]\t\t" << calibFileContent_ << endl ;
    }
    inTmp.close() ;
    // End of temporary patch
    
    return;

}
PixelCalibConfiguration::PixelCalibConfiguration ( std::vector< std::vector< std::string > > &  tableMat)

EXTENSION_TABLE_NAME: PIXEL_CALIB_CLOB (VIEW: CONF_KEY_PIXEL_CALIB_V)

CONFIG_KEY NOT NULL VARCHAR2(80) KEY_TYPE NOT NULL VARCHAR2(80) KEY_ALIAS NOT NULL VARCHAR2(80) VERSION VARCHAR2(40) KIND_OF_COND NOT NULL VARCHAR2(40) CALIB_TYPE VARCHAR2(200) CALIB_OBJ_DATA_FILE NOT NULL VARCHAR2(200) CALIB_OBJ_DATA_CLOB NOT NULL CLOB

Definition at line 24 of file PixelCalibConfiguration.cc.

References _bufferData, buildROCAndModuleListsFromROCSet(), trackerHits::c, calibFileContent_, ExpressReco_HICollisions_FallBack::cerr, cols_, gather_cfg::cout, dacs_, first, highVCalRange_, recoMuon::in, getHLTprescales::index, pos::k_DACName_Vcal, prof2calltree::last, reco_application_tbsim_DetSim-Digi_cfg::mix, pos::PixelCalibBase::mode_, n, AlCaRecoCosmics_cfg::name, ntrigger_, objectsDependingOnTheNameTranslationBuilt_, parameters_, rocAndModuleListsBuilt_, rocListInstructions_, tablePrinter::rows, rows_, pos::PixelDACScanRange::setRelative(), singleROC_, ExpressReco_HICollisions_FallBack::step, tmp, usesROCList_, and makeHLTPrescaleTable::values.

                                                                                            :
                                                 PixelCalibBase(), PixelConfigBase("","","") 
{
  std::string mthn = "[PixelCalibConfiguration::PixelCalibConfiguration()]\t    " ;
  std::map<std::string , int > colM;
  std::vector<std::string > colNames;
  colNames.push_back("CONFIG_KEY"         );
  colNames.push_back("KEY_TYPE"           );
  colNames.push_back("KEY_ALIAS"          );
  colNames.push_back("VERSION"            );
  colNames.push_back("KIND_OF_COND"       );
  colNames.push_back("CALIB_TYPE"         );
  colNames.push_back("CALIB_OBJ_DATA_FILE");
  colNames.push_back("CALIB_OBJ_DATA_CLOB");

  for(unsigned int c = 0 ; c < tableMat[0].size() ; c++)
    {
      for(unsigned int n=0; n<colNames.size(); n++)
        {
          if(tableMat[0][c] == colNames[n])
            {
              colM[colNames[n]] = c;
              break;
            }
        }
    }//end for
  for(unsigned int n=0; n<colNames.size(); n++)
    {
      if(colM.find(colNames[n]) == colM.end())
        {
          std::cerr << mthn << "Couldn't find in the database the column with name " << colNames[n] << std::endl;
          assert(0);
        }
    }

  _bufferData=true; 
  
  std::istringstream in ;
  in.str(tableMat[1][colM["CALIB_OBJ_DATA_CLOB"]]) ;
  
  std::string tmp;

  in >> tmp;
  
  if (tmp=="Mode:"){
    in >> mode_;
    std::cout << __LINE__ << "]\t" << mthn << "mode=" << mode_ << std::endl;
    in >>tmp;
  } else {
    mode_="FEDChannelOffsetPixel";
    std::cout << __LINE__ << "]\t" << mthn << "mode not set, is this an old file? "
              << std::endl;
    assert(0);
  }
  
  singleROC_=false;
  
  if (tmp=="SingleROC") {
    singleROC_=true;
    in >> tmp;
  }
  
  // Read in parameters, if any.
  if (tmp=="Parameters:") {
    in >> tmp;
    while (tmp!="Rows:")
      {
        assert( !in.eof() );
        std::string paramName = tmp;
        in >> tmp; // tmp contains the parameter value
        parameters_[paramName] = tmp;
        in >> tmp; // tmp contains the next parameter's name, or "Rows:"
      }
  }
  
  assert(tmp=="Rows:");
  
  in >> tmp;
  
  std::vector <unsigned int> rows;
  while (tmp!="Cols:"){
    if (tmp=="|") {
      rows_.push_back(rows);
      rows.clear();
    }
    else{
      if (tmp!="*"){
        rows.push_back(atoi(tmp.c_str()));
      }
    }
    in >> tmp;
  }
  rows_.push_back(rows);
  rows.clear();
  
  in >> tmp;
  
  std::vector <unsigned int> cols;
  while ((tmp!="VcalLow:")&&(tmp!="VcalHigh:")&&
         (tmp!="Vcal:")&&(tmp!="VcalHigh")&&(tmp!="VcalLow")){
    if (tmp=="|") {
      cols_.push_back(cols);
      cols.clear();
    }
    else{
      if (tmp!="*"){
        cols.push_back(atoi(tmp.c_str()));
      }
    }
    in >> tmp;
  }
  cols_.push_back(cols);
  cols.clear();
  
  highVCalRange_=true;
  
  if (tmp=="VcalLow") {
    highVCalRange_=false;
    in >> tmp;
  }
  
  if (tmp=="VcalHigh") {
    highVCalRange_=true;
    in >> tmp;
  }
  
  if (tmp=="VcalLow:") {
    highVCalRange_=false;
  }
  
  if ((tmp=="VcalLow:")||(tmp=="VcalHigh:")||(tmp=="Vcal:")){
    unsigned int  first,last,step;
    in >> first >> last >> step;
    unsigned int index=1;
    if (dacs_.size()>0) {
      index=dacs_.back().index()*dacs_.back().getNPoints();
    }
    in >> tmp;
    bool mix = false;
    if ( tmp=="mix" )
      {
        mix = true;
        in >> tmp;
      }
    PixelDACScanRange dacrange(pos::k_DACName_Vcal,first,last,step,index,mix);
    dacs_.push_back(dacrange);
  }
  else{
    
    //in >> tmp;
    while(tmp=="Scan:"||tmp=="ScanValues:"){
      if (tmp=="ScanValues:"){
        std::string dacname;
        in >> dacname;
        vector<unsigned int> values;
        int val;  
        in >> val;
        while (val!=-1) {
          values.push_back(val);
          in >> val;
        }
        unsigned int index=1;
        if (dacs_.size()>0) {
          index=dacs_.back().index()*dacs_.back().getNPoints();
        }
        PixelDACScanRange dacrange(dacname,values,index,false);
        dacs_.push_back(dacrange);
        in >> tmp;
      }
      else {
        std::string dacname;
        in >> dacname;
        unsigned int  first,last,step;
        in >> first >> last >> step;
        unsigned int index=1;
        if (dacs_.size()>0) {
          index=dacs_.back().index()*dacs_.back().getNPoints();
        }
        in >> tmp;
        bool mix = false;
        if ( tmp=="mix" )
          {
            mix = true;
            in >> tmp;
          }
        PixelDACScanRange dacrange(dacname,first,last,step,index,mix);
        dacs_.push_back(dacrange);
      }
    }
    
    while ((tmp=="Set:")||(tmp=="SetRelative:")){
      string name;
      in >> name;
      int val;
      in >> val;
      unsigned int index=1;
      if (dacs_.size()>0) index=dacs_.back().index()*dacs_.back().getNPoints();
      PixelDACScanRange dacrange(name,val,val,1,index,false);
      if (tmp=="SetRelative:") {
        dacrange.setRelative();
      }
      dacs_.push_back(dacrange);
      in >> tmp;
    }
  }
  
  assert(tmp=="Repeat:");

  in >> ntrigger_;
  
  in >> tmp;
  
  usesROCList_=false;
  bool buildROCListNow = false;
  if ( tmp=="Rocs:" ) {
    buildROCListNow = true;
    usesROCList_=true;
  }
  else { assert(tmp=="ToCalibrate:"); buildROCListNow = false; }
  
  while (!in.eof())
    {
      tmp = "";
      in >> tmp;
      
      // added by F.Blekman to be able to deal with POS245 style calib.dat files in CMSSW
      // these files use the syntax: 
      // Rocs:
      // all
      
      if( tmp=="all" || tmp=="+" || tmp=="-" ){
        buildROCListNow=false;
      }
      // end of addition by F.B.
      
      if ( tmp=="" ) continue;
      rocListInstructions_.push_back(tmp);
    }
  
  rocAndModuleListsBuilt_ = false;
  if ( buildROCListNow )
    {
      std::set<PixelROCName> rocSet;
      for(std::vector<std::string>::iterator rocListInstructions_itr = rocListInstructions_.begin(); rocListInstructions_itr != rocListInstructions_.end(); rocListInstructions_itr++)
        {
          PixelROCName rocname(*rocListInstructions_itr);
          rocSet.insert(rocname);
        }
      buildROCAndModuleListsFromROCSet(rocSet);
    }
  
  objectsDependingOnTheNameTranslationBuilt_ = false;
  
  // Added by Dario as a temporary patch for Debbie (this will disappear in the future)
  calibFileContent_ = in.str() ;
  // End of temporary patch
  
  return;
  
}
PixelCalibConfiguration::~PixelCalibConfiguration ( ) [virtual]

Definition at line 553 of file PixelCalibConfiguration.cc.

{}

Member Function Documentation

void PixelCalibConfiguration::buildObjectsDependingOnTheNameTranslation ( const PixelNameTranslation aNameTranslation) [private]

Definition at line 747 of file PixelCalibConfiguration.cc.

References channels_, pos::PixelNameTranslation::getChannelForROC(), pos::PixelNameTranslation::getROCsFromChannel(), numROCsCalibratedOnChannel_, objectsDependingOnTheNameTranslationBuilt_, rocAndModuleListsBuilt_, ROCNumberOnChannelAmongThoseCalibrated_, and rocs_.

Referenced by buildROCAndModuleLists().

{
  assert( !objectsDependingOnTheNameTranslationBuilt_ );
  assert( rocAndModuleListsBuilt_ );
  assert( aNameTranslation != 0 );
  
  // Build the channel list.
  assert ( channels_.empty() );
  for (std::vector<PixelROCName>::const_iterator rocs_itr = rocs_.begin(); rocs_itr != rocs_.end(); ++rocs_itr)
    {
      channels_.insert( aNameTranslation->getChannelForROC(*rocs_itr) );
    }
  
  // Build the maps from ROC to ROC number.

  assert ( ROCNumberOnChannelAmongThoseCalibrated_.empty() && numROCsCalibratedOnChannel_.empty() );
  
  std::set<PixelROCName> tempROCs;
  
  for(std::vector<PixelROCName>::const_iterator it=rocs_.begin();it!=rocs_.end();it++){
    tempROCs.insert(*it);
  }


  for ( std::set<PixelChannel>::const_iterator channels_itr = channels_.begin(); 
        channels_itr != channels_.end(); 
        channels_itr++ ) {

    std::vector<PixelROCName> rocsOnChannel = 
      aNameTranslation->getROCsFromChannel(*channels_itr);

    std::set<PixelROCName> foundROCs;

    for ( std::vector<PixelROCName>::const_iterator rocsOnChannel_itr = rocsOnChannel.begin(); 
          rocsOnChannel_itr != rocsOnChannel.end(); 
          rocsOnChannel_itr++ ) {

      if ( tempROCs.find(*rocsOnChannel_itr) != tempROCs.end() ){
        ROCNumberOnChannelAmongThoseCalibrated_[*rocsOnChannel_itr] = foundROCs.size();
        foundROCs.insert(*rocsOnChannel_itr);
      }
    }

    for ( std::set<PixelROCName>::const_iterator foundROCs_itr = foundROCs.begin(); 
          foundROCs_itr != foundROCs.end(); 
          foundROCs_itr++ ) {
      numROCsCalibratedOnChannel_[*foundROCs_itr] = foundROCs.size();
    }

  }

  objectsDependingOnTheNameTranslationBuilt_ = true;
}
void PixelCalibConfiguration::buildROCAndModuleLists ( const PixelNameTranslation translation,
const PixelDetectorConfig detconfig 
)

Definition at line 555 of file PixelCalibConfiguration.cc.

References buildObjectsDependingOnTheNameTranslation(), buildROCAndModuleListsFromROCSet(), pos::PixelDetectorConfig::containsModule(), pos::PixelDetectorConfig::getModuleList(), pos::PixelNameTranslation::getROCs(), pos::PixelNameTranslation::getROCsFromModule(), pos::PixelDetectorConfig::getROCsList(), moduleList(), pos::PixelModuleName::modulename(), pos::PixelROCStatus::noAnalogSignal, rocAndModuleListsBuilt_, and rocListInstructions_.

{
  assert( translation != 0 );
  assert( detconfig != 0 );

  if ( rocAndModuleListsBuilt_ )
    {
      buildObjectsDependingOnTheNameTranslation(translation);
      return;
    }
  
  // Build the ROC set from the instructions.
  std::set<PixelROCName> rocSet;
  bool addNext = true;
  const map<PixelROCName, PixelROCStatus>& iroclist=detconfig->getROCsList();
  for(std::vector<std::string>::iterator rocListInstructions_itr = rocListInstructions_.begin(); rocListInstructions_itr != rocListInstructions_.end(); rocListInstructions_itr++)
        {
          std::string instruction = *rocListInstructions_itr;
          
          if ( instruction == "+" )
            {
              addNext = true;
              continue;
                }
          if ( instruction == "-" )
            {
              addNext = false;
              continue;
            }
                
          if ( instruction == "all" )
            {
              if ( addNext ) // add all ROCs in the configuration
                {
                  const std::vector <PixelModuleName>& moduleList = detconfig->getModuleList();
                  for ( std::vector <PixelModuleName>::const_iterator moduleList_itr = moduleList.begin(); moduleList_itr != moduleList.end(); moduleList_itr++ )
                    {
                      std::vector<PixelROCName> ROCsOnThisModule = translation->getROCsFromModule( *moduleList_itr );
                      for ( std::vector<PixelROCName>::const_iterator ROCsOnThisModule_itr = ROCsOnThisModule.begin(); ROCsOnThisModule_itr != ROCsOnThisModule.end(); ROCsOnThisModule_itr++ ) {
                        map<PixelROCName, PixelROCStatus>::const_iterator it=
                          iroclist.find(*ROCsOnThisModule_itr);
                        assert(it!=iroclist.end());
                        PixelROCStatus istatus =  it->second;
                        if ( !istatus.get(PixelROCStatus::noAnalogSignal) )
                          rocSet.insert(*ROCsOnThisModule_itr);
                      }
                    }
                }
              else // remove all ROCs
                {
                  rocSet.clear();
                }
              addNext = true;
              continue;
            }
                
          // Assume it's a ROC or module name.
          PixelModuleName modulename(instruction);
          
          // Skip if this module (or the module this ROC is on) isn't in the detector config.
          if ( !(detconfig->containsModule(modulename)) )
            {
              addNext = true;
              continue;
            }
          
          if ( modulename.modulename() == instruction ) // it's a module
            {
              std::vector<PixelROCName> ROCsOnThisModule = translation->getROCsFromModule( modulename );
              for ( std::vector<PixelROCName>::iterator ROCsOnThisModule_itr = ROCsOnThisModule.begin(); ROCsOnThisModule_itr != ROCsOnThisModule.end(); ROCsOnThisModule_itr++ )
                {
                  if ( addNext ) {
                    map<PixelROCName, PixelROCStatus>::const_iterator it= iroclist.find(*ROCsOnThisModule_itr);
                    assert(it!=iroclist.end());
                    PixelROCStatus istatus =  it->second;
                    if ( !istatus.get(PixelROCStatus::noAnalogSignal) )  rocSet.insert(*ROCsOnThisModule_itr);
                  }
                  else           rocSet.erase( *ROCsOnThisModule_itr);
                }
              addNext = true;
              continue;
            }
          else // it's a ROC
            {
              PixelROCName rocname(instruction);
              if ( addNext )
                {
                  // Only add this ROC if it's in the configuration.
                  bool foundIt = false;
                  std::list<const PixelROCName*> allROCs = translation->getROCs();
                  for ( std::list<const PixelROCName*>::iterator allROCs_itr = allROCs.begin(); allROCs_itr != allROCs.end(); allROCs_itr++ )
                    {
                      if ( (*(*allROCs_itr)) == rocname )
                        {
                          foundIt = true;
                          break;
                        }
                    }
                  if (foundIt) {
                    map<PixelROCName, PixelROCStatus>::const_iterator it= iroclist.find(rocname);
                    assert(it!=iroclist.end());
                    PixelROCStatus istatus =  it->second;
                    if ( !istatus.get(PixelROCStatus::noAnalogSignal) ) rocSet.insert(rocname);
                  }
                }
              else
                {
                  rocSet.erase(rocname);
                }
              addNext = true;
              continue;
            }
          
          // should never get here
          assert(0);
        }
  // done building ROC set

  buildROCAndModuleListsFromROCSet(rocSet);

  buildObjectsDependingOnTheNameTranslation(translation);
       
}
void PixelCalibConfiguration::buildROCAndModuleListsFromROCSet ( const std::set< PixelROCName > &  rocSet) [private]

Definition at line 679 of file PixelCalibConfiguration.cc.

References gather_cfg::cout, modules_, nROC_, old_icols, old_irows, rocAndModuleListsBuilt_, rocs_, and singleROC_.

Referenced by buildROCAndModuleLists(), and PixelCalibConfiguration().

{
  assert( !rocAndModuleListsBuilt_ );

  std::string mthn = "[PixelCalibConfiguration::buildROCAndModuleListsFromROCSet()]    " ;
  // Build the ROC list from the ROC set.
  for (std::set<PixelROCName>::iterator rocSet_itr = rocSet.begin(); 
       rocSet_itr != rocSet.end(); 
       rocSet_itr++ ) {
    rocs_.push_back(*rocSet_itr);
  }

  //t.stop();
  //cout << "buildROCAndModuleListsFromROCSet 1 time="<<t.tottime()<<endl;
  //t.start();

  // Build the module set from the ROC set.
  std::map <PixelModuleName,unsigned int> countROC;
  for (std::set<PixelROCName>::iterator rocSet_itr = rocSet.begin(); rocSet_itr != rocSet.end(); rocSet_itr++ ){
    //t1.start();
    PixelModuleName modulename(*rocSet_itr);
    //t1.stop();
    //t2.start();
    modules_.insert( modulename );
    countROC[modulename]++;
    //t2.stop();
  }

  //t.stop();
  //cout << "buildROCAndModuleListsFromROCSet 2 time="<<t.tottime()<<endl;
  //cout << "buildROCAndModuleListsFromROCSet t1="<<t1.tottime()<<endl;
  //cout << "buildROCAndModuleListsFromROCSet t2="<<t2.tottime()<<endl;
  //t.start();
  
  // Test printout.
  /*cout << "\nROC list:\n";
    for ( std::vector<PixelROCName>::iterator rocs_itr = rocs_.begin(); 
    rocs_itr != rocs_.end(); 
    rocs_itr++ ){
    cout << rocs_itr->rocname() << "\n";
    }    cout << "\nModule list:\n";
    for ( std::set<PixelModuleName>::iterator modules_itr = modules_.begin(); modules_itr != modules_.end(); modules_itr++ )
        {
        cout << modules_itr->modulename() << "\n";
        }
        cout << "\n";*/
  
  // Determine max ROCs on a module for singleROC mode.
  nROC_=1;
  if (singleROC_) {
    unsigned maxROCs=0;
    for (std::map<PixelModuleName,unsigned int>::iterator imodule=countROC.begin();imodule!=countROC.end();++imodule) {
      if (imodule->second>maxROCs) maxROCs=imodule->second;
    }
    nROC_=maxROCs;
                
    std::cout << __LINE__ << "]\t" << mthn << "Max ROCs on a module="<<nROC_<<std::endl;
  }
        
  for(unsigned int irocs=0;irocs<rocs_.size();irocs++){
    old_irows.push_back(-1);
    old_icols.push_back(-1);
  }
  
  rocAndModuleListsBuilt_ = true;

}
const std::set<PixelChannel>& pos::PixelCalibConfiguration::channelList ( ) const [inline]
unsigned int PixelCalibConfiguration::colCounter ( unsigned int  state) const [private]

Definition at line 903 of file PixelCalibConfiguration.cc.

References cols_, nScanPoints(), rowCounter(), rows_, and scanROC().

Referenced by nextFECState(), and pixelsWithHits().

{
        unsigned int i_col=( state - scanROC(state)*cols_.size()*rows_.size()*nScanPoints() - rowCounter(state)*cols_.size()*nScanPoints() )/(nScanPoints());
        assert(i_col<cols_.size());
        return i_col;
}
const std::vector<std::vector<unsigned int> >& pos::PixelCalibConfiguration::columnList ( ) const [inline]

Definition at line 150 of file PixelCalibConfiguration.h.

References cols_.

Referenced by SiPixelCalibConfiguration::SiPixelCalibConfiguration().

{return cols_;}
bool PixelCalibConfiguration::containsScan ( std::string  name) const

Definition at line 1663 of file PixelCalibConfiguration.cc.

References i, AlCaRecoCosmics_cfg::name, numberOfScanVariables(), and scanName().

{
        for ( unsigned int i = 0; i < numberOfScanVariables(); i++ )
        {
                if ( scanName(i) == name )
                {
                        return true;
                }
        }
        return false;
}
void PixelCalibConfiguration::disablePixels ( PixelFECConfigInterface pixelFEC,
unsigned int  irows,
unsigned int  icols,
pos::PixelROCTrimBits trims,
PixelHdwAddress  theROC 
) const [private]

Definition at line 1486 of file PixelCalibConfiguration.cc.

References _bufferData, bits, cols_, pos::PixelHdwAddress::hubaddress(), pos::PixelHdwAddress::mfec(), pos::PixelHdwAddress::mfecchannel(), pos::PixelHdwAddress::portaddress(), pos::PixelFECConfigInterface::progpix(), pos::PixelHdwAddress::rocid(), rows_, and pos::PixelROCTrimBits::trim().

Referenced by nextFECState().

                                                           {

        for (unsigned int irow=0;irow<rows_[irows].size();irow++){
            for (unsigned int icol=0;icol<cols_[icols].size();icol++){
              /*                std::cout << "Will turn off pixel col="
                          <<cols_[old_icols][icol]
                          <<" row="<<rows_[old_irows][irow]<<std::endl;
              */
              unsigned int bits=trims->trim(cols_[icols][icol],rows_[irows][irow]);
              pixelFEC->progpix(theROC.mfec(),
                                theROC.mfecchannel(),
                                theROC.hubaddress(),
                                theROC.portaddress(),
                                theROC.rocid(),
                                cols_[icols][icol],
                                rows_[irows][irow],
                                bits,_bufferData);
            }
        }
}
void PixelCalibConfiguration::disablePixels ( PixelFECConfigInterface pixelFEC,
pos::PixelROCTrimBits trims,
PixelHdwAddress  theROC 
) const [private]

Definition at line 1511 of file PixelCalibConfiguration.cc.

References _bufferData, bits, pos::PixelHdwAddress::hubaddress(), pos::PixelHdwAddress::mfec(), pos::PixelHdwAddress::mfecchannel(), pos::PixelHdwAddress::portaddress(), pos::PixelFECConfigInterface::progpix(), pos::PixelHdwAddress::rocid(), and pos::PixelROCTrimBits::trim().

                                                                         {

  //cout<<" disable ROC "<<theROC.hubaddress()<<" "<<theROC.rocid()<<endl;
  //FIXME This should be done with more efficient commands!
  for (unsigned int row=0;row<80;row++){
    for (unsigned int col=0;col<52;col++){
      unsigned int bits=trims->trim(col,row);
      pixelFEC->progpix(theROC.mfec(),
                        theROC.mfecchannel(),
                        theROC.hubaddress(),
                        theROC.portaddress(),
                        theROC.rocid(),
                        col,
                        row,
                        bits,_bufferData);
    }
  }
}
void PixelCalibConfiguration::enablePixels ( PixelFECConfigInterface pixelFEC,
unsigned int  irows,
unsigned int  icols,
pos::PixelROCMaskBits masks,
pos::PixelROCTrimBits trims,
PixelHdwAddress  theROC 
) const [private]

Definition at line 1455 of file PixelCalibConfiguration.cc.

References _bufferData, bits, cols_, pos::PixelHdwAddress::hubaddress(), pos::PixelROCMaskBits::mask(), pos::PixelHdwAddress::mfec(), pos::PixelHdwAddress::mfecchannel(), pos::PixelHdwAddress::portaddress(), pos::PixelFECConfigInterface::progpix(), pos::PixelHdwAddress::rocid(), rows_, and pos::PixelROCTrimBits::trim().

Referenced by nextFECState().

                                                                        {

  for (unsigned int irow=0;irow<rows_[irows].size();irow++){
    for (unsigned int icol=0;icol<cols_[icols].size();icol++){
      /*            std::cout << "Will turn on pixel col="
                    <<cols_[icols][icol]
                    <<" row="<<rows_[irows][irow]<<std::endl;
      */
      unsigned int bits=trims->trim(cols_[icols][icol],rows_[irows][irow]);

      //if masks==0 always enable pixel
      if (masks==0||
          masks->mask(cols_[icols][icol],rows_[irows][irow])) bits|=0x80;

      pixelFEC->progpix(theROC.mfec(),
                        theROC.mfecchannel(),
                        theROC.hubaddress(),
                        theROC.portaddress(),
                        theROC.rocid(),
                        cols_[icols][icol],
                        rows_[irows][irow],
                        bits,_bufferData);
    }
  }  
}
std::vector< std::pair< unsigned int, std::vector< unsigned int > > > & PixelCalibConfiguration::fedCardsAndChannels ( unsigned int  crate,
PixelNameTranslation translation,
PixelFEDConfig fedconfig,
PixelDetectorConfig detconfig 
) const

Definition at line 1265 of file PixelCalibConfiguration.cc.

References pos::PixelDetectorConfig::containsModule(), pos::PixelFEDConfig::crateFromFEDNumber(), fedCardsAndChannels_, pos::PixelHdwAddress::fedchannel(), pos::PixelHdwAddress::fednumber(), first, newFWLiteAna::found, pos::PixelNameTranslation::getHdwAddress(), i, getHLTprescales::index, j, gen::k, module(), rocAndModuleListsBuilt_, rocs_, and tmp.

                                                                                                                                                     {

    assert(rocAndModuleListsBuilt_);
    
    assert(rocs_.size()!=0);

    for(unsigned int i=0;i<rocs_.size();i++){
      PixelModuleName module(rocs_[i].rocname());
      if (!detconfig->containsModule(module)) continue;
      const PixelHdwAddress* hdw=translation->getHdwAddress(rocs_[i]);
        assert(hdw!=0);
        //std::cout << "ROC, fednumber:"<<rocs_[i]<<" "<<hdw->fednumber()
        //        << std::endl;
        //first check if fed associated with the roc is in the right crate
        if (fedconfig->crateFromFEDNumber(hdw->fednumber())!=crate) continue;
        //next look if we have already found fed number
        unsigned int index=fedCardsAndChannels_.size();
        for(unsigned int j=0;j<fedCardsAndChannels_.size();j++){
            if (fedCardsAndChannels_[j].first==hdw->fednumber()){
                index=j;
                break;
            }
        }
        //If we didn't find the fedcard we will create it
        if (index==fedCardsAndChannels_.size()){
            std::vector<unsigned int> tmp;
            tmp.push_back(hdw->fedchannel());
            std::pair<unsigned int, std::vector<unsigned int> > tmp2(hdw->fednumber(),tmp);
            fedCardsAndChannels_.push_back(tmp2);
            continue;
        }
        //Now look and see if the channel has been added
        std::vector<unsigned int>& channels=fedCardsAndChannels_[index].second;
        bool found=false;
        for(unsigned int k=0;k<channels.size();k++){
            if (channels[k]==hdw->fedchannel()) {
                found=true;
                break;
            }
        }
        if (found) continue;
        channels.push_back(hdw->fedchannel());

    }


    return fedCardsAndChannels_;

}
std::set< unsigned int > PixelCalibConfiguration::getFECCrates ( const PixelNameTranslation translation,
const PixelFECConfig fecconfig 
) const

Definition at line 1358 of file PixelCalibConfiguration.cc.

References pos::PixelFECConfig::crateFromFECNumber(), pos::PixelHdwAddress::fecnumber(), pos::PixelNameTranslation::getChannelsOnModule(), pos::PixelNameTranslation::getHdwAddress(), modules_, and rocAndModuleListsBuilt_.

                                                                                                                                         {

        assert(rocAndModuleListsBuilt_);
        
        std::set<unsigned int> feccrates;
        assert(modules_.size()!=0);
        std::set<PixelModuleName>::iterator imodule=modules_.begin();

        for (;imodule!=modules_.end();++imodule)
        {
                std::set<PixelChannel> channelsOnThisModule = translation->getChannelsOnModule(*imodule);
                for ( std::set<PixelChannel>::const_iterator channelsOnThisModule_itr = channelsOnThisModule.begin(); channelsOnThisModule_itr != channelsOnThisModule.end(); channelsOnThisModule_itr++ )
                {
                        const PixelHdwAddress& channel_hdwaddress = translation->getHdwAddress(*channelsOnThisModule_itr);
                        unsigned int fecnumber=channel_hdwaddress.fecnumber();
                        feccrates.insert(fecconfig->crateFromFECNumber(fecnumber));
                }
        }

        return feccrates;
}
std::set< unsigned int > PixelCalibConfiguration::getFEDCrates ( const PixelNameTranslation translation,
const PixelFEDConfig fedconfig 
) const

Definition at line 1336 of file PixelCalibConfiguration.cc.

References pos::PixelFEDConfig::crateFromFEDNumber(), pos::PixelHdwAddress::fednumber(), pos::PixelNameTranslation::getChannelsOnModule(), pos::PixelNameTranslation::getHdwAddress(), modules_, and rocAndModuleListsBuilt_.

                                                                                                                                         {

        assert(rocAndModuleListsBuilt_);
        
        std::set<unsigned int> fedcrates;
        assert(modules_.size()!=0);
        std::set<PixelModuleName>::iterator imodule=modules_.begin();

        for (;imodule!=modules_.end();++imodule)
        {
                std::set<PixelChannel> channelsOnThisModule = translation->getChannelsOnModule(*imodule);
                for ( std::set<PixelChannel>::const_iterator channelsOnThisModule_itr = channelsOnThisModule.begin(); channelsOnThisModule_itr != channelsOnThisModule.end(); channelsOnThisModule_itr++ )
                {
                        const PixelHdwAddress& channel_hdwaddress = translation->getHdwAddress(*channelsOnThisModule_itr);
                        unsigned int fednumber=channel_hdwaddress.fednumber();
                        fedcrates.insert(fedconfig->crateFromFEDNumber(fednumber));
                }
        }

        return fedcrates;
}
std::map< unsigned int, std::set< unsigned int > > PixelCalibConfiguration::getFEDsAndChannels ( PixelNameTranslation translation)

Definition at line 1318 of file PixelCalibConfiguration.cc.

References pos::PixelHdwAddress::fedchannel(), pos::PixelHdwAddress::fednumber(), pos::PixelNameTranslation::getHdwAddress(), rocAndModuleListsBuilt_, and rocs_.

                                                                                                                           {

  assert(rocAndModuleListsBuilt_);
  
  std::map <unsigned int, std::set<unsigned int> > fedsChannels;
  assert(rocs_.size()!=0);
  std::vector<PixelROCName>::iterator iroc=rocs_.begin();

  for (;iroc!=rocs_.end();++iroc){
    const PixelHdwAddress *roc_hdwaddress=translation->getHdwAddress(*iroc);
    unsigned int fednumber=roc_hdwaddress->fednumber();
    unsigned int fedchannel=roc_hdwaddress->fedchannel();
    fedsChannels[fednumber].insert(fedchannel);
  }

  return fedsChannels;
}
std::string pos::PixelCalibConfiguration::getStreamedContent ( void  ) const [inline]

Definition at line 168 of file PixelCalibConfiguration.h.

References calibFileContent_.

{return calibFileContent_;} ;
std::set< unsigned int > PixelCalibConfiguration::getTKFECCrates ( const PixelPortcardMap portcardmap,
const std::map< std::string, PixelPortCardConfig * > &  mapNamePortCard,
const PixelTKFECConfig tkfecconfig 
) const

Definition at line 1380 of file PixelCalibConfiguration.cc.

References pos::PixelTKFECConfig::crateFromTKFECID(), pos::PixelPortCardConfig::getTKFECID(), modules_, pos::PixelPortcardMap::portcards(), and rocAndModuleListsBuilt_.

                                                                                                                                                                                                          {

        assert(rocAndModuleListsBuilt_);
        
        std::set<unsigned int> tkfeccrates;
        assert(modules_.size()!=0);
        std::set<PixelModuleName>::iterator imodule=modules_.begin();

        for (;imodule!=modules_.end();++imodule)
        {
                // implement this by module --(PixelPortcardMap)-> port card(s) --(PixelPortCardConfig)-> FEC # --(PixelFECConfig theTKFECConfiguration_)-> crate
                const std::set< std::string > portCards = portcardmap->portcards(*imodule);
                for ( std::set< std::string >::const_iterator portCards_itr = portCards.begin(); portCards_itr != portCards.end(); ++portCards_itr)
                {
                        const std::string portcardname=*portCards_itr;
                        std::map<std::string,PixelPortCardConfig*>::const_iterator portcardconfig_itr = mapNamePortCard.find(portcardname);
                        assert(portcardconfig_itr != mapNamePortCard.end());
                        PixelPortCardConfig* portcardconfig = portcardconfig_itr->second;
                        std::string TKFECID = portcardconfig->getTKFECID();
                        tkfeccrates.insert(tkfecconfig->crateFromTKFECID(TKFECID));
                }
        }

        return tkfeccrates;
}
unsigned int PixelCalibConfiguration::iScan ( std::string  dac) const

Definition at line 801 of file PixelCalibConfiguration.cc.

References gather_cfg::cout, dacs_, i, and AlCaRecoCosmics_cfg::name.

Referenced by nScanPoints(), scanCounter(), scanValue(), scanValueMax(), scanValueMin(), scanValues(), scanValuesMixedAcrossROCs(), and scanValueStep().

                                                              {

  for (unsigned int i=0;i<dacs_.size();i++){
    if (dac==dacs_[i].name()) return i;
  }

  std::cout << __LINE__ << "]\t[PixelCalibConfiguration::iScan()]\t\t    could not find dac="
            << dac <<std::endl; 

  assert(0);

  return 0;

}
unsigned int PixelCalibConfiguration::maxNumHitsPerROC ( ) const

Definition at line 1633 of file PixelCalibConfiguration.cc.

References cols_, max(), and rows_.

Referenced by noHits().

{
        unsigned int returnValue = 0;
        for ( std::vector<std::vector<unsigned int> >::const_iterator rows_itr = rows_.begin(); rows_itr != rows_.end(); rows_itr++ )
        {
                for ( std::vector<std::vector<unsigned int> >::const_iterator cols_itr = cols_.begin(); cols_itr != cols_.end(); cols_itr++ )
                {
                      unsigned int theSize = rows_itr->size()*cols_itr->size(); 
                      returnValue = max( returnValue, theSize );
                }
        }
        return returnValue;
}
std::string pos::PixelCalibConfiguration::mode ( ) const [inline, virtual]

Reimplemented from pos::PixelCalibBase.

Definition at line 156 of file PixelCalibConfiguration.h.

References pos::PixelCalibBase::mode_.

Referenced by nextFECState(), and SiPixelCalibConfiguration::SiPixelCalibConfiguration().

{return mode_;}
const std::set<PixelModuleName>& pos::PixelCalibConfiguration::moduleList ( ) const [inline]

Definition at line 153 of file PixelCalibConfiguration.h.

References modules_, and rocAndModuleListsBuilt_.

Referenced by buildROCAndModuleLists().

{assert(rocAndModuleListsBuilt_); return modules_;}
unsigned int pos::PixelCalibConfiguration::nConfigurations ( ) const [inline]

Definition at line 109 of file PixelCalibConfiguration.h.

References nPixelPatterns(), nROC(), and nScanPoints().

Referenced by nextFECState(), nTriggersTotal(), scanCounter(), and scanROC().

{ return nPixelPatterns()*nScanPoints()*nROC();}
void PixelCalibConfiguration::nextFECState ( std::map< unsigned int, PixelFECConfigInterface * > &  pixelFECs,
PixelDetectorConfig detconfig,
PixelNameTranslation trans,
std::map< pos::PixelModuleName, pos::PixelMaskBase * > *  masks,
std::map< pos::PixelModuleName, pos::PixelTrimBase * > *  trims,
std::map< pos::PixelModuleName, pos::PixelDACSettings * > *  dacss,
unsigned int  state 
) const

Definition at line 910 of file PixelCalibConfiguration.cc.

References _bufferData, colCounter(), cols_, gather_cfg::cout, dacs_, pos::PixelROCInfo::defaultDACs_, disablePixels(), enablePixels(), pos::PixelHdwAddress::fecnumber(), first, pos::PixelNameTranslation::getChannelForROC(), pos::PixelNameTranslation::getHdwAddress(), pos::PixelROCInfo::hdwadd_, highVCalRange_, pos::PixelHdwAddress::hubaddress(), i, j, pos::k_DACAddress_WBC, pos::PixelROCInfo::masks_, max(), pos::PixelHdwAddress::mfec(), pos::PixelHdwAddress::mfecchannel(), mode(), module(), n, AlCaRecoCosmics_cfg::name, nConfigurations(), parameterValue(), pos::PixelHdwAddress::portaddress(), relativeConstraints::relative, rocAndModuleListsBuilt_, pos::PixelHdwAddress::rocid(), rocInfo_, rocs_, rowCounter(), rows_, scanCounter(), scanningROCForState(), scanValue(), pos::PixelROCInfo::tbmChannel_, pos::PixelChannel::TBMChannelString(), pos::PixelROCInfo::trims_, and pos::PixelROCInfo::use_.

                                                                     {

  std::string mthn = "[PixelCalibConfiguration::nextFECState()]\t\t    " ;
  std::string modeName=parameterValue("ScanMode");

  int mode=-1;

  if (modeName=="maskAllPixel")  mode=0;
  if (modeName=="useAllPixel"||modeName=="")  mode=1;
  if (modeName=="default")  mode=2;

  static bool first=true;

  if (first) {
    cout << __LINE__ << "]\t" << mthn << "mode="<<mode<<endl;
    first=false;
  }
  
  if (mode==-1) {
    cout << __LINE__ << "]\t" << mthn << "ScanMode=" << modeName
         << " not understood."<< endl;
    ::abort();
  }

  if (rocInfo_.size()==0){
    //here we will do some initialization...
    for(unsigned int i=0;i<rocs_.size();i++){
      const PixelHdwAddress* hdwadd=trans->getHdwAddress(rocs_[i]);
      PixelROCInfo rocInfo;
      rocInfo.use_=true;
      //FIXME This is very inefficient
      PixelModuleName module(rocs_[i].rocname());

      std::map<pos::PixelModuleName,pos::PixelMaskBase*>::const_iterator foundMask = masks->find(module);
      if (foundMask==masks->end()){
        rocInfo.use_=false;
        rocInfo_.push_back(rocInfo);
        continue;
      }
      


      rocInfo.hdwadd_=hdwadd;
      rocInfo.trims_=(*trims)[module]->getTrimBits(rocs_[i]);
      rocInfo.masks_=(*masks)[module]->getMaskBits(rocs_[i]);

#ifdef BPIX      
      const PixelChannel channel = trans->getChannelForROC(rocs_[i]);
      string tbmChannel = channel.TBMChannelString();
      //cout<<" tbm channel "<<tbmChannel<<endl; 
      rocInfo.tbmChannel_ = tbmChannel;
#endif

      std::map<std::string, unsigned int> defaultDACValues;
      (*dacs)[PixelModuleName(rocs_[i].rocname())]->getDACSettings(rocs_[i])->getDACs(defaultDACValues);

      for ( std::vector<PixelDACScanRange>::const_iterator dacs_itr = dacs_.begin(); dacs_itr != dacs_.end(); dacs_itr++ )
      {
        std::map<std::string, unsigned int>::const_iterator foundThisDAC = defaultDACValues.find(dacs_itr->name());
        assert( foundThisDAC != defaultDACValues.end() );

        pair<unsigned int, unsigned int> 
          dacchannelAndValue(dacs_itr->dacchannel(),
                             foundThisDAC->second);

        rocInfo.defaultDACs_.push_back(dacchannelAndValue);
      }
      rocInfo_.push_back(rocInfo);
    }
  }

  assert(rocs_.size()==rocInfo_.size());

  bool changedWBC=false;

  std::map<unsigned int, PixelFECConfigInterface*>::iterator iPixelFEC=pixelFECs.begin();
  //for(;iPixelFEC!=pixelFECs.end();++iPixelFEC){
  //iPixelFEC->second->fecDebug(1);
  //}

  //unsigned long version=0;
  //pixelFEC->getversion(&version);
  //std::cout<<"mfec firmware version:"<<version<<std::endl;

  assert(rocAndModuleListsBuilt_);
    
  assert(state<nConfigurations());

  // Which set of rows we're on.
  unsigned int i_row=rowCounter(state);

  // Which set of columns we're on.
  unsigned int i_col=colCounter(state);

  // Whether we're beginning a new scan over the DACs after changing which ROC or which pixel pattern.
  unsigned int first_scan=true;
  for (unsigned int i=0;i<dacs_.size();i++){
    if (scanCounter(i,state)!=0) first_scan=false;
  }

  // Disable all pixels at the beginning.
  if (state==0&&(mode==0||mode==1)) {

    for(unsigned int i=0;i<rocs_.size();i++){

      if (!rocInfo_[i].use_) continue;

      PixelHdwAddress theROC=*rocInfo_[i].hdwadd_;
      PixelROCTrimBits* rocTrims=rocInfo_[i].trims_;

      //Turn off all pixels
      disablePixels(pixelFECs[theROC.fecnumber()], rocTrims, theROC);

    }

    // reset
    //cout<<"finish init"<<endl;
    //sleep(1);
    //pixelFEC->injectrstroc(7,1);
    // or do    pixelFEC->rocreset(theROC.mfec(),
    //                 theROC.mfecchannel(),
    //                 14,                    //FIXME hardcode for Channel A
    //                 theROC.hubaddress());

   
  }

  // When a scan is complete for a given ROC or pixel pattern, reset the DACs to default values and disable the previously-enabled pixels.
  if (first_scan && state!=0 && mode!=2){

    unsigned int previousState=state-1;

    unsigned int i_row_previous=rowCounter(previousState);

    unsigned int i_col_previous=colCounter(previousState);

    for(unsigned int i=0;i<rocs_.size();i++){

      if (!rocInfo_[i].use_) continue;

      PixelHdwAddress theROC=*rocInfo_[i].hdwadd_;

      if ( !scanningROCForState(rocs_[i], previousState) ) continue;

      // Set the DACs back to their default values when we're done with a scan.
      for ( unsigned int j=0; j< dacs_.size(); j++ ) {


        //Try to not reprogram DACs as often..
        if (state!=0){
          if (scanCounter(dacs_[j].name(),state)==scanCounter(dacs_[j].name(),state-1)){
            continue;
          }
        }

        pixelFECs[theROC.fecnumber()]->progdac(theROC.mfec(),
                                               theROC.mfecchannel(),
                                               theROC.hubaddress(),
                                               theROC.portaddress(),
                                               theROC.rocid(),
                                               rocInfo_[i].defaultDACs_[j].first,
                                               rocInfo_[i].defaultDACs_[j].second,
                                               _bufferData);    

        if (dacs_[j].dacchannel()==k_DACAddress_WBC) {
          changedWBC=true;
          //cout << "Changed WBC 1"<<endl;
        }

      }
      
      PixelROCTrimBits* rocTrims=rocInfo_[i].trims_;

      disablePixels(pixelFECs[theROC.fecnumber()], 
                    i_row_previous, 
                    i_col_previous, 
                    rocTrims, 
                    theROC);

    }
  }
  
  // Set each ROC with the new settings for this state.
  for(unsigned int i=0;i<rocs_.size();i++){

    if (!rocInfo_[i].use_) continue;


    PixelHdwAddress theROC=*rocInfo_[i].hdwadd_;

    
    // Skip this ROC if we're in SingleROC mode and we're not on this ROC number.
    if ( !scanningROCForState(rocs_[i], state) ) continue;

    //  std::cout << "Will call progdac for vcal:"<< vcal << std::endl;
    
    // Program all the DAC values.
    for (unsigned int ii=0;ii<dacs_.size();ii++){

      //Try to not reprogram DACs as often..
      if (state!=0){
        if (scanCounter(dacs_[ii].name(),state)==scanCounter(dacs_[ii].name(),state-1)){
          continue;
        }
      }

      int dacvalue = scanValue(ii, state, rocs_[i]);

      //cout << "dacname ii:"<<dacs_[ii].name()<<" "<<ii<<endl;
      
      if (dacs_[ii].relative()){

        //We have to find the default DAC setting so that we can
        //add the offset as we are in relative mode.

        if (dacs_[ii].negative()) dacvalue=-dacvalue;
        
        dacvalue+=rocInfo_[i].defaultDACs_[ii].second;
        //cout << "[PixelCalibConfiguration::nextFECState] ROC="<<rocs_[i]
        //     << " dac="<<dacs_[ii].name()<<" new value="<<dacvalue<<endl;
      }

      pixelFECs[theROC.fecnumber()]->progdac(theROC.mfec(),
                                             theROC.mfecchannel(),
                                             theROC.hubaddress(),
                                             theROC.portaddress(),
                                             theROC.rocid(),
                                             rocInfo_[i].defaultDACs_[ii].first,
                                             dacvalue,_bufferData);

      if (dacs_[ii].dacchannel()==k_DACAddress_WBC) {
        changedWBC=true;
        //cout << "Changed WBC 2"<<endl;
      }

    }

    // At the beginning of a scan, set the pixel pattern.
    if (first_scan){

      // Set masks and trims.
      if (mode!=2){


        PixelROCMaskBits* rocMasks=rocInfo_[i].masks_;
        PixelROCTrimBits* rocTrims=rocInfo_[i].trims_;

        if (mode==1) rocMasks=0;

        //std::cout << "Will enable pixels!" <<std::endl;
        enablePixels(pixelFECs[theROC.fecnumber()], 
                     i_row, 
                     i_col, 
                     rocMasks, 
                     rocTrims, 
                     theROC);

      }

      // Set high or low Vcal range.

      if (state==0) {

        PixelModuleName module(rocs_[i].rocname());

        unsigned int roccontrolword=(*dacs)[module]->getDACSettings(rocs_[i])->getControlRegister();
   
        //range is controlled here by one bit, but rest must match config
        //bit 0 on/off= 20/40 MHz speed; bit 1 on/off=disabled/enable; bit 3=Vcal range

        if (highVCalRange_) roccontrolword|=0x4;  //turn range bit on
        else roccontrolword&=0xfb;                //turn range bit off
      
        pixelFECs[theROC.fecnumber()]->progdac(theROC.mfec(),
                                               theROC.mfecchannel(),
                                               theROC.hubaddress(),
                                               theROC.portaddress(),
                                               theROC.rocid(),
                                               0xfd,
                                               roccontrolword,_bufferData);
        

      }      

      // Clear all pixels before setting the pixel pattern.
      pixelFECs[theROC.fecnumber()]->clrcal(theROC.mfec(),
                                            theROC.mfecchannel(),
                                            theROC.hubaddress(),
                                            theROC.portaddress(),
                                            theROC.rocid(),_bufferData);

      // Program the pixel pattern.
      unsigned int nrow=rows_[i_row].size();
      unsigned int ncol=cols_[i_col].size();
      unsigned int nmax=std::max(nrow,ncol);
      if (nrow==0||ncol==0) nmax=0;
      for (unsigned int n=0;n<nmax;n++){
        unsigned int irow=n;
        unsigned int icol=n;
        if (irow>=nrow) irow=nrow-1;
        if (icol>=ncol) icol=ncol-1;
        unsigned int row=rows_[i_row][irow];
        unsigned int col=cols_[i_col][icol];

        pixelFECs[theROC.fecnumber()]->calpix(theROC.mfec(),
                                              theROC.mfecchannel(),
                                              theROC.hubaddress(),
                                              theROC.portaddress(),
                                              theROC.rocid(),
                                              col,
                                              row,
                                              1,_bufferData);
      }
      
    } // end of instructions for the beginning of a scan
  } // end of loop over ROCs

  if (_bufferData) {
    std::map<unsigned int, PixelFECConfigInterface*>::iterator iPixelFEC=pixelFECs.begin();
    for(;iPixelFEC!=pixelFECs.end();++iPixelFEC){
      iPixelFEC->second->qbufsend();
    }
  }
  
  if (changedWBC){
    for(unsigned int i=0;i<rocs_.size();i++){

      if (!rocInfo_[i].use_) continue;
      
      PixelHdwAddress theROC=*rocInfo_[i].hdwadd_;
      
      int tbmRegister = 14;  // define for TBM-A
#ifdef BPIX
      string tbmChannel = rocInfo_[i].tbmChannel_; // get TBM channel
      if( tbmChannel=="B") tbmRegister = 15;  // for TBM=B
#endif     

      pixelFECs[theROC.fecnumber()]->rocreset(theROC.mfec(),
                         theROC.mfecchannel(),
                         tbmRegister, 
                         theROC.hubaddress());
    } // for rocs
  }

  return;
} 
bool pos::PixelCalibConfiguration::noHits ( ) const [inline]

Definition at line 112 of file PixelCalibConfiguration.h.

References maxNumHitsPerROC().

{return (maxNumHitsPerROC()==0);} // returns true if no hits will be produced
unsigned int pos::PixelCalibConfiguration::nParameters ( ) const [inline]

Definition at line 160 of file PixelCalibConfiguration.h.

References parameters_.

{return parameters_.size();}
unsigned int pos::PixelCalibConfiguration::nPixelPatterns ( ) const [inline]

Definition at line 99 of file PixelCalibConfiguration.h.

References cols_, and rows_.

Referenced by nConfigurations().

{ return rows_.size()*cols_.size(); }
unsigned int pos::PixelCalibConfiguration::nROC ( ) const [inline]

Definition at line 98 of file PixelCalibConfiguration.h.

References nROC_, and rocAndModuleListsBuilt_.

Referenced by nConfigurations().

{ assert(rocAndModuleListsBuilt_); return nROC_; }
unsigned int pos::PixelCalibConfiguration::nScanPoints ( std::string  dac) const [inline]

Definition at line 101 of file PixelCalibConfiguration.h.

References iScan(), and nScanPoints().

Referenced by nScanPoints().

{ return nScanPoints(iScan(dac)); }    
unsigned int pos::PixelCalibConfiguration::nScanPoints ( ) const [inline]

Definition at line 103 of file PixelCalibConfiguration.h.

References dacs_, and i.

Referenced by colCounter(), nConfigurations(), rowCounter(), scanCounter(), scanROC(), scanValue(), and scanValueMax().

                                     {unsigned int points=1;
      for(unsigned int i=0;i<dacs_.size();i++) {
        points*=nScanPoints(i);
      }
      return points;
    }
unsigned int pos::PixelCalibConfiguration::nScanPoints ( unsigned int  iscan) const [inline, private]

Definition at line 201 of file PixelCalibConfiguration.h.

References dacs_.

{ return dacs_[iscan].getNPoints(); }
unsigned int pos::PixelCalibConfiguration::nTriggersPerPattern ( ) const [inline]

Definition at line 100 of file PixelCalibConfiguration.h.

References ntrigger_.

Referenced by nTriggersTotal(), and SiPixelCalibConfiguration::SiPixelCalibConfiguration().

{ return ntrigger_; }
unsigned int pos::PixelCalibConfiguration::nTriggersTotal ( ) const [inline]
unsigned int pos::PixelCalibConfiguration::numberOfScanVariables ( ) const [inline]

Definition at line 136 of file PixelCalibConfiguration.h.

References dacs_.

Referenced by containsScan().

{return dacs_.size();}
unsigned int PixelCalibConfiguration::numROCsCalibratedOnChannel ( PixelROCName  roc) const [private]

Definition at line 870 of file PixelCalibConfiguration.cc.

References numROCsCalibratedOnChannel_, and objectsDependingOnTheNameTranslationBuilt_.

Referenced by scanValue().

{
        assert( objectsDependingOnTheNameTranslationBuilt_ );
        std::map <PixelROCName, unsigned int>::const_iterator foundROC = numROCsCalibratedOnChannel_.find(roc);
        assert( foundROC != numROCsCalibratedOnChannel_.end() );
        return foundROC->second;
}
std::map<std::string, std::string> pos::PixelCalibConfiguration::parametersList ( ) const [inline]

Definition at line 163 of file PixelCalibConfiguration.h.

References parameters_.

{return parameters_;}
std::string PixelCalibConfiguration::parameterValue ( std::string  parameterName) const

Definition at line 1532 of file PixelCalibConfiguration.cc.

References parameters_.

Referenced by nextFECState().

{
        std::map<std::string, std::string>::const_iterator itr = parameters_.find(parameterName);
        if (itr == parameters_.end()) // parameterName is not in the list
        {
                return "";
        }
        else
        {
                return itr->second;
        }
}
std::set< std::pair< unsigned int, unsigned int > > PixelCalibConfiguration::pixelsWithHits ( unsigned int  state) const

Definition at line 1647 of file PixelCalibConfiguration.cc.

References begin, colCounter(), cols_, rowCounter(), and rows_.

{
        std::set< std::pair<unsigned int, unsigned int> > pixels;
        //                  column #      row #
        
        for ( std::vector<unsigned int>::const_iterator col_itr = cols_[colCounter(state)].begin(); col_itr != cols_[colCounter(state)].end(); col_itr++ )
        {
                for ( std::vector<unsigned int>::const_iterator row_itr = rows_[rowCounter(state)].begin(); row_itr != rows_[rowCounter(state)].end(); row_itr++ )
                {
                        pixels.insert( std::pair<unsigned int, unsigned int>( *col_itr, *row_itr ) );
                }
        }
        
        return pixels;
}
const std::vector<PixelROCName>& pos::PixelCalibConfiguration::rocList ( ) const [inline]

Definition at line 152 of file PixelCalibConfiguration.h.

References rocAndModuleListsBuilt_, and rocs_.

{assert(rocAndModuleListsBuilt_); return rocs_;}
unsigned int PixelCalibConfiguration::ROCNumberOnChannelAmongThoseCalibrated ( PixelROCName  roc) const [private]

Definition at line 862 of file PixelCalibConfiguration.cc.

References objectsDependingOnTheNameTranslationBuilt_, and ROCNumberOnChannelAmongThoseCalibrated_.

Referenced by scanningROCForState(), and scanValue().

{
        assert( objectsDependingOnTheNameTranslationBuilt_ );
        std::map <PixelROCName, unsigned int>::const_iterator foundROC = ROCNumberOnChannelAmongThoseCalibrated_.find(roc);
        assert( foundROC != ROCNumberOnChannelAmongThoseCalibrated_.end() );
        return foundROC->second;
}
unsigned int PixelCalibConfiguration::rowCounter ( unsigned int  state) const [private]

Definition at line 896 of file PixelCalibConfiguration.cc.

References cols_, nScanPoints(), rows_, and scanROC().

Referenced by colCounter(), nextFECState(), and pixelsWithHits().

{
        unsigned int i_row=( state - scanROC(state)*cols_.size()*rows_.size()*nScanPoints() )/( cols_.size()*nScanPoints() );
        assert(i_row<rows_.size());
        return i_row;
}
const std::vector<std::vector<unsigned int> >& pos::PixelCalibConfiguration::rowList ( ) const [inline]

Definition at line 151 of file PixelCalibConfiguration.h.

References rows_.

Referenced by SiPixelCalibConfiguration::SiPixelCalibConfiguration().

{return rows_;}
unsigned int pos::PixelCalibConfiguration::scanCounter ( std::string  dac,
unsigned int  state 
) const [inline]

Definition at line 122 of file PixelCalibConfiguration.h.

References iScan().

Referenced by nextFECState(), and scanValue().

                                                                     {
      return scanCounter(iScan(dac),state);
    }
unsigned int PixelCalibConfiguration::scanCounter ( unsigned int  iscan,
unsigned int  state 
) const [private]

Definition at line 878 of file PixelCalibConfiguration.cc.

References i, nConfigurations(), and nScanPoints().

                                                                          {


    assert(state<nConfigurations());

    unsigned int i_scan=state%nScanPoints();

    for(unsigned int i=0;i<iscan;i++){
      i_scan/=nScanPoints(i);
    }

    unsigned int i_threshold=i_scan%nScanPoints(iscan);

    return i_threshold;

}
std::string pos::PixelCalibConfiguration::scanName ( unsigned int  iscan) const [inline]

Definition at line 140 of file PixelCalibConfiguration.h.

References dacs_.

Referenced by containsScan(), and SiPixelCalibConfiguration::SiPixelCalibConfiguration().

{return dacs_[iscan].name();}
bool PixelCalibConfiguration::scanningROCForState ( PixelROCName  roc,
unsigned int  state 
) const

Definition at line 846 of file PixelCalibConfiguration.cc.

References ROCNumberOnChannelAmongThoseCalibrated(), scanROC(), and singleROC_.

Referenced by nextFECState().

{
        if (!singleROC_) return true;
        return scanROC(state) == ROCNumberOnChannelAmongThoseCalibrated(roc);
}
unsigned int PixelCalibConfiguration::scanROC ( unsigned int  state) const [private]

Definition at line 818 of file PixelCalibConfiguration.cc.

References cols_, nConfigurations(), nScanPoints(), and rows_.

Referenced by colCounter(), rowCounter(), and scanningROCForState().

                                                                     {

  assert(state<nConfigurations());

  unsigned int i_ROC=state/(cols_.size()*rows_.size()*nScanPoints());
  
  return i_ROC;
}
unsigned int pos::PixelCalibConfiguration::scanValue ( std::string  dac,
unsigned int  state,
PixelROCName  roc 
) const [inline]

Definition at line 126 of file PixelCalibConfiguration.h.

References iScan().

Referenced by nextFECState(), and scanValue().

                                                                                      {
      return scanValue(iScan(dac), state, roc);
    }
unsigned int pos::PixelCalibConfiguration::scanValue ( std::string  dac,
unsigned int  state 
) const [inline]

Definition at line 131 of file PixelCalibConfiguration.h.

References dacs_, iScan(), and scanValue().

                                                                    {
      assert( !(dacs_[iScan(dac)].mixValuesAcrossROCs()) );
      return scanValue(iScan(dac), state, 0, 1);
    }
unsigned int PixelCalibConfiguration::scanValue ( unsigned int  iscan,
unsigned int  state,
unsigned int  ROCNumber,
unsigned int  ROCsOnChannel 
) const [private]

Definition at line 828 of file PixelCalibConfiguration.cc.

References dacs_, nScanPoints(), scanCounter(), and crabWrap::threshold.

                                                                                 {

    unsigned int i_threshold = scanCounter(iscan, state);

    // Spread the DAC values on the different ROCs uniformly across the scan range.
    if ( dacs_[iscan].mixValuesAcrossROCs() ) i_threshold = (i_threshold + (nScanPoints(iscan)*ROCNumber)/ROCsOnChannel)%nScanPoints(iscan);

    unsigned int threshold=dacs_[iscan].value(i_threshold);
    
    //assert(threshold==dacs_[iscan].first()+i_threshold*dacs_[iscan].step());

    return threshold;

}
unsigned int PixelCalibConfiguration::scanValue ( unsigned int  iscan,
unsigned int  state,
PixelROCName  roc 
) const [private]

Definition at line 852 of file PixelCalibConfiguration.cc.

References numROCsCalibratedOnChannel(), ROCNumberOnChannelAmongThoseCalibrated(), and scanValue().

                                                                        {

        unsigned int ROCNumber = ROCNumberOnChannelAmongThoseCalibrated(roc);
        unsigned int ROCsOnChannel = numROCsCalibratedOnChannel(roc);
        
        return scanValue( iscan, state, ROCNumber, ROCsOnChannel );
}
double pos::PixelCalibConfiguration::scanValueMax ( std::string  dac) const [inline]

Definition at line 144 of file PixelCalibConfiguration.h.

References iScan(), and scanValueMax().

Referenced by scanValueMax().

{return scanValueMax(iScan(dac));}
double pos::PixelCalibConfiguration::scanValueMax ( unsigned int  iscan) const [inline, private]

Definition at line 211 of file PixelCalibConfiguration.h.

References dacs_, and nScanPoints().

                                                  {return dacs_[iscan].first()+
                                                   dacs_[iscan].step()*(nScanPoints(iscan)-1);}
double pos::PixelCalibConfiguration::scanValueMin ( std::string  dac) const [inline]

Definition at line 143 of file PixelCalibConfiguration.h.

References iScan(), and scanValueMin().

Referenced by scanValueMin().

{return scanValueMin(iScan(dac));}
double pos::PixelCalibConfiguration::scanValueMin ( unsigned int  iscan) const [inline, private]

Definition at line 210 of file PixelCalibConfiguration.h.

References dacs_.

{return dacs_[iscan].first();}
std::vector<unsigned int> pos::PixelCalibConfiguration::scanValues ( unsigned int  iscan) const [inline, private]

Definition at line 208 of file PixelCalibConfiguration.h.

References dacs_.

{return dacs_[iscan].values();}
std::vector<unsigned int> pos::PixelCalibConfiguration::scanValues ( std::string  dac) const [inline]

Definition at line 141 of file PixelCalibConfiguration.h.

References iScan(), and scanValues().

Referenced by scanValues(), and SiPixelCalibConfiguration::SiPixelCalibConfiguration().

{return scanValues(iScan(dac));}
bool pos::PixelCalibConfiguration::scanValuesMixedAcrossROCs ( std::string  dac) const [inline]

Definition at line 146 of file PixelCalibConfiguration.h.

References iScan(), and scanValuesMixedAcrossROCs().

Referenced by scanValuesMixedAcrossROCs().

bool pos::PixelCalibConfiguration::scanValuesMixedAcrossROCs ( unsigned int  iscan) const [inline, private]

Definition at line 214 of file PixelCalibConfiguration.h.

References dacs_.

{return dacs_[iscan].mixValuesAcrossROCs();}
double pos::PixelCalibConfiguration::scanValueStep ( unsigned int  iscan) const [inline, private]

Definition at line 213 of file PixelCalibConfiguration.h.

References dacs_.

{return dacs_[iscan].step();}
double pos::PixelCalibConfiguration::scanValueStep ( std::string  dac) const [inline]

Definition at line 145 of file PixelCalibConfiguration.h.

References iScan(), and scanValueStep().

Referenced by scanValueStep().

{return scanValueStep(iScan(dac));}
bool pos::PixelCalibConfiguration::singleROC ( ) const [inline]

Definition at line 158 of file PixelCalibConfiguration.h.

References singleROC_.

{return singleROC_;}
void PixelCalibConfiguration::writeASCII ( std::string  dir = "") const [virtual]

Implements pos::PixelConfigBase.

Definition at line 1545 of file PixelCalibConfiguration.cc.

References cols_, dacs_, lut2db_cfg::filename, first, highVCalRange_, i, j, pos::PixelCalibBase::mode_, ntrigger_, dbtoconf::out, parameters_, rocListInstructions_, rows_, singleROC_, and usesROCList_.

Referenced by writeXMLHeader().

                                                            {


  //FIXME this is not tested for all the use cases...

  if (dir!="") dir+="/";
  std::string filename=dir+"calib.dat";
  std::ofstream out(filename.c_str());

  out << "Mode: "<<mode_<<endl;
  if (singleROC_) out << "SingleROC"<<endl;
  if (!parameters_.empty()){
    out << "Parameters:"<<endl;
    std::map<std::string, std::string>::const_iterator it=parameters_.begin();
    for (;it!=parameters_.end();++it){
      out << it->first << "        " << it->second <<endl;
    }
  }
  out << "Rows:" <<endl;
  for (unsigned int i=0;i<rows_.size();i++){
    for (unsigned int j=0;j<rows_[i].size();j++){
      out << rows_[i][j] <<" ";
    }
    if (i!=rows_.size()-1) out <<"|";
    out <<endl;
  }
  out << "Cols:" <<endl;
  for (unsigned int i=0;i<cols_.size();i++){
    for (unsigned int j=0;j<cols_[i].size();j++){
      out << cols_[i][j] <<" ";
    }
    if (i!=cols_.size()-1) out <<"|";
    out <<endl;
  }

  if (highVCalRange_) {
    out << "VcalHigh" << endl;
  }
  else {
    out << "VcalLow" << endl;
  }


  for (unsigned int i=0;i<dacs_.size();i++){
    if (dacs_[i].uniformSteps()) {
      if (dacs_[i].first()!=dacs_[i].last()) {
        out << "Scan: "<<dacs_[i].name()<<" ";
        out <<dacs_[i].first()<<" ";
        out <<dacs_[i].last()<<" ";
        out <<dacs_[i].step()<<endl;
      }
      else {
        out << "Set: "<<dacs_[i].name()<<" ";
        out <<dacs_[i].first()<<endl;
      }
    }
    else {
      out << "ScanValues: "<<dacs_[i].name()<<" ";
      for(unsigned int ival=0;ival<dacs_[i].getNPoints();ival++){
        out << dacs_[i].value(ival)<<" ";
      }
      out<<" -1"<<endl;
    }
  }

  out << "Repeat:" <<endl;
  out << ntrigger_ << endl;

  if (usesROCList_){
    out << "Rocs:"<< endl;
  }
  else{
    out << "ToCalibrate:"<< endl;
  }
  for (unsigned int i=0;i<rocListInstructions_.size();i++){
    out << rocListInstructions_[i] <<endl;
    if (rocListInstructions_[i]=="+"||rocListInstructions_[i]=="-"){
      out << " ";
    }
    else {
      out << endl;
    }
  }  

  out.close();

}
void PixelCalibConfiguration::writeXML ( std::ofstream *  out,
std::ofstream *  out1 = NULL,
std::ofstream *  out2 = NULL 
) const [virtual]

Reimplemented from pos::PixelCalibBase.

Definition at line 1725 of file PixelCalibConfiguration.cc.

{
  std::string mthn = "[PixelCalibConfiguration::writeXML()]\t\t    " ;
  

  *outstream << " "                                                                                       << std::endl ;
  *outstream << "  <DATA>"                                                                                << std::endl ;
  *outstream << "   <CALIB_OBJ_DATA_FILE>./calib.dat</CALIB_OBJ_DATA_FILE>"                               << std::endl ;
  *outstream << "   <CALIB_TYPE>calib</CALIB_TYPE>"                                                       << std::endl ;
  *outstream << "  </DATA>"                                                                               << std::endl ;
  *outstream << " "                                                                                       << std::endl ;
}
void pos::PixelCalibConfiguration::writeXML ( pos::PixelConfigKey  key,
int  version,
std::string  path 
) const [inline, virtual]

Reimplemented from pos::PixelConfigBase.

Definition at line 173 of file PixelCalibConfiguration.h.

{;}
void PixelCalibConfiguration::writeXMLHeader ( pos::PixelConfigKey  key,
int  version,
std::string  path,
std::ofstream *  out,
std::ofstream *  out1 = NULL,
std::ofstream *  out2 = NULL 
) const [virtual]

Reimplemented from pos::PixelConfigBase.

Definition at line 1676 of file PixelCalibConfiguration.cc.

References gather_cfg::cout, pos::PixelConfigBase::getAuthor(), pos::PixelConfigBase::getComment(), pos::PixelTimeFormatter::getmSecTime(), edm::service::getTime(), and writeASCII().

{
  std::string mthn = "[PixelCalibConfiguration::writeXMLHeader()]\t\t    " ;
  std::stringstream maskFullPath ;

  writeASCII(path) ;

  maskFullPath << path << "/PixelCalib_Test_" << PixelTimeFormatter::getmSecTime() << ".xml";
  std::cout << __LINE__ << "]\t" << mthn << "Writing to: " << maskFullPath.str() << std::endl ;

  outstream->open(maskFullPath.str().c_str()) ;
  
  *outstream << "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>"                                 << std::endl ;
  *outstream << "<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>"                            << std::endl ;
  *outstream << ""                                                                                        << std::endl ; 
  *outstream << " <!-- " << mthn << "-->"                                                                 << std::endl ; 
  *outstream << ""                                                                                        << std::endl ; 
  *outstream << " <HEADER>"                                                                               << std::endl ; 
  *outstream << "  <TYPE>"                                                                                << std::endl ; 
  *outstream << "   <EXTENSION_TABLE_NAME>PIXEL_CALIB_CLOB</EXTENSION_TABLE_NAME>"                        << std::endl ; 
  *outstream << "   <NAME>Calibration Object Clob</NAME>"                                                 << std::endl ; 
  *outstream << "  </TYPE>"                                                                               << std::endl ; 
  *outstream << "  <RUN>"                                                                                 << std::endl ; 
  *outstream << "   <RUN_TYPE>Gain Calibration</RUN_TYPE>"                                                << std::endl ; 
  *outstream << "   <RUN_NUMBER>1</RUN_NUMBER>"                                                           << std::endl ; 
  *outstream << "   <RUN_BEGIN_TIMESTAMP>" << PixelTimeFormatter::getTime() << "</RUN_BEGIN_TIMESTAMP>"   << std::endl ; 
  *outstream << "   <LOCATION>CERN P5</LOCATION>"                                                         << std::endl ; 
  *outstream << "  </RUN>"                                                                                << std::endl ; 
  *outstream << " </HEADER>"                                                                              << std::endl ; 
  *outstream << ""                                                                                        << std::endl ; 
  *outstream << " <DATA_SET>"                                                                             << std::endl ;
  *outstream << ""                                                                                        << std::endl ;
  *outstream << "  <VERSION>" << version << "</VERSION>"                                                  << std::endl ;
  *outstream << "  <COMMENT_DESCRIPTION>" << getComment() << "</COMMENT_DESCRIPTION>"                     << std::endl ;
  *outstream << "  <CREATED_BY_USER>"     << getAuthor()  << "</CREATED_BY_USER>"                         << std::endl ; 
  *outstream << ""                                                                                        << std::endl ;
  *outstream << "  <PART>"                                                                                << std::endl ;
  *outstream << "   <NAME_LABEL>CMS-PIXEL-ROOT</NAME_LABEL>"                                              << std::endl ;      
  *outstream << "   <KIND_OF_PART>Detector ROOT</KIND_OF_PART>"                                           << std::endl ;         
  *outstream << "  </PART>"                                                                               << std::endl ;

}
void PixelCalibConfiguration::writeXMLTrailer ( std::ofstream *  out,
std::ofstream *  out1 = NULL,
std::ofstream *  out2 = NULL 
) const [virtual]

Reimplemented from pos::PixelCalibBase.

Definition at line 1741 of file PixelCalibConfiguration.cc.

References gather_cfg::cout.

{
  std::string mthn = "[PixelCalibConfiguration::writeXMLTrailer()]\t\t    " ;
  
  *outstream << " </DATA_SET>"                                                                            << std::endl ;
  *outstream << "</ROOT>"                                                                                 << std::endl ;
  
  outstream->close() ;
  std::cout << __LINE__ << "]\t" << mthn << "Data written "                                               << std::endl ;

}

Friends And Related Function Documentation

std::ostream& pos::operator<< ( std::ostream &  s,
const PixelCalibConfiguration calib 
) [friend]

Member Data Documentation

Definition at line 285 of file PixelCalibConfiguration.h.

Referenced by getStreamedContent(), and PixelCalibConfiguration().

std::vector<std::vector<unsigned int> > pos::PixelCalibConfiguration::cols_ [private]
std::vector<std::pair<unsigned int, std::vector<unsigned int> > > pos::PixelCalibConfiguration::fedCardsAndChannels_ [mutable, private]

Definition at line 241 of file PixelCalibConfiguration.h.

Referenced by fedCardsAndChannels().

Definition at line 257 of file PixelCalibConfiguration.h.

Referenced by nextFECState(), PixelCalibConfiguration(), and writeASCII().

unsigned int pos::PixelCalibConfiguration::nROC_ [private]

Definition at line 255 of file PixelCalibConfiguration.h.

Referenced by buildROCAndModuleListsFromROCSet(), and nROC().

std::vector<int> pos::PixelCalibConfiguration::old_icols [mutable, private]

Definition at line 275 of file PixelCalibConfiguration.h.

Referenced by buildROCAndModuleListsFromROCSet().

std::vector<int> pos::PixelCalibConfiguration::old_irows [mutable, private]

Definition at line 274 of file PixelCalibConfiguration.h.

Referenced by buildROCAndModuleListsFromROCSet().

std::map<std::string, std::string> pos::PixelCalibConfiguration::parameters_ [private]
std::vector<PixelROCInfo> pos::PixelCalibConfiguration::rocInfo_ [mutable, private]

Definition at line 230 of file PixelCalibConfiguration.h.

Referenced by nextFECState().

std::vector<std::string> pos::PixelCalibConfiguration::rocListInstructions_ [private]
std::vector<PixelROCName> pos::PixelCalibConfiguration::rocs_ [mutable, private]
std::vector<std::vector<unsigned int> > pos::PixelCalibConfiguration::rows_ [private]

Definition at line 282 of file PixelCalibConfiguration.h.

Referenced by PixelCalibConfiguration(), and writeASCII().