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

#include <MuonVeto.h>

Collaboration diagram for MuonVeto:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 MuonVeto ()
virtual ~MuonVeto ()
void updateVetoWindow (PhyEvent *event)
bool veto (PhyEvent *event)
PhyEventpreMuon (PhyEvent *event, const int det=0)
PhyEventnextMuon (PhyEvent *event, const int det=0)
PhyEventpreAdMuon (PhyEvent *event, double eLow, double eHigh)
PhyEventpreShowerMuon (PhyEvent *event)
double muVetoWin ()
double adMuVetoWin ()
double showerMuVetoWin ()
double preVetoWin ()
const std::string & name ()

Static Public Member Functions

static MuonVetoinstance ()

Public Attributes

TTimeStamp m_vetoWindowPost [4]
double m_deadTime [4]

Private Member Functions

const TTimeStamp timeCnv (double time)

Private Attributes

PhyEventBufm_buffer
std::string m_name
double m_muVetoWin
double m_adMuVetoWin
double m_showerMuVetoWin
double m_preVetoWin
bool m_useRPCVeto

Static Private Attributes

static MuonVetom_instance = 0

Detailed Description

Definition at line 9 of file MuonVeto.h.


Constructor & Destructor Documentation

MuonVeto::MuonVeto ( )

Definition at line 17 of file MuonVeto.cc.

    : m_name("MuonVeto")
{
  m_buffer = SvcMgr::get<PhyEventBuf>("Cycler");
  for(int det=1; det<=GlobalVar::NumADs; det++) {
    m_deadTime[det-1] = 0.;
    m_vetoWindowPost[det-1] = 0;
  }
  OptionParser::setOption("MuonVeto","MuVetoWindow",m_muVetoWin=2.e-4);
  OptionParser::setOption("MuonVeto","AdMuVetoWindow",m_adMuVetoWin=1.e-3);
  OptionParser::setOption("MuonVeto","ShowerMuVetoWindow",m_showerMuVetoWin=0.1);
  OptionParser::setOption("MuonVeto","PreVetoWindow",m_preVetoWin=2.e-6);
  OptionParser::setOption("MuonVeto", "useRPCVeto", m_useRPCVeto=true);
}
virtual MuonVeto::~MuonVeto ( ) [inline, virtual]

Definition at line 13 of file MuonVeto.h.

{}

Member Function Documentation

MuonVeto * MuonVeto::instance ( ) [static]

Definition at line 11 of file MuonVeto.cc.

{
  if(!m_instance) m_instance = new MuonVeto();
  return m_instance;
}
void MuonVeto::updateVetoWindow ( PhyEvent event)

Definition at line 32 of file MuonVeto.cc.

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

  for(int det=1;det<=GlobalVar::NumADs;det++) {
    if(!event->isMuon()) continue;
    LogDebug << "det=" << det << "," << event->m_muonTag << std::endl;

    TTimeStamp newVetoWindowPost(event->m_trigTime);
    if(event->isWpMuon()) {
      newVetoWindowPost.Add(timeCnv(m_muVetoWin));
    } else if(event->isRpcMuon() && m_useRPCVeto) {
      newVetoWindowPost.Add(timeCnv(m_muVetoWin));
    } else if(event->isAdMuon() && event->m_det==det) { 
      newVetoWindowPost.Add(timeCnv(m_adMuVetoWin));
    } else if(event->isShowerMuon() && event->m_det==det) {
      newVetoWindowPost.Add(timeCnv(m_showerMuVetoWin));
    } else {
      continue;
    }

    TTimeStamp newVetoWindowPre(event->m_trigTime);
    // Apply pre veto window for WP or RPC muon
    if(event->isWP() || event->isRPC()) {
      newVetoWindowPre.Add(timeCnv(-m_preVetoWin));
    }

    LogDebug << "Current time=" << event->m_trigTime
      << ", veto window pre=" << newVetoWindowPre
      << ", veto window post=" << newVetoWindowPost << endl;
    if(newVetoWindowPost > m_vetoWindowPost[det-1]) {
      LogDebug << "Update muon veto window to " << newVetoWindowPost
        << " by event " << event->m_entry
        << " in detector " << event->m_det << endl;
      if(newVetoWindowPre > m_vetoWindowPost[det-1]) {
        m_deadTime[det-1] += (newVetoWindowPost-newVetoWindowPre);
        LogDebug << (newVetoWindowPost-event->m_trigTime) << std::endl;
      } else {
        m_deadTime[det-1] += (newVetoWindowPost-m_vetoWindowPost[det-1]);
      }
      m_vetoWindowPost[det-1] = newVetoWindowPost;
    }
  }
}
bool MuonVeto::veto ( PhyEvent event)

Definition at line 77 of file MuonVeto.cc.

