]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - VZERO/AliVZEROTrigger.cxx
Making online tracklets usable in offline reconstruction
[u/mrichter/AliRoot.git] / VZERO / AliVZEROTrigger.cxx
index 23ceff60288d2242460518f1186b3e17578adf7e..a84380c28f0845a4768d3b97e1460119fa7c1041 100644 (file)
@@ -1,7 +1,27 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id$ */
+
+#include <TClonesArray.h>
+
 #include "AliRun.h"
 #include "AliRunLoader.h"
 
 #include "AliVZEROTrigger.h"
+#include "AliVZEROTriggerMask.h"
 
 //______________________________________________________________________
 ClassImp(AliVZEROTrigger)
@@ -14,15 +34,21 @@ ClassImp(AliVZEROTrigger)
 ////////////////////////////////////////////////////////////////////////
 
 //______________________________________________________________________
+
 AliVZEROTrigger::AliVZEROTrigger()
-  : AliTriggerDetector()
+  :AliTriggerDetector(),
+   fAdcThresHold(0.0),
+   fTimeWindowWidthBBA(50.0),
+   fTimeWindowWidthBGA(20.0),
+   fTimeWindowWidthBBC(50.0),
+   fTimeWindowWidthBGC(20.0)
+   
 {
    SetName("VZERO");
    CreateInputs();
 
    SetAdcThreshold();
 }
-
 //______________________________________________________________________
 void AliVZEROTrigger::CreateInputs()
 {
@@ -31,12 +57,11 @@ void AliVZEROTrigger::CreateInputs()
    // Do not create inputs again!!
    if( fInputs.GetEntriesFast() > 0 ) return;
 
-   fInputs.AddLast( new AliTriggerInput( "VZERO_LEFT", "At least one hit in the left VZERO", 0x01 ) );
-   fInputs.AddLast( new AliTriggerInput( "VZERO_RIGHT","At least one hit in the right VZERO", 0x02 ) );
-   fInputs.AddLast( new AliTriggerInput( "VZERO_AND",  "At least one hit in the each (left and right) VZERO", 0x04 ) );
-   fInputs.AddLast( new AliTriggerInput( "VZERO_OR",   "At least one hit in the one (left one right) VZERO", 0x08 ) );
-
-   fInputs.AddLast( new AliTriggerInput( "VZERO_BEAMGAS", "Beam gas VZERO trigger ", 0x010 ) );
+   fInputs.AddLast( new AliTriggerInput( "VZERO_LEFT", "VZERO", 0 ) );
+   fInputs.AddLast( new AliTriggerInput( "VZERO_RIGHT","VZERO", 0 ) );
+   fInputs.AddLast( new AliTriggerInput( "VZERO_AND",  "VZERO", 0 ) );
+   fInputs.AddLast( new AliTriggerInput( "VZERO_OR",   "VZERO", 0 ) );
+   fInputs.AddLast( new AliTriggerInput( "VZERO_BEAMGAS", "VZERO", 0 ) );
 }
 
 //______________________________________________________________________
