]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Code to match jet patch trigger to jets (from Jiri Kral)
authorloizides <loizides@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 26 Jun 2013 20:46:43 +0000 (20:46 +0000)
committerloizides <loizides@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 26 Jun 2013 20:46:43 +0000 (20:46 +0000)
More info at https://indico.cern.ch/conferenceDisplay.py?confId=255775

PWG/CMakelibPWGEMCAL.pkg
PWG/EMCAL/AliAnalysisTaskEmcal.cxx
PWG/EMCAL/AliAnalysisTaskEmcal.h
PWG/EMCAL/AliEmcalTriggerMaker.cxx [new file with mode: 0644]
PWG/EMCAL/AliEmcalTriggerMaker.h [new file with mode: 0644]
PWG/EMCAL/AliEmcalTriggerPatchInfo.cxx [new file with mode: 0644]
PWG/EMCAL/AliEmcalTriggerPatchInfo.h [new file with mode: 0644]
PWG/EMCAL/AliEmcalTriggerSetupInfo.cxx [new file with mode: 0644]
PWG/EMCAL/AliEmcalTriggerSetupInfo.h [new file with mode: 0644]
PWG/EMCAL/macros/AddTaskEmcalTriggerMaker.C [new file with mode: 0644]
PWG/PWGEMCALLinkDef.h

index 98e77e387d4015ded6cb3dd72370937cbcf31c98..3a0ffd165e92f05e78d0864812199600a85c026b 100644 (file)
@@ -49,6 +49,9 @@ set ( SRCS
  EMCAL/AliEsdTrackExt.cxx
  EMCAL/AliParticleContainer.cxx
  EMCAL/AliPicoTrack.cxx
+ EMCAL/AliEmcalTriggerPatchInfo.cxx
+ EMCAL/AliEmcalTriggerSetupInfo.cxx
+ EMCAL/AliEmcalTriggerMaker.cxx
 )
 
 string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" )
index 51075bdd43f55095f23b2963be81cb757cdc9bf6..51b77e9d143c62f83238fe0676b51a632f9882df 100644 (file)
@@ -24,6 +24,7 @@
 #include "AliVCluster.h"
 #include "AliVEventHandler.h"
 #include "AliVParticle.h"
+#include "AliVCaloTrigger.h"
 
 ClassImp(AliAnalysisTaskEmcal)
 
@@ -38,6 +39,7 @@ AliAnalysisTaskEmcal::AliAnalysisTaskEmcal() :
   fTracksName(),
   fCaloName(),
   fCaloCellsName(),
+  fCaloTriggersName(),
   fMinCent(-999),
   fMaxCent(-999),
   fMinVz(-999),
@@ -71,6 +73,7 @@ AliAnalysisTaskEmcal::AliAnalysisTaskEmcal() :
   fTracks(0),
   fCaloClusters(0),
   fCaloCells(0),
+  fCaloTriggers(0),
   fCent(0),
   fCentBin(-1),
   fEPV0(-1.0),
@@ -101,6 +104,7 @@ AliAnalysisTaskEmcal::AliAnalysisTaskEmcal(const char *name, Bool_t histo) :
   fTracksName(),
   fCaloName(),
   fCaloCellsName(),
+  fCaloTriggersName(),
   fMinCent(-999),
   fMaxCent(-999),
   fMinVz(-999),
@@ -134,6 +138,7 @@ AliAnalysisTaskEmcal::AliAnalysisTaskEmcal(const char *name, Bool_t histo) :
   fTracks(0),
   fCaloClusters(0),
   fCaloCells(0),
+  fCaloTriggers(0),
   fCent(0),
   fCentBin(-1),
   fEPV0(-1.0),
@@ -417,6 +422,14 @@ void AliAnalysisTaskEmcal::ExecOnce()
     }
   }
 
+  if (!fCaloTriggersName.IsNull() && !fCaloTriggers) {
+    fCaloTriggers =  dynamic_cast<AliVCaloTrigger*>(InputEvent()->FindListObject(fCaloTriggersName));
+    if (!fCaloTriggers) {
+      AliError(Form("%s: Could not retrieve calo triggers %s!", GetName(), fCaloTriggersName.Data())); 
+      return;
+    }
+  }
+
   fInitialized = kTRUE;
 }
 
index d7c445f00429bf4b56908bf477ddc959c2af47e1..432393f89adcbe3bb868cd6f991fa50f7206b4e9 100644 (file)
@@ -14,6 +14,7 @@ class AliVParticle;
 class AliVCaloCells;
 class TH1F;
 class AliEMCALGeometry;
