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

#include <ADSingleTag.h>

Collaboration diagram for ADSingleTag:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ADSingleTag (const std::string &name, ISvcLocator *svcloc)
 Constructor has to be in this form.
virtual ~ADSingleTag ()
StatusCode initialize ()
 Three mandatory member functions of any algorithm.
StatusCode execute ()
StatusCode finalize ()

Private Attributes

IJobInfoSvcm_jobInfoSvc
map< DetectorId::DetectorId_t,
std::vector< RecHeader * > > 
m_adSingleBuffer_map
TimeStamp m_lastTimeStamp
map< DetectorId::DetectorId_t,
TimeStamp
m_lastTimeStamp_map
HeaderObjectlast_ADSingleTag
IDataProviderSvc * p_archiveSvc
double lastmuontime
double deadtime
int n
string reclocation
string outcomelocation
int timeCut
int muonVetoTime
int NumTag
int veto
double dtveto
double m_maxGapWindow

Detailed Description

Definition at line 29 of file ADSingleTag.h.


Constructor & Destructor Documentation

ADSingleTag::ADSingleTag ( const std::string &  name,
ISvcLocator *  svcloc 
)

Constructor has to be in this form.

Definition at line 14 of file ADSingleTag.cc.

                                                                :
  GaudiAlgorithm(name, svcloc) {
    declareProperty("dtCut",timeCut,
        "single time Cut");
    declareProperty("location",reclocation,
        "location of inputfile");
    declareProperty("muonVeto",veto ,
        "muon veto or not");
    declareProperty("numTag",NumTag,
        "every NumTag singles tag a single");
    declareProperty("vetoTime",muonVetoTime,
        "muon veto window");
    declareProperty("outcomelocation",outcomelocation,
        "outcomelocation of TES");
    declareProperty("maxGapWindow", m_maxGapWindow=0.2*Gaudi::Units::second,
        "Maximum Gap between two triggers in one AD"); 
  }
ADSingleTag::~ADSingleTag ( ) [virtual]

Definition at line 32 of file ADSingleTag.cc.

                          {
}

Member Function Documentation

StatusCode ADSingleTag::initialize ( )

Three mandatory member functions of any algorithm.

Definition at line 35 of file ADSingleTag.cc.

                                   {
  debug() << "initialize()" << endreq;

  m_jobInfoSvc = svc<IJobInfoSvc> ("JobInfoSvc", true);
  if (!m_jobInfoSvc) {
    error() << "Failed to initialize JobInfoSvc" << endreq;
    return StatusCode::FAILURE;
  }
  //Get Archive Svc
  StatusCode status = service("EventDataArchiveSvc", p_archiveSvc);
  if (status.isFailure()) {
    Error("Service [EventDataArchiveSvc] not found", status);
  }

  return StatusCode::SUCCESS;
}
StatusCode ADSingleTag::execute ( )

