CMS 3D CMS Logo

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

SiPixelOfflineCalibAnalysisBase Class Reference

#include <CalibTracker/SiPixelTools/src/SiPixelOfflineCalibAnalysisBase.cc>

Inheritance diagram for SiPixelOfflineCalibAnalysisBase:
edm::EDAnalyzer SiPixelGainCalibrationAnalysis SiPixelIsAliveCalibration SiPixelSCurveCalibrationAnalysis

List of all members.

Public Member Functions

void addTF1ToDQMMonitoringElement (MonitorElement *ele, TF1 *func)
MonitorElementbookDQMHistogram1D (uint32_t detid, std::string name, std::string title, int nchX, double lowX, double highX)
MonitorElementbookDQMHistogram1D (uint32_t detid, std::string name, std::string title, int nchX, float *xbinsize)
MonitorElementbookDQMHistogram2D (uint32_t detid, std::string name, std::string title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
MonitorElementbookDQMHistoPlaquetteSummary2D (uint32_t detid, std::string name, std::string title)
virtual bool doFits (uint32_t detid, std::vector< SiPixelCalibDigi >::const_iterator ipix)
std::vector< uint32_t > & getRunNumbers ()
bool setDQMDirectory (std::string dirName)
bool setDQMDirectory (uint32_t detID)
 SiPixelOfflineCalibAnalysisBase (const edm::ParameterSet &)
 SiPixelOfflineCalibAnalysisBase ()
std::string translateDetIdToString (uint32_t detid)
 ~SiPixelOfflineCalibAnalysisBase ()

Static Public Member Functions

static const std::vector< short > * getVcalValues ()

Static Public Attributes

static TF1 * fitFunction_ = NULL

Protected Member Functions

uint32_t & EventNumber ()

Protected Attributes

edm::ESHandle
< SiPixelCalibConfiguration
calib_
std::string calibrationMode_
edm::ESHandle< TrackerGeometrygeom_
short nTriggers_
edm::ESHandle
< SiPixelFedCablingMap
theCablingMap_

Static Protected Attributes

static std::vector< short > vCalValues_

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &)
void beginJob ()
void beginRun (const edm::EventSetup &iSetup)
virtual void beginRun (const edm::Run &, const edm::EventSetup &)
virtual void calibrationEnd ()
virtual void calibrationSetup (const edm::EventSetup &iSetup)
virtual bool checkCorrectCalibrationType ()
bool checkPixel (uint32_t detid, short row, short column)
void endJob ()
virtual void newDetID (uint32_t detid)

Private Attributes

bool createOutputFile_
DQMStoredaqBE_
std::map< uint32_t, std::string > detIdNames_
std::map< uint32_t, int > detIdsEntered_
uint32_t eventCounter_
SiPixelFolderOrganizerfolderMaker_
std::string outputFileName_
std::vector< uint32_t > runnumbers_
edm::InputTag siPixelCalibDigiProducer_
SiPixelHistogramIdtheHistogramIdWorker_

Detailed Description

Description: Base class for Pixel calibrations

Implementation: <Notes on="" implementation>="">

Definition at line 68 of file SiPixelOfflineCalibAnalysisBase.h.


Constructor & Destructor Documentation

SiPixelOfflineCalibAnalysisBase::SiPixelOfflineCalibAnalysisBase ( const edm::ParameterSet iConfig) [explicit]
SiPixelOfflineCalibAnalysisBase::~SiPixelOfflineCalibAnalysisBase ( )

Definition at line 52 of file SiPixelOfflineCalibAnalysisBase.cc.

{
}
SiPixelOfflineCalibAnalysisBase::SiPixelOfflineCalibAnalysisBase ( )

Definition at line 47 of file SiPixelOfflineCalibAnalysisBase.cc.

References Exception.

{
   throw cms::Exception("") << "ERROR: Classes derived from SiPixelOfflineCalibAnalysisBase must call SiPixelOfflineCalibAnalysisBase::SiPixelOfflineCalibAnalysisBase(const edm::ParameterSet& iConfig) from their constructor." << std::endl;
}

Member Function Documentation

