]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliTriggerDetector.cxx
turned off HLTError into Debug
[u/mrichter/AliRoot.git] / STEER / AliTriggerDetector.cxx
index 3f02d7d414459ade7fe50cd04c02b79f6c159d00..c43be38511342061bb4b2a72ead2e9faf8b08808 100644 (file)
@@ -25,6 +25,7 @@
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
+#include <Riostream.h>
 #include <TNamed.h>
 #include <TString.h>
 #include <TObjArray.h>
@@ -34,6 +35,7 @@
 #include "AliLog.h"
 #include "AliRun.h"
 #include "AliRunLoader.h"
+#include "AliLoader.h"
 
 #include "AliTriggerInput.h"
 #include "AliTriggerDetector.h"
 ClassImp( AliTriggerDetector )
 
 //_____________________________________________________________________________
-AliTriggerDetector::AliTriggerDetector() : TNamed()
+AliTriggerDetector::AliTriggerDetector() :
+  TNamed(),
+  fMask(0),
+  fInputs()
 {
    // Default constructor
-   fMask    = 0;
+}
+
+//_____________________________________________________________________________
+AliTriggerDetector::AliTriggerDetector(const AliTriggerDetector & de ):
+  TNamed(de),
+  fMask(de.fMask),
+  fInputs(de.fInputs)
+{
+  // Copy constructor
+  
+}
+
+//_____________________________________________________________________________
+AliTriggerDetector::~AliTriggerDetector()
+{
+  // Destructor
+  // Delete only inputs that are not
+  // associated to the CTP
+  Int_t ninputs = fInputs.GetEntriesFast();
+  for(Int_t i = 0; i < ninputs; i++) {
+    AliTriggerInput *inp = (AliTriggerInput *)fInputs.At(i);
+    if (inp->GetSignature() == -1 &&
+       inp->GetMask() == 0)
+      delete fInputs.RemoveAt(i);
+  }
+}
+
+//_____________________________________________________________________________
+void AliTriggerDetector::AssignInputs(const TObjArray &inputs)
+{
+  // Cross-check the trigger inputs provided by the detector trigger
+  // processor (TP) and the inputs defined in CTP
+  // a) If the input is defined in the TP, but not in CTP it
+  // will be generated but not used by CTP. It will be possibly stored
+  // in the detector raw data if the hardware allows this.
+  // b) If hte input is not defined in the TP, but is defined in CTP
+  // then a warning is issued and the CTP simulation is working
+  // with this input disabled.
+   // Check if we have to create the inputs first
+   if( fInputs.GetEntriesFast() == 0 ) {
+     // Create the inputs that the detector can provide
+     CreateInputs();
+   }
+
+   TString name = GetName();
+
+   // Pointer to the available inputs provided by the detector
+   TObjArray* availInputs = &fInputs;
+
+   Int_t ninputs = inputs.GetEntriesFast();
+   for( Int_t j=0; j<ninputs; j++ ) {
+     AliTriggerInput *inp = (AliTriggerInput*)inputs.At(j);
+     if ( name.CompareTo(inp->GetModule().Data()) ) continue;
+
+     TObject *tempObj = availInputs->FindObject(inp->GetInputName().Data());
+     if ( tempObj ) {
+       Int_t tempIndex = availInputs->IndexOf(tempObj);
+       delete availInputs->Remove(tempObj);
+       fInputs.AddAt( inp, tempIndex );
+       inp->Enable();
+       AliDebug(1,Form("Trigger input (%s) is found in the CTP configuration. Therefore it is enabled for trigger detector (%s)",
+                   inp->GetInputName().Data(),name.Data()));
+     }
+     else {
+       AliWarning(Form("Trigger Input (%s) is not implemented for the trigger detector (%s) ! It will be disabled !",
+                      inp->GetInputName().Data(),name.Data()));
+     }
+   }
+
+   for( Int_t j=0; j<fInputs.GetEntriesFast(); j++ ) {
+     AliTriggerInput *inp = (AliTriggerInput *)fInputs.At(j);
+     if (inp->GetSignature() == -1 &&
+        inp->GetMask() == 0) {
+       inp->Enable();
+       AliDebug(1,Form("Trigger input (%s) was not found in the CTP configuration. Therefore it will be run in a stand-alone mode",
+                   inp->GetInputName().Data()));
+     }
+   }
+
+   fInputs.SetOwner(kFALSE);
 }
 
 //_____________________________________________________________________________
@@ -58,10 +143,9 @@ void AliTriggerDetector::CreateInputs()
    // Do not create inputs again!!
    if( fInputs.GetEntriesFast() > 0 ) return;
    
-   TString name = GetName();
-   fInputs.AddLast( new AliTriggerInput( name+"_TEST1_L0", "Dummy input 1", 0x01 ) );
-   fInputs.AddLast( new AliTriggerInput( name+"_TEST2_L0", "Dummy input 2", 0x02 ) );
-   fInputs.AddLast( new AliTriggerInput( name+"_TEST3_L0", "Dummy input 3", 0x04 ) );
+   fInputs.AddLast( new AliTriggerInput( "TEST1_L0", "TEST", 0 ) );
+   fInputs.AddLast( new AliTriggerInput( "TEST2_L0", "TEST", 0 ) );
+   fInputs.AddLast( new AliTriggerInput( "TEST3_L0", "TEST", 0 ) );
 }
 
 //_____________________________________________________________________________
@@ -72,7 +156,7 @@ void AliTriggerDetector::Trigger()
    AliWarning( Form( "Triggering dummy detector %s", GetName() ) );
 
    //  ********** Get Digits for the current event **********
-   AliRunLoader* runLoader = gAlice->GetRunLoader();
+   AliRunLoader* runLoader = AliRunLoader::Instance();
    AliInfo( Form( "Event %d", runLoader->GetEventNumber() ) );
    
    TString loadername = GetName(); 
@@ -104,9 +188,7 @@ void AliTriggerDetector::Trigger()
 void AliTriggerDetector::SetInput( TString& name )
 {
    // Set Input by name
-   AliTriggerInput* in = ((AliTriggerInput*)fInputs.FindObject( name.Data() ));
-   in->Set();
-   fMask |= in->GetValue();
+   SetInput( name.Data() );
 }
 
 //_____________________________________________________________________________
@@ -114,22 +196,22 @@ void AliTriggerDetector::SetInput( const char * name )
 {
    // Set Input by name
    AliTriggerInput* in = ((AliTriggerInput*)fInputs.FindObject( name ));
-   in->Set();
-   fMask |= in->GetValue();
+   if( in ) {
+      in->Set();
+      fMask |= in->GetValue();
+   } else
+      AliError( Form( "There is not input named %s", name ) );
 }
 
 //_____________________________________________________________________________
-void AliTriggerDetector::SetInput( Int_t mask )
+void AliTriggerDetector::Print( const Option_t* opt ) const
 {
-   // Set Input by mask
+   // Print
+   cout << "Trigger Detector : " << GetName() << endl;
+   cout << "  Trigger Class Mask: 0x" << hex << GetMask() << dec << endl;
    Int_t nInputs = fInputs.GetEntriesFast();
    for( Int_t j=0; j<nInputs; j++ ) {
       AliTriggerInput* in = (AliTriggerInput*)fInputs.At( j );
-      if( in->GetMask() == mask ) { 
-         in->Set();
-         fMask |= in->GetValue();
-         break;
-      }
+      in->Print( opt );
    }
 }
-