/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
Spallation Class Reference

#include <Spallation.h>

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

List of all members.

Public Member Functions

 Spallation (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~Spallation ()
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
TimeStamp m_vetoMuonTime
TimeStamp m_AD1MuonTime
TimeStamp m_AD2MuonTime
TimeStamp m_AD3MuonTime
TimeStamp m_AD4MuonTime
double m_AD1MuonCharge
double m_AD2MuonCharge
double m_AD3MuonCharge
double m_AD4MuonCharge
int m_MuonCut
int m_TimeLow
int m_TimeHigh
bool first
float m_ratio

Detailed Description

Definition at line 31 of file Spallation.h.


Constructor & Destructor Documentation

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

Definition at line 34 of file Spallation.cc.

  : GaudiTool(type,name,parent)
  , m_cableSvc(0)
  , m_statsSvc(0)
{
  
  declareInterface< IEnergyCalibTool >(this) ;   
  declareProperty("MuonCut",m_MuonCut=10000,"PE threshold of a muon");
  declareProperty("TimeLow",m_TimeLow=2000,"small time for spallation neutron selection");
  declareProperty("TimeHigh",m_TimeHigh=200000,"large time for spallation neutron selection");
  declareProperty("CableSvcName",m_cableSvcName="CableSvc",
                  "Name of service to map between detector, hardware, and electronic IDs");
  declareProperty("OutFilePath",m_outfilepath="/file1/Spallation",
                  "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");

}
Spallation::~Spallation ( ) [virtual]

Definition at line 59 of file Spallation.cc.

{}

Member Function Documentation

StatusCode Spallation::initialize ( ) [virtual]

Definition at line 61 of file Spallation.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 Spallation::finalize ( ) [virtual]

Definition at line 88 of file Spallation.cc.

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

  return StatusCode::SUCCESS;
}
StatusCode Spallation::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 96 of file Spallation.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) + "/SpallationRawSpectrum");
   TH2F* TimeToLastMuon = m_statsSvc->getTH2F( this->getOutPath(det) + "/TimeToLastMuon");
   TH2F* NeutronMultiplicity = m_statsSvc->getTH2F( this->getOutPath(det) + "/NeutronMultiplicity");
   TH1F* Interval = m_statsSvc->getTH1F( this->getOutPath(det) + "/TimeInterval");
        if(first){
                m_vetoMuonTime = TriTime;
                m_AD1MuonTime = TriTime;
                m_AD2MuonTime = TriTime;
                m_AD3MuonTime = TriTime;
                m_AD4MuonTime = TriTime;
                first = false;
                return StatusCode::SUCCESS;
        }
        if(det.isWaterShield() || det.detectorId() == DetectorId::kRPC){
                m_vetoMuonTime = TriTime;
                return StatusCode::SUCCESS;
        }
        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];
            }
        }
                //double largecharge = it->maxCharge();
        qsum+=largecharge;
        }
        if(qsum > m_MuonCut) {
                if(det.detectorId() == 1) { m_AD1MuonTime = TriTime; m_AD1MuonCharge = qsum;}
                else if(det.detectorId() == 2)  { m_AD2MuonTime = TriTime;m_AD2MuonCharge = qsum;}
                else if(det.detectorId() == 3)  { m_AD3MuonTime = TriTime;m_AD3MuonCharge = qsum;}
                else if(det.detectorId() == 4)  { m_AD4MuonTime = TriTime;m_AD4MuonCharge = qsum;}
                else ;
                return StatusCode::SUCCESS;
        }
        if(det.detectorId() == 1&&( TriTime.GetNanoSec()-m_AD1MuonTime.GetNanoSec() )< m_TimeHigh && ( TriTime.GetNanoSec()-m_AD1MuonTime.GetNanoSec() )> m_TimeLow){
                Spectrum->Fill(qsum);
                TimeToLastMuon->Fill(TriTime.GetNanoSec()-m_AD1MuonTime.GetNanoSec(), qsum);
                if(qsum>1500&&qsum<1800) Interval->Fill(TriTime.GetNanoSec()-m_AD1MuonTime.GetNanoSec());
        }
        if(det.detectorId() == 2&&( TriTime.GetNanoSec()-m_AD2MuonTime.GetNanoSec() )< m_TimeHigh && ( TriTime.GetNanoSec()-m_vetoMuonTime.GetNanoSec() )> m_TimeLow){
                Spectrum->Fill(qsum);
                TimeToLastMuon->Fill(TriTime.GetNanoSec()-m_AD2MuonTime.GetNanoSec(), qsum);
                 if(qsum>1500&&qsum<1800) Interval->Fill(TriTime.GetNanoSec()-m_AD2MuonTime.GetNanoSec());      
        }
        if(det.detectorId() == 3&&( TriTime.GetNanoSec()-m_AD3MuonTime.GetNanoSec() )< m_TimeHigh && ( TriTime.GetNanoSec()-m_vetoMuonTime.GetNanoSec() )> m_TimeLow){
                Spectrum->Fill(qsum);
                TimeToLastMuon->Fill(TriTime.GetNanoSec()-m_AD3MuonTime.GetNanoSec(), qsum);
                if(qsum>1500&&qsum<1800) Interval->Fill(TriTime.GetNanoSec()-m_AD3MuonTime.GetNanoSec());
        }
        if(det.detectorId() == 4&&( TriTime.GetNanoSec()-m_AD4MuonTime.GetNanoSec() )< m_TimeHigh && ( TriTime.GetNanoSec()-m_vetoMuonTime.GetNanoSec() )> m_TimeLow){
                Spectrum->Fill(qsum);
                TimeToLastMuon->Fill(TriTime.GetNanoSec()-m_AD4MuonTime.GetNanoSec(), qsum);
                if(qsum>1500&&qsum<1800)        Interval->Fill(TriTime.GetNanoSec()-m_AD4MuonTime.GetNanoSec());
        }
        return StatusCode::SUCCESS; 
}
StatusCode Spallation::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 174 of file Spallation.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);
                }
        }
        return StatusCode::SUCCESS;
}
bool Spallation::hasStats ( const DayaBay::Detector detector) [private]