void SiPixelOfflineCalibAnalysisBase::addTF1ToDQMMonitoringElement ( MonitorElement ele,
TF1 *  func 
)

Definition at line 333 of file SiPixelOfflineCalibAnalysisBase.cc.

References MonitorElement::getTH1().

                                                                                                {
  
  if(func){
    ele->getTH1()->GetListOfFunctions()->Add(func);
  }
  return;
}
void SiPixelOfflineCalibAnalysisBase::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDAnalyzer.

Definition at line 63 of file SiPixelOfflineCalibAnalysisBase.cc.

References calib_, calibrationSetup(), checkCorrectCalibrationType(), edm::DetSet< T >::data, detIdNames_, detIdsEntered_, doFits(), edm::DetSet< T >::end(), eventCounter_, geom_, edm::EventSetup::get(), edm::Event::getByLabel(), edm::EventBase::id(), newDetID(), edm::EventID::run(), cond::runnumber, runnumbers_, siPixelCalibDigiProducer_, theCablingMap_, and translateDetIdToString().

{
   using namespace edm;

   iSetup.get<TrackerDigiGeometryRecord>().get( geom_ );
   iSetup.get<SiPixelFedCablingMapRcd>().get(theCablingMap_);
   iSetup.get<SiPixelCalibConfigurationRcd>().get(calib_);
   if(eventCounter_==0)
     this->calibrationSetup(iSetup);
   eventCounter_++;
     
   // check first if you're analyzing the right type of calibration
   if(!checkCorrectCalibrationType())
     return;
   
   uint32_t runnumber=iEvent.id().run();
   if(runnumbers_.size()==0)
     runnumbers_.push_back(runnumber);
   else{
     bool foundnumber=false;
     for(size_t iter=0; iter<runnumbers_.size() && !foundnumber; ++ iter){
       if(runnumbers_[iter]==runnumber){
         foundnumber=true;
         continue;
       }
     }
     if(!foundnumber)
       runnumbers_.push_back(runnumber);
   }
    
   Handle<DetSetVector<SiPixelCalibDigi> > thePlaquettes;
   iEvent.getByLabel(siPixelCalibDigiProducer_, thePlaquettes);

   DetSetVector<SiPixelCalibDigi>::const_iterator digiIter;

   //loop over the plaquettes pulsed in this pattern 
   for(digiIter=thePlaquettes->begin(); digiIter!=thePlaquettes->end(); ++digiIter) 
   {
      uint32_t detId = digiIter->id;
      //check to see if this detID has not been encountered.  If not, run the newDetID (pure virtual) function
      if (detIdsEntered_.find(detId) == detIdsEntered_.end()) 
      {
         detIdsEntered_.insert(std::make_pair(detId, 0));
         detIdNames_.insert(std::make_pair(detId, translateDetIdToString(detId)));
         newDetID(detId);
      }
      DetSet<SiPixelCalibDigi>::const_iterator ipix;
      //loop over pixels pulsed in the current plaquette
      for(ipix=digiIter->data.begin(); ipix!=digiIter->end(); ++ipix)
      {
         //called derived function to fit this curve
        this->doFits(detId, ipix);
      }
   }
   
}
void SiPixelOfflineCalibAnalysisBase::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 137 of file SiPixelOfflineCalibAnalysisBase.cc.

{

}
void SiPixelOfflineCalibAnalysisBase::beginRun ( const edm::Run ,
const edm::EventSetup iSetup 
) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 120 of file SiPixelOfflineCalibAnalysisBase.cc.

References calib_, calibrationMode_, calibrationSetup(), gather_cfg::cout, geom_, edm::EventSetup::get(), edm::InputTag::label(), nTriggers_, siPixelCalibDigiProducer_, theCablingMap_, theHistogramIdWorker_, and vCalValues_.

