]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliCentralTrigger.cxx
update some settings, add option depending on year, collision type, output file name
[u/mrichter/AliRoot.git] / STEER / AliCentralTrigger.cxx
index a794bee4fc49be49ad6842fae76a49c1a936a9b8..3f87ca7f91c0fc2ea6d602e017fdbb6296a89c59 100644 (file)
@@ -64,9 +64,13 @@ AliCentralTrigger::AliCentralTrigger() :
    TObject(),
    fClassMask(0),
    fClusterMask(0),
+   fL0TriggerInputs(0),
+   fL1TriggerInputs(0),
+   fL2TriggerInputs(0),
    fConfiguration(NULL)
 {
    // Default constructor
+  SetOwner();
 }
 
 //_____________________________________________________________________________
@@ -74,6 +78,9 @@ AliCentralTrigger::AliCentralTrigger( TString & config ) :
    TObject(),
    fClassMask(0),
    fClusterMask(0),
+   fL0TriggerInputs(0),
+   fL1TriggerInputs(0),
+   fL2TriggerInputs(0),
    fConfiguration(NULL)
 {
    // Default constructor
@@ -93,7 +100,13 @@ void AliCentralTrigger::DeleteConfiguration()
   // Delete the active configuration
   fClassMask = 0;
   fClusterMask = 0;
-  if (fConfiguration) delete fConfiguration;
+  fL0TriggerInputs = 0;
+  fL1TriggerInputs = 0;
+  fL2TriggerInputs = 0;
+  if (fConfiguration) {
+    if (IsOwner()) delete fConfiguration;
+    fConfiguration = 0x0;
+  }
 }
 
 //_____________________________________________________________________________
@@ -102,6 +115,9 @@ void AliCentralTrigger::Reset()
    // Reset Class Mask and classes
    fClassMask = 0;
    fClusterMask = 0;
+   fL0TriggerInputs = 0;
+   fL1TriggerInputs = 0;
+   fL2TriggerInputs = 0;
 
    if (fConfiguration) {
      const TObjArray& classesArray = fConfiguration->GetClasses();
@@ -123,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 {
@@ -146,6 +162,7 @@ Bool_t AliCentralTrigger::LoadConfiguration( TString & config )
    // Load the selected configuration
    if (!config.IsNull()) {
      fConfiguration = AliTriggerConfiguration::LoadConfiguration( config );
+     SetOwner();
      if(fConfiguration)
        return kTRUE;
      else {
@@ -155,11 +172,12 @@ Bool_t AliCentralTrigger::LoadConfiguration( TString & config )
    }
    else {
      // Load one and only one trigger descriptor from CDB
-     AliInfo( "GETTING TRIGGER DESCRIPTORS 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();
@@ -204,15 +222,15 @@ Bool_t AliCentralTrigger::RunTrigger( AliRunLoader* runLoader, const char *detec
    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(" Triggering Detectors: %s \n", detStr.Data() ) );
       TString detWithDigits = detectors;
-      AliInfo( Form(" Detectors with digits: %s \n", detWithDigits.Data() ) );
       TObjArray* detArray = runLoader->GetAliRun()->Detectors();
       // Reset Mask
       fClassMask = 0;
@@ -226,13 +244,13 @@ Bool_t AliCentralTrigger::RunTrigger( AliRunLoader* runLoader, const char *detec
          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(fConfiguration->GetInputs());
+            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() ) );
 
             trgdetArray.AddLast( trgdet );
@@ -262,6 +280,8 @@ Bool_t AliCentralTrigger::RunTrigger( AliRunLoader* runLoader, const char *detec
 
       // Check trigger conditions and create the trigger class mask
       TriggerClasses();
+      // Calculate trigger Input pattern
+      TriggerInputs();
 
       // Clear trigger detectors
       trgdetArray.SetOwner();
@@ -275,7 +295,7 @@ Bool_t AliCentralTrigger::RunTrigger( AliRunLoader* runLoader, const char *detec
 
       // 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();
@@ -287,12 +307,38 @@ Bool_t AliCentralTrigger::RunTrigger( AliRunLoader* runLoader, const char *detec
 
    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; j<ninputs; j++ ) {
+      AliTriggerInput* input = (AliTriggerInput*)inputsArray.At( j );
+      if(input->GetValue()){
+       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));
+       }
+      }
+    }
+ }
+}
 //_____________________________________________________________________________
 ULong64_t AliCentralTrigger::TriggerClasses()
 {
   // 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();
@@ -300,8 +346,10 @@ ULong64_t AliCentralTrigger::TriggerClasses()
       AliTriggerClass* trclass = (AliTriggerClass*)classesArray.At( j );
       trclass->Trigger( fConfiguration->GetInputs(), fConfiguration->GetFunctions() );
       fClassMask |= trclass->GetValue();
-      if (trclass->GetStatus())
-       fClusterMask |= (trclass->GetCluster())->GetClusterMask();
+      if (trclass->GetStatus()) {
+       AliTriggerCluster *trclust = trclass->GetCluster();
+       fClusterMask |= AliDAQ::DetectorPattern(trclust->GetDetectorsInCluster());
+      }
     }
   }
   return fClassMask;
@@ -371,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; j<nclasses; j++ ) {
+      AliTriggerClass* trclass = (AliTriggerClass*)classesArray.At( j );
+      if (trclass->GetMask() & 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;
+}