Check if the statistics for this detector have been initialized.

Definition at line 188 of file Spallation.cc.

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

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

Definition at line 199 of file Spallation.cc.

                                                         {
        DayaBay::Detector detector(context.GetSite(), context.GetDetId());
  {
    std::ostringstream title, path;
    std::string name = "SpallationRawSpectrum";
    title << "Spallation neutrons Raw Spectrum in " << detector.detName();
    path << this->getOutPath(detector) << "/" << name;
    TH1F* RawSpectrum = new TH1F(name.c_str(),title.str().c_str(),1000,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;
    }
    }

        // 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;
    }
        {
                std::ostringstream title, path;
                std::string name = "TimeToLastMuon";
                title << "Time to last muon vs energy in " << detector.detName();
                path << this->getOutPath(detector) << "/" << name;
                TH2F* timetolast = new TH2F(name.c_str(),title.str().c_str(),200,0,200000,1000,0.5,20000); 
                timetolast->GetXaxis()->SetTitle("Time to last muon in ns");
                timetolast->GetYaxis()->SetTitle("Total charge of the event");
                if( m_statsSvc->put(path.str(),timetolast).isFailure() ) {
                        error() << "prepareStats(): Could not register " << path << endreq;
                        delete timetolast;
                        return StatusCode::FAILURE;
                        }
        }
        {
                std::ostringstream title, path;
                std::string name = "NeutronMultiplicity";
                title << "Neutron Multiplicity in " << detector.detName();
                path << this->getOutPath(detector) << "/" << name;
                TH2F* multi = new TH2F(name.c_str(),title.str().c_str(),100,0,100,10000,0,6000000); 
                multi->GetXaxis()->SetTitle("neutron multiplicity");
                multi->GetYaxis()->SetTitle("muon total charge");
                if( m_statsSvc->put(path.str(),multi).isFailure() ) {
                        error() << "prepareStats(): Could not register " << path << endreq;
                        delete multi;
                        return StatusCode::FAILURE;
                        }
        }
        {
                std::ostringstream title, path;
                std::string name = "TimeInterval";
                title << "Neutron time interval to last muon in " << detector.detName();
                path << this->getOutPath(detector) << "/" << name;
                TH1F* interval = new TH1F(name.c_str(),title.str().c_str(),200,0,200000); 
                interval->GetXaxis()->SetTitle("Time to last muon in ns");
                interval->GetYaxis()->SetTitle("entries");
                if( m_statsSvc->put(path.str(),interval).isFailure() ) {
                        error() << "prepareStats(): Could not register " << path << endreq;
                        delete interval;
                        return StatusCode::FAILURE;
                        }
        }
  m_processedDetectors.push_back(detector);

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

Definition at line 193 of file Spallation.cc.

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

Definition at line 196 of file Spallation.cc.

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

Definition at line 67 of file Spallation.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 Spallation::m_cableSvcName [private]

Definition at line 71 of file Spallation.h.

std::string Spallation::m_outfilepath [private]

Definition at line 79 of file Spallation.h.

std::string Spallation::m_infilepath [private]

Definition at line 80 of file Spallation.h.

std::string Spallation::m_pmtGeomSvcName [private]

Definition at line 82 of file Spallation.h.

Definition at line 85 of file Spallation.h.

Definition at line 88 of file Spallation.h.

Definition at line 91 of file Spallation.h.

Definition at line 94 of file Spallation.h.

int Spallation::m_tdclow [private]

Definition at line 100 of file Spallation.h.

int Spallation::m_tdchigh [private]

Definition at line 101 of file Spallation.h.

Definition at line 102 of file Spallation.h.

Definition at line 103 of file Spallation.h.

Definition at line 104 of file Spallation.h.

Definition at line 105 of file Spallation.h.

Definition at line 106 of file Spallation.h.

double Spallation::m_AD1MuonCharge [private]

Definition at line 107 of file Spallation.h.

double Spallation::m_AD2MuonCharge [private]

Definition at line 108 of file Spallation.h.

double Spallation::m_AD3MuonCharge [private]

Definition at line 109 of file Spallation.h.

double Spallation::m_AD4MuonCharge [private]

Definition at line 110 of file Spallation.h.

int Spallation::m_MuonCut [private]

Definition at line 111 of file Spallation.h.

int Spallation::m_TimeLow [private]

Definition at line 112 of file Spallation.h.

int Spallation::m_TimeHigh [private]

Definition at line 113 of file Spallation.h.

bool Spallation::first [private]

Definition at line 114 of file Spallation.h.

float Spallation::m_ratio [private]

Definition at line 115 of file Spallation.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