/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 | Protected Attributes | Private Attributes
MuonTagAlg Class Reference

#include <MuonTagAlg.h>

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

List of all members.

Public Member Functions

 MuonTagAlg (const std::string &name)
virtual ~MuonTagAlg ()
virtual bool initialize ()
virtual bool execute ()
virtual bool finalize ()
const std::string & name ()
SvcBaseservice (const std::string &name)
TOutputSvcntupleSvc ()
bool setOption (const std::string &option, Type &var)

Protected Attributes

std::string m_name

Private Attributes

PhyEventBufm_buffer
TTimeStamp m_beginTime
TTimeStamp m_endTime
MuonVetom_muonVeto
LiveTimeSvcm_liveTimeSvc
TH1F * m_hIwsMuonNum
TH1F * m_hOwsMuonNum
TH1F * m_hRpcMuonNum
TH1F * m_hAdMuonNum [4]
TH1F * m_hShowerMuonNum [4]
TH1F * m_hIwsMuon
TH1F * m_hOwsMuon
TH1F * m_hRpcMuon
TH1F * m_hAdMuon [4]
TH1F * m_hShowerMuon [4]
int m_timeBin
double m_vetoTimeInCurBin [4]
double m_vetoTimeAccum [4]

Detailed Description

Definition at line 13 of file MuonTagAlg.h.


Constructor & Destructor Documentation

MuonTagAlg::MuonTagAlg ( const std::string &  name)

Definition at line 12 of file MuonTagAlg.cc.

: AlgBase(name),m_timeBin(-1)
{
  for(int det=1;det<=GlobalVar::NumADs;det++) {
    m_vetoTimeInCurBin[det-1] = 0.;
    m_vetoTimeAccum[det-1] = 0.;
  }
}
virtual MuonTagAlg::~MuonTagAlg ( ) [inline, virtual]

Definition at line 17 of file MuonTagAlg.h.

{}

Member Function Documentation

bool MuonTagAlg::initialize ( ) [virtual]

Implements AlgBase.

Definition at line 21 of file MuonTagAlg.cc.

{
  m_buffer = dynamic_cast<PhyEventBuf*>(service("Cycler"));
  m_muonVeto = MuonVeto::instance();
  m_liveTimeSvc = dynamic_cast<LiveTimeSvc*>(service("LiveTimeSvc"));
  if(!m_liveTimeSvc) {
    LogError << "Can't get LiveTimeSvc." << endl;
    return false;
  }

  m_hIwsMuonNum = new TH1F("IwsMuonNum","IWS muon number",
      m_liveTimeSvc->nBins(),
      m_liveTimeSvc->startTime().AsDouble(),
      m_liveTimeSvc->endTime().AsDouble()
      );
  m_hOwsMuonNum = new TH1F("OwsMuonNum","OWS muon number",
      m_liveTimeSvc->nBins(),
      m_liveTimeSvc->startTime().AsDouble(),
      m_liveTimeSvc->endTime().AsDouble()
      );
  m_hRpcMuonNum = new TH1F("RpcMuonNum","RPC muon number",
      m_liveTimeSvc->nBins(),
      m_liveTimeSvc->startTime().AsDouble(),
      m_liveTimeSvc->endTime().AsDouble()
      );
  for(int det=1;det<=GlobalVar::NumADs;det++) {
    stringstream ss;
    ss << "AD" << det << "MuonNum";
    m_hAdMuonNum[det-1] = new TH1F(ss.str().c_str(),ss.str().c_str(),
      m_liveTimeSvc->nBins(),
      m_liveTimeSvc->startTime().AsDouble(),
      m_liveTimeSvc->endTime().AsDouble()
      );
  }
  for(int det=1;det<=GlobalVar::NumADs;det++) {
    stringstream ss;
    ss << "AD" << det << "ShowerMuonNum";
    m_hShowerMuonNum[det-1] = new TH1F(ss.str().c_str(),ss.str().c_str(),
      m_liveTimeSvc->nBins(),
      m_liveTimeSvc->startTime().AsDouble(),
      m_liveTimeSvc->endTime().AsDouble()
      );
  }
  ntupleSvc()->attach("FILE1/Muon/",m_hIwsMuonNum);
  ntupleSvc()->attach("FILE1/Muon/",m_hOwsMuonNum);
  ntupleSvc()->attach("FILE1/Muon/",m_hRpcMuonNum);
  for(int det=1;det<=GlobalVar::NumADs;det++) {
    ntupleSvc()->attach("FILE1/Muon/",m_hAdMuonNum[det-1]);
    ntupleSvc()->attach("FILE1/Muon/",m_hShowerMuonNum[det-1]);
  }

  m_hIwsMuon = new TH1F("IwsMuonRate","IWS muon rate",
      m_liveTimeSvc->nBins(),
      m_liveTimeSvc->startTime().AsDouble(),
      m_liveTimeSvc->endTime().AsDouble()
      );
  m_hOwsMuon = new TH1F("OwsMuonRate","OWS muon rate",
      m_liveTimeSvc->nBins(),
      m_liveTimeSvc->startTime().AsDouble(),
      m_liveTimeSvc->endTime().AsDouble()
      );
  m_hRpcMuon = new TH1F("RpcMuonRate","RPC muon rate",
      m_liveTimeSvc->nBins(),
      m_liveTimeSvc->startTime().AsDouble(),
      m_liveTimeSvc->endTime().AsDouble()
      );
  for(int det=1;det<=GlobalVar::NumADs;det++) {
    stringstream ss;
    ss << "AD" << det << "MuonRate";
    m_hAdMuon[det-1] = new TH1F(ss.str().c_str(),ss.str().c_str(),
      m_liveTimeSvc->nBins(),
      m_liveTimeSvc->startTime().AsDouble(),
      m_liveTimeSvc->endTime().AsDouble()
      );
  }
  for(int det=1;det<=GlobalVar::NumADs;det++) {
    stringstream ss;
    ss << "AD" << det << "ShowerMuonRate";
    m_hShowerMuon[det-1] = new TH1F(ss.str().c_str(),ss.str().c_str(),
      m_liveTimeSvc->nBins(),
      m_liveTimeSvc->startTime().AsDouble(),
      m_liveTimeSvc->endTime().AsDouble()
      );
  }
  ntupleSvc()->attach("FILE1/Muon/",m_hIwsMuon);
  ntupleSvc()->attach("FILE1/Muon/",m_hOwsMuon);
  ntupleSvc()->attach("FILE1/Muon/",m_hRpcMuon);
  for(int det=1;det<=GlobalVar::NumADs;det++) {
    ntupleSvc()->attach("FILE1/Muon/",m_hAdMuon[det-1]);
    ntupleSvc()->attach("FILE1/Muon/",m_hShowerMuon[det-1]);
  }

  return true;
}
bool MuonTagAlg::execute ( ) [virtual]