{
  //PhyEvent *event = m_buffer->curEvt();
  if(event->m_trigTime < m_vetoWindowPost[event->m_det-1]) {
    LogDebug << "Current time=" << event->m_trigTime
      << ", veto window=" << m_vetoWindowPost[event->m_det-1]
      <<endl;
    return true;
  } else {
    // Make sure there is no WP or RPC muon in following small time window
    PhyEvent *nextMuon=0;
    //DataBuffer<PhyEvent>::Iterator it=m_buffer->current();
    DataBuffer<PhyEvent>::Iterator it=m_buffer->find(event);
    it++;
    for(;it!=m_buffer->end();it++) {
      if((*it)->isMuon() && (*it)->m_good) { // find a muon
        if((*it)->isWP() || ((*it)->isRPC() && m_useRPCVeto)) { // WP or RPC muon
          nextMuon = (*it);
          break;
        }
      }
    }

    if(nextMuon) {
      LogDebug << "Current entry: " << event->m_entry
        << ", next muon entry and trigger type: " << nextMuon->m_entry 
        << "," << hex << nextMuon->m_trigType << dec << endl;
      double t2nextMu = nextMuon->m_trigTime - event->m_trigTime;
      LogDebug << "Time to next muon: " << t2nextMu << endl;
      if(t2nextMu < m_preVetoWin) {
        LogDebug << "Veto this event in front of muon." << endl;
        return true;
      }
    }

  }

  return false;
}
PhyEvent * MuonVeto::preMuon ( PhyEvent event,
const int  det = 0 
)

Definition at line 117 of file MuonVeto.cc.

{
  //PhyEventBuf::Iterator it = m_buffer->current();
  DataBuffer<PhyEvent>::Iterator it=m_buffer->find(event);
  LogDebug << "Current entry: " << (*it)->m_entry << endl;
  it--;
  while ( it >= m_buffer->begin() ) {
    PhyEvent* event = (*it);
    if(event->isMuon()) {
      if(event->m_det==det || det==0) {
        LogDebug << "Last muon entry: " << event->m_entry << endl;
        return event;
      }
    }
    it--;
  }
  return 0;
}
PhyEvent * MuonVeto::nextMuon ( PhyEvent event,
const int  det = 0 
)

Definition at line 136 of file MuonVeto.cc.

{
  //PhyEventBuf::Iterator it = m_buffer->current();
  DataBuffer<PhyEvent>::Iterator it=m_buffer->find(event);
  LogDebug << "Current entry: " << (*it)->m_entry << endl;
  it++;
  while ( it < m_buffer->end() ) {
    PhyEvent* event = (*it);
    if(event->isMuon()) {
      if(event->m_det==det || det==0) {
        return event;
      }
    }
    it++;
  }
  return 0;
}
PhyEvent * MuonVeto::preAdMuon ( PhyEvent event,
double  eLow,
double  eHigh 
)

Definition at line 154 of file MuonVeto.cc.

{
  DataBuffer<PhyEvent>::Iterator it=m_buffer->find(event);
  LogDebug << "Current entry: " << (*it)->m_entry << endl;
  int det = event->m_det;
  --it;
  while ( it >= m_buffer->begin() ) {
      PhyEvent* event = (*it);
      if ( event->isAdMuon() && event->m_det == det ) {
          if ( event->energy() < eHigh && event->energy() > eLow ) {
              return event;
          }
      }
      --it;
  }
  return 0;
}
PhyEvent * MuonVeto::preShowerMuon ( PhyEvent event)

Definition at line 172 of file MuonVeto.cc.

{
  DataBuffer<PhyEvent>::Iterator it=m_buffer->find(event);
  LogDebug << "Current entry: " << (*it)->m_entry << endl;
  int det = event->m_det;
  --it;
  while ( it >= m_buffer->begin() ) {
      PhyEvent* event = (*it);
      if ( event->isShowerMuon() && event->m_det == det ) {
          return event;
      }
      --it;
  }
  return 0;
}
double MuonVeto::muVetoWin ( ) [inline]

Definition at line 24 of file MuonVeto.h.

{ return m_muVetoWin; }
double MuonVeto::adMuVetoWin ( ) [inline]

Definition at line 25 of file MuonVeto.h.

{ return m_adMuVetoWin; }
double MuonVeto::showerMuVetoWin ( ) [inline]

Definition at line 26 of file MuonVeto.h.

{ return m_showerMuVetoWin; }
double MuonVeto::preVetoWin ( ) [inline]

Definition at line 27 of file MuonVeto.h.

{ return m_preVetoWin; }
const std::string& MuonVeto::name ( ) [inline]

Definition at line 32 of file MuonVeto.h.

{ return m_name; }
const TTimeStamp MuonVeto::timeCnv ( double  time) [private]

Definition at line 188 of file MuonVeto.cc.

{
  int sec = (int)time;
  int nanosec = (int)((time-sec)*1.e9);
  return TTimeStamp(sec,nanosec);
}

Member Data Documentation

Definition at line 29 of file MuonVeto.h.

Definition at line 30 of file MuonVeto.h.

Definition at line 40 of file MuonVeto.h.

std::string MuonVeto::m_name [private]

Definition at line 41 of file MuonVeto.h.

MuonVeto * MuonVeto::m_instance = 0 [static, private]

Definition at line 43 of file MuonVeto.h.

double MuonVeto::m_muVetoWin [private]

Definition at line 47 of file MuonVeto.h.

double MuonVeto::m_adMuVetoWin [private]

Definition at line 48 of file MuonVeto.h.

double MuonVeto::m_showerMuVetoWin [private]

Definition at line 49 of file MuonVeto.h.

double MuonVeto::m_preVetoWin [private]

Definition at line 50 of file MuonVeto.h.

bool MuonVeto::m_useRPCVeto [private]

Definition at line 51 of file MuonVeto.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:36 for MuonVeto by doxygen 1.7.4