{
   //load the calibration information from the database
   iSetup.get<SiPixelCalibConfigurationRcd>().get(calib_);
   iSetup.get<TrackerDigiGeometryRecord>().get( geom_ );
   iSetup.get<SiPixelFedCablingMapRcd>().get(theCablingMap_);

   calibrationMode_     = calib_->getCalibrationMode();
   nTriggers_           = calib_->getNTriggers();
   vCalValues_          = calib_->getVCalValues();
   std::cout << "!!!! in beginRun" << std::endl;
   edm::LogInfo("SiPixelOfflineCalibAnalysisBase") << "Calibration file loaded. Mode: " << calibrationMode_ << " nTriggers: " << nTriggers_ << " Vcal steps: " << vCalValues_.size() << std::endl;
   //call calibrationSetup virtual function
   this->calibrationSetup(iSetup);
   theHistogramIdWorker_ = new SiPixelHistogramId(siPixelCalibDigiProducer_.label());
}
void SiPixelOfflineCalibAnalysisBase::beginRun ( const edm::EventSetup iSetup) [private]
MonitorElement * SiPixelOfflineCalibAnalysisBase::bookDQMHistogram1D ( uint32_t  detid,
std::string  name,
std::string  title,
int  nchX,
float *  xbinsize 
)

Definition at line 197 of file SiPixelOfflineCalibAnalysisBase.cc.

References DQMStore::book1D(), daqBE_, SiPixelHistogramId::setHistoId(), and theHistogramIdWorker_.

{
  std::string hid = theHistogramIdWorker_->setHistoId(name,detid);
  return daqBE_->book1D(hid, title, nchX, xbinsize);
}
MonitorElement * SiPixelOfflineCalibAnalysisBase::bookDQMHistogram1D ( uint32_t  detid,
std::string  name,
std::string  title,
int  nchX,
double  lowX,
double  highX 
)
MonitorElement * SiPixelOfflineCalibAnalysisBase::bookDQMHistogram2D ( uint32_t  detid,
std::string  name,
std::string  title,
int  nchX,
double  lowX,
double  highX,
int  nchY,
double  lowY,
double  highY 
)

Definition at line 203 of file SiPixelOfflineCalibAnalysisBase.cc.

References DQMStore::book2D(), daqBE_, SiPixelHistogramId::setHistoId(), and theHistogramIdWorker_.

{
  std::string hid = theHistogramIdWorker_->setHistoId(name,detid);
  return daqBE_->book2D(hid, title, nchX, lowX, highX, nchY, lowY, highY);
}
MonitorElement * SiPixelOfflineCalibAnalysisBase::bookDQMHistoPlaquetteSummary2D ( uint32_t  detid,
std::string  name,
std::string  title 
)
void SiPixelOfflineCalibAnalysisBase::calibrationEnd ( ) [private, virtual]

Reimplemented in SiPixelGainCalibrationAnalysis, SiPixelIsAliveCalibration, and SiPixelSCurveCalibrationAnalysis.

Definition at line 270 of file SiPixelOfflineCalibAnalysisBase.cc.

Referenced by endJob().

{
  // do nothing
}
void SiPixelOfflineCalibAnalysisBase::calibrationSetup ( const edm::EventSetup iSetup) [private, virtual]

Reimplemented in SiPixelGainCalibrationAnalysis, SiPixelIsAliveCalibration, and SiPixelSCurveCalibrationAnalysis.

Definition at line 265 of file SiPixelOfflineCalibAnalysisBase.cc.

Referenced by analyze(), and beginRun().

{
   //do nothing
}
bool SiPixelOfflineCalibAnalysisBase::checkCorrectCalibrationType ( ) [private, virtual]

Reimplemented in SiPixelGainCalibrationAnalysis, SiPixelIsAliveCalibration, and SiPixelSCurveCalibrationAnalysis.

Definition at line 237 of file SiPixelOfflineCalibAnalysisBase.cc.

Referenced by analyze().

{
  return true;
}
bool SiPixelOfflineCalibAnalysisBase::checkPixel ( uint32_t  detid,
short  row,
short  column 
) [private]

Definition at line 282 of file SiPixelOfflineCalibAnalysisBase.cc.

