/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 Attributes
SpallationFigsAlg Class Reference

#include <SpallationFigsAlg.h>

Collaboration diagram for SpallationFigsAlg:
Collaboration graph
[legend]

List of all members.

Public Member Functions

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

Private Attributes

IStatisticsSvcm_statsSvc
int m_execNumber
DayaBay::Detector m_detector
TH2 * m_energyVsDtH [4]
TH1 * m_energyNCaptureGdH [4]
TH1 * m_dtNCaptureGdH [4]
TH1 * m_timeNCaptureGdH [4]
TH1 * m_IWStagADmuEvt [4]
TH1 * m_OWStagADmuEvt [4]
TH1 * m_IWSOWStagADmuEvt [4]
TH1 * m_ADmuEvt [4]
int FillFlag
int tempTime
unsigned int minTime0
std::string m_spallLocation
double m_minNCaptureGdEnergy
double m_maxNCaptureGdEnergy
double m_minNCaptureGdTime
double m_maxNCaptureGdTime
double m_lastMuonVetoTime
double m_nextMuonVetoTime

Detailed Description

Definition at line 24 of file SpallationFigsAlg.h.


Constructor & Destructor Documentation

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

Definition at line 20 of file SpallationFigsAlg.cc.

  : GaudiAlgorithm(name,pSvcLocator),
    m_statsSvc(0),
    m_execNumber(0),
    m_energyVsDtH(),
    m_energyNCaptureGdH(),
    m_dtNCaptureGdH(),
    m_timeNCaptureGdH(),
    m_IWStagADmuEvt(),
    m_OWStagADmuEvt(),
    m_IWSOWStagADmuEvt(),
    m_ADmuEvt()
{
  declareProperty("SpallLocation", 
                  m_spallLocation="/Event/Data/Physics/Spallation",
                  "Generate figures from this Spallation TES path");
  declareProperty("MinNCaptureGdEnergy",
                  m_minNCaptureGdEnergy=6*MeV,
                  "Lower cut on n-Gd capture energy");
  declareProperty("MaxNCaptureGdEnergy", 
                  m_maxNCaptureGdEnergy=10*MeV,
                  "Upper cut on n-Gd capture energy");
  declareProperty("MinNCaptureGdTime",
                  m_minNCaptureGdTime=15*microsecond,
                  "Minimum spallation n-Gd capture time");
  declareProperty("MaxNCaptureGdTime",
                  m_maxNCaptureGdTime=300*microsecond,
                  "Maximum spallation n-Gd capture time");
  declareProperty("LastMuonVetoTime",
                  m_lastMuonVetoTime=-1e9*s,
                  "Veto time after last muon pool trigger");
  declareProperty("NextMuonVetoTime",
                  m_nextMuonVetoTime=-1e9*s,
                  "Veto time before next muon pool trigger");
  for(int i=0; i<4; i++){
    m_energyVsDtH[i] = 0;
    m_energyNCaptureGdH[i] = 0;
    m_dtNCaptureGdH[i] = 0;
    m_timeNCaptureGdH[i] = 0;
    m_IWStagADmuEvt[i] =0;
    m_OWStagADmuEvt[i] =0;
    m_IWSOWStagADmuEvt[i] =0;
    m_ADmuEvt[i] =0;

   }
}
SpallationFigsAlg::~SpallationFigsAlg ( ) [virtual]

Definition at line 68 of file SpallationFigsAlg.cc.

{
}

Member Function Documentation

StatusCode SpallationFigsAlg::initialize ( ) [virtual]

Definition at line 72 of file SpallationFigsAlg.cc.

{
  // Initialize

  // Initialize the necessary services  
  StatusCode sc = this->service("StatisticsSvc",m_statsSvc,true);
  if(sc.isFailure()){
    error() << "Failed to get StatisticsSvc" << endreq;
    return sc;
  }
  return StatusCode::SUCCESS;
}
StatusCode SpallationFigsAlg::execute ( ) [virtual]

Definition at line 85 of file SpallationFigsAlg.cc.

