Fix histo title axis name; fix checking of NLM in Pi0EbE
[u/mrichter/AliRoot.git] / TRD / AliTRDTriggerL0.cxx
index 4c17b86..bba3389 100644 (file)
 #include "AliRunLoader.h"
 #include "AliLoader.h"
 
+#include "AliTRDptrgParam.h"
+#include "AliTRDptrgCBB.h"
+
 #include "AliTRDTriggerL0.h"
-#include "AliTRDgtuSim.h"
-#include "AliTRDtrackGTU.h"
 
 AliTRDTriggerL0::AliTRDTriggerL0()
 {
+  // constructor
+
   SetName("TRD");
 }
 
 AliTRDTriggerL0::~AliTRDTriggerL0()
 {
-
+  // destructor
 }
 
 void AliTRDTriggerL0::CreateInputs()
 {
+  // create the L0 inputs which are provided by the TRD
+
   if (fInputs.GetEntriesFast() > 0)
     return;
 
-  fInputs.AddLast(new AliTriggerInput("TRD_MB_L0", "TRD", 1)); // whatever should be there
+  fInputs.AddLast(new AliTriggerInput("0HWU", "TRD", 1)); // TRD wake up
+  fInputs.AddLast(new AliTriggerInput("0HSG", "TRD", 1)); // single gap
+  fInputs.AddLast(new AliTriggerInput("0HDG", "TRD", 1)); // double gap
 }
 
 void AliTRDTriggerL0::Trigger()
 {
-  // just an example:
+  // do the actual trigger calculation
+
   AliRunLoader *runLoader = AliRunLoader::Instance();
   if (!runLoader)
     return;
@@ -61,6 +69,36 @@ void AliTRDTriggerL0::Trigger()
   if (!trdLoader)
     return;
 
-  // here comes the actual pretrigger simulation
+  AliTRDptrgParam* param = AliTRDptrgParam::Instance();
+
+  AliTRDptrgCBB* ptrgCBB = new AliTRDptrgCBB(runLoader, param, kDigits);
+
+  Int_t* simulationResult;
+  simulationResult = ptrgCBB->Simulate();
+  if (!simulationResult) {
+    return;
+  }
+  for (Int_t iResult = 1; iResult <= simulationResult[0]; iResult++) {
+    AliDebug(5, Form("Result[%d]=0x%x\n",iResult,simulationResult[iResult]));
+  }
+  if ((simulationResult[0] > 0) || (simulationResult[1] > 0)) {
+    AliInfo("Fired single gap trigger");
+    SetInput("0HSG");
+  }
+
+  if (simulationResult[2] > 0) {
+    AliInfo("Fired  double gap trigger");
+    SetInput("0HDG");
+  }
+
+  if (simulationResult[3] > 0) {
+    AliInfo("Fired TRD wake up call trigger");
+    SetInput("0HWU");
+  }
+
+  delete ptrgCBB;
+  delete[] simulationResult;
+  simulationResult = 0x0;
 
+  AliDebug(5, Form("memory state: %d", param->CheckVariables()));
 }