/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 | Static Public Member Functions | Private Member Functions | Private Attributes
ScinBall Class Reference

#include <ScinBall.h>

Inheritance diagram for ScinBall:
Inheritance graph
[legend]
Collaboration diagram for ScinBall:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ScinBall (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~ScinBall ()
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual StatusCode process (const DayaBay::CalibReadoutHeader &calibReadout, int st, int acu, int zpo)
 Implementation of IEnergyCalibTool ////////////////////////////.
virtual StatusCode calibrate (float TimeInterval, int, int, int, int)
 calibrate() is called after processing many readouts.

Static Public Member Functions

static const InterfaceID & interfaceID ()
 Retrieve interface ID.

Private Member Functions

bool hasStats (const DayaBay::Detector &detector)
 Check if the statistics for this detector have been initialized.
StatusCode prepareStats (const Context &context)
 Get the current statistics for a detector, or create if needed.
std::string getOutPath (const DayaBay::Detector &detector)
std::string getInPath (const DayaBay::Detector &detector)
bool GoodTdc (int Tdc)

Private Attributes

std::string m_cableSvcName
std::string m_outfilepath
std::string m_infilepath
std::string m_pmtGeomSvcName
IPmtGeomInfoSvcm_pmtGeomSvc
ICableSvcm_cableSvc
IStatisticsSvcm_statsSvc
std::vector< DayaBay::Detectorm_processedDetectors
int m_tdclow
int m_tdchigh
float m_ratio
bool first

Detailed Description

Definition at line 31 of file ScinBall.h.


Constructor & Destructor Documentation

ScinBall::ScinBall ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 33 of file ScinBall.cc.

  : GaudiTool(type,name,parent)
  , m_cableSvc(0)
  , m_statsSvc(0)
{
  
  declareInterface< IEnergyCalibTool >(this) ;   
  declareProperty("CableSvcName",m_cableSvcName="CableSvc",
                  "Name of service to map between detector, hardware, and electronic IDs");
  declareProperty("OutFilePath",m_outfilepath="/file1/ScinBall",
                  "File path of registered histograms.");
                    declareProperty("InFilePath",m_infilepath="/file0/Background",
                  "File path of background histograms.");
  declareProperty("TDCCutLow",m_tdclow=900,"low tdc cut for good hits");
  declareProperty("TDCCutHigh",m_tdchigh=1050,"high tdc cut for good hits");
        declareProperty("PmtGeomSvcName", m_pmtGeomSvcName = "PmtGeomInfoSvc", 
      "Name of Pmt Geometry Information Service");

}
ScinBall::~ScinBall ( ) [virtual]

Definition at line 55 of file ScinBall.cc.

{}

Member Function Documentation

StatusCode ScinBall::initialize ( ) [virtual]

Definition at line 57 of file ScinBall.cc.

                               {
         info() << "initialize()" << endreq;
  StatusCode sc = this->GaudiTool::initialize();
  if( sc != StatusCode::SUCCESS ) return sc;
  
  //Get PMT geometry service
  m_pmtGeomSvc = svc<IPmtGeomInfoSvc>(m_pmtGeomSvcName, true);
   if(!m_pmtGeomSvc ){
    error() << "Failed to access PMT geometry svc: " << m_pmtGeomSvcName << endreq;
    return StatusCode::FAILURE;
  }
  // Get Cable Service
  m_cableSvc = svc<ICableSvc>(m_cableSvcName,true);
  if(!m_cableSvc){
    error() << "Failed to access cable svc: " << m_cableSvcName << endreq;
    return StatusCode::FAILURE;
  }
  // Get the histogram service
  m_statsSvc = svc<IStatisticsSvc>("StatisticsSvc",true);
  if(!m_statsSvc) {
    error() << " No StatisticsSvc available." << endreq;
    return StatusCode::FAILURE;
  }
  first = true;
    return StatusCode::SUCCESS;
}
StatusCode ScinBall::finalize ( ) [virtual]

Definition at line 84 of file ScinBall.cc.

{
  StatusCode sc = this->GaudiTool::finalize();
  if( sc != StatusCode::SUCCESS ) return sc;

  return StatusCode::SUCCESS;
}
StatusCode ScinBall::process ( const DayaBay::CalibReadoutHeader calibReadout,
int  st,
int  acu,
int  zpo 
) [virtual]

Implementation of IEnergyCalibTool ////////////////////////////.

process(const DayaBay::CalibReadoutPmtCrate&) process a single readout, extracting the information needed for calibration

Implements IEnergyCalibTool.

Definition at line 92 of file ScinBall.cc.

                                                                                                        {
        
        CalibReadout* calibReadout = const_cast<CalibReadout*>(calibReadoutHeader.calibReadout());
        const DayaBay::Detector& det = calibReadout->detector();
        const TimeStamp TriTime = calibReadout->triggerTime();
        Context context = calibReadoutHeader.context();
        if( !hasStats(det) ){
    // New detector; initialize all the detector statistics
                StatusCode sc = prepareStats(context);
        if( sc != StatusCode::SUCCESS ) return sc;
    }
   TH1F* Spectrum = m_statsSvc->getTH1F( this->getOutPath(det) + "/ScinBallRawSpectrum");

        CalibReadoutPmtCrate* calibCrate = dynamic_cast<CalibReadoutPmtCrate*>(calibReadout);
        CalibReadoutPmtCrate::PmtChannelReadouts calibChannels = calibCrate->channelReadout();
        double qsum = 0;
        CalibReadoutPmtCrate::PmtChannelReadouts::iterator it;
        for (it=calibChannels.begin(); it != calibChannels.end(); it++) {
                std::vector<double> charge = it->charge();
                std::vector<double> time = it->time();
                double largecharge=0;
                for(int i = 0; i<time.size();i++){
                        //cout<<time[i]<<endl;      //////more precise cuts research////
                        if(time[i]<-1*m_tdclow*1.5625&&time[i]>-1*m_tdchigh*1.5625&&charge[i]>largecharge){
                                largecharge = charge[i];
                        }
                }
                qsum+=largecharge;
        }
        Spectrum->Fill(qsum);
        /*if(det.detectorId() == 1){
                Spectrum->Fill(qsum);
        }
        if(det.detectorId() == 2){
                Spectrum->Fill(qsum);
        }*/
        
        return StatusCode::SUCCESS; 
}
StatusCode ScinBall::calibrate ( float  TimeInterval,
int  st,
int  acu,
int  zpo,
int  runN 
) [virtual]

calibrate() is called after processing many readouts.

This method is responsible for calculating the calibration parameters.

Implements IEnergyCalibTool.

Definition at line 133 of file ScinBall.cc.

                                                                                  {
        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()){
                        TObject* nTime = m_statsSvc->get(this->getOutPath(detector) + "/Time");
                        TParameter<float>* nTimePar= dynamic_cast<TParameter<float>*>(nTime);
                        nTimePar->SetVal(TimeInterval);
                        TH1F* RawSpectrum = m_statsSvc->getTH1F( this->getOutPath(detector) + "/ScinBallRawSpectrum");
                        
                        
                        TH1F* SubSpectrum = m_statsSvc->getTH1F( this->getOutPath(detector) + "/ScinBallSubSpectrum");
                        TObject* bTime = m_statsSvc->get(this->getInPath(detector) + "/Time");
                        TParameter<float>* bTimePar= dynamic_cast<TParameter<float>*>(bTime);
                        float backgroundTime = bTimePar->GetVal();
                        TH1F* Background = m_statsSvc->getTH1F( this->getInPath(detector) + "/BackgroundSpectrum");
                        double Large1=0, Large2=0;
                        for(int i=200;i<350;i++){
                                Large1+=RawSpectrum->GetBinContent(i);
                                Large2+=Background->GetBinContent(i);
                        }
                        for(int i=0; i<10000;i++){
                                m_ratio = Large1/Large2; 
                                int sub = (int) (RawSpectrum->GetBinContent(i) -  m_ratio * Background->GetBinContent(i));
                                if(sub<0) sub=0;
                                SubSpectrum->SetBinContent(i,sub);

                        }       
                }
        }
        return StatusCode::SUCCESS;
}
bool ScinBall::hasStats ( const DayaBay::Detector detector) [private]