{
  // Generate figures from spallation data
  m_execNumber++;

  if(!exist<DayaBay::UserDataHeader>(m_spallLocation)){
    // No spallation data this cycle
    return StatusCode::SUCCESS;
  }

  DayaBay::UserDataHeader* spallHeader = 
    get<DayaBay::UserDataHeader>(m_spallLocation);
  if(!spallHeader){
    error() << "Failed to get Spallation header" << endreq;
    return StatusCode::FAILURE;
  }

  int run = spallHeader->getInt("runNumber");

  unsigned int tMu_s 
    = spallHeader->getInt("tMu_s");
  unsigned int nSpall
    = spallHeader->getInt("nSpall");
  if(nSpall<1){
    return StatusCode::SUCCESS;
  }
  const std::vector<float>& dtSpall_ms 
    = spallHeader->getFloatArray("dtSpall_ms");
  const std::vector<int>& detectorId_sp 
    = spallHeader->getIntArray("detectorId_sp");
  const std::vector<int>& energyStatus_sp 
    = spallHeader->getIntArray("energyStatus_sp");
  const std::vector<float>& energy_sp 
    = spallHeader->getFloatArray("energy_sp");
  //const std::vector<float>& quadrant_sp
  //  = spallHeader->getFloatArray("quadrant_sp");
  //const std::vector<float>& maxQ_sp
  //  = spallHeader->getFloatArray("maxQ_sp");

   //int execNumber
   // = spallHeader->getInt("execNumber");   
   int calib_nHit_IWS
    = spallHeader->getInt("calib_nHit_IWS");
   int calib_nHit_OWS
    = spallHeader->getInt("calib_nHit_OWS");

   float calib_nPESum_AD[4];
   calib_nPESum_AD[0]
    = spallHeader->getFloat("calib_nPESum_AD1");
   calib_nPESum_AD[1]
    = spallHeader->getFloat("calib_nPESum_AD2");
   calib_nPESum_AD[2]
    = spallHeader->getFloat("calib_nPESum_AD3");
   calib_nPESum_AD[3]
    = spallHeader->getFloat("calib_nPESum_AD4");
 
  // for muon efficiency by AD muon event

  for(unsigned int idet=0;idet<4;idet++){
    int detectorId = idet + 1;
    if(calib_nPESum_AD[idet]>3000){
      // found a alive AD
      TH1* timeADMuEvt = m_ADmuEvt[detectorId-1];
      TH1* timeIWStagADMuEvt = m_IWStagADmuEvt[detectorId-1];
      TH1* timeOWStagADMuEvt = m_OWStagADmuEvt[detectorId-1];
      TH1* timeIWSOWStagADMuEvt = m_IWSOWStagADmuEvt[detectorId-1];
      if(!timeADMuEvt){
        int minTime0 = tMu_s;
        // timeADMuEvt
        timeADMuEvt = new TH1F("ADmuEvt","AD mu event rate",
                               60,minTime0,minTime0+60);
        timeADMuEvt->GetXaxis()->SetTitle("Run Time [Beijing]");
        timeADMuEvt->GetXaxis()->SetTimeDisplay(1);
        timeADMuEvt->GetXaxis()->SetTimeFormat(timeFormat);
        timeADMuEvt->GetXaxis()->SetTimeOffset(0,"gmt");
        timeADMuEvt->GetXaxis()->SetNdivisions(505);
        timeADMuEvt->GetYaxis()->SetTitle("AD mu rate[Hz]");
        m_ADmuEvt[detectorId-1] = timeADMuEvt;

        // timeIWStagADEvt
        timeIWStagADMuEvt = new TH1F("IWStagADmuEvt","iws tagged by AD mu evt.",
                                   60,minTime0,minTime0+60);
        timeIWStagADMuEvt->GetXaxis()->SetTitle("Run Time [Beijing]");
        timeIWStagADMuEvt->GetXaxis()->SetTimeDisplay(1);
        timeIWStagADMuEvt->GetXaxis()->SetTimeFormat(timeFormat);
        timeIWStagADMuEvt->GetXaxis()->SetTimeOffset(0,"gmt");
        timeIWStagADMuEvt->GetXaxis()->SetNdivisions(505);
        timeIWStagADMuEvt->GetYaxis()->SetTitle("IWS tagged AD mu rate[Hz]");
        m_IWStagADmuEvt[detectorId-1] = timeIWStagADMuEvt;

        // timeOWStagADEvt
        timeOWStagADMuEvt = new TH1F("OWStagADmuEvt","ows tagged AD mu evt.",
                                   60,minTime0,minTime0+60);
        timeOWStagADMuEvt->GetXaxis()->SetTitle("Run Time [Beijing]");
        timeOWStagADMuEvt->GetXaxis()->SetTimeDisplay(1);
        timeOWStagADMuEvt->GetXaxis()->SetTimeFormat(timeFormat);
        timeOWStagADMuEvt->GetXaxis()->SetTimeOffset(0,"gmt");
        timeOWStagADMuEvt->GetXaxis()->SetNdivisions(505);
        timeOWStagADMuEvt->GetYaxis()->SetTitle("OWS tagged AD mu rate[Hz]");
        m_OWStagADmuEvt[detectorId-1] = timeOWStagADMuEvt;

        // timeIWSOWStagADMuEvt
        timeIWSOWStagADMuEvt = new TH1F("IWSOWStagADmuEvt","ws tagged AD mu evt.",
                                        60,minTime0,minTime0+60);
        timeIWSOWStagADMuEvt->GetXaxis()->SetTitle("Run Time [Beijing]");
        timeIWSOWStagADMuEvt->GetXaxis()->SetTimeDisplay(1);
        timeIWSOWStagADMuEvt->GetXaxis()->SetTimeFormat(timeFormat);
        timeIWSOWStagADMuEvt->GetXaxis()->SetTimeOffset(0,"gmt");
        timeIWSOWStagADMuEvt->GetXaxis()->SetNdivisions(505);
        timeIWSOWStagADMuEvt->GetYaxis()->SetTitle("WS tagged AD mu rate[Hz]");
        m_IWSOWStagADmuEvt[detectorId-1] = timeIWSOWStagADMuEvt;

        DayaBay::Detector detector(spallHeader->context().GetSite(),
                                 (DetectorId::DetectorId_t)detectorId);
        std::stringstream path;
        path << "/file1/diagnostics/run_" 
             << std::setfill('0') << std::setw(7) << run << "/detector_" 
             << detector.detName() << "/";

        m_statsSvc->put((path.str()+timeADMuEvt->GetName()).c_str(),
                      timeADMuEvt);
        m_statsSvc->put((path.str()+timeIWStagADMuEvt->GetName()).c_str(),
                      timeIWStagADMuEvt);
        m_statsSvc->put((path.str()+timeOWStagADMuEvt->GetName()).c_str(),
                      timeOWStagADMuEvt);
        m_statsSvc->put((path.str()+timeIWSOWStagADMuEvt->GetName()).c_str(),
                      timeIWSOWStagADMuEvt);
        
      
      } // end initialize hist
      while ( tMu_s >= timeADMuEvt->GetXaxis()->GetXmax() ) {
                 StatusCode sc = HistogramTools::extendRange(msgSvc(),
                                 timeADMuEvt, 60);
                 if(!sc.isSuccess()) return sc;
         }
      while ( tMu_s >= timeIWStagADMuEvt->GetXaxis()->GetXmax() ) {
                   StatusCode sc = HistogramTools::extendRange(msgSvc(),
                                   timeIWStagADMuEvt, 60);
                   if(!sc.isSuccess()) return sc;
           }
      while ( tMu_s >= timeOWStagADMuEvt->GetXaxis()->GetXmax() ) {
                   StatusCode sc = HistogramTools::extendRange(msgSvc(),
                                   timeOWStagADMuEvt, 60);
                   if(!sc.isSuccess()) return sc;
           }
      while ( tMu_s >= timeIWSOWStagADMuEvt->GetXaxis()->GetXmax() ) {
                   StatusCode sc = HistogramTools::extendRange(msgSvc(),
                                   timeIWSOWStagADMuEvt, 60);
                   if(!sc.isSuccess()) return sc;
           }

      timeADMuEvt->Fill(tMu_s);
      if(calib_nHit_IWS>12) timeIWStagADMuEvt->Fill(tMu_s);
      if(calib_nHit_OWS>12) timeOWStagADMuEvt->Fill(tMu_s);
      if(calib_nHit_OWS>12||calib_nHit_IWS>12) timeIWSOWStagADMuEvt->Fill(tMu_s);
    
    }// end if
  
  }// end loop detector


   //muon spallation
  for(unsigned int spallIdx=0;spallIdx<nSpall-1;spallIdx++){
    int detectorId = detectorId_sp[spallIdx];
    if(detectorId<1 || detectorId>4) continue;
    if(energyStatus_sp[spallIdx]!=1) continue;
    float dtSpall = dtSpall_ms[spallIdx]*ms;
    if( dtSpall > m_maxNCaptureGdTime) break;
    float energy = energy_sp[spallIdx]*MeV;

    TH2* energyVsDtH = m_energyVsDtH[detectorId-1];
    TH1* energyNCaptureGdH = m_energyNCaptureGdH[detectorId-1];
    TH1* dtNCaptureGdH = m_dtNCaptureGdH[detectorId-1];
    TH1* timeNCaptureGdH = m_timeNCaptureGdH[detectorId-1];


    info()<<"Spallation message"; 
 
    if(!energyVsDtH){
      // Initialize histograms for this detector

     // Energy Vs Dt
      energyVsDtH = new TH2F("spallEnergyVsDt","Spallation Energy after Muon",
                             150,0,300,
                             150,0,1300);
      energyVsDtH->GetXaxis()->SetTitle("#Deltat Muon [#mus]");
      energyVsDtH->GetYaxis()->SetTitle("Energy [MeV]");
      m_energyVsDtH[detectorId-1] = energyVsDtH;

      // n-Gd Capture Energy
      energyNCaptureGdH = new TH1F("spallEnergyNCaptureGd",
                                   "Spallation neutron capture energy on Gd",
                                   300,5,11);
      energyNCaptureGdH->GetXaxis()->SetTitle("Energy [MeV]");
      energyNCaptureGdH->GetYaxis()->SetTitle("Events / 20 keV");
      m_energyNCaptureGdH[detectorId-1] = energyNCaptureGdH;

      // n-Gd Capture Time
      dtNCaptureGdH = new TH1F("spallDtNCaptureGd",
                               "Spallation neutron capture time on Gd",
                               300,0,300);
      dtNCaptureGdH->GetXaxis()->SetTitle("#Deltat Muon [#mus]");
      dtNCaptureGdH->GetYaxis()->SetTitle("Events / #mus");
      m_dtNCaptureGdH[detectorId-1] = dtNCaptureGdH;

      int minTime = tMu_s - (tMu_s % 60);
      timeNCaptureGdH = new TH1F("spallTimeNCaptureGd",
                                 "Rate of Spallation n-Gd capture",
                                 1,minTime,minTime+60);
      timeNCaptureGdH->GetXaxis()->SetTitle("Run Time");
      timeNCaptureGdH->GetYaxis()->SetTitle("Events [m^{-1}]");
      timeNCaptureGdH->GetXaxis()->SetTimeDisplay(1);
      timeNCaptureGdH->GetXaxis()->SetTimeFormat(timeFormat);
      timeNCaptureGdH->GetXaxis()->SetTimeOffset(0,"gmt");
      timeNCaptureGdH->GetXaxis()->SetNdivisions(505);
      m_timeNCaptureGdH[detectorId-1] = timeNCaptureGdH;

      DayaBay::Detector detector(spallHeader->context().GetSite(),
                                 (DetectorId::DetectorId_t)detectorId);
      std::stringstream path;
      path << "/file1/diagnostics/run_" 
           << std::setfill('0') << std::setw(7) << run << "/detector_" 
           << detector.detName() << "/";

      m_statsSvc->put((path.str()+energyVsDtH->GetName()).c_str(),
                      energyVsDtH);
      m_statsSvc->put((path.str()+energyNCaptureGdH->GetName()).c_str(),
                      energyNCaptureGdH);
      m_statsSvc->put((path.str()+dtNCaptureGdH->GetName()).c_str(),
                      dtNCaptureGdH);
      m_statsSvc->put((path.str()+timeNCaptureGdH->GetName()).c_str(),
                      timeNCaptureGdH);
    }
    
   
   
    if( dtSpall >= energyVsDtH->GetXaxis()->GetXmin()*microsecond
        && dtSpall < energyVsDtH->GetXaxis()->GetXmax()*microsecond
        && energy >= energyVsDtH->GetYaxis()->GetXmin()*MeV
        && energy < energyVsDtH->GetYaxis()->GetXmax()*MeV){
      energyVsDtH->Fill(dtSpall/microsecond,energy/MeV);
    }

    if(dtSpall>m_minNCaptureGdTime && dtSpall<m_maxNCaptureGdTime){
      energyNCaptureGdH->Fill(energy/MeV);
    }

    if(energy>m_minNCaptureGdEnergy && energy<m_maxNCaptureGdEnergy){
      dtNCaptureGdH->Fill(dtSpall/microsecond);
    }
    
    if(dtSpall>m_minNCaptureGdTime && dtSpall<m_maxNCaptureGdTime
       && energy>m_minNCaptureGdEnergy && energy<m_maxNCaptureGdEnergy){
      while(tMu_s >= timeNCaptureGdH->GetXaxis()->GetXmax()){
        StatusCode sc = HistogramTools::extendRange(msgSvc(), 
                                                    timeNCaptureGdH, 1);
        if(!sc.isSuccess()) return sc;
      }
      if(tMu_s >= timeNCaptureGdH->GetXaxis()->GetXmin()){
        timeNCaptureGdH->Fill(tMu_s);
      }else{
        error() << "Muon timestamp is out of order: " 
                << TimeStamp((double)tMu_s) 
                << "   [dt = " << tMu_s-timeNCaptureGdH->GetXaxis()->GetXmin()
                << " ]" << endreq;
      }
    }
  }
  return StatusCode::SUCCESS;
}
StatusCode SpallationFigsAlg::finalize ( ) [virtual]

