X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=STEER%2FAliCentralTrigger.cxx;h=3f87ca7f91c0fc2ea6d602e017fdbb6296a89c59;hb=a1ecbc973fb74bf37be8e8916f9a75ea701bd458;hp=7fa3bbbad015313fecc12e01943d5bc5c1387ff1;hpb=7a03541c9d45da0ab91c87d5b95e3ea0b852204f;p=u%2Fmrichter%2FAliRoot.git diff --git a/STEER/AliCentralTrigger.cxx b/STEER/AliCentralTrigger.cxx index 7fa3bbbad01..3f87ca7f91c 100644 --- a/STEER/AliCentralTrigger.cxx +++ b/STEER/AliCentralTrigger.cxx @@ -20,12 +20,12 @@ // This class for running the Central Trigger Processor // // // // // -// Load Descriptors // -// Make a list the trigger detectors involve from the descriptors // +// Load Configuration // +// Make a list the trigger detectors involved (from the classes) // // For the each event // // Run the Trigger for the each detector // // Get the inputs // -// Check the condition classes // +// Check the trigger classes // // Create the class mask // // Save result // // // @@ -46,80 +46,86 @@ #include "AliTriggerInput.h" #include "AliTriggerDetector.h" -#include "AliTriggerCondition.h" -#include "AliTriggerDescriptor.h" +#include "AliTriggerConfiguration.h" +#include "AliTriggerClass.h" +#include "AliTriggerCluster.h" #include "AliCentralTrigger.h" #include "AliDetectorEventHeader.h" #include "AliHeader.h" +#include "AliCDBManager.h" +#include "AliCDBPath.h" +#include "AliCDBEntry.h" ClassImp( AliCentralTrigger ) //_____________________________________________________________________________ AliCentralTrigger::AliCentralTrigger() : TObject(), - fClassMask(0) + fClassMask(0), + fClusterMask(0), + fL0TriggerInputs(0), + fL1TriggerInputs(0), + fL2TriggerInputs(0), + fConfiguration(NULL) { // Default constructor -// LoadDescriptor("Pb-Pb"); + SetOwner(); } //_____________________________________________________________________________ -AliCentralTrigger::AliCentralTrigger( TString & descriptor ) : +AliCentralTrigger::AliCentralTrigger( TString & config ) : TObject(), - fClassMask(0) + fClassMask(0), + fClusterMask(0), + fL0TriggerInputs(0), + fL1TriggerInputs(0), + fL2TriggerInputs(0), + fConfiguration(NULL) { // Default constructor - LoadDescriptor( descriptor ); -} - -//_____________________________________________________________________________ -AliCentralTrigger::AliCentralTrigger( const AliCentralTrigger& ctp ): - TObject( ctp ), - fClassMask( ctp.fClassMask ) -{ - // Copy constructor - - Int_t ndes = ctp.fDescriptors.GetEntriesFast(); - for( Int_t j=0; jGetTriggerConditions(); - Int_t ncond = condArray->GetEntriesFast(); - for( Int_t j=0; jAt( j ); - cond->Reset(); - } + fClusterMask = 0; + fL0TriggerInputs = 0; + fL1TriggerInputs = 0; + fL2TriggerInputs = 0; + + if (fConfiguration) { + const TObjArray& classesArray = fConfiguration->GetClasses(); + Int_t nclasses = classesArray.GetEntriesFast(); + for( Int_t j=0; jReset(); + } } } @@ -133,7 +139,7 @@ void AliCentralTrigger::MakeBranch( TString name, TTree * tree ) TBranch* branch = tree->GetBranch( name ); if( branch == 0x0 ) { AliDebug( 1, "Creating new branch" ); - branch = tree->Branch( name, &(this->fClassMask), "fClassMask/l" ); + branch = tree->Branch( name, &(this->fClassMask), "fClassMask/l:fClusterMask/i:fL0TriggerInputs/i:fL1TriggerInputs/i:fL2TriggerInputs/s" ); branch->SetAutoDelete( kFALSE ); } else { @@ -144,134 +150,109 @@ void AliCentralTrigger::MakeBranch( TString name, TTree * tree ) } //_____________________________________________________________________________ -Bool_t AliCentralTrigger::LoadDescriptor( TString & descriptor ) +Bool_t AliCentralTrigger::LoadConfiguration( TString & config ) { - // Load one or more pre-created Descriptors from database/file that match - // with the input string 'descriptor' - // Ej: "Pb-Pb" or "p-p-DIMUON CALIBRATION-CENTRAL-BARREL" - - // Delete any descriptor - Reset(); - - // Load the selected descriptors - TObjArray* desArray = descriptor.Tokenize( " " ); - Int_t ndes = desArray->GetEntriesFast(); - for( Int_t i=0; iAt( i ); - AliTriggerDescriptor* des = AliTriggerDescriptor::LoadDescriptor( val->String() ); - if( des ) - fDescriptors.AddLast( des ); - else - AliWarning( Form( "Descriptor (%s) not found", val->String().Data() ) ); + // Load one and only one pre-created COnfiguration from database/file that match + // with the input string 'config' + // Ej: "p-p", "Pb-Pb" or "p-p-DIMUON CALIBRATION-CENTRAL-BARREL" + + // Delete the active configuration, if any + DeleteConfiguration(); + + // Load the selected configuration + if (!config.IsNull()) { + fConfiguration = AliTriggerConfiguration::LoadConfiguration( config ); + SetOwner(); + if(fConfiguration) + return kTRUE; + else { + AliError( Form( "Valid TriggerConfiguration (%s) is not found ! Disabling the trigger simulation !", config.Data() ) ); + return kFALSE; + } + } + else { + // Load one and only one trigger descriptor from CDB + AliInfo( "Getting trigger configuration from OCDB!" ); + + AliCDBPath path( "GRP", "CTP", "Config" ); + + AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath()); + SetOwner(kFALSE); + if( !entry ) AliFatal( "Couldn't load trigger description data from CDB!" ); + + fConfiguration = (AliTriggerConfiguration *)entry->GetObject(); + if(fConfiguration) + return kTRUE; + else { + AliError( "No valid configuration is found in the CDB ! Disabling the trigger simulation !" ); + return kFALSE; + } } - Bool_t desfound = kTRUE; - if( fDescriptors.GetEntriesFast() == 0 ) desfound = kFALSE; - - delete desArray; - - return desfound; } //_____________________________________________________________________________ TString AliCentralTrigger::GetDetectors() { - // return TString with the detectors to be trigger - // merging detectors from all descriptors + // return TString with the detectors (modules) to be used for triggering TString result; - Int_t ndes = fDescriptors.GetEntriesFast(); - for( Int_t i=0; iGetDetectorCluster(); - TObjArray* det = detStr.Tokenize(" "); - Int_t ndet = det->GetEntriesFast(); - for( Int_t j=0; jAt(j))->String() ) )continue; - result.Append( " " ); - result.Append( ((TObjString*)det->At(j))->String() ); - } - } + if (fConfiguration) + result = fConfiguration->GetTriggeringModules(); return result; } //_____________________________________________________________________________ -UChar_t AliCentralTrigger::GetClusterMask() -{ - // Return the detector cluster mask following - // table 4.3 pag 60, TDR Trigger and DAQ - - TString detStr = GetDetectors(); - TObjArray* det = detStr.Tokenize(" "); - Int_t ndet = det->GetEntriesFast(); - - UInt_t idmask = 0; - if( ndet >= 8 ) { // All detectors, should be 9 but CRT is not implemented yet - idmask = 1; - return idmask; - } - - if( ndet >= 7 && !detStr.Contains("MUON") ) { // Central Barrel, All but MUON - idmask = 2; - return idmask; - } - - if( detStr.Contains("MUON") && detStr.Contains("START") ) { // MUON arm - idmask = 4; - return idmask; - } - - return idmask; // 0 something else!!! -} -//_____________________________________________________________________________ -Bool_t AliCentralTrigger::RunTrigger( AliRunLoader* runLoader ) +Bool_t AliCentralTrigger::RunTrigger( AliRunLoader* runLoader, const char *detectors ) { // run the trigger - if( fDescriptors.GetEntriesFast() == 0 ) { - AliError( "not trigger descriptor loaded, skipping trigger" ); + if( !fConfiguration ) { + AliError( "No trigger configuration loaded, skipping trigger" ); return kFALSE; } TTree *tree = runLoader->TreeCT(); if( !tree ) { - AliError( "not folder with trigger loaded, skipping trigger" ); + AliError( "No folder with trigger loaded, skipping trigger" ); return kFALSE; } TStopwatch stopwatch; stopwatch.Start(); + AliInfo( Form(" Triggering Detectors: %s \n", GetDetectors().Data() ) ); + AliInfo( Form(" Detectors with digits: %s \n", detectors ) ); + // Process each event for( Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++ ) { - AliInfo( Form(" ***** Processing event %d *****\n", iEvent) ); runLoader->GetEvent( iEvent ); // Get detectors involve TString detStr = GetDetectors(); - AliInfo( Form(" Cluster Detectors %s \n", detStr.Data() ) ); + TString detWithDigits = detectors; TObjArray* detArray = runLoader->GetAliRun()->Detectors(); // Reset Mask fClassMask = 0; + fClusterMask = 0; + // Reset configuration object (inputs and classes) + fConfiguration->Reset(); TObjArray trgdetArray; // use as garbage collector for( Int_t iDet = 0; iDet < detArray->GetEntriesFast(); iDet++ ) { AliModule* det = (AliModule*) detArray->At( iDet ); if( !det || !det->IsActive() ) continue; - if( IsSelected(det->GetName(), detStr) ) { + if( IsSelected(det->GetName(), detStr) && + IsSelected(det->GetName(), detWithDigits) ) { - AliInfo( Form("Triggering from digits for %s", det->GetName() ) ); + AliDebug(1,Form("Triggering from digits for %s", det->GetName() ) ); AliTriggerDetector* trgdet = det->CreateTriggerDetector(); - trgdet->CreateInputs(); + trgdet->AssignInputs(fConfiguration->GetInputs()); TStopwatch stopwatchDet; stopwatchDet.Start(); trgdet->Trigger(); - AliInfo( Form("Execution time for %s: R:%.2fs C:%.2fs", + AliDebug(1, Form("Execution time for %s: R:%.2fs C:%.2fs", det->GetName(), stopwatchDet.RealTime(), stopwatchDet.CpuTime() ) ); - // Get the inputs - TObjArray* detInp = trgdet->GetInputs(); - for( Int_t i=0; iGetEntriesFast(); i++ ) { - fInputs.AddLast( detInp->At(i) ); - } trgdetArray.AddLast( trgdet ); // Write trigger detector in Event folder in Digits file @@ -298,8 +279,9 @@ Bool_t AliCentralTrigger::RunTrigger( AliRunLoader* runLoader ) } // Check trigger conditions and create the trigger class mask - CheckConditions(); - fInputs.Clear(); + TriggerClasses(); + // Calculate trigger Input pattern + TriggerInputs(); // Clear trigger detectors trgdetArray.SetOwner(); @@ -308,12 +290,12 @@ Bool_t AliCentralTrigger::RunTrigger( AliRunLoader* runLoader ) if( (detStr.CompareTo( "ALL" ) != 0) && !detStr.IsNull() ) { AliError( Form("the following detectors were not found: %s", detStr.Data())); - return kFALSE; + //JF return kFALSE; } // Save trigger mask tree->Fill(); - AliInfo( Form("**************** Central Trigger Class Mask:0x%X", fClassMask ) ); + AliDebug(1, Form("Event:%d Class Mask:0x%llX", iEvent,fClassMask ) ); } // end event loop Reset(); @@ -325,41 +307,67 @@ Bool_t AliCentralTrigger::RunTrigger( AliRunLoader* runLoader ) return kTRUE; } - +//---------------------------------------------------------------------------- +void AliCentralTrigger::TriggerInputs() +{ + // Find which inputs are in configuration + // and calculate input pattern + fL0TriggerInputs=0; + fL1TriggerInputs=0; + fL2TriggerInputs=0; + if(fConfiguration){ + const TObjArray& inputsArray = fConfiguration->GetInputs(); + Int_t ninputs = inputsArray.GetEntriesFast(); + for( Int_t j=0; jGetValue()){ + UChar_t level=input->GetLevel(); + if(level == 0) fL0TriggerInputs |= (input->GetMask()); + else if(level == 1) fL1TriggerInputs |= (input->GetMask()); + else if(level == 2) fL2TriggerInputs |= (input->GetMask()); + else{ + AliError(Form("Unknown input level:%c:",level)); + } + } + } + } +} //_____________________________________________________________________________ -Long_t AliCentralTrigger::CheckConditions() +ULong64_t AliCentralTrigger::TriggerClasses() { - // Check trigger conditions and create the trigger class mask - - Int_t ndes = fDescriptors.GetEntriesFast(); - for( Int_t i=0; iGetTriggerConditions(); - Int_t ncond = condArray->GetEntriesFast(); - for( Int_t j=0; jAt( j ); - if( !cond->CheckInputs( fInputs ) ) continue; - cond->Trigger( fInputs ); - // cond->Print(); - fClassMask |= cond->GetValue(); + // Check trigger conditions and create the trigger class + // and trigger cluster masks + fClassMask = 0; + fClusterMask = 0; + if (fConfiguration) { + const TObjArray& classesArray = fConfiguration->GetClasses(); + Int_t nclasses = classesArray.GetEntriesFast(); + for( Int_t j=0; jTrigger( fConfiguration->GetInputs(), fConfiguration->GetFunctions() ); + fClassMask |= trclass->GetValue(); + if (trclass->GetStatus()) { + AliTriggerCluster *trclust = trclass->GetCluster(); + fClusterMask |= AliDAQ::DetectorPattern(trclust->GetDetectorsInCluster()); } - } - return fClassMask; + } + } + return fClassMask; } //_____________________________________________________________________________ -TObjArray* AliCentralTrigger::GetResultConditions() +TObjArray* AliCentralTrigger::GetFiredClasses() const { // return only the true conditions TObjArray* result = new TObjArray(); - Int_t ndes = fDescriptors.GetEntriesFast(); - for( Int_t i=0; iGetTriggerConditions(); - Int_t ncond = condArray->GetEntriesFast(); - for( Int_t j=0; jAt( j ); - if( cond->GetStatus() ) result->AddLast( cond ); - } + if (fConfiguration) { + const TObjArray& classesArray = fConfiguration->GetClasses(); + Int_t nclasses = classesArray.GetEntriesFast(); + for( Int_t j=0; jGetStatus() ) result->AddLast( trclass ); + } } return result; @@ -371,12 +379,7 @@ void AliCentralTrigger::Print( const Option_t* ) const // Print cout << "Central Trigger: " << endl; cout << " Trigger Class Mask: 0x" << hex << fClassMask << dec << endl; - - Int_t ndes = fDescriptors.GetEntriesFast(); - for( Int_t i=0; iPrint(); - } + if (fConfiguration) fConfiguration->Print(); cout << endl; } @@ -416,3 +419,52 @@ Bool_t AliCentralTrigger::IsSelected( TString detName, TString& detectors ) cons return result; } + +//_____________________________________________________________________________ +Bool_t AliCentralTrigger::CheckTriggeredDetectors() const +{ + // Check the trigger mask, finds which trigger classes + // have been fired, load the corresponding trigger clusters and + // finally makes a list of the detectors that have been readout + // for each particular event. This list is then compared to the + // one stored in fClusterMask. Return value: + // true = two lists are equal + // false = two lists are not equal meaning wrong trigger config + // is loaded. + + if (!fConfiguration) { + AliError("The trigger confiration has not yet been loaded! Cross-check is not possible!"); + return kFALSE; + } + else { + + // Make a cross-check so that to exclude wrong trigger configuration used + // Loop over the trigger classes + UInt_t clusterMask = 0; + const TObjArray& classesArray = fConfiguration->GetClasses(); + Int_t nclasses = classesArray.GetEntriesFast(); + for( Int_t j=0; jGetMask() & fClassMask) { // class was fired + AliTriggerCluster *trclust = trclass->GetCluster(); + clusterMask |= AliDAQ::DetectorPattern(trclust->GetDetectorsInCluster()); + } + } + // Compare the stored cluster mask with the one + // that we get from trigger classes + if (clusterMask != fClusterMask) { + if ((clusterMask & fClusterMask) == clusterMask) { + AliInfo(Form("Cluster mask from trigger classes (%x) and from data (%x) differ. Concurrent DAQ run(s) could be the reason.", + (UInt_t)clusterMask,(UInt_t)fClusterMask)); + return kTRUE; + } + else { + AliError(Form("Wrong cluster mask from trigger classes (%x), expecting (%x)! Loaded trigger configuration is possibly wrong!", + (UInt_t)clusterMask,(UInt_t)fClusterMask)); + return kFALSE; + } + } + } + + return kTRUE; +}