Check if the statistics for this detector have been initialized.

Definition at line 168 of file ScinBall.cc.

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

Get the current statistics for a detector, or create if needed.

Definition at line 179 of file ScinBall.cc.

                                                       {
        DayaBay::Detector detector(context.GetSite(), context.GetDetId());
  {
    std::ostringstream title, path;
    std::string name = "ScinBallRawSpectrum";
    title << "ScinBall Raw Spectrum in " << detector.detName();
    path << this->getOutPath(detector) << "/" << name;
    TH1F* RawSpectrum = new TH1F(name.c_str(),title.str().c_str(),10000,0,10000); // to hold water PMT fee board 
    RawSpectrum->GetXaxis()->SetTitle("P.E number after calibration");
    RawSpectrum->GetYaxis()->SetTitle("Entries");
    if( m_statsSvc->put(path.str(),RawSpectrum).isFailure() ) {
      error() << "prepareStats(): Could not register " << path << endreq;
       delete RawSpectrum;
       return StatusCode::FAILURE;
    }
    }
        {
         std::ostringstream title, path;
    std::string name = "ScinBallSubSpectrum";
    title << "Background Subtracted ScinBall Spectrum in " << detector.detName();
    path << this->getOutPath(detector) << "/" << name;
    TH1F* SubSpectrum = new TH1F(name.c_str(),title.str().c_str(),10000,0,10000); // to hold water PMT fee board 
    SubSpectrum->GetXaxis()->SetTitle("P.E number after calibration");
    SubSpectrum->GetYaxis()->SetTitle("Entries");
    if( m_statsSvc->put(path.str(),SubSpectrum).isFailure() ) {
      error() << "prepareStats(): Could not register " << path << endreq;
      delete SubSpectrum;
      return StatusCode::FAILURE;
    }
        }
        // Time latence in the run
  
    std::string name = "Time";
    std::ostringstream path;
    path << this->getOutPath(detector) << "/" << name;
    TParameter<float>* par = new TParameter<float>(name.c_str(), 
                                               0);
    if( m_statsSvc->put(path.str(),par).isFailure() ) {
      error() << "prepareStats(): Could not register " << name 
              << " at " << path << endreq;
      delete par;
      par = 0;
      return StatusCode::FAILURE;
    }
  
  
  m_processedDetectors.push_back(detector);

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

Definition at line 173 of file ScinBall.cc.

                                                               {
        return m_outfilepath + "/" + detector.detName();
}
std::string ScinBall::getInPath ( const DayaBay::Detector detector) [private]

Definition at line 176 of file ScinBall.cc.

                                                              {
        return m_infilepath + "/" + detector.detName();
}
bool ScinBall::GoodTdc ( int  Tdc) [inline, private]

Definition at line 67 of file ScinBall.h.

    {
      if(Tdc>m_tdclow&&Tdc<m_tdchigh) return true;
      else return false;
    };
const InterfaceID & IEnergyCalibTool::interfaceID ( ) [static, inherited]

Retrieve interface ID.

Definition at line 8 of file IEnergyCalibTool.cc.

{ 
    return IID_IEnergyCalibTool; 
}

Member Data Documentation

std::string ScinBall::m_cableSvcName [private]

Definition at line 71 of file ScinBall.h.

std::string ScinBall::m_outfilepath [private]

Definition at line 79 of file ScinBall.h.

std::string ScinBall::m_infilepath [private]

Definition at line 80 of file ScinBall.h.

std::string ScinBall::m_pmtGeomSvcName [private]

Definition at line 82 of file ScinBall.h.

Definition at line 85 of file ScinBall.h.

Definition at line 88 of file ScinBall.h.

Definition at line 91 of file ScinBall.h.

Definition at line 94 of file ScinBall.h.

int ScinBall::m_tdclow [private]

Definition at line 100 of file ScinBall.h.

int ScinBall::m_tdchigh [private]

Definition at line 101 of file ScinBall.h.

float ScinBall::m_ratio [private]

Definition at line 102 of file ScinBall.h.

bool ScinBall::first [private]

Definition at line 103 of file ScinBall.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:20 for CalibEnergy by doxygen 1.7.4