References calib_, sipixelobjects::ElectronicIndex::dcol, sipixelobjects::LocalPixel::DcolPxid::dcol, cond::rpcobgas::detid, edm::ESHandle< T >::product(), sipixelobjects::ElectronicIndex::pxid, sipixelobjects::LocalPixel::DcolPxid::pxid, sipixelobjects::LocalPixel::rocCol(), sipixelobjects::LocalPixel::rocRow(), and theCablingMap_.

{
  // finds the fed ID:
  int thefedid = -1;
  for(int fedid=0; fedid<=40 && thefedid==-1; ++fedid)
    {
      SiPixelFrameConverter converter(theCablingMap_.product(),fedid);
      if(converter.hasDetUnit(detid))
        {
          thefedid=fedid;
        }
    }
  if(thefedid==-1)
    return false; // fed ID not associated with det ID. No pattern check possible
  
  SiPixelFrameConverter formatter(theCablingMap_.product(),thefedid);
  sipixelobjects::DetectorIndex detector ={detid, row, col};
  sipixelobjects::ElectronicIndex cabling;
  
  formatter.toCabling(cabling,detector);
  // cabling should now contain cabling.roc and cabling.dcol  and cabling.pxid

  // however, the coordinates now need to be converted from dcl, pxid to the row,col coordinates used in the calibration info
  sipixelobjects::LocalPixel::DcolPxid loc;
  loc.dcol = cabling.dcol;
  loc.pxid = cabling.pxid;
  sipixelobjects::LocalPixel locpixel(loc);
  short localrow = locpixel.rocRow();
  short localcol = locpixel.rocCol();

  // now get the patterns from the calib object:
  std::vector<short> calibcols = calib_->getColumnPattern();
  std::vector<short> calibrows = calib_->getRowPattern();
  // first check rows:
  for(size_t irow=0; irow<calibrows.size(); ++irow)
    {
      if(calibrows[irow]==localrow)
        {
          // check the columns
          for(size_t icol=0; icol<calibcols.size(); ++icol)
            {
              if(calibcols[icol]==localcol)
                return true;
            }
        }
    }

  return false;
}
bool SiPixelOfflineCalibAnalysisBase::doFits ( uint32_t  detid,
std::vector< SiPixelCalibDigi >::const_iterator  ipix 
) [virtual]

Reimplemented in SiPixelGainCalibrationAnalysis, SiPixelIsAliveCalibration, and SiPixelSCurveCalibrationAnalysis.

Definition at line 243 of file SiPixelOfflineCalibAnalysisBase.cc.

References gather_cfg::cout, and i.

Referenced by analyze().

{
  short row=ipix->row();
  short col=ipix->col();
  std::vector<uint8_t> nentries = ipix->getnentries();
  std::vector<uint32_t> sum = ipix->getsum();
  std::vector<uint32_t> sumquares = ipix->getsumsquares();
   //do nothing
   //return false;
   //
   //DEBUG
   std::cout << "Row: " << row << "   Col: " << col << std::endl;
   for (unsigned int i = 0; i < sum.size(); i++)
   {
      std::cout << sum[i] << "  ";
   }
   std::cout << std::endl;
   return false;

}
void SiPixelOfflineCalibAnalysisBase::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 145 of file SiPixelOfflineCalibAnalysisBase.cc.

References calibrationEnd(), createOutputFile_, daqBE_, outputFileName_, and DQMStore::save().

                                        {
  this->calibrationEnd();
   edm::LogInfo("SiPixelOfflineCalibAnalysisBase") << "Running end job... output file name is: " << outputFileName_;
   if (!outputFileName_.empty() && createOutputFile_) 
   {
      edm::LogInfo("SiPixelOfflineCalibAnalysisBase") << "Writing ROOT file to: " << outputFileName_ << std::endl;
      daqBE_->save(outputFileName_);
   }
}
uint32_t& SiPixelOfflineCalibAnalysisBase::EventNumber ( ) [inline, protected]

Definition at line 109 of file SiPixelOfflineCalibAnalysisBase.h.

References eventCounter_.

{ return eventCounter_;}
std::vector<uint32_t>& SiPixelOfflineCalibAnalysisBase::getRunNumbers ( ) [inline]

Definition at line 97 of file SiPixelOfflineCalibAnalysisBase.h.

