// ESAF : Euso Simulation and Analysis Framework
// $Id: ChipTrackingTrgEngine4.cc,v 1.4 2005/10/24 09:06:42 pesce Exp $
// R. Pesce created
//_____________________________________________________________________________
//
// Chip Tracking Trigger Engine 4
// ==============================
//
// Tracking trigger built in front end chip.
// The algorithm searches for sequences of pixels (over the threshold)
// consequtive and adjacent. If the track length is over a threshold,
// trigger occurs.
// The algorithm searches also between track segments of two nearby chips:
// if two track segments are consequtive in time and the total length is
// over a threshold (different from the previous one), trigger occurs
//
// Parameters:
//
// fThresholdType: specify if the threshold on pixel hits in a gtu is absolute
// or relative
// Valid options:
// - absolute: the value specified in fThreshold is the minimum number of hits
// in a gtu to consider
// - relative: trigger threshold depends by the mean value of the background
// hits (B) in each pixel:
// threshold = (B) + fThreshold*sqrt(B)
// fThreshold: threshold on pixel hits in a gtu; if fThresholdType=relative the
// true threshold used by trigger algorithm depends by the mean hits
// of background in each pixel (see above)
// fMinTrackLenght: min length of the valid tracks
// fMaxTrackLength: max length of the valid tracks
// fMinTriggerTrackLength: min track length to have a trigger (single chip)
// fMinTriggerTwoLength: min total track length in 2 nearby chips
// fMaxTwoLength: max track length allowed in 2 nearby chips
//
// fAcceptHole [bool] : an hole in a single track segment is or not accepted
// fOnlyWithSignal [bool] : processes or not only chips ith at least a signal
//
// Special multiple configuration:
// The alorithm counts the numebr of tracks of the various trigger lengths,
// fill a specific trigger word and dump the numbers of the recognized tracks
//
#include "ChipTrackingTrgEngine4.hh"
#include "MacroCellData.hh"
#include "MacroCell.hh"
#include "ElementaryCell.hh"
#include "FrontEndChip.hh"
#include "BoolAlgebra.hh"
#include "ChipTrackSegment.hh"
#include "EusoElectronics.hh"
#include "Photomultiplier.hh"
#include "EusoDetector.hh"
#include "TMath.h"
#include "EChipTrackTriggerDataAdder.hh"
#include "Config.hh"
ClassImp(ChipTrackingTrgEngine4)
//______________________________________________________________________________
ChipTrackingTrgEngine4::ChipTrackingTrgEngine4() :
ChipTrackingTrgEngine1(string("ChipTrackingTrgEngine4"), kChipTrackingTrigger4 ) {
//
// Constructor
//
fMinTrackLength = (Int_t)Conf()->GetNum("ChipTrackingTrgEngine4.fMinTrackLength");
fMaxTrackLength = (Int_t)Conf()->GetNum("ChipTrackingTrgEngine4.fMaxTrackLength");
fMinTriggerTrackLength = (Int_t)Conf()->GetNum("ChipTrackingTrgEngine4.fMinTriggerTrackLength");
fMinTriggerTwoLength = (Int_t)Conf()->GetNum("ChipTrackingTrgEngine4.fMinTriggerTwoLength");
fMaxTwoLength = (Int_t)Conf()->GetNum("ChipTrackingTrgEngine4.fMaxTwoLength");
if ( Conf()->GetStr("ChipTrackingTrgEngine4.fThresholdType")=="absolute" ) fRelativeThreshold = kFALSE;
else if ( Conf()->GetStr("ChipTrackingTrgEngine4.fThresholdType")=="relative" ) fRelativeThreshold = kTRUE;
else Msg(EsafMsg::Panic) << "Wrong cfg value fThresholdType" << MsgDispatch;
fAcceptHole = Conf()->GetBool("ChipTrackingTrgEngine4.fAcceptHole");
fOnlyWithSignal = Conf()->GetBool("ChipTrackingTrgEngine4.fOnlyWithSignal");
fThreshold = (Int_t)Conf()->GetNum("ChipTrackingTrgEngine4.fThreshold");
// panic if we want to simulate >32 trigger patterns
if ( ((fMaxTrackLength-fMinTriggerTrackLength+1)+(fMaxTwoLength-fMinTriggerTwoLength+1)) > 32 )
Msg(EsafMsg::Panic) << "Request for > 32 patterns of trigger." << MsgDispatch;
ConfigFileParser *pConfig = Config::Get()->GetCF("Electronics","MacroCell");
if ( !pConfig->GetBool("MacroCell.fSaveAllChipGtuData") )
Msg(EsafMsg::Warning) << "MacroCell.fSaveAllChipGtuData is not enabled. Some infos are missing" << MsgDispatch;
FillRunPars();
Clear();
}
//______________________________________________________________________________
ChipTrackingTrgEngine4::~ChipTrackingTrgEngine4() {
//
// Destructor
//
}