using namespace std;
#include "hlvl1evtfilter.h"
#include "hlinearcategory.h"
#include "hmatrixcategory.h"
#include "hevent.h"
#include "hspectrometer.h"
#include "hdetector.h"
#include "hcategory.h"
#include "hiterator.h"
#include "hades.h"
#include "tofinodef.h"
#include "htofraw.h"
#include "htofinoraw.h"
#include "htofinocalsim.h"
#include "tofdef.h"
#include "TFile.h"
#include <iostream>
ClassImp(HLvl1EvtFilter)
HLvl1EvtFilter::HLvl1EvtFilter(const Text_t *name,const Text_t *title,TString opt,Int_t multMeta, Int_t multTofino, Int_t multTof) : HReconstructor(name,title)
{
nMetaMult = 0;
nTofMult = 0;
nTofinoMult = 0;
kOpSec = kFALSE;
isSimulation = kFALSE;
if ((opt.Contains("metamult")) && (multMeta!=0)) nMetaMult=multMeta;
if ((opt.Contains("tofinomult")) && (multTofino!=0)) nTofinoMult=multTofino;
if ((opt.Contains("tofmult")) && (multTof!=0)) nTofMult=multTof;
if (opt.Contains("opsec")) kOpSec = kTRUE;
if (opt.Contains("sim")) isSimulation = kTRUE;
}
HLvl1EvtFilter::HLvl1EvtFilter()
{
nMetaMult = 0;
nTofMult = 0;
nTofinoMult = 0;
kOpSec = kFALSE;
isSimulation = kFALSE;
}
HLvl1EvtFilter::~HLvl1EvtFilter(void) {
}
Bool_t HLvl1EvtFilter::init() {
if (gHades) {
HEvent *event=gHades->getCurrentEvent();
HRuntimeDb *rtdb=gHades->getRuntimeDb();
HSpectrometer *spec=gHades->getSetup();
if (event && rtdb) {
HDetector *tofino = spec->getDetector("Tofino");
if (tofino){
if (isSimulation) fTofino = event->getCategory(catTofinoCal);
else fTofino = event->getCategory(catTofinoRaw);
if (!fTofino) {
Error("init","No TOFINO input");
return kFALSE;
}
}
fTofinoIter=(HIterator *)fTofino->MakeIterator();
HDetector *tof=spec->getDetector("Tof");
if (tof)
{
fTofRaw=event->getCategory(catTofRaw);
if (!fTofRaw) {
Error("init","No TOF input");
return kFALSE;
}
}
fTofIter=(HIterator *)fTofRaw->MakeIterator();
}
}
cout << " HLvl1EvtFilter: *** 1st level trigger event filter initialization ***" << endl;
cout << " META >= " << nMetaMult << "\tTOFINO >= " << nTofinoMult << "\tTOF >= " << nTofMult<< "\t Opposite sector " << kOpSec << "\t Simulation: "<< isSimulation << endl;
resetCounters();
return kTRUE;
}
Bool_t HLvl1EvtFilter::finalize()
{
cout<<"Number of rejected evts: "<<nCounterNbRejectedEvts<<endl;
cout<<"Number of remaining evts: "<<nCntProcessedEvents-nCounterNbRejectedEvts<<endl;
cout<<"Percentage of rejected evts: "<<(((Float_t)nCounterNbRejectedEvts)/((Float_t)nCntProcessedEvents))*100<<"%"<<endl;
return kTRUE;
}
Int_t HLvl1EvtFilter::execute()
{
nCntProcessedEvents++;
Int_t kReturnValue=0;
if (isFilteredEvt())
{
nCounterNbRejectedEvts++;
kReturnValue = kSkipEvent;
}
return kReturnValue;
}
void HLvl1EvtFilter::resetCounters()
{
nCntProcessedEvents=0;
nCounterNbRejectedEvts=0;
}
Bool_t HLvl1EvtFilter::isFilteredEvt()
{
Int_t TofLeftMult[6] = {0,0,0,0,0,0};
Int_t TofRightMult[6] = {0,0,0,0,0,0};
Int_t TofinoMult[6] = {0,0,0,0,0,0};
Bool_t MetaMult[6] = {kFALSE,kFALSE,kFALSE,kFALSE,kFALSE,kFALSE};
Int_t tofraw_count = 0, tofinocal_count = 0, meta_mult = 0, tof_mult = 0, tofino_mult = 0;
Bool_t opposite_sector = kFALSE;
Bool_t kSwitch = kFALSE;
HTofRaw *TofRaw = 0;
HTofinoRaw *TofinoRaw = 0;
HTofinoCal *TofinoCal = 0;
fTofIter->Reset();
while ((TofRaw=(HTofRaw *)fTofIter->Next()) != 0)
{
if (TofRaw->getRightTime()>0.)
{
TofRightMult[(Int_t)TofRaw->getSector()]++;
tofraw_count++;
}
if (TofRaw->getLeftTime()>0.)
{
TofLeftMult[(Int_t)TofRaw->getSector()]++;
tofraw_count++;
}
}
fTofinoIter->Reset();
if (isSimulation)
{
while ((TofinoCal=(HTofinoCalSim *)fTofinoIter->Next())!= 0)
{
TofinoMult[TofinoCal->getSector()]++;
tofinocal_count++;
}
}
else
while ((TofinoRaw=(HTofinoRaw *)fTofinoIter->Next())!= 0)
{
if (TofinoRaw->getTime()>0.)
{
TofinoMult[TofinoRaw->getSector()]++;
tofinocal_count++;
}
}
for (Int_t yyy=0; yyy<6; yyy++) MetaMult[yyy]=(((TofRightMult[yyy]+TofLeftMult[yyy])>=2)||(TofinoMult[yyy]>=1));
opposite_sector = ((MetaMult[0]&&MetaMult[3]) || (MetaMult[1]&&MetaMult[4]) || (MetaMult[2]&&MetaMult[5]));
meta_mult = int(tofraw_count/2)+tofinocal_count;
tof_mult = int(tofraw_count/2);
tofino_mult = tofinocal_count;
if ((meta_mult<nMetaMult) || (tofino_mult<nTofinoMult) || (tof_mult<nTofMult) || (!opposite_sector&&kOpSec))
kSwitch = kTRUE;
return kSwitch;
}
Last change: Sat May 22 12:59:06 2010
Last generated: 2010-05-22 12:59
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.