References runnumbers_.

{ return runnumbers_;}
const std::vector< short > * SiPixelOfflineCalibAnalysisBase::getVcalValues ( ) [static]
void SiPixelOfflineCalibAnalysisBase::newDetID ( uint32_t  detid) [private, virtual]

Reimplemented in SiPixelGainCalibrationAnalysis, SiPixelIsAliveCalibration, and SiPixelSCurveCalibrationAnalysis.

Definition at line 275 of file SiPixelOfflineCalibAnalysisBase.cc.

References cond::rpcobgas::detid, and detIdNames_.

Referenced by analyze().

{
   //do nothing
   edm::LogInfo("SiPixelOfflineCalibAnalysisBase") << "SiPixelOfflineCalibAnalysisBase - Found new DetID: " << detid << "  Name: " << detIdNames_[detid];
}
bool SiPixelOfflineCalibAnalysisBase::setDQMDirectory ( uint32_t  detID)
bool SiPixelOfflineCalibAnalysisBase::setDQMDirectory ( std::string  dirName)
std::string SiPixelOfflineCalibAnalysisBase::translateDetIdToString ( uint32_t  detid)

Definition at line 164 of file SiPixelOfflineCalibAnalysisBase.cc.

References detIdNames_, PixelEndcapName::name(), PixelBarrelName::name(), convertSQLitetoXML_cfg::output, and DetId::subdetId().

Referenced by analyze(), SiPixelSCurveCalibrationAnalysis::buildACurveHistogram(), SiPixelIsAliveCalibration::calibrationEnd(), SiPixelGainCalibrationAnalysis::doFits(), SiPixelSCurveCalibrationAnalysis::newDetID(), SiPixelGainCalibrationAnalysis::newDetID(), SiPixelIsAliveCalibration::newDetID(), and SiPixelGainCalibrationAnalysis::printSummary().

{
   std::map<uint32_t, std::string>::iterator detNameIter = detIdNames_.find(detid);
   if (detNameIter != detIdNames_.end()) {
      return detNameIter->second;
   }
   std::string output = "DetID translation error";
   DetId detId(detid);
   uint32_t detSubId = detId.subdetId();
   if (detSubId > 2 || detSubId < 1)
   {
      edm::LogError("SiPixelOfflineCalibAnalysisBase") << "ERROR: Expected a pixel detector ID (1 - barrel, 2 - forward) but got " << detSubId << std::endl;
      return output;
   }
   if (detSubId == 2)   //FPIX
   {
      PixelEndcapName nameworker(detid);
      output = nameworker.name();
   } else               //BPIX
   {
      PixelBarrelName nameworker(detid);
      output = nameworker.name();
   }
   detIdNames_.insert(std::make_pair(detid, output));
   return output;
}

Member Data Documentation

Definition at line 118 of file SiPixelOfflineCalibAnalysisBase.h.

Referenced by endJob(), and SiPixelOfflineCalibAnalysisBase().

std::map<uint32_t, std::string> SiPixelOfflineCalibAnalysisBase::detIdNames_ [private]

Definition at line 126 of file SiPixelOfflineCalibAnalysisBase.h.

Referenced by analyze(), newDetID(), and translateDetIdToString().

std::map<uint32_t, int> SiPixelOfflineCalibAnalysisBase::detIdsEntered_ [private]

Definition at line 125 of file SiPixelOfflineCalibAnalysisBase.h.

Referenced by analyze().

Definition at line 121 of file SiPixelOfflineCalibAnalysisBase.h.

Referenced by analyze(), and EventNumber().

Definition at line 117 of file SiPixelOfflineCalibAnalysisBase.h.

Referenced by endJob(), and SiPixelOfflineCalibAnalysisBase().

std::vector<uint32_t> SiPixelOfflineCalibAnalysisBase::runnumbers_ [private]

Definition at line 120 of file SiPixelOfflineCalibAnalysisBase.h.

Referenced by analyze(), and getRunNumbers().

std::vector< short > SiPixelOfflineCalibAnalysisBase::vCalValues_ [static, protected]