@@ -44,9 +69,10 @@ void AliVZEROTrigger::Trigger()
 {
   
   //  ********** Get run loader for the current event **********
-  AliRunLoader* runLoader = gAlice->GetRunLoader();
+  AliRunLoader* runLoader = AliRunLoader::Instance();
 
-  AliVZEROLoader* loader = (AliVZEROLoader* )runLoader->GetLoader( "VZEROLoader" );
+  AliVZEROLoader* loader = 
+    (AliVZEROLoader* )runLoader->GetLoader( "VZEROLoader" );
 
   loader->LoadDigits("READ");
   TTree* vzeroDigitsTree = loader->TreeD();
@@ -56,66 +82,23 @@ void AliVZEROTrigger::Trigger()
   TBranch* digitBranch = vzeroDigitsTree->GetBranch("VZERODigit");
   digitBranch->SetAddress(&vzeroDigits);
 
-  // number of hits in left/right
-  Int_t nLeftDig  = 0;
-  Int_t nRightDig = 0;
-  
-  // first time 
-  Float_t firstTimeLeft = 9999;
-  Float_t firstTimeRight = 9999;
-
-  // loop over vzero entries
-  Int_t nEntries = (Int_t)vzeroDigitsTree->GetEntries();
-  for (Int_t e=0; e<nEntries; e++) {
-    vzeroDigitsTree->GetEvent(e);
-
-    Int_t nDigits = vzeroDigits->GetEntriesFast();
-    
-    for (Int_t d=0; d<nDigits; d++) {
-      //      vzeroDigitsTree->GetEvent(d);
-      AliVZEROdigit* digit = (AliVZEROdigit*)vzeroDigits->At(d);
-      
-      Int_t   cellNumber = digit->CellNumber();
-      Float_t adc        = digit->ADC();
-      Float_t tdc        = digit->Time(); // in 100 of picoseconds
-      
-      if (cellNumber<=47 && adc>fAdcThresHold) {
-       nLeftDig++;
-       if (tdc<firstTimeLeft) firstTimeLeft = tdc;
-      }        
-      if (cellNumber>=48 && adc>fAdcThresHold) {
-       nRightDig++;
-       if (tdc<firstTimeRight) firstTimeRight = tdc;
-      }
-    } // end of loop over digits
-  } // end of loop over events in digits tree
-  
-  // Beam gas trigger set from the time difference. The time it takes
-  // to travel between the two counters is ~14.3 ns = 143 * 100 ps.
-  //  NB: this should be defined
-  // from time windows relative to the time of the bunch crossing!
-  // beam gas comming from the left ...
-
-  if (TMath::Abs(TMath::Abs(firstTimeLeft - firstTimeRight)-143) < 20) // time window of 2 ns
-    SetInput( "VZERO_BEAMGAS" );
-
-  if (nLeftDig > 0)
-    SetInput( "VZERO_LEFT" );
-
-  if (nRightDig > 0)
-    SetInput( "VZERO_RIGHT" );
-  
-  if (nLeftDig>0 || nRightDig>0) {
-    SetInput( "VZERO_OR" );
-
-    if (nLeftDig>0 && nRightDig>0) {
-    SetInput( "VZERO_AND" );   
-    }
-  }
-  
-  AliDebug(1,Form("VZERO cells fired: %d (left) %d (right)", nLeftDig, nRightDig));
+  AliVZEROTriggerMask *TriggerMask = new AliVZEROTriggerMask();
+  TriggerMask->SetAdcThreshold(fAdcThresHold);
+  TriggerMask->SetTimeWindowWidthBBA(fTimeWindowWidthBBA);
+  TriggerMask->SetTimeWindowWidthBGA(fTimeWindowWidthBGA);
+  TriggerMask->SetTimeWindowWidthBBC(fTimeWindowWidthBBC);
+  TriggerMask->SetTimeWindowWidthBGC(fTimeWindowWidthBGC);
+  TriggerMask->FillMasks(vzeroDigitsTree,vzeroDigits);
+
+  if ( (TriggerMask->GetBGtriggerV0A()>0) ||
+       (TriggerMask->GetBGtriggerV0C()>0)) SetInput( "VZERO_BEAMGAS" );
+  if (TriggerMask->GetBBtriggerV0A()>0)  SetInput( "VZERO_LEFT" );
+  if (TriggerMask->GetBBtriggerV0C()>0)  SetInput( "VZERO_RIGHT" );
+  if ( (TriggerMask->GetBBtriggerV0A()>0) ||
+       (TriggerMask->GetBBtriggerV0C()>0)) SetInput( "VZERO_OR" );
+  if ( (TriggerMask->GetBBtriggerV0A()>0) &&
+       (TriggerMask->GetBBtriggerV0C()>0)) SetInput( "VZERO_AND" );
 
   return;
 }
 
-