Definition at line 52 of file ADSingleTag.cc.

                                {
  debug() << "execute() ______________________________ start" << endreq;

  // Get ReadoutHeader from TES
  if(!exist<RecHeader>(reclocation)) return StatusCode::SUCCESS;
  RecHeader* recHeader = get<RecHeader> (reclocation);
  DetectorId::DetectorId_t detectorId = recHeader->context().GetDetId();
  TimeStamp currentTime(recHeader->timeStamp());
  double time = currentTime.GetSec() * 1e9 + currentTime.GetNanoSec();
  //  cout <<currentTime.GetNanoSec()<<" "<<detectorId<<endl;
  //get muon information caculate deadtime
  int i = 0;
  SmartDataPtr < DybArchiveList > muonlist(p_archiveSvc, "/Event/Tag/Muon/FirstMuonTrigger");
  if (muonlist) {
    DybArchiveList::const_iterator iter = muonlist->begin();
    for (; iter != muonlist->end(); iter++) {
      HeaderObject* muonTag = dynamic_cast<HeaderObject*> (*iter);
      TimeStamp muonTime(muonTag->timeStamp());
      if (i == 0) {
        double muontime = muonTime.GetSec() * 1e9 + muonTime.GetNanoSec();
        if (time == muontime) {
          if ((muontime - lastmuontime) > 1000000) {
            deadtime = deadtime + 1000000;
            i = i + 1;
            lastmuontime = muontime;
          } else {
            deadtime = deadtime + muontime - lastmuontime;
            i = i + 1;
            lastmuontime = muontime;
          }
          //cout << "muon " << muonTime.GetSec() << " "
          //            << muonTime.GetNanoSec() << " " << detectorId << endl;
        }
      }
    }
  }

  double dt = currentTime.GetSec() * 1e9 + currentTime.GetNanoSec() - m_lastTimeStamp_map[detectorId].GetSec() * 1e9 - m_lastTimeStamp_map[detectorId].GetNanoSec();
  if(dt > m_maxGapWindow && detectorId < 5) {  // long gap in DAQ, the previous multiplets not in memory any more
     warning() << "Event gap in AD " << detectorId << ": " << dt/Gaudi::Units::second << " sec" << endreq;
  } else {
    double lasttimeSec1;
    double lasttimeNano1;
    double dtSec;
    double dtNano;
    //  int dtveto=2000000;
    //int k = 0;
    int b =-1;
    //  cout <<dt << endl;
    if (dt > timeCut && detectorId < 5) {
      int multiplicity = m_adSingleBuffer_map[detectorId].size();
      if (multiplicity > 1) {
        m_adSingleBuffer_map[detectorId].clear();
      }
      else if (multiplicity == 1) {
        if (veto == 0) {
          //      cout<<"muon veto"<<endl;
          SmartDataPtr < DybArchiveList > muonlist1(p_archiveSvc, "/Event/Tag/Muon/FirstMuonTrigger");
          if (muonlist1) {
            DybArchiveList::const_iterator iter1 = muonlist1->begin();
            for (; iter1 != muonlist1->end(); iter1++) {
              HeaderObject* muonTag1 = dynamic_cast<HeaderObject*> (*iter1);
              TimeStamp muonTime1(muonTag1->timeStamp());
              TimeStamp lasttime1(m_lastTimeStamp_map[detectorId]);
              //   cout <<"muon "<<muonTime1.GetNanoSec()<<" "<<lasttime1.GetNanoSec()<<endl;
              if (lasttime1>muonTime1){
                dtveto=lasttime1.GetSec()*1e9+lasttime1.GetNanoSec()-muonTime1.GetSec()*1e9-muonTime1.GetNanoSec();
                //         cout<<"good "<<dtveto<<endl;
                break;
              }
            }
          }
          else {dtveto=2000000;
          }
          //            cout << "dtveto=" << dtveto << endl;
          if (dtveto > muonVetoTime) {
            //each Numtag tag single
            n = n + 1;
            b = n % NumTag;
          }
          if (b == 0) {
            // Make a new Header as a tag
            HeaderObject *ADSingleTag = new HeaderObject();
            // Use inputHeaders to record the RecoutHeader which is connect to this tag
            vector<const IHeader*> inputHeaders;
            RecHeader* recheader = *(m_adSingleBuffer_map[detectorId].begin());
            inputHeaders.push_back(recheader);
            ADSingleTag->setInputHeaders(inputHeaders);
            // Copy from the RecoutHeader
            ADSingleTag->setExecNumber(recheader->execNumber());
            ADSingleTag->setContext(recheader->context());
            ADSingleTag->setEarliest(recheader->earliest());
            ADSingleTag->setLatest(recheader->latest());
            // Get job id
            const DayaBay::JobId &m_currentJobId = m_jobInfoSvc->currentJobInfo()->jobId();
            ADSingleTag->setJobId(m_currentJobId);
            // Make different tag according to the detector's id
            if (detectorId == DetectorId::kAD1) {
              put(ADSingleTag,outcomelocation);
            } else if (detectorId == DetectorId::kAD2) {
              put(ADSingleTag,outcomelocation);
            } else if (detectorId == DetectorId::kAD3) {
              put(ADSingleTag,outcomelocation);
            } else if (detectorId == DetectorId::kAD4) {
              put(ADSingleTag,outcomelocation);
            }

            //         cout<<"single veto"<<m_lastTimeStamp_map[detectorId].GetNanoSec()<<" det "<<detectorId<<" "<<n<<endl;
            m_adSingleBuffer_map[detectorId].clear();
          }

          m_adSingleBuffer_map[detectorId].clear();
        }
        else if (veto == 1) {
          {
            n = n + 1;
            b = n % NumTag;
          }

          if (b == 0) {
            // Make a new Header as a tag
            HeaderObject *ADSingleTag = new HeaderObject();
            // Use inputHeaders to record the RecoutHeader which is connect to this tag
            vector<const IHeader*> inputHeaders;
            RecHeader* recheader = *(m_adSingleBuffer_map[detectorId].begin());
            inputHeaders.push_back(recheader);
            ADSingleTag->setInputHeaders(inputHeaders);
            // Copy from the RecoutHeader
            ADSingleTag->setExecNumber(recheader->execNumber());
            ADSingleTag->setContext(recheader->context());
            ADSingleTag->setEarliest(recheader->earliest());
            ADSingleTag->setLatest(recheader->latest());
            // Get job id
            const DayaBay::JobId &m_currentJobId =
              m_jobInfoSvc->currentJobInfo()->jobId();
            ADSingleTag->setJobId(m_currentJobId);
            // Make different tag according to the detector's id
            if (detectorId == DetectorId::kAD1) {
              put(ADSingleTag,outcomelocation);
            } else if (detectorId == DetectorId::kAD2) {
              put(ADSingleTag,outcomelocation);
            } else if (detectorId == DetectorId::kAD3) {
              put(ADSingleTag,outcomelocation);
            } else if (detectorId == DetectorId::kAD4) {
              put(ADSingleTag,outcomelocation);
            }

            //      cout<<"single "<<m_lastTimeStamp_map[detectorId].GetNanoSec()<<" det "<<detectorId<<endl;
            m_adSingleBuffer_map[detectorId].clear();
          }
          m_adSingleBuffer_map[detectorId].clear();
        }
      }
    }
  }

  m_lastTimeStamp_map[detectorId] = currentTime;
  m_adSingleBuffer_map[detectorId].push_back(recHeader);

  //k = k + 1;

  debug() << "execute() ______________________________ end" << endreq;
  return StatusCode::SUCCESS;

}
StatusCode ADSingleTag::finalize ( )

