#include <Riostream.h>
#include <TMath.h>
#include "AliLog.h"
#include "AliTriggerInput.h"
using std::endl;
using std::cout;
ClassImp( AliTriggerInput )
Bool_t AliTriggerInput::fgkIsTriggerDetector[AliDAQ::kNDetectors] = {1,0,0,1,1,1,0,1,0,0,0,1,0,1,1,1,1,1,1,1,0};
const char* AliTriggerInput::fgkCTPDetectorName[AliDAQ::kNDetectors] = {
"SPD",
"SDD",
"SSD",
"TPC",
"TRD",
"TOF",
"HMPID",
"PHOS",
"CPV",
"PMD",
"MUON_TRK",
"MUON_TRG",
"FMD",
"T0",
"V0",
"ZDC",
"ACORDE",
"CTP",
"EMCal",
"DAQ_TEST",
"HLT"
};
AliTriggerInput::AliTriggerInput( TString name, TString det, UChar_t level, Int_t signature, Char_t number ):
TNamed( name.Data(), det.Data() ),
fMask((number > 0) ? 1 << (number-1) : 0 ),
fValue(0),
fSignature(signature),
fLevel(level),
fDetectorId(-1),
fIsActive(kFALSE)
{
Int_t iDet = 0;
for( iDet = 0; iDet < AliDAQ::kNDetectors; iDet++ ) {
if( !fgkIsTriggerDetector[iDet] ) continue;
if( det.CompareTo( fgkCTPDetectorName[iDet] ) == 0 ) {
fTitle = AliDAQ::DetectorName(iDet);
fDetectorId = iDet;
break;
}
if( det.CompareTo( AliDAQ::DetectorName(iDet) ) == 0 ) {
fDetectorId = iDet;
break;
}
}
if( iDet == AliDAQ::kNDetectors ) {
AliError( Form( "%s is not a valid trigger input, it must contain a valid trigger detector name instead of (%s)", name.Data(), det.Data() ) );
}
}
void AliTriggerInput::Print( const Option_t* ) const
{
cout << "Trigger Input:" << endl;
cout << " Name: " << GetName() << endl;
cout << " Detector: " << GetTitle() << "(Id=" << (Int_t)fDetectorId << ")" << endl;
cout << " Level: " << (Int_t)fLevel << endl;
cout << " Signature: " << fSignature << endl;
if(fMask)
cout << " Number: " << (Int_t)TMath::Log2(fMask) << endl;
else cout << " fMask: " << fMask << endl;
if (IsActive())
cout << " Input is active " << endl;
else
cout << " Input is not active " << endl;
if (Status())
cout << " Input is fired " << endl;
else
cout << " Input is not fired " << endl;
}
TString AliTriggerInput::GetModule() const
{
TString name = "";
if (fDetectorId >= 0 && fDetectorId < AliDAQ::kNDetectors)
name = AliDAQ::OfflineModuleName((Int_t)fDetectorId);
else
AliError(Form("Invalid detector Id (%d)",(Int_t)fDetectorId));
return name;
}