Implements AlgBase.

Definition at line 173 of file MuonTagAlg.cc.

{
  PhyEvent *event = m_buffer->curEvt();

  int bin = m_liveTimeSvc->bin(event->m_trigTime);
  if(m_timeBin == -1) { // the first event
    m_timeBin = bin;
  } else {
    if(bin > m_timeBin) { // a new time bin
      for(int det=1;det<=GlobalVar::NumADs;det++) {
        double vetoTimeInCurBin = m_muonVeto->m_deadTime[det-1] - m_vetoTimeAccum[det-1];
        double liveTimeInCurBin = m_liveTimeSvc->daqTimePerBin(m_timeBin) - vetoTimeInCurBin;
        //cout << "AD" << det << ",bin" << m_timeBin << ":" 
        //  << m_muonVeto->m_deadTime[det-1] << ","
        //  << m_vetoTimeAccum[det-1] << ","
        //  << vetoTimeInCurBin << endl;
        m_liveTimeSvc->setLiveTimePerBin(det,m_timeBin,liveTimeInCurBin);
        m_vetoTimeAccum[det-1] = m_muonVeto->m_deadTime[det-1];
      }
      m_timeBin = bin;
    }
  }

  if(event->isMuon()) {
    LogDebug << "This is a muon: " << event->m_muonTag << endl;
    m_muonVeto->updateVetoWindow(event);
  }

  for(int det=1;det<=GlobalVar::NumADs;det++) {
    m_liveTimeSvc->setLiveTime(det, m_liveTimeSvc->daqTime()
        - m_muonVeto->m_deadTime[det-1]);
  }

  if(event->isMuon() && event->m_det==5) {
    m_hIwsMuonNum->Fill(event->m_trigTime.AsDouble());
  } else if(event->isMuon() && event->m_det==6) {
    m_hOwsMuonNum->Fill(event->m_trigTime.AsDouble());
  } else if(event->isRpcMuon()) {
    m_hRpcMuonNum->Fill(event->m_trigTime.AsDouble());
  } else if(event->isAdMuon()) {
    m_hAdMuonNum[event->m_det-1]->Fill(event->m_trigTime.AsDouble());
  } else if(event->isShowerMuon()) {
    m_hShowerMuonNum[event->m_det-1]->Fill(event->m_trigTime.AsDouble());
  }

  return true;
}
bool MuonTagAlg::finalize ( ) [virtual]

Implements AlgBase.

Definition at line 116 of file MuonTagAlg.cc.

