/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Private Member Functions | Private Attributes
RandomGainAlg Class Reference

#include <RandomGainAlg.h>

Collaboration diagram for RandomGainAlg:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RandomGainAlg (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~RandomGainAlg ()
virtual StatusCode initialize ()
virtual StatusCode execute ()
virtual StatusCode finalize ()

Private Member Functions

bool hasStats (const DayaBay::Detector &detector)
StatusCode prepareStats (const Context &context)
std::string getPath (const DayaBay::Detector &detector)
std::string getPath (const DayaBay::FeeChannelId &channelId)

Private Attributes

std::string m_readoutLocation
std::string m_cableSvcName
std::string m_filepath
ICableSvcm_cableSvc
IStatisticsSvcm_statsSvc
std::vector< DayaBay::Detectorm_processedDetectors
TimeStamp m_beginTime
TimeStamp m_endTime
bool m_first
int m_lastTriTimeAD1
int m_lastTriTimeAD2
int m_lastTriTimeWPO
int m_lastTriTimeWPI
int total_event
int used_event

Detailed Description

Definition at line 24 of file RandomGainAlg.h.


Constructor & Destructor Documentation

RandomGainAlg::RandomGainAlg ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 21 of file RandomGainAlg.cc.

    : GaudiAlgorithm(name,pSvcLocator)
{
        declareProperty("ReadoutLocation",m_readoutLocation=DayaBay::ReadoutHeaderLocation::Default,"Location in the TES where the input ReadoutHeader is to be found.");
        declareProperty("CableSvcName",m_cableSvcName="CableSvc", "Name of service to map between detector, hardware, and electronic IDs");
        declareProperty("FilePath",m_filepath="/file0/pmtCalibRandomGain", "File path of registered histograms.");
}
RandomGainAlg::~RandomGainAlg ( ) [virtual]

Definition at line 29 of file RandomGainAlg.cc.

{}

Member Function Documentation

StatusCode RandomGainAlg::initialize ( ) [virtual]

Definition at line 31 of file RandomGainAlg.cc.

                                    {
        
        info() << "initialize()" << endreq;
        m_cableSvc = svc<ICableSvc>(m_cableSvcName, true);
        if(!m_cableSvc){
        error() << "Failed to access cable svc: " << m_cableSvcName << endreq;
        return StatusCode::FAILURE;
        }
  
        m_statsSvc = svc<IStatisticsSvc>("StatisticsSvc",true);
        if(!m_statsSvc) {
        error() << " No StatisticsSvc available." << endreq;
        return StatusCode::FAILURE;
        }

        std::vector<std::string> detDirs = m_statsSvc->getSubFolders(m_filepath);
        std::vector<std::string>::iterator dirIter, dirEnd = detDirs.end();
        for(dirIter=detDirs.begin(); dirIter != dirEnd; dirIter++){
        info() << "Processing input directory: " << m_filepath << "/"  << *dirIter << endreq;
        DayaBay::Detector detector( DayaBay::Detector::siteDetPackedFromString(*dirIter) );
        if( detector.site() == Site::kUnknown || detector.detectorId() == DetectorId::kUnknown ){
                warning() << "Input directory: " << m_filepath << "/" << *dirIter << " not processed." << endreq;
        }
                m_processedDetectors.push_back(detector);
        }
        m_first = true;
        m_lastTriTimeAD1=0;
        m_lastTriTimeAD2=0;
        m_lastTriTimeWPI=0;
        m_lastTriTimeWPO=0;
        total_event=0;
        used_event =0;
        return StatusCode::SUCCESS;
}
StatusCode RandomGainAlg::execute ( ) [virtual]

Definition at line 66 of file RandomGainAlg.cc.

                                 {
        debug() << "calling execute()" << endreq; 
        DayaBay::ReadoutHeader* readoutHeader = get<DayaBay::ReadoutHeader>(m_readoutLocation);
        TimeStamp trigTime = readoutHeader->timeStamp();

        if(m_first) {
                m_beginTime = trigTime;
        m_first = false;
        }
        m_endTime = trigTime;
        
        DayaBay::Detector det(readoutHeader->context().GetSite(),readoutHeader->context().GetDetId());
        debug() << "Got readout from " << det.detName() <<" id= "<< det.siteDetPackedData() <<endreq;
        
        if(det.detectorId()==7) return StatusCode::SUCCESS;
        
        if(det.isAD() || det.isWaterShield()){
                const DayaBay::DaqCrate* daqCrate = readoutHeader->daqCrate();
                if(!daqCrate){
                error() << "Failed to get DAQ crate from header" << endreq;
                return StatusCode::FAILURE;
        }
        const DayaBay::DaqPmtCrate* pmtCrate= daqCrate->asPmtCrate();
                if(!pmtCrate){
                debug() << "process(): Do not process detector: " << det.detName() << endreq;
                return StatusCode::SUCCESS;
                }
                int trigType = pmtCrate->triggerType();
                if(det.detectorId()==1&&trigType == 0x10000020) total_event++;
                if(det.detectorId()==1&&(trigTime.GetNanoSec()-m_lastTriTimeAD1)<20000) { m_lastTriTimeAD1 = trigTime.GetNanoSec(); return StatusCode::SUCCESS;}
                if(det.detectorId()==2&&(trigTime.GetNanoSec()-m_lastTriTimeAD2)<20000) { m_lastTriTimeAD2 = trigTime.GetNanoSec(); return StatusCode::SUCCESS;}
                if(det.detectorId()==5&&(trigTime.GetNanoSec()-m_lastTriTimeWPI)<20000) { m_lastTriTimeWPI = trigTime.GetNanoSec(); return StatusCode::SUCCESS;}
                if(det.detectorId()==6&&(trigTime.GetNanoSec()-m_lastTriTimeWPO)<20000) { m_lastTriTimeWPO = trigTime.GetNanoSec(); return StatusCode::SUCCESS;}
        
                if(det.detectorId()==1) { m_lastTriTimeAD1 = trigTime.GetNanoSec();}
                if(det.detectorId()==2) { m_lastTriTimeAD2 = trigTime.GetNanoSec();}
                if(det.detectorId()==5) { m_lastTriTimeWPI = trigTime.GetNanoSec(); }
                if(det.detectorId()==6) { m_lastTriTimeWPO = trigTime.GetNanoSec();}
        
                
                if(trigType != 0x10000020) return StatusCode::SUCCESS;
                
                Context context = readoutHeader->context();
                if( !hasStats(det) ){
                        StatusCode sc = prepareStats(context);
                if( sc != StatusCode::SUCCESS ) return sc;
                }
                ServiceMode svcMode(context, 0);
                const DayaBay::DaqPmtCrate::PmtChannelPtrList& channels= pmtCrate->channelReadouts();
        DayaBay::DaqPmtCrate::PmtChannelPtrList::const_iterator channelIter, channelEnd = channels.end();
        if(channels.size()>15) return StatusCode::SUCCESS;
        used_event++;
                for(channelIter = channels.begin(); channelIter!=channelEnd; channelIter++) { 
                const DayaBay::DaqPmtChannel& channel = *(*channelIter);
                        const DayaBay::FeeChannelId& chanId = channel.channelId();
                        const DayaBay::DetectorSensor& sensDetId 
                = m_cableSvc->sensor(chanId, svcMode);
                if (sensDetId.bogus()) {
                 warning() << "Got bogus PMT: \"" << sensDetId
                          << "\" using channelId: \"" << chanId
                          << "\" and context \"" << context.AsString() << "\""
                          << endreq;
                    continue;
                }

                        //if((channel.tdc()).size()>1) continue;
                        if(channel.hitCount()>1) continue;
                        TH1F* tdcRawH = m_statsSvc->getTH1F( this->getPath(chanId) + "/tdcRaw");
                if(!tdcRawH) return StatusCode::FAILURE;
                TH1F* adcRawH = m_statsSvc->getTH1F( this->getPath(chanId) + "/adcRaw");
                if(!adcRawH) return StatusCode::FAILURE;
                TH1F* preAdcH = m_statsSvc->getTH1F( this->getPath(chanId) + "/preAdc");
                if(!preAdcH) return StatusCode::FAILURE;
                TH1F* adcH = m_statsSvc->getTH1F( this->getPath(chanId) + "/adc");    
                if(!adcH) return StatusCode::FAILURE;
                        
                        int tdc = channel.tdc(0);
                        int adc = channel.adc(0);
                        float preAdc = channel.preAdcAvg(0);
                        int cycle = channel.peakCycle(0);
                        
                        if(channel.isHighGainAdc(0)&&cycle>3&&cycle<8 ) {
                                tdcRawH->Fill(tdc);
                                adcRawH->Fill(adc);
                                preAdcH->Fill(preAdc);
                                adcH->Fill(adc-preAdc);
                        }
                }
        }
        else
                return StatusCode::SUCCESS;
                
        return StatusCode::SUCCESS;             
}
StatusCode RandomGainAlg::finalize ( ) [virtual]

Definition at line 162 of file RandomGainAlg.cc.

                                  {
        info()<<"Begin time: "<< m_beginTime.GetSec()<< endreq; 
        info()<<"End Time "<< m_endTime.GetSec() <<endreq;
        info()<<"Total Random Triggers in AD1" << total_event<<endreq;
        info()<<"used Random Triggers in AD1" << used_event<<endreq;
        
        std::vector<DayaBay::Detector>::iterator detIter, detEnd = m_processedDetectors.end();
        for(detIter = m_processedDetectors.begin(); detIter != detEnd; detIter++){
        DayaBay::Detector detector = *detIter;
        if(detector.isAD()) {
                TH1F* expAdcMeanH = m_statsSvc->getTH1F( this->getPath(detector)+"/expAdcMean");
                if(!expAdcMeanH) return StatusCode::FAILURE;
                TH1F* expAdcSigmaH = m_statsSvc->getTH1F( this->getPath(detector)+"/expAdcSigma");
                if(!expAdcSigmaH) return StatusCode::FAILURE;
                TH2F* gainH2D = m_statsSvc->getTH2F( this->getPath(detector) + "/ADgain2D");
                if(!gainH2D) return StatusCode::FAILURE;
                TH1F* gainH1D = m_statsSvc->getTH1F( this->getPath(detector)  + "/gain1D");
                if(!gainH1D) return StatusCode::FAILURE;
                        TH2F* Chi2NDF = m_statsSvc->getTH2F( this->getPath(detector) + "/ADChi2NDF");
                if(!Chi2NDF) return StatusCode::FAILURE;
                TH1F* Chi2NDF_1D = m_statsSvc->getTH1F( this->getPath(detector) + "/Chi2_1D");
                if(!Chi2NDF_1D) return StatusCode::FAILURE;
                        
                        TObject* simFlagObj = m_statsSvc->get(this->getPath(detector) +"/simFlag");
                TParameter<int>* simFlagPar = dynamic_cast<TParameter<int>*>(simFlagObj);
                if(!simFlagPar) return StatusCode::FAILURE;

                TObject* timeSecObj = m_statsSvc->get(this->getPath(detector) +"/timeSec");
                TParameter<int>* timeSecPar = dynamic_cast<TParameter<int>*>(timeSecObj);
                if(!timeSecPar) return StatusCode::FAILURE;

                TObject* timeNanoSecObj = 
                 m_statsSvc->get(this->getPath(detector) +"/timeNanoSec");
                TParameter<int>* timeNanoSecPar = 
                dynamic_cast<TParameter<int>*>(timeNanoSecObj);
                if(!timeNanoSecPar) return StatusCode::FAILURE;

                Site::Site_t site = detector.site();
                        DetectorId::DetectorId_t detId = detector.detectorId();
                SimFlag::SimFlag_t simFlag = (SimFlag::SimFlag_t)(simFlagPar->GetVal());
                time_t timeSec = (time_t)(timeSecPar->GetVal());
                int timeNanoSec = timeNanoSecPar->GetVal();

                Context context(site,simFlag,TimeStamp(timeSec,timeNanoSec),detId);
                ServiceMode svcMode(context, 0);

                        const std::vector<DayaBay::FeeChannelId>& channelList = m_cableSvc->feeChannelIds( svcMode );
                std::vector<DayaBay::FeeChannelId>::const_iterator chanIter, chanEnd = channelList.end();

                    for(chanIter = channelList.begin(); chanIter != chanEnd; chanIter++){
                        DayaBay::FeeChannelId chanId = *chanIter;
                        TH1F* adcH = m_statsSvc->getTH1F( this->getPath(chanId) + "/adc");
                        if(!adcH) return StatusCode::FAILURE;
                        DayaBay::AdPmtSensor pmtId = m_cableSvc->adPmtSensor(chanId, svcMode);
                        int ring = pmtId.ring();
                        int column = pmtId.column();
                        double adcMean = 0;
                        double adcMeanUncert = 0;
                        double adcSigma = 0;
                        double adcSigmaUncert = 0;
                                TF1 *nimmodelfunc = new TF1("nimmodelfunc",NIMmodel,5,100,8);
        nimmodelfunc->SetParNames(  "N","Q_{0}","#sigma_{0}","Q_{1}","#sigma_{1}","w", "#alpha","#mu");
        double AreaGuess, Q1MeanGuess, Q1SigmaGuess;
        float q0=0;//for a pedestal substracted distribution
        float sigma0=0;//for a pedestal substracted distribution
        AreaGuess = adcH->GetEntries();
        Q1MeanGuess = adcH->GetMean() - q0;
        Q1SigmaGuess = adcH->GetRMS();
        nimmodelfunc->SetParameters(AreaGuess, 90,1.9,Q1MeanGuess, Q1SigmaGuess, 0.01, 0.03,    0.1);
        //fix four parameters
        nimmodelfunc->FixParameter(1,q0);
        nimmodelfunc->FixParameter(2,sigma0);
        nimmodelfunc->FixParameter(5,0.);
        nimmodelfunc->FixParameter(6,0.);
       
        adcH->Fit(nimmodelfunc,"R");
        if(nimmodelfunc!=NULL){
          
          adcMean=nimmodelfunc->GetParameter(3);
          adcMeanUncert =nimmodelfunc->GetParError(3);
          adcSigma = nimmodelfunc->GetParameter(4);
          adcSigmaUncert = nimmodelfunc->GetParError(4);
          
          if(fabs(adcH->GetMean()-nimmodelfunc->GetParameter(3)) > adcH->GetRMS()){
            warning() << "Issues with fit on ring, column: " << ring << " / " 
                      << column << " mean/peak: " << adcMean << " / " << adcH->GetMean() 
                      << endreq;
            //gainOk = false;
          }//print warning if issues
          
          
        } else {

          adcMean=0;
          adcMeanUncert=0;
          adcSigma = 0;
          adcSigmaUncert = 0;

          warning() << "PMT full model fit error on ring/column: " << ring << "," << column << endreq;
          //gainOk = false;
        }
         double Chi2 = nimmodelfunc->GetChisquare();
        double ndf = nimmodelfunc->GetNDF();
        double fitquality = Chi2/ndf;
                                
                                
        
                                gainH2D->SetBinContent(gainH2D->GetXaxis()->FindBin(column),
                                        gainH2D->GetYaxis()->FindBin(ring),
                                        adcMean);
                                gainH2D->SetBinError(gainH2D->GetXaxis()->FindBin(column),
                                        gainH2D->GetYaxis()->FindBin(ring),
                                        adcMeanUncert);
                                gainH1D->Fill(adcMean);
                                Chi2NDF->SetBinContent(Chi2NDF->GetXaxis()->FindBin(column),
                                        Chi2NDF->GetYaxis()->FindBin(ring),
                                        fitquality);
                                if(chanId.board()<=18) {
                                        expAdcMeanH->SetBinContent(chanId.board()*16+chanId.connector(),adcMean);
                                        expAdcMeanH->SetBinError(chanId.board()*16+chanId.connector(),adcMeanUncert);
                                        expAdcSigmaH->SetBinContent(chanId.board()*16+chanId.connector(),adcSigma);
                                        expAdcSigmaH->SetBinError(chanId.board()*16+chanId.connector(),adcSigmaUncert);
                                        Chi2NDF_1D->SetBinContent(chanId.board()*16+chanId.connector(), fitquality);
                                }
                        }
                }
                else if(detector.isWaterShield()){  
                        TH1F* expAdcMeanH = m_statsSvc->getTH1F( this->getPath(detector)+"/expAdcMean");
                if(!expAdcMeanH) return StatusCode::FAILURE;
                TH1F* expAdcSigmaH = m_statsSvc->getTH1F( this->getPath(detector)+"/expAdcSigma");
                if(!expAdcSigmaH) return StatusCode::FAILURE;
                TH1F* gainH1D = m_statsSvc->getTH1F( this->getPath(detector)  + "/gain1D");
                if(!gainH1D) return StatusCode::FAILURE;
                TH1F* Chi2NDF_1D = m_statsSvc->getTH1F( this->getPath(detector) + "/Chi2_1D");
                if(!Chi2NDF_1D) return StatusCode::FAILURE;
                
                TObject* simFlagObj = m_statsSvc->get(this->getPath(detector) +"/simFlag");
                TParameter<int>* simFlagPar = dynamic_cast<TParameter<int>*>(simFlagObj);
                if(!simFlagPar) return StatusCode::FAILURE;

                TObject* timeSecObj = m_statsSvc->get(this->getPath(detector) +"/timeSec");
                TParameter<int>* timeSecPar = dynamic_cast<TParameter<int>*>(timeSecObj);
                if(!timeSecPar) return StatusCode::FAILURE;

                TObject* timeNanoSecObj = 
                 m_statsSvc->get(this->getPath(detector) +"/timeNanoSec");
                TParameter<int>* timeNanoSecPar = 
                dynamic_cast<TParameter<int>*>(timeNanoSecObj);
                if(!timeNanoSecPar) return StatusCode::FAILURE;

                Site::Site_t site = detector.site();
                        DetectorId::DetectorId_t detId = detector.detectorId();
                SimFlag::SimFlag_t simFlag = (SimFlag::SimFlag_t)(simFlagPar->GetVal());
                time_t timeSec = (time_t)(timeSecPar->GetVal());
                int timeNanoSec = timeNanoSecPar->GetVal();

                Context context(site,simFlag,TimeStamp(timeSec,timeNanoSec),detId);
                ServiceMode svcMode(context, 0);
                
                const std::vector<DayaBay::FeeChannelId>& channelList = m_cableSvc->feeChannelIds( svcMode );
                std::vector<DayaBay::FeeChannelId>::const_iterator chanIter, chanEnd = channelList.end();

                    for(chanIter = channelList.begin(); chanIter != chanEnd; chanIter++){
                        DayaBay::FeeChannelId chanId = *chanIter;
                        TH1F* adcH = m_statsSvc->getTH1F( this->getPath(chanId) + "/adc");
                        if(!adcH) return StatusCode::FAILURE;
                        //DayaBay::AdPmtSensor pmtId = m_cableSvc->adPmtSensor(chanId, svcMode);
                        //int ring = pmtId.ring();
                        //int column = pmtId.column();
                        double adcMean = 0;
                        double adcMeanUncert = 0;
                        double adcSigma = 0;
                        double adcSigmaUncert = 0;

                                TF1 *nimmodelfunc = new TF1("nimmodelfunc",NIMmodel,5,100,8);
                                nimmodelfunc->SetParNames(  "N","Q_{0}","#sigma_{0}","Q_{1}","#sigma_{1}","w", "#alpha","#mu");
                                double AreaGuess, Q1MeanGuess, Q1SigmaGuess;
                                float q0=0;//for a pedestal substracted distribution
                                float sigma0=0;//for a pedestal substracted distribution
                                AreaGuess = adcH->GetEntries();
                                Q1MeanGuess = adcH->GetMean() - q0;
                                Q1SigmaGuess = adcH->GetRMS();
                                nimmodelfunc->SetParameters(AreaGuess, 90,1.9,Q1MeanGuess, Q1SigmaGuess, 0.01, 0.03,    0.1);
                                //fix four parameters
                                nimmodelfunc->FixParameter(1,q0);
                                nimmodelfunc->FixParameter(2,sigma0);
                                nimmodelfunc->FixParameter(5,0.);
                                nimmodelfunc->FixParameter(6,0.);
       
                                adcH->Fit(nimmodelfunc,"R");
                                if(nimmodelfunc!=NULL){
                                 adcMean=nimmodelfunc->GetParameter(3);
                                 adcMeanUncert =nimmodelfunc->GetParError(3);
                                 adcSigma = nimmodelfunc->GetParameter(4);
                                 adcSigmaUncert = nimmodelfunc->GetParError(4);
                                 if(fabs(adcH->GetMean()-nimmodelfunc->GetParameter(3)) > adcH->GetRMS()){
                                //warning() << "Issues with fit on ring, column: " << ring << " / " 
                                //<< column << " mean/peak: " << adcMean << " / " << adcH->GetMean() 
                                //<< endreq;
                                }//print warning if issues
                          } else {
                                        adcMean=0;
                                        adcMeanUncert=0;
                                        adcSigma = 0;
                                        adcSigmaUncert = 0;

                                        //warning() << "PMT full model fit error on ring/column: " << ring << "," << column << endreq;
                                }
                                double Chi2 = nimmodelfunc->GetChisquare();
                                double ndf = nimmodelfunc->GetNDF();
                                double fitquality = Chi2/ndf;

                                
                                gainH1D->Fill(adcMean);
                                if(chanId.board()<=18) {
                                        expAdcMeanH->SetBinContent(chanId.board()*16+chanId.connector(),adcMean);
                                        expAdcMeanH->SetBinError(chanId.board()*16+chanId.connector(),adcMeanUncert);
                                        expAdcSigmaH->SetBinContent(chanId.board()*16+chanId.connector(),adcSigma);
                                        expAdcSigmaH->SetBinError(chanId.board()*16+chanId.connector(),adcSigmaUncert);
                                        Chi2NDF_1D->SetBinContent(chanId.board()*16+chanId.connector(), fitquality);
                                }
                        }
                }
                else 
                        return StatusCode::SUCCESS;
        }//end of detectors
        
        return StatusCode::SUCCESS;
}
bool RandomGainAlg::hasStats ( const DayaBay::Detector detector) [private]

Definition at line 392 of file RandomGainAlg.cc.

                                                           {
  // Check if statistics have been initialized for this detector
  return (std::find(m_processedDetectors.begin(), 
                    m_processedDetectors.end(), 
                    detector) 
          != m_processedDetectors.end());
}
StatusCode RandomGainAlg::prepareStats ( const Context context) [private]

Definition at line 411 of file RandomGainAlg.cc.

                                                            {

        DayaBay::Detector detector(context.GetSite(), context.GetDetId());
        // SimFlag
        {
        std::string name = "simFlag";
        std::ostringstream path;
        path << this->getPath(detector) << "/" << name;
        TParameter<int>* par = new TParameter<int>(name.c_str(), 
                                               context.GetSimFlag());
        if( m_statsSvc->put(path.str(),par).isFailure() ) {
                error() << "prepareStats(): Could not register " << name 
                        << " at " << path << endreq;
                delete par;
                par = 0;
                return StatusCode::FAILURE;
        }
        }
        
        // Timestamp: seconds
        {
        std::string name = "timeSec";
        std::ostringstream path;
        path << this->getPath(detector) << "/" << name;
        TParameter<int>* par = new TParameter<int>(name.c_str(), 
                                               context.GetTimeStamp().GetSec());
        if( m_statsSvc->put(path.str(),par).isFailure() ) {
                error() << "prepareStats(): Could not register " << name 
                        << " at " << path << endreq;
                delete par;
                par = 0;
                return StatusCode::FAILURE;
        }
        }

  // Timestamp: nanoseconds
        {
        std::string name = "timeNanoSec";
        std::ostringstream path;
        path << this->getPath(detector) << "/" << name;
        TParameter<int>* par = new TParameter<int>(name.c_str(), context.GetTimeStamp().GetNanoSec());
        if( m_statsSvc->put(path.str(),par).isFailure() ) {
                error() << "prepareStats(): Could not register " << name 
                        << " at " << path << endreq;
                delete par;
                par = 0;
                return StatusCode::FAILURE;
        }
        }
        
        // Adc - Ave preAdc, mean
  {
    std::ostringstream title, path;
    std::string name = "expAdcMean";
    title << "ADC - ave preAdc, mean in " << detector.detName();
    path << this->getPath(detector) << "/" << name;
    TH1F* expAdcMean = new TH1F(name.c_str(),title.str().c_str(),400,0,400); // to hold water PMT fee board 
    expAdcMean->GetXaxis()->SetTitle("board*16+connector");
    expAdcMean->GetYaxis()->SetTitle("ExpAdc mean");
    if( m_statsSvc->put(path.str(),expAdcMean).isFailure() ) {
      error() << "prepareStats(): Could not register " << path << endreq;
      delete expAdcMean;
      return StatusCode::FAILURE;
    }
  }
  // Adc - Ave preAdc, sigma
  {
    std::ostringstream title, path;
    std::string name = "expAdcSigma";
    title << "ADC - ave preAdc, sigma in " << detector.detName();
    path << this->getPath(detector) << "/" << name;
    TH1F* expAdcSigma = new TH1F(name.c_str(),title.str().c_str(),400,0,400);
    expAdcSigma->GetXaxis()->SetTitle("board*16+connector");
    expAdcSigma->GetYaxis()->SetTitle("ExpAdc sigma");
    if( m_statsSvc->put(path.str(),expAdcSigma).isFailure() ) {
      error() << "prepareStats(): Could not register " << path << endreq;
      delete expAdcSigma;
      return StatusCode::FAILURE;
    }
  }
    // fitting chi2/ndf
  {
    std::ostringstream title, path;
    std::string name = "Chi2_1D";
    title << "Chi2/NDF of fitting " << detector.detName();
    path << this->getPath(detector) << "/" << name;
    TH1F* Chi2_1D = new TH1F(name.c_str(),title.str().c_str(),400,0,400);
    Chi2_1D->GetXaxis()->SetTitle("board*16+connector");
    Chi2_1D->GetYaxis()->SetTitle("Chi2/NDF");
    if( m_statsSvc->put(path.str(),Chi2_1D).isFailure() ) {
      error() << "prepareStats(): Could not register " << path << endreq;
      delete Chi2_1D;
      return StatusCode::FAILURE;
    }
  }

        // AD Gain for each channel (jpochoa)
  {
      std::ostringstream title, path;
      std::string name = "ADgain2D";
      title << "AD Gain per channel " << detector.detName();
      path << this->getPath(detector) << "/" << name;
      TH2F* ADgain2D = new TH2F(name.c_str(),title.str().c_str(),49,0.25,24.75,19,-0.75,8.75);
      ADgain2D->GetXaxis()->SetTitle("Column");
      ADgain2D->GetYaxis()->SetTitle("Ring");
      if( m_statsSvc->put(path.str(),ADgain2D).isFailure() ) {
        error() << "prepareStats(): Could not register " << path << endreq;
        delete ADgain2D;
        return StatusCode::FAILURE;
      }
    }

        // Gain for all channels (jpochoa)
  {
      std::ostringstream title, path;
      std::string name = "gain1D";
      title << "Gain for all channels " << detector.detName();
      path << this->getPath(detector) << "/" << name;
      TH1F* gain1D = new TH1F(name.c_str(),title.str().c_str(),400,-200,200);
      gain1D->GetXaxis()->SetTitle("ADC/PE");
      gain1D->GetYaxis()->SetTitle("Number of entries");
      if( m_statsSvc->put(path.str(),gain1D).isFailure() ) {
        error() << "prepareStats(): Could not register " << path << endreq;
        delete gain1D;
        return StatusCode::FAILURE;
      }
    }
    
    // AD Chi2/ndf for each channel (yuzy)
  {
      std::ostringstream title, path;
      std::string name = "ADChi2NDF";
      title << "AD Chi2/NDF per channel " << detector.detName();
      path << this->getPath(detector) << "/" << name;
      TH2F* ADChi2NDF = new TH2F(name.c_str(),title.str().c_str(),49,0.25,24.75,19,-0.75,8.75);
      ADChi2NDF->GetXaxis()->SetTitle("Column");
      ADChi2NDF->GetYaxis()->SetTitle("Ring");
      if( m_statsSvc->put(path.str(),ADChi2NDF).isFailure() ) {
        error() << "prepareStats(): Could not register " << path << endreq;
        delete ADChi2NDF;
        return StatusCode::FAILURE;
      }
    }

        ServiceMode svcMode(context, 0);

  // Get list of all FEE channels
  const std::vector<DayaBay::FeeChannelId>& channelList 
    = m_cableSvc->feeChannelIds( svcMode );
  std::vector<DayaBay::FeeChannelId>::const_iterator chanIter, 
    chanEnd = channelList.end();
  // Initialize statistics for each channel
  for(chanIter = channelList.begin(); chanIter != chanEnd; chanIter++){
    DayaBay::FeeChannelId chanId = *chanIter;
        // Raw TDC spectrum
    {
      std::string name = "tdcRaw";
      std::ostringstream title, path;
      title << "Raw TDC values for " << detector.detName() 
            << " channel " << chanId.board() << "_"
            << chanId.connector();
      path << this->getPath(chanId) << "/" << name;
      TH1F* tdcRaw = new TH1F(name.c_str(),title.str().c_str(),
                              2000,0,2000);
      tdcRaw->GetXaxis()->SetTitle("TDC value");
      tdcRaw->GetYaxis()->SetTitle("Entries");
      if( m_statsSvc->put(path.str(),tdcRaw).isFailure() ) {
        error() << "prepareStats(): Could not register " << path << endreq;
        delete tdcRaw;
        return StatusCode::FAILURE;
      }
    }
        // Raw ADC spectrum
    {
      std::ostringstream title, path;
      std::string name = "adcRaw";
      title << "ADC values for " << detector.detName() 
            << " channel " << chanId.board() << "_"
            << chanId.connector();
      path << this->getPath(chanId) << "/" << name;
      TH1F* adcRaw = new TH1F(name.c_str(),title.str().c_str(),
                              4096,0,4096);
      adcRaw->GetXaxis()->SetTitle("ADC value");
      adcRaw->GetYaxis()->SetTitle("Entries");
      if( m_statsSvc->put(path.str(),adcRaw).isFailure() ) {
        error() << "prepareStats(): Could not register " << path << endreq;
        delete adcRaw;
        return StatusCode::FAILURE;
      }
    }

        // ADC spectrum, average pedestal substracted
    {
      std::ostringstream title, path;
      std::string name = "adc";
      title << "ADC - Average preAdc " << detector.detName() 
            << " channel " << chanId.board() << "_"
            << chanId.connector();
      path << this->getPath(chanId) << "/" << name;
      TH1F* adc = new TH1F(name.c_str(),title.str().c_str(),
                           120,-20,100);
      adc->GetXaxis()->SetTitle("ADC value");
      adc->GetYaxis()->SetTitle("Entries");
      if( m_statsSvc->put(path.str(),adc).isFailure() ) {
        error() << "prepareStats(): Could not register " << path << endreq;
        delete adc;
        return StatusCode::FAILURE;
      }
    }

    // PreADC spectrum, baseline subtracted
    {
      std::ostringstream title, path;
      std::string name = "preAdc";
      title << "PreADC values for " << detector.detName()
            << " channel " << chanId.board() << "_"
            << chanId.connector();
      path << this->getPath(chanId) << "/" << name;
      TH1F* preAdc = new TH1F(name.c_str(),title.str().c_str(),
                           1200,-200,1000);
      preAdc->GetXaxis()->SetTitle("PreADC value");
      preAdc->GetYaxis()->SetTitle("Entries");
      if( m_statsSvc->put(path.str(),preAdc).isFailure() ) {
        error() << "prepareStats(): Could not register " << path << endreq;
        delete preAdc;
        return StatusCode::FAILURE;
      }
    }
        }
        
        m_processedDetectors.push_back(detector);

  return StatusCode::SUCCESS;
}
std::string RandomGainAlg::getPath ( const DayaBay::Detector detector) [private]

Definition at line 400 of file RandomGainAlg.cc.

                                                                 {
  return m_filepath + "/" + detector.detName();
}
std::string RandomGainAlg::getPath ( const DayaBay::FeeChannelId channelId) [private]

Definition at line 404 of file RandomGainAlg.cc.

                                                                 {
  std::ostringstream path;
  path << m_filepath << "/" << chanId.detName() 
       << "/chan_" << chanId.board() << "_" << chanId.connector(); 
  return path.str();
}

Member Data Documentation

std::string RandomGainAlg::m_readoutLocation [private]

Definition at line 43 of file RandomGainAlg.h.

std::string RandomGainAlg::m_cableSvcName [private]

Definition at line 45 of file RandomGainAlg.h.

std::string RandomGainAlg::m_filepath [private]

Definition at line 47 of file RandomGainAlg.h.

Definition at line 49 of file RandomGainAlg.h.

Definition at line 51 of file RandomGainAlg.h.

Definition at line 53 of file RandomGainAlg.h.

Definition at line 55 of file RandomGainAlg.h.

Definition at line 56 of file RandomGainAlg.h.

bool RandomGainAlg::m_first [private]

Definition at line 58 of file RandomGainAlg.h.

Definition at line 60 of file RandomGainAlg.h.

Definition at line 61 of file RandomGainAlg.h.

Definition at line 62 of file RandomGainAlg.h.

Definition at line 63 of file RandomGainAlg.h.

Definition at line 64 of file RandomGainAlg.h.

Definition at line 65 of file RandomGainAlg.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 10:03:04 for RandomGain by doxygen 1.7.4