Definition at line 356 of file SpallationFigsAlg.cc.

{
  // Finalize
  if(m_statsSvc) m_statsSvc->release();
  return StatusCode::SUCCESS;
}

Member Data Documentation

Definition at line 38 of file SpallationFigsAlg.h.

Definition at line 41 of file SpallationFigsAlg.h.

Definition at line 44 of file SpallationFigsAlg.h.

Definition at line 47 of file SpallationFigsAlg.h.

Definition at line 48 of file SpallationFigsAlg.h.

Definition at line 49 of file SpallationFigsAlg.h.

Definition at line 50 of file SpallationFigsAlg.h.

Definition at line 51 of file SpallationFigsAlg.h.

Definition at line 52 of file SpallationFigsAlg.h.

Definition at line 53 of file SpallationFigsAlg.h.

TH1* SpallationFigsAlg::m_ADmuEvt[4] [private]

Definition at line 54 of file SpallationFigsAlg.h.

Definition at line 55 of file SpallationFigsAlg.h.

Definition at line 56 of file SpallationFigsAlg.h.

unsigned int SpallationFigsAlg::minTime0 [private]

Definition at line 57 of file SpallationFigsAlg.h.

std::string SpallationFigsAlg::m_spallLocation [private]

Definition at line 60 of file SpallationFigsAlg.h.

Definition at line 64 of file SpallationFigsAlg.h.

Definition at line 68 of file SpallationFigsAlg.h.

Definition at line 72 of file SpallationFigsAlg.h.

Definition at line 76 of file SpallationFigsAlg.h.

Definition at line 80 of file SpallationFigsAlg.h.

Definition at line 84 of file SpallationFigsAlg.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:10:00 for SpallationFigs by doxygen 1.7.4