{
  // set live time for the last time bin
  for(int det=1;det<=GlobalVar::NumADs;det++) {
    double vetoTimeInCurBin = m_muonVeto->m_deadTime[det-1] - m_vetoTimeAccum[det-1];
    double liveTimeInCurBin = m_liveTimeSvc->daqTimePerBin(m_timeBin) - vetoTimeInCurBin;
    m_liveTimeSvc->setLiveTimePerBin(det,m_timeBin,liveTimeInCurBin);
    m_vetoTimeAccum[det-1] = m_muonVeto->m_deadTime[det-1];
  }

  cout << "Wall time :" << m_liveTimeSvc->wallTime() << "s, "
    << "DAQ data taking time: " << m_liveTimeSvc->daqTime()
    << "s, Live time and ratio: ";
  for(int det=1;det<=GlobalVar::NumADs;det++) {
    cout << "AD" << det << ":(" << m_liveTimeSvc->liveTime(det) << "s,"
      << m_liveTimeSvc->liveTime(det)/m_liveTimeSvc->daqTime() << "),";
  }
  cout << endl;

  cout << "DAQ time, live time and ratio for each time bin:" << endl;
  for(int i=0;i<m_liveTimeSvc->nBins();i++) {
    if(m_liveTimeSvc->daqTimePerBin(i) > 0.) {
      cout << "Bin " << i+1 << "(" << m_liveTimeSvc->startTime(i) << " to "
        << m_liveTimeSvc->startTime(i+1)
        << "):\n DAQ time=" << m_liveTimeSvc->daqTimePerBin(i) << "s, live time=";
      for(int det=1;det<=GlobalVar::NumADs;det++) {
        cout << "AD" << det << ":(" << m_liveTimeSvc->liveTimePerBin(det,i) << "s,"
          << m_liveTimeSvc->liveTimePerBin(det,i)/m_liveTimeSvc->daqTimePerBin(i) << "),";
      }
      cout << endl;
    }
  }

  for(int i=0;i<m_liveTimeSvc->nBins();i++) {
    if(m_liveTimeSvc->daqTimePerBin(i) > 0.) {
      m_hIwsMuon->Fill(m_liveTimeSvc->startTime(i) + m_liveTimeSvc->binWidth()/2,
          m_hIwsMuonNum->GetBinContent(i+1)/m_liveTimeSvc->daqTimePerBin(i));
      m_hOwsMuon->Fill(m_liveTimeSvc->startTime(i) + m_liveTimeSvc->binWidth()/2,
          m_hOwsMuonNum->GetBinContent(i+1)/m_liveTimeSvc->daqTimePerBin(i));
      m_hRpcMuon->Fill(m_liveTimeSvc->startTime(i) + m_liveTimeSvc->binWidth()/2,
          m_hRpcMuonNum->GetBinContent(i+1)/m_liveTimeSvc->daqTimePerBin(i));
      for(int det=1;det<=GlobalVar::NumADs;det++) {
        m_hAdMuon[det-1]->Fill(m_liveTimeSvc->startTime(i) + m_liveTimeSvc->binWidth()/2,
            m_hAdMuonNum[det-1]->GetBinContent(i+1)/m_liveTimeSvc->daqTimePerBin(i));
        m_hShowerMuon[det-1]->Fill(m_liveTimeSvc->startTime(i) + m_liveTimeSvc->binWidth()/2,
            m_hShowerMuonNum[det-1]->GetBinContent(i+1)/m_liveTimeSvc->daqTimePerBin(i));
      }
      //cout << "muon num=" << m_hIwsMuonNum->GetBinContent(i+1)
      //  << ", daq time= " << m_liveTimeSvc->daqTimePerBin(i)
      //  << ", muon rate=" << m_hIwsMuonNum->GetBinContent(i+1)/m_liveTimeSvc->daqTimePerBin(i)
      //  << endl;
    }
  }

  return true;
}

Member Data Documentation

Definition at line 25 of file MuonTagAlg.h.

TTimeStamp MuonTagAlg::m_beginTime [private]

Definition at line 27 of file MuonTagAlg.h.

TTimeStamp MuonTagAlg::m_endTime [private]

Definition at line 28 of file MuonTagAlg.h.

Definition at line 30 of file MuonTagAlg.h.

Definition at line 31 of file MuonTagAlg.h.

TH1F* MuonTagAlg::m_hIwsMuonNum [private]

Definition at line 34 of file MuonTagAlg.h.

TH1F* MuonTagAlg::m_hOwsMuonNum [private]

Definition at line 35 of file MuonTagAlg.h.

TH1F* MuonTagAlg::m_hRpcMuonNum [private]

Definition at line 36 of file MuonTagAlg.h.

TH1F* MuonTagAlg::m_hAdMuonNum[4] [private]

Definition at line 37 of file MuonTagAlg.h.

TH1F* MuonTagAlg::m_hShowerMuonNum[4] [private]

Definition at line 38 of file MuonTagAlg.h.

TH1F* MuonTagAlg::m_hIwsMuon [private]

Definition at line 40 of file MuonTagAlg.h.

TH1F* MuonTagAlg::m_hOwsMuon [private]

Definition at line 41 of file MuonTagAlg.h.

TH1F* MuonTagAlg::m_hRpcMuon [private]

Definition at line 42 of file MuonTagAlg.h.

TH1F* MuonTagAlg::m_hAdMuon[4] [private]

Definition at line 43 of file MuonTagAlg.h.

TH1F* MuonTagAlg::m_hShowerMuon[4] [private]

Definition at line 44 of file MuonTagAlg.h.

int MuonTagAlg::m_timeBin [private]

Definition at line 46 of file MuonTagAlg.h.

double MuonTagAlg::m_vetoTimeInCurBin[4] [private]

Definition at line 47 of file MuonTagAlg.h.

double MuonTagAlg::m_vetoTimeAccum[4] [private]

Definition at line 48 of file MuonTagAlg.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 09:50:49 for Algorithms by doxygen 1.7.4