+class AliVCaloTrigger;
 
 #include "AliAnalysisTaskSE.h"
 
@@ -45,6 +46,7 @@ class AliAnalysisTaskEmcal : public AliAnalysisTaskSE {
   void                        SetCentRange(Double_t min, Double_t max)              { fMinCent           = min  ; fMaxCent = max          ; }
   void                        SetClusName(const char *n)                            { fCaloName          = n                              ; }
   void                        SetCaloCellsName(const char *n)                       { fCaloCellsName     = n                              ; }
+  void                        SetCaloTriggersName(const char *n)                    { fCaloTriggersName  = n                              ; }
   void                        SetClusPtCut(Double_t cut)                            { fClusPtCut         = cut                            ; }
   void                        SetClusTimeCut(Double_t min, Double_t max)            { fClusTimeCutLow    = min  ; fClusTimeCutUp = max    ; }
   void                        SetHistoBins(Int_t nbins, Double_t min, Double_t max) { fNbins = nbins; fMinBinPt = min; fMaxBinPt = max    ; }
@@ -91,6 +93,7 @@ class AliAnalysisTaskEmcal : public AliAnalysisTaskSE {
   TString                     fTracksName;                 // name of track collection
   TString                     fCaloName;                   // name of calo cluster collection
   TString                     fCaloCellsName;              // name of calo cell collection
+  TString                     fCaloTriggersName;           // name of calo triggers collection
   Double_t                    fMinCent;                    // min centrality for event selection
   Double_t                    fMaxCent;                    // max centrality for event selection
   Double_t                    fMinVz;                      // min vertex for event selection
@@ -124,6 +127,7 @@ class AliAnalysisTaskEmcal : public AliAnalysisTaskSE {
   TClonesArray               *fTracks;                     //!tracks
   TClonesArray               *fCaloClusters;               //!clusters
   AliVCaloCells              *fCaloCells;                  //!cells
+  AliVCaloTrigger            *fCaloTriggers;               //!calo triggers
   Double_t                    fCent;                       //!event centrality
   Int_t                       fCentBin;                    //!event centrality bin
   Double_t                    fEPV0;                       //!event plane V0
@@ -142,6 +146,6 @@ class AliAnalysisTaskEmcal : public AliAnalysisTaskSE {
   AliAnalysisTaskEmcal(const AliAnalysisTaskEmcal&);            // not implemented
   AliAnalysisTaskEmcal &operator=(const AliAnalysisTaskEmcal&); // not implemented
 
-  ClassDef(AliAnalysisTaskEmcal, 14) // EMCAL base analysis task
+  ClassDef(AliAnalysisTaskEmcal, 15) // EMCAL base analysis task
 };
 #endif
diff --git a/PWG/EMCAL/AliEmcalTriggerMaker.cxx b/PWG/EMCAL/AliEmcalTriggerMaker.cxx
new file mode 100644 (file)
index 0000000..9d9e8c5
--- /dev/null
@@ -0,0 +1,282 @@
+// $Id$
+//
+// Class to make emcal particles in AOD/ESD events.
+//
+// Author: J.Kral
+
+#include <TClonesArray.h>
+#include <iostream>
+
+#include "AliLog.h"
+#include "AliEmcalTriggerPatchInfo.h"
+#include "AliEmcalTriggerSetupInfo.h"
+
+#include "AliEmcalTriggerMaker.h"
+#include "AliEMCALTriggerTypes.h"
+#include "AliEMCALGeometry.h"
+
+#include "AliVCaloTrigger.h"
+#include "AliVCaloCells.h"
+
+ClassImp(AliEmcalTriggerMaker)
+
+using namespace std;
+
+//________________________________________________________________________
+AliEmcalTriggerMaker::AliEmcalTriggerMaker() : 
+  AliAnalysisTaskEmcal("AliEmcalTriggerMaker",kFALSE),
+  fCaloTriggersOutName("EmcalTriggers"),
+  fCaloTriggerSetupOutName("EmcalTriggersSetup"),
+  fCaloTriggersOut(0),
+  fCaloTriggerSetupOut(0)
+{
+  // Constructor.
+}
+
+//________________________________________________________________________
+AliEmcalTriggerMaker::AliEmcalTriggerMaker(const char *name) : 
+  AliAnalysisTaskEmcal(name,kFALSE),
+  fCaloTriggersOutName("EmcalTriggers"),
+  fCaloTriggerSetupOutName("EmcalTriggersSetup"),
+  fCaloTriggersOut(0),
+  fCaloTriggerSetupOut(0)
+{
+  // Constructor.
+
+}
+
+//________________________________________________________________________
+AliEmcalTriggerMaker::~AliEmcalTriggerMaker()
+{
+  // Destructor.
+}
+
+//________________________________________________________________________
+void AliEmcalTriggerMaker::ExecOnce()
+{
+  // Init the analysis.
+
+  AliAnalysisTaskEmcal::ExecOnce();
+
+  if (!fInitialized)
+    return;
+
+  if (!fCaloTriggersOutName.IsNull()) {
+    fCaloTriggersOut = new TClonesArray("AliEmcalTriggerPatchInfo");
+    fCaloTriggersOut->SetName(fCaloTriggersOutName);
+
+    if (!(InputEvent()->FindListObject(fCaloTriggersOutName))) {
+      InputEvent()->AddObject(fCaloTriggersOut);
+    }
+    else {
+      fInitialized = kFALSE;
+      AliFatal(Form("%s: Container with same name %s already present. Aborting", GetName(), fCaloTriggersOutName.Data()));
+      return;
+    }
+  }
+
+  if (!fCaloTriggerSetupOutName.IsNull()) {
+    fCaloTriggerSetupOut = new AliEmcalTriggerSetupInfo();
+    fCaloTriggerSetupOut->SetName(fCaloTriggerSetupOutName);
+
+    if (!(InputEvent()->FindListObject(fCaloTriggerSetupOutName))) {
+      InputEvent()->AddObject(fCaloTriggerSetupOut);
+    }
+    else {
+      fInitialized = kFALSE;
+      AliFatal(Form("%s: Container with same name %s already present. Aborting", GetName(), fCaloTriggerSetupOutName.Data()));
+      return;
+    }
+  }
+
+}
+
+//________________________________________________________________________
+Bool_t AliEmcalTriggerMaker::Run() 
+{
+  // Create the emcal particles
+
+  Int_t globCol, globRow, tBits, cellAbsId[4];
+  Int_t absId, adcAmp;
+  Int_t i, j, k, iMain, cmCol, cmRow, cmiCellCol, cmiCellRow;
+  Int_t jetTrigger, iTriggers;
+  Double_t amp, ca, eMain, cmiCol, cmiRow;
+  
+  TVector3 centerGeo, center1, center2, centerMass, edge1, edge2, vertex;
+  
+  AliEmcalTriggerPatchInfo *trigger;
+
+  // delete patch array, clear setup object
+  fCaloTriggersOut->Delete();
+  fCaloTriggerSetupOut->Clean();
+
+  if( !fCaloTriggers ){
+    AliError(Form("Calo triggers container %s not available.", fCaloTriggersName.Data()));
+    return kTRUE;
+  }
+  if( !fCaloCells ){
+    AliError(Form("Calo cells container %s not available.", fCaloCellsName.Data()));
+    return kTRUE;
+  }
+  
+  // must reset before usage, or the class will fail 
+  fCaloTriggers->Reset();
+  
+  // dig out common data (thresholds)
+  // 0 - jet high, 1 - gamma high, 2 - jet low, 3 - gamma low
+  fCaloTriggerSetupOut->SetThresholds( fCaloTriggers->GetL1Threshold( 0 ),
+                                       fCaloTriggers->GetL1Threshold( 1 ),
+                                       fCaloTriggers->GetL1Threshold( 2 ),
+                                       fCaloTriggers->GetL1Threshold( 3 ));
+
+  // class is not empty
+  if( fCaloTriggers->GetEntries() > 0 ){
+    iTriggers = 0;
+    iMain = -1;
+    eMain = -1;
+
+    // save primary vertex in vector
+    vertex.SetXYZ( fVertex[0], fVertex[1], fVertex[2] );
+
+    // go throuth the trigger channels
+    while( fCaloTriggers->Next() ){
+      
+      // check if jet trigger low or high
+      fCaloTriggers->GetTriggerBits( tBits );
+      
+      jetTrigger = 0;
+      if(( tBits >> ( kTriggerTypeEnd + kL1JetLow )) & 1 )
+        jetTrigger = 1;
+      if(( tBits >> ( kTriggerTypeEnd + kL1JetHigh )) & 1)
+        jetTrigger = jetTrigger | 2;
+      
+      if( jetTrigger == 0 )
+        continue;
+      
+      // get position in global 2x2 tower coordinates
+      // A0 left bottom (0,0)
+      fCaloTriggers->GetPosition( globCol, globRow );
+
+      // get the absolute trigger ID
+      fGeom->GetAbsFastORIndexFromPositionInEMCAL( globCol, globRow, absId );
+      // convert to the 4 absId of the cells composing the trigger channel
+      fGeom->GetCellIndexFromFastORIndex( absId, cellAbsId );
+      
+      // get low left edge (eta max, phi min)
+      fGeom->GetGlobal( cellAbsId[0], edge1 );
+      
+      // sum the available energy in the 32/32 window of cells
+      // step over trigger channels and get all the corresponding cells
+      // make CM
+      amp = 0;
+      cmiCol = 0;
+      cmiRow = 0;
+      for( i = 0; i < 16; i++ ){
+        for( j = 0; j < 16; j++ ){
+          // get the 4 cells composing the trigger channel
+          fGeom->GetAbsFastORIndexFromPositionInEMCAL( globCol+i, globRow+j, absId );
+          fGeom->GetCellIndexFromFastORIndex( absId, cellAbsId );
+          // add amplitudes and find patch edges
+          for( k = 0; k < 4; k++ ){
+            ca = fCaloCells->GetCellAmplitude( cellAbsId[k] );
+            amp += ca;
+            cmiCol += ca*(Double_t)i;
+            cmiRow += ca*(Double_t)j;
+          }
+        }
+      } // 32x32 cell window
+      if( amp == 0 ){
+        AliDebug(2,"EMCal trigger patch with 0 energy.");
+        continue;
+      }
+      
+      // get the CM and patch index
+      cmiCol /= amp;
+      cmiRow /= amp;
+      cmCol = globCol + (Int_t)cmiCol;
+      cmRow = globRow + (Int_t)cmiRow;
+
+      // get the patch and corresponding cells
+      fGeom->GetAbsFastORIndexFromPositionInEMCAL( cmCol, cmRow, absId );
+      fGeom->GetCellIndexFromFastORIndex( absId, cellAbsId );
+
+      // find which out of the 4 cells is closest to CM and get it's position
+      cmiCellCol = TMath::Nint( cmiCol * 2. );
+      cmiCellRow = TMath::Nint( cmiRow * 2. );
+      fGeom->GetGlobal( cellAbsId[(cmiCellRow%2)*2 + cmiCellCol%2], centerMass );
+      
+      // get up right edge (eta min, phi max)
+      // get the absolute trigger ID
+      fGeom->GetAbsFastORIndexFromPositionInEMCAL( globCol+15, globRow+15, absId );
+      // convert to the 4 absId of the cells composing the trigger channel
+      fGeom->GetCellIndexFromFastORIndex( absId, cellAbsId );
+
+      fGeom->GetGlobal( cellAbsId[3], edge2 );
+      
+      // get the geometrical center as an average of two diagonally
+      // adjacent patches in the center
+      // picking two diagonally closest cells from the patches
+      fGeom->GetAbsFastORIndexFromPositionInEMCAL( globCol+7, globRow+7, absId );
+      fGeom->GetCellIndexFromFastORIndex( absId, cellAbsId );
+      fGeom->GetGlobal( cellAbsId[3], center1 );
+      
+      fGeom->GetAbsFastORIndexFromPositionInEMCAL( globCol+8, globRow+8, absId );
+      fGeom->GetCellIndexFromFastORIndex( absId, cellAbsId );
+      fGeom->GetGlobal( cellAbsId[0], center2 );
+      
+      centerGeo = center1;
+      centerGeo += center2;
+      centerGeo *= 0.5;
+      
+      // relate all to primary vertex
+      centerGeo -= vertex;
+      centerMass -= vertex;
+      edge1 -= vertex;
+      edge2 -= vertex;
+    
+      // get ADC amplitude
+      fCaloTriggers->GetL1TimeSum( adcAmp );
+
+      // save the trigger object
+      new ((*fCaloTriggersOut)[iTriggers])AliEmcalTriggerPatchInfo();
+      trigger = (AliEmcalTriggerPatchInfo*)fCaloTriggersOut->At( iTriggers );
+      iTriggers++;
+      
+      trigger->SetCenterGeo( centerGeo, amp );
+      trigger->SetCenterMass( centerMass, amp );
+      trigger->SetEdge1( edge1, amp );
+      trigger->SetEdge2( edge2, amp );
+      trigger->SetADCAmp( adcAmp );
+      trigger->SetTriggerBits( tBits );
+      
+      // check if more energetic than others for main patch marking
+      if( eMain < amp ){
+        eMain = amp;
+        iMain = iTriggers - 1;
+      }
+      
+//       cout << " pi:" << trigger->GetPhiMin() << " px:" << trigger->GetPhiMax();
+//       cout << " pg:" << trigger->GetPhiGeo() << " " << (trigger->GetPhiMin()+trigger->GetPhiMax()) / 2.;
+//       cout << " pc:" << trigger->GetPhiCM();
+//       cout << " ei:" << trigger->GetEtaMin() << " ex:" << trigger->GetEtaMax();
+//       cout << " eg:" << trigger->GetEtaGeo() << " " << (trigger->GetEtaMin()+trigger->GetEtaMax()) / 2.;
+//       cout << " ec:" << trigger->GetEtaCM();
+//       cout << " e:" << trigger->GetPatchE();
+//       cout << " jl:" << trigger->IsJetLow() << " jh:" << trigger->IsJetHigh() << endl;
+      
+    } // triggers
+    
+    // mark the most energetic patch as main
+    if( iMain > -1 ){
+      trigger = (AliEmcalTriggerPatchInfo*)fCaloTriggersOut->At( iMain );
+      tBits = trigger->GetTriggerBits();
+      // main trigger flag
+      tBits = tBits | ( 1 << 24 );
+      trigger->SetTriggerBits( tBits );
+    }
+    
+  } // there are some triggers
+
+  return kTRUE;
+}
diff --git a/PWG/EMCAL/AliEmcalTriggerMaker.h b/PWG/EMCAL/AliEmcalTriggerMaker.h
new file mode 100644 (file)
index 0000000..2a49027
--- /dev/null
@@ -0,0 +1,35 @@
+#ifndef ALIEMCALTRIGGERMAKER_H
+#define ALIEMCALTRIGGERMAKER_H
+
+// $Id$
+
+class TClonesArray;
+class AliEmcalTriggerSetupInfo;
+
+#include "AliAnalysisTaskEmcal.h"
+
+class AliEmcalTriggerMaker : public AliAnalysisTaskEmcal {
+ public:
+  AliEmcalTriggerMaker();
+  AliEmcalTriggerMaker(const char *name);
+  virtual ~AliEmcalTriggerMaker();
+
+  void ExecOnce();
+  Bool_t Run();
+
+  void SetCaloTriggersOutName(const char *name) { fCaloTriggersOutName      = name; }
+  void SetCaloTriggerSetupOutName(const char *name) { fCaloTriggerSetupOutName      = name; }
+
+ protected:  
+  TString            fCaloTriggersOutName;    // name of output track array
+  TString            fCaloTriggerSetupOutName;    // name of output track array
+  TClonesArray      *fCaloTriggersOut;        //!trigger array out
+  AliEmcalTriggerSetupInfo  *fCaloTriggerSetupOut;        //!trigger setup
+
+ private:
+  AliEmcalTriggerMaker(const AliEmcalTriggerMaker&);            // not implemented
+  AliEmcalTriggerMaker &operator=(const AliEmcalTriggerMaker&); // not implemented
+
+  ClassDef(AliEmcalTriggerMaker, 1); // Task to make array of EMCAL particle
+};
+#endif
diff --git a/PWG/EMCAL/AliEmcalTriggerPatchInfo.cxx b/PWG/EMCAL/AliEmcalTriggerPatchInfo.cxx
new file mode 100644 (file)
index 0000000..9ee8d34
--- /dev/null
@@ -0,0 +1,68 @@
+// $Id$
+//
+// Emcal particle trigger class, which can contain either
+//
+// Author: J.Kral
+
+#include "AliEmcalTriggerPatchInfo.h"
+#include "AliLog.h"
+
+//_________________________________________________________________________________________________
+AliEmcalTriggerPatchInfo::AliEmcalTriggerPatchInfo() :
+  TObject(),
+  fCenterGeo(),
+  fCenterMass(),
+  fEdge1(),
+  fEdge2(),
+  fADCAmp(-1),
+  fTriggerBits(0)
+{
+  // Default constructor.
+  
+}
+
+  
+//_________________________________________________________________________________________________
+AliEmcalTriggerPatchInfo::AliEmcalTriggerPatchInfo(const AliEmcalTriggerPatchInfo &p) :
+  TObject(p),
+  fCenterGeo(p.fCenterGeo),
+  fCenterMass(p.fCenterMass),
+  fEdge1(p.fEdge1),
+  fEdge2(p.fEdge2),
+  fADCAmp(p.fADCAmp),
+  fTriggerBits(p.fTriggerBits)
+{
+  // Copy constructor.
+}
+
+//_________________________________________________________________________________________________
+AliEmcalTriggerPatchInfo::~AliEmcalTriggerPatchInfo()
+{
+  // Destructor.
+}
+
+//_________________________________________________________________________________________________
+AliEmcalTriggerPatchInfo &AliEmcalTriggerPatchInfo::operator=(const AliEmcalTriggerPatchInfo &p)
+{
+  // Assignment operator.
+
+  if (this != &p) {
+    fCenterGeo = p.fCenterGeo;
+    fCenterMass = p.fCenterMass;
+    fEdge1 = p.fEdge1;
+    fEdge2 = p.fEdge2;
+    fADCAmp = p.fADCAmp;
+    fTriggerBits = p.fTriggerBits;
+  }
+
+  return *this;
+}
+
+//_________________________________________________________________________________________________
+void AliEmcalTriggerPatchInfo::SetLorentzVector( TLorentzVector &lv, TVector3 &v, Double_t e ){
+  // sets the vector
+  Double_t r = TMath::Sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2] ) ; 
+  
+  lv.SetPxPyPzE( e*v[0]/r,  e*v[1]/r,  e*v[2]/r,  e) ;   
+}
+
diff --git a/PWG/EMCAL/AliEmcalTriggerPatchInfo.h b/PWG/EMCAL/AliEmcalTriggerPatchInfo.h
new file mode 100644 (file)
index 0000000..ced92f1
--- /dev/null
@@ -0,0 +1,65 @@
+#ifndef ALIEMCALTRIGGERPATCHINFO_H
+#define ALIEMCALTRIGGERPATCHINFO_H
+
+// $Id$
+
+#include "TObject.h"
+
+#include <TLorentzVector.h>
+#include <TMath.h>
+#include "AliEMCALTriggerTypes.h"
+#include "AliEmcalTriggerSetupInfo.h"
+
+class AliEmcalTriggerPatchInfo: public TObject {
+ public:
+  AliEmcalTriggerPatchInfo();
+  AliEmcalTriggerPatchInfo(const AliEmcalTriggerPatchInfo &p); 
+  AliEmcalTriggerPatchInfo &operator=(const AliEmcalTriggerPatchInfo &p);
+  virtual ~AliEmcalTriggerPatchInfo();
+
+
+  Double_t GetPhiGeo() const { return fCenterGeo.Phi(); }
+  Double_t GetPhiCM()  const { return fCenterMass.Phi(); }
+  Double_t GetPhiMin() const { return fEdge1.Phi(); }
+  Double_t GetPhiMax() const { return fEdge2.Phi(); }
+  Double_t GetEtaGeo() const { return fCenterGeo.Eta(); }
+  Double_t GetEtaCM()  const { return fCenterMass.Eta(); }
+  Double_t GetEtaMin() const { return fEdge2.Eta(); }
+  Double_t GetEtaMax() const { return fEdge1.Eta(); }
+  Double_t GetPatchE() const { return fCenterGeo.E(); }
+  Int_t    GetADCAmp() const { return fADCAmp; }
+  Double_t GetADCAmpGeVRough() const { return (Double_t)fADCAmp * kEMCL1ADCtoGeV; }
+  Int_t    GetTriggerBits() const { return fTriggerBits; }
+  
+  Bool_t   IsJetLow() const { return (Bool_t)((fTriggerBits >> (kTriggerTypeEnd + kL1JetLow))&1); }
+  Bool_t   IsJetHigh() const { return (Bool_t)((fTriggerBits >> (kTriggerTypeEnd + kL1JetHigh))&1); }
+  Bool_t   IsMainTrigger() const { return (Bool_t)((fTriggerBits >> 24)&1); }
+  
+  void SetCenterGeo( TVector3 &v, Double_t e ) { SetLorentzVector( fCenterGeo, v, e ); }
+  void SetCenterGeo( TLorentzVector &v ) { fCenterGeo = v; }
+  void SetCenterMass( TLorentzVector &v ) { fCenterMass = v; }
+  void SetCenterMass( TVector3 &v, Double_t e ) { SetLorentzVector( fCenterMass, v, e ); }
+  void SetEdge1( TLorentzVector &v ) { fEdge1 = v; }
+  void SetEdge1( TVector3 &v, Double_t e ) { SetLorentzVector( fEdge1, v, e ); }
+  void SetEdge2( TLorentzVector &v ) { fEdge2 = v; }
+  void SetEdge2( TVector3 &v, Double_t e ) { SetLorentzVector( fEdge2, v, e ); }
+  void SetADCAmp( Int_t a ) { fADCAmp = a; }
+
+  void SetLorentzVector( TLorentzVector &lv, TVector3 &v, Double_t e );
+
+  void SetTriggerBits( Int_t i ) { fTriggerBits = i; }
+
+
+ protected:
+  TLorentzVector   &GetLorentzVector(const Double_t *vertex = 0)  const;
+
+  TLorentzVector    fCenterGeo;                     // geometrical center
+  TLorentzVector    fCenterMass;                    // CM
+  TLorentzVector    fEdge1;                         // max eta/ min phi edge
+  TLorentzVector    fEdge2;                         // min eta/ max phi edge
+  Int_t             fADCAmp;                        // online ADC amplitude
+  Int_t             fTriggerBits;                   //trigger bit mask
+
+  ClassDef(AliEmcalTriggerPatchInfo, 1) // Emcal particle class
+};
+#endif
diff --git a/PWG/EMCAL/AliEmcalTriggerSetupInfo.cxx b/PWG/EMCAL/AliEmcalTriggerSetupInfo.cxx
new file mode 100644 (file)
index 0000000..522ef9b
--- /dev/null
@@ -0,0 +1,55 @@
+// $Id$
+//
+// Emcal particle trigger class, which can contain either
+//
+// Author: J.Kral
+
+#include "AliEmcalTriggerSetupInfo.h"
+#include "AliLog.h"
+
+//_________________________________________________________________________________________________
+AliEmcalTriggerSetupInfo::AliEmcalTriggerSetupInfo() :
+  TNamed(),
+  fThresholds()
+{
+  // Default constructor.
+  for( int i = 0; i < 4; i++ )
+    fThresholds[i] = -1;
+}
+
+  
+//_________________________________________________________________________________________________
+AliEmcalTriggerSetupInfo::AliEmcalTriggerSetupInfo(const AliEmcalTriggerSetupInfo &p) :
+  TNamed(p)
+{
+  // Copy constructor.
+  for( int i = 0; i < 4; i++ )
+    fThresholds[i] = p.fThresholds[i];
+}
+
+//_________________________________________________________________________________________________
+AliEmcalTriggerSetupInfo::~AliEmcalTriggerSetupInfo()
+{
+  // Destructor.
+}
+
+//_________________________________________________________________________________________________
+AliEmcalTriggerSetupInfo &AliEmcalTriggerSetupInfo::operator=(const AliEmcalTriggerSetupInfo &p)
+{
+  // Assignment operator.
+
+  if (this != &p) {
+    for( int i = 0; i < 4; i++ )
+      fThresholds[i] = p.fThresholds[i];
+  }
+
+  return *this;
+}
+
+//_________________________________________________________________________________________________
+void AliEmcalTriggerSetupInfo::Clean(){
+  // cleaner
+  for( int i = 0; i < 4; i++ )
+    fThresholds[i] = -1;
+}
+
diff --git a/PWG/EMCAL/AliEmcalTriggerSetupInfo.h b/PWG/EMCAL/AliEmcalTriggerSetupInfo.h
new file mode 100644 (file)
index 0000000..494e62d
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef ALIEMCALTRIGGERSETUPINFO_H
+#define ALIEMCALTRIGGERSETUPINFO_H
+
+// $Id$
+
+#include "TNamed.h"
+
+static const Double_t kEMCL1ADCtoGeV = 0.07874;
+
+class AliEmcalTriggerSetupInfo: public TNamed {
+ public:
+  AliEmcalTriggerSetupInfo();
+  AliEmcalTriggerSetupInfo(const AliEmcalTriggerSetupInfo &p); 
+  AliEmcalTriggerSetupInfo &operator=(const AliEmcalTriggerSetupInfo &p);
+  virtual ~AliEmcalTriggerSetupInfo();
+
+  Int_t GetThresholdJetLow() const { return fThresholds[2]; }
+  Int_t GetThresholdJetHigh() const { return fThresholds[0]; }
+  
+   Double_t GetThresholdGeVRoughJetLow() const { return ((Double_t)fThresholds[2])*kEMCL1ADCtoGeV; }
+   Double_t GetThresholdGeVRoughJetHigh() const { return ((Double_t)fThresholds[0])*kEMCL1ADCtoGeV; }
+  
+  void SetThresholds( Int_t i0, Int_t i1, Int_t i2, Int_t i3 ) {
+            fThresholds[0] = i0; fThresholds[1] = i1; fThresholds[2] = i2; fThresholds[3] = i3;}
+            
+  void Clean();
+
+
+ protected:
+  Int_t             fThresholds[4];                 // per event L1 online thresholds in ADC counts
+
+  ClassDef(AliEmcalTriggerSetupInfo, 1) // Emcal trigger setup class
+};
+#endif
diff --git a/PWG/EMCAL/macros/AddTaskEmcalTriggerMaker.C b/PWG/EMCAL/macros/AddTaskEmcalTriggerMaker.C
new file mode 100644 (file)
index 0000000..9681135
--- /dev/null
@@ -0,0 +1,74 @@
+// $Id$
+
+AliEmcalTriggerMaker* AddTaskEmcalTriggerMaker(
+  const char *triggersOutName     = "EmcalTriggers",
+  const char *triggerSetupOutName = "EmcalTriggerSetup",
+  const char *cellsName           = 0,
+  const char *triggersName        = 0,
+  const char *taskName            = "AliEmcalTriggerMaker"
+)
+{  
+  // Get the pointer to the existing analysis manager via the static access method.
+  //==============================================================================
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr)
+  {
+    ::Error("AddTaskEmcalTriggerMaker", "No analysis manager to connect to.");
+    return NULL;
+  }  
+  
+  // Check the analysis type using the event handlers connected to the analysis manager.
+  //==============================================================================
+  AliVEventHandler *evhand = mgr->GetInputEventHandler();
+  if (!evhand) {
+    ::Error("AddTaskEmcalTriggerMaker", "This task requires an input event handler");
+    return NULL;
+  }
+
+  if (!triggersName) {
+    triggersName = new char[100];
+
+    if (evhand->InheritsFrom("AliESDInputHandler")) {
+      strcpy(triggersName,"EMCALTrigger");
+      ::Info("AddTaskEmcalTriggerMaker", Form( "ESD analysis, triggersName = \"%s\"", triggersName ));
+    }
+    else {
+      strcpy(triggersName,"emcalTrigger");
+      ::Info("AddTaskEmcalTriggerMaker", Form( "AOD analysis, triggersName = \"%s\"", triggersName ));
+    }
+  }
+  if (!cellsName) {
+    cellsName = new char[100];
+
+    if (evhand->InheritsFrom("AliESDInputHandler")) {
+      strcpy(cellsName,"EMCALCells");
+      ::Info("AddTaskEmcalTriggerMaker", Form( "ESD analysis, cellsName = \"%s\"", cellsName ));
+    }
+    else {
+      strcpy(cellsName,"emcalCells");
+      ::Info("AddTaskEmcalTriggerMaker", Form( "AOD analysis, cellsName = \"%s\"", cellsName ));
+    }
+  }
+   //-------------------------------------------------------
+  // Init the task and do settings
+  //-------------------------------------------------------
+
+  AliEmcalTriggerMaker *eTask = new AliEmcalTriggerMaker(taskName);
+  eTask->SetCaloTriggersName(triggersName);
+  eTask->SetCaloTriggersOutName(triggersOutName);
+  eTask->SetCaloTriggerSetupOutName(triggerSetupOutName);
+  eTask->SetCaloCellsName(cellsName);
+  eTask->SetAnaType(AliAnalysisTaskEmcal::kEMCAL);
+
+  //-------------------------------------------------------
+  // Final settings, pass to manager and set the containers
+  //-------------------------------------------------------
+  mgr->AddTask(eTask);
+  
+  // Create containers for input/output
+  AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer();
+  mgr->ConnectInput  (eTask, 0,  cinput1 );
+  
+  return eTask;
+}
index c67d365a62d1fbb3fdfd4a8a026bc657ff74eb0c..08c96e3ff1b4efe10031154c14e5c5b1afc3a565 100644 (file)
@@ -26,6 +26,9 @@
 #pragma link C++ class AliEsdTrackExt+;
 #pragma link C++ class AliParticleContainer+;
 #pragma link C++ class AliPicoTrack+;
+#pragma link C++ class AliEmcalTriggerSetupInfo+;
+#pragma link C++ class AliEmcalTriggerPatchInfo+;
+#pragma link C++ class AliEmcalTriggerMaker+;
 
 #endif