Definition at line 218 of file ADSingleTag.cc.

                                 {
  //  string deadtimefile="test.txt";
  //    ofstream outputfile;
  //      outputfile.open(deadtimefile.c_str());
  debug() << "finalize()" << endreq;
  info() << "Summary: ADSingleTag : "<<n <<" was tagged."<< endreq;
  info() << "deadtime: ADSingleTag : "<<deadtime <<" is."<< endreq;
  //  outputfile<< deadtime<< endl;
  return StatusCode::SUCCESS;
}

Member Data Documentation

Definition at line 42 of file ADSingleTag.h.

Definition at line 43 of file ADSingleTag.h.

Definition at line 44 of file ADSingleTag.h.

Definition at line 45 of file ADSingleTag.h.

Definition at line 46 of file ADSingleTag.h.

IDataProviderSvc* ADSingleTag::p_archiveSvc [private]

Definition at line 47 of file ADSingleTag.h.

double ADSingleTag::lastmuontime [private]

Definition at line 48 of file ADSingleTag.h.

double ADSingleTag::deadtime [private]

Definition at line 49 of file ADSingleTag.h.

int ADSingleTag::n [private]

Definition at line 50 of file ADSingleTag.h.

string ADSingleTag::reclocation [private]

Definition at line 51 of file ADSingleTag.h.

string ADSingleTag::outcomelocation [private]

Definition at line 52 of file ADSingleTag.h.

int ADSingleTag::timeCut [private]

Definition at line 53 of file ADSingleTag.h.

Definition at line 54 of file ADSingleTag.h.

int ADSingleTag::NumTag [private]

Definition at line 55 of file ADSingleTag.h.

int ADSingleTag::veto [private]

Definition at line 56 of file ADSingleTag.h.

double ADSingleTag::dtveto [private]

Definition at line 57 of file ADSingleTag.h.

double ADSingleTag::m_maxGapWindow [private]

Definition at line 58 of file ADSingleTag.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:11:36 for ADSinglesTagging by doxygen 1.7.4