]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
More refactoring of the task
authormfasel <mfasel@lbl.gov>
Wed, 10 Dec 2014 02:41:23 +0000 (18:41 -0800)
committermfasel <mfasel@lbl.gov>
Fri, 12 Dec 2014 01:12:32 +0000 (17:12 -0800)
========================================================
- Create analysis components for single track and single cluster
  analysis.
- Create a class storing storing the trigger decision based on trigger
  strings and based on found clusters, and propagate it to the analysis
components
- Create helper function for the axis definition in the base analysis
  component.
- Make adaptions in the steering analysis task.

16 files changed:
PWGJE/CMakelibPWGJEEMCALJetTasks.pkg
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskPtEMCalTriggerV1.cxx
PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerAnaTriggerDecision.cxx [new file with mode: 0644]
PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerAnaTriggerDecision.h [new file with mode: 0644]
PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerBinningComponent.cxx
PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerClusterAnalysisComponent.cxx [new file with mode: 0644]
PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerClusterAnalysisComponent.h [new file with mode: 0644]
PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerMCParticleAnalysisComponent.cxx
PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerMCParticleAnalysisComponent.h
PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerRecTrackAnalysisComponent.cxx [new file with mode: 0644]
PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerRecTrackAnalysisComponent.h [new file with mode: 0644]
PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerTaskGroup.cxx
PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerTaskGroup.h
PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerTracksAnalysisComponent.cxx
PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerTracksAnalysisComponent.h
PWGJE/PWGJEEMCALJetTasksLinkDef.h

index d82ef978e9647b377601a203b2cbc244cc259d6c..56118806b24f4a93c26f5c5e002971e6bf9720bd 100644 (file)
@@ -106,10 +106,13 @@ set ( SRCS
  EMCALJetTasks/UserTasks/AliEMCalTriggerEventSelection.cxx
  EMCALJetTasks/UserTasks/AliEMCalTriggerTaskGroup.cxx
  EMCALJetTasks/UserTasks/AliEMCalTriggerTracksAnalysisComponent.cxx
- EMCALJetTasks/UserTasks/AliEMCALTriggerMCParticleAnalysisComponent.cxx
+ EMCALJetTasks/UserTasks/AliEMCalTriggerMCParticleAnalysisComponent.cxx
+ EMCALJetTasks/UserTasks/AliEMCalTriggerClusterAnalysisComponent.cxx
+ EMCALJetTasks/UserTasks/AliEMCalTriggerRecTrackAnalysisComponent.cxx
  EMCALJetTasks/UserTasks/AliEMCalTriggerBinningComponent.cxx
  EMCALJetTasks/UserTasks/AliEMCalTriggerBinningFactory.cxx
  EMCALJetTasks/UserTasks/AliEMCalTriggerKineCuts.cxx
+ EMCALJetTasks/UserTasks/AliEMCalTriggerAnaTriggerDecision.cxx
  EMCALJetTasks/UserTasks/AliAnalysisTaskPtEMCalTriggerV1.cxx
  EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalTriggerTreeWriter.cxx
 )
index 225d9050036ba28efb688bb41493808ec211c7ad..5131e467f0f0afa60cfb5cb5bdb9824dcb95f49f 100644 (file)
  */
 #include "AliJetContainer.h"
 #include "AliParticleContainer.h"
+#include "AliInputEventHandler.h"
+#include "AliVEvent.h"
+
+#include "AliEMCalTriggerAnaTriggerDecision.h"
 #include "AliEMCalTriggerBinningComponent.h"
 #include "AliEMCalTriggerBinningFactory.h"
 #include "AliEMCalTriggerEventData.h"
 #include "AliEMCalTriggerTaskGroup.h"
 #include "AliAnalysisTaskPtEMCalTriggerV1.h"
-#include "AliVEvent.h"
 
 ClassImp(EMCalTriggerPtAnalysis::AliAnalysisTaskPtEMCalTriggerV1)
 
@@ -106,10 +109,15 @@ Bool_t AliAnalysisTaskPtEMCalTriggerV1::Run() {
    * 2nd loop over task groups and run them
    */
   AliEMCalTriggerEventData *event = BuildEvent();
+  AliEMCalTriggerAnaTriggerDecision triggerDecision;
+  triggerDecision.Create(event);
+  triggerDecision.SetIsMinBias(fInputHandler->IsEventSelected() & AliVEvent::kINT7);
   TIter groupIter(fTaskGroups);
   AliEMCalTriggerTaskGroup *mygroup(NULL);
-  while((mygroup = dynamic_cast<AliEMCalTriggerTaskGroup *>(groupIter())))
+  while((mygroup = dynamic_cast<AliEMCalTriggerTaskGroup *>(groupIter()))){
+    mygroup->SetTriggerDecision(&triggerDecision);
     mygroup->Process(event);
+  }
 
   delete event;
 
diff --git a/PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerAnaTriggerDecision.cxx b/PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerAnaTriggerDecision.cxx
new file mode 100644 (file)
index 0000000..71e924c
--- /dev/null
@@ -0,0 +1,76 @@
+#include <TClonesArray.h>
+#include <TString.h>
+
+#include "AliVEvent.h"
+
+#include "AliEmcalTriggerPatchInfo.h"
+#include "AliEMCalTriggerAnaTriggerDecision.h"
+#include "AliEMCalTriggerEventData.h"
+
+ClassImp(EMCalTriggerPtAnalysis::AliEMCalTriggerAnaTriggerDecision)
+
+namespace EMCalTriggerPtAnalysis {
+
+//______________________________________________________________________________
+AliEMCalTriggerAnaTriggerDecision::AliEMCalTriggerAnaTriggerDecision() :
+    fSwapThresholds(kFALSE),
+    fIsMinBias(kFALSE)
+{
+  /*
+   * Main constructor
+   */
+  Reset();
+}
+
+//______________________________________________________________________________
+void AliEMCalTriggerAnaTriggerDecision::Create(const AliEMCalTriggerEventData* const data) {
+  /*
+   * Steer creation of the trigger decision
+   *
+   * @param data: all event information
+   */
+  Reset();
+  MakeDecisionFromPatches(*(data->GetTriggerPatchContainer()));
+  MakeDecisionFromString(data->GetRecEvent()->GetFiredTriggerClasses());
+}
+
+//______________________________________________________________________________
+void AliEMCalTriggerAnaTriggerDecision::Reset() {
+  for(int itrg = 0; itrg < 4; itrg++){
+    fDecisionFromPatches[itrg] = kFALSE;
+    fDecisionFromString[itrg] = kFALSE;
+  }
+}
+
+//______________________________________________________________________________
+void AliEMCalTriggerAnaTriggerDecision::MakeDecisionFromString(const TString& triggerstring) {
+  /*
+   * Create trigger decision from trigger string
+   *
+   * @param triggerstring: the trigger string
+   */
+  if(triggerstring.Contains("EJ1")) fDecisionFromString[kTAEMCJHigh]  = kTRUE;
+  if(triggerstring.Contains("EJ2")) fDecisionFromString[kTAEMCJLow]   = kTRUE;
+  if(triggerstring.Contains("EG1")) fDecisionFromString[kTAEMCGHigh]  = kTRUE;
+  if(triggerstring.Contains("EG2")) fDecisionFromString[kTAEMCGLow]   = kTRUE;
+}
+
+//______________________________________________________________________________
+void AliEMCalTriggerAnaTriggerDecision::MakeDecisionFromPatches(const TClonesArray& listOfPatches) {
+  /*
+   * Create trigger decision from trigger patches. In case swap thresholds is requested, the low threshold
+   * triggers are replaced by the high threshold triggers and vice versa
+   *
+   * @param triggerstring: the TClonesArray of the trigger patches, created by the trigger patch maker
+   */
+  TIter patchIter(&listOfPatches);
+  AliEmcalTriggerPatchInfo *mypatch(NULL);
+  while((mypatch = dynamic_cast<AliEmcalTriggerPatchInfo *>(patchIter()))){
+    if(mypatch->IsJetHigh()) fDecisionFromPatches[fSwapThresholds ? kTAEMCJLow : kTAEMCJHigh] = kTRUE;
+    if(mypatch->IsJetLow()) fDecisionFromPatches[fSwapThresholds ? kTAEMCJHigh : kTAEMCJLow] = kTRUE;
+    if(mypatch->IsGammaHigh()) fDecisionFromPatches[fSwapThresholds ? kTAEMCGLow : kTAEMCGHigh] = kTRUE;
+    if(mypatch->IsGammaLow()) fDecisionFromPatches[fSwapThresholds ? kTAEMCGHigh : kTAEMCJLow] = kTRUE;
+  }
+}
+
+} /* namespace EMCalTriggerPtAnalysis */
diff --git a/PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerAnaTriggerDecision.h b/PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerAnaTriggerDecision.h
new file mode 100644 (file)
index 0000000..bf94de5
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef ALIEMCALTRIGGERANATRIGGERDECISION_H
+#define ALIEMCALTRIGGERANATRIGGERDECISION_H
+
+class TClonesArray;
+class TString;
+
+namespace EMCalTriggerPtAnalysis {
+
+class AliEMCalTriggerEventData;
+
+class AliEMCalTriggerAnaTriggerDecision : public TObject {
+public:
+  enum ETATriggerType{
+    kTAEMCJHigh       = 0,
+    kTAEMCJLow        = 1,
+    kTAEMCGHigh       = 2,
+    kTAEMCGLow        = 3
+  };
+  AliEMCalTriggerAnaTriggerDecision();
+  virtual ~AliEMCalTriggerAnaTriggerDecision(){}
+
+  void Create(const AliEMCalTriggerEventData * const data);
+  Bool_t IsTriggered(ETATriggerType trigger, Bool_t fromPatches = kFALSE) const {
+    if(fromPatches) return fDecisionFromPatches[trigger];
+    return fDecisionFromString[trigger];
+  }
+  void SetSwapThresholds(Bool_t doSwap = kTRUE) { fSwapThresholds = doSwap; }
+  void SetIsMinBias(Bool_t isMB = kTRUE) { fIsMinBias = isMB; }
+  void Reset();
+
+  Bool_t IsMinBias() const { return fIsMinBias; }
+
+protected:
+  void MakeDecisionFromString(const TString &triggerstring);
+  void MakeDecisionFromPatches(const TClonesArray &listOfPatches);
+
+  Bool_t fSwapThresholds;
+  Bool_t fIsMinBias;
+  Bool_t fDecisionFromPatches[4];
+  Bool_t fDecisionFromString[4];
+
+  ClassDef(AliEMCalTriggerAnaTriggerDecision, 1);     // EMCal trigger decision
+};
+
+} /* namespace EMCalTriggerPtAnalysis */
+
+#endif /* ALIEMCALTRIGGERANATRIGGERDECISION_H */
index c3255416a9e8f6d2c87939e80789d1479cfa0a4c..0e56854f5f2a56a799a8810e149cfb83af2d4998 100644 (file)
@@ -25,7 +25,7 @@ ClassImp(EMCalTriggerPtAnalysis::AliEMCalTriggerBinningComponent)
 
 namespace EMCalTriggerPtAnalysis {
 
-  //______________________________________________________________________________
+//______________________________________________________________________________
 AliEMCalTriggerBinningComponent::AliEMCalTriggerBinningComponent() :
   TObject(),
   fDimensions(NULL)
diff --git a/PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerClusterAnalysisComponent.cxx b/PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerClusterAnalysisComponent.cxx
new file mode 100644 (file)
index 0000000..9671948
--- /dev/null
@@ -0,0 +1,161 @@
+/**************************************************************************
+ * Copyright(c) 1998-2014, 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.                  *
+ **************************************************************************/
+/*
+ * Analysis component for EMCal clusters. Loops over calibrated and uncalibrated clusters
+ *
+ *   Author: Markus Fasel
+ */
+#include <map>
+#include <string>
+#include <vector>
+
+#include <TClonesArray.h>
+#include <TLorentzVector.h>
+
+#include "AliVCluster.h"
+#include "AliVEvent.h"
+
+#include "AliEMCalHistoContainer.h"
+#include "AliEMCalTriggerAnaTriggerDecision.h"
+#include "AliEMCalTriggerBinningComponent.h"
+#include "AliEMCalTriggerEventData.h"
+#include "AliEMCalTriggerClusterAnalysisComponent.h"
+
+ClassImp(EMCalTriggerPtAnalysis::AliEMCalTriggerClusterAnalysisComponent)
+
+namespace EMCalTriggerPtAnalysis {
+
+//______________________________________________________________________________
+AliEMCalTriggerClusterAnalysisComponent::AliEMCalTriggerClusterAnalysisComponent() :
+  AliEMCalTriggerTracksAnalysisComponent(),
+  fEnergyRange(),
+  fUsePatches(kFALSE)
+{
+  /*
+   * Dummy (I/O) constructor
+   */
+}
+
+//______________________________________________________________________________
+AliEMCalTriggerClusterAnalysisComponent::AliEMCalTriggerClusterAnalysisComponent(const char* name) :
+  AliEMCalTriggerTracksAnalysisComponent(name),
+  fEnergyRange(),
+  fUsePatches(kFALSE)
+{
+  /*
+   * Main constructor
+   */
+  fEnergyRange.SetLimits(0., 1000.);
+}
+
+//______________________________________________________________________________
+void AliEMCalTriggerClusterAnalysisComponent::CreateHistos() {
+  /*
+   * Create histos for clusters in different event categories
+   */
+  AliEMCalTriggerTracksAnalysisComponent::CreateHistos();
+
+  // Create trigger definitions
+  std::map<std::string, std::string> triggerCombinations;
+  const char *triggernames[12] = {"MinBias", "EMCJHigh", "EMCJLow", "EMCGHigh",
+      "EMCGLow", "NoEMCal", "EMCHighBoth", "EMCHighGammaOnly", "EMCHighJetOnly",
+      "EMCLowBoth", "EMCLowGammaOnly", "EMCLowJetOnly"};
+  // Define names and titles for different triggers in the histogram container
+  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[0], "min. bias events"));
+  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[1], "jet-triggered events (high threshold)"));
+  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[2], "jet-triggered events (low threshold)"));
+  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[3], "gamma-triggered events (high threshold)"));
+  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[4], "gamma-triggered events (low threshold)"));
+  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[5], "non-EMCal-triggered events"));
+  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[6], "jet and gamma triggered events (high threshold)"));
+  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[7], "exclusively gamma-triggered events (high threshold)"));
+  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[8], "exclusively jet-triggered events (high threshold)"));
+  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[9], "jet and gamma triggered events (low threshold)"));
+  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[10], "exclusively gamma-triggered events (low threshold)"));
+  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[11], "exclusively-triggered events (low threshold)"));
+
+  // Create axis definitions
+  const AliEMCalTriggerBinningDimension *ptbinning = fBinning->GetBinning("pt"),
+      *etabinning = fBinning->GetBinning("eta"),
+      *phibinning = fBinning->GetBinning("phi"),
+      *vertexbinning = fBinning->GetBinning("vertex");
+
+  const TAxis *clusteraxes[5] = {
+      DefineAxis("energy", ptbinning),
+      DefineAxis("eta", etabinning),
+      DefineAxis("phi", phibinning),
+      DefineAxis("zvertex", vertexbinning),
+      DefineAxis("mbtrigger", 2, -0.5, 1.5)
+  };
+
+  // Build histograms
+  for(std::map<std::string,std::string>::iterator it = triggerCombinations.begin(); it != triggerCombinations.end(); ++it){
+    const std::string name = it->first, &title = it->second;
+    fHistos->CreateTHnSparse(Form("hClusterCalibHist%s", name.c_str()), Form("Calib. cluster-based histogram for %s events", title.c_str()), 5, clusteraxes, "s");
+    fHistos->CreateTHnSparse(Form("hClusterUncalibHist%s", name.c_str()), Form("Uncalib. cluster-based histogram for %s events", title.c_str()), 5, clusteraxes, "s");
+  }
+
+  for(int iaxis = 0; iaxis < 5; iaxis++) delete clusteraxes[iaxis];
+}
+
+//______________________________________________________________________________
+void AliEMCalTriggerClusterAnalysisComponent::Process(const AliEMCalTriggerEventData* const data) {
+  /*
+   * Run loop over calibrated and uncalibrated clusters
+   */
+
+  // First loop over uncalibrated clusters
+  AliVCluster *clust(NULL);
+  AliVEvent *recEv = data->GetRecEvent();
+  std::vector<std::string> triggerNames;
+  this->GetMachingTriggerNames(triggerNames, fUsePatches);
+  for(int iclust = 0; iclust < recEv->GetNumberOfCaloClusters(); iclust++){
+    clust = recEv->GetCaloCluster(iclust);
+    if(!clust->IsEMCAL()) continue;
+    if(!fEnergyRange.IsInRange(clust->E())) continue;
+    for(std::vector<std::string>::iterator name = triggerNames.begin(); name != triggerNames.end(); ++name)
+      FillHistogram(Form("hClusterUncalibHist%s", name->c_str()), clust, recEv, fTriggerDecision->IsMinBias());
+  }
+
+  // Loop also over calibrated clusters
+  TIter clusterIter(data->GetClusterContainer());
+  while((clust = dynamic_cast<AliVCluster *>(clusterIter()))){
+    if(!clust->IsEMCAL()) continue;
+    if(!fEnergyRange.IsInRange(clust->E())) continue;
+    for(std::vector<std::string>::iterator name = triggerNames.begin(); name != triggerNames.end(); ++name)
+      FillHistogram(Form("hClusterUncalibHist%s", name->c_str()), clust, recEv, fTriggerDecision->IsMinBias());
+  }
+}
+
+//______________________________________________________________________________
+void AliEMCalTriggerClusterAnalysisComponent::FillHistogram(const TString& histname, const AliVCluster* clust, AliVEvent *ev, Bool_t inMB) {
+  /*
+   * Fill Histogram for cluster
+   *
+   * @param histname: the histogram to fill
+   * @param clust: the cluster analysed
+   * @param event: reconstructed event information
+   * @param inMB: true if event fulfills min bias condition
+   */
+  TLorentzVector vec;
+  double xyz[3];
+  ev->GetPrimaryVertex()->GetXYZ(xyz);
+  clust->GetMomentum(vec, xyz);
+  double infs[5] = {clust->E(), vec.Eta(), vec.Phi(), xyz[2], inMB ? 1. : 0.};
+  fHistos->FillTHnSparse(histname.Data(), infs);
+}
+
+
+} /* namespace EMCalTriggerPtAnalysis */
diff --git a/PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerClusterAnalysisComponent.h b/PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerClusterAnalysisComponent.h
new file mode 100644 (file)
index 0000000..52aa337
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef ALIEMCALTRIGGERCLUSTERANALYSISCOMPONENT_H
+#define ALIEMCALTRIGGERCLUSTERANALYSISCOMPONENT_H
+/* Copyright(c) 1998-2014, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+// Author: Markus Fasel
+
+#include "AliCutValueRange.h"
+#include "AliEMCalTriggerTracksAnalysisComponent.h"
+
+class TString;
+class AliVCluster;
+class AliVEvent;
+
+namespace EMCalTriggerPtAnalysis {
+
+class AliEMCalTriggerEventData;
+
+class AliEMCalTriggerClusterAnalysisComponent : public AliEMCalTriggerTracksAnalysisComponent {
+public:
+  AliEMCalTriggerClusterAnalysisComponent();
+  AliEMCalTriggerClusterAnalysisComponent(const char *name);
+  virtual ~AliEMCalTriggerClusterAnalysisComponent() {}
+
+  virtual void CreateHistos();
+  virtual void Process(const AliEMCalTriggerEventData * const data);
+
+  void SetUsePatches(Bool_t usePatches = kTRUE) { fUsePatches = usePatches; }
+  void SetEnergyRange(double min, double max) { fEnergyRange.SetLimits(min, max); }
+
+protected:
+  void FillHistogram(const TString &histname, const AliVCluster *clust, AliVEvent *ev, Bool_t inMB);
+
+  AliCutValueRange<double>    fEnergyRange;
+  Bool_t                      fUsePatches;
+
+  ClassDef(AliEMCalTriggerClusterAnalysisComponent, 1);       // Analysis component for EMCal cluster
+};
+
+} /* namespace EMCalTriggerPtAnalysis */
+
+#endif /* ALIEMCALTRIGGERCLUSTERANALYSISCOMPONENT_H */
index 0295c48467b0e8cabe4e94e938eacac48237b9f6..52d0201a43ad184367a8eaf5902cb5ad3d809a0a 100644 (file)
@@ -94,18 +94,4 @@ void AliEMCalTriggerMCParticleAnalysisComponent::Process(const AliEMCalTriggerEv
   }
 }
 
-//______________________________________________________________________________
-TAxis* AliEMCalTriggerMCParticleAnalysisComponent::DefineAxis(const char* name, const AliEMCalTriggerBinningDimension* binning) {
-  /*
-   * Create and define axis
-   *
-   * @param name: Name of the axis
-   * @param binning: binning information
-   * @return: the new axis
-   */
-  TAxis *result = new TAxis(binning->GetNumberOfBins(), binning->GetBinLimits());
-  result->SetName(name);
-  return result;
-}
-
 } /* namespace EMCalTriggerPtAnalysis */
index 65acef6874d7c6867f2d939ae657cf20264f6fcb..6a909814d75ec717ce42f7840ffbb162baebf72c 100644 (file)
@@ -24,7 +24,6 @@ public:
   virtual void Process(const AliEMCalTriggerEventData * const data);
 
 protected:
-  TAxis *DefineAxis(const char *name, const AliEMCalTriggerBinningDimension *binning);
 
   ClassDef(AliEMCalTriggerMCParticleAnalysisComponent, 1);
 };
diff --git a/PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerRecTrackAnalysisComponent.cxx b/PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerRecTrackAnalysisComponent.cxx
new file mode 100644 (file)
index 0000000..79635b5
--- /dev/null
@@ -0,0 +1,211 @@
+/**************************************************************************
+ * Copyright(c) 1998-2014, 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.                  *
+ **************************************************************************/
+/*
+ * Track analysis component: Loops over tracks from the EMCal track container and
+ * counts the tracks in histograms
+ *
+ *   Author: Markus Fasel
+ */
+#include <map>
+#include <string>
+#include <vector>
+
+#include <TClonesArray.h>
+#include <TMath.h>
+#include <TString.h>
+
+#include "AliMCEvent.h"
+#include "AliVCluster.h"
+#include "AliVEvent.h"
+#include "AliVParticle.h"
+#include "AliVTrack.h"
+#include "AliVVertex.h"
+
+#include "AliEMCalTriggerBinningComponent.h"
+#include "AliEMCalTriggerAnaTriggerDecision.h"
+#include "AliEMCalTriggerEventData.h"
+#include "AliEMCalTriggerKineCuts.h"
+#include "AliEMCalPtTaskVTrackSelection.h"
+#include "AliEMCalTriggerRecTrackAnalysisComponent.h"
+
+ClassImp(EMCalTriggerPtAnalysis::AliEMCalTriggerRecTrackAnalysisComponent)
+
+namespace EMCalTriggerPtAnalysis {
+
+//______________________________________________________________________________
+AliEMCalTriggerRecTrackAnalysisComponent::AliEMCalTriggerRecTrackAnalysisComponent() :
+  AliEMCalTriggerTracksAnalysisComponent(),
+  fTrackSelection(NULL),
+  fSwapEta(kFALSE),
+  fUsePatches(kFALSE),
+  fRequestMCtrue(kFALSE)
+{
+  /*
+   * Dummy (I/O) constructor
+   */
+}
+
+//______________________________________________________________________________
+AliEMCalTriggerRecTrackAnalysisComponent::AliEMCalTriggerRecTrackAnalysisComponent(const char *name) :
+  AliEMCalTriggerTracksAnalysisComponent(name),
+  fTrackSelection(NULL),
+  fSwapEta(kFALSE),
+  fUsePatches(kFALSE),
+  fRequestMCtrue(kFALSE)
+{
+  /*
+   * Main constructor
+   */
+}
+
+//______________________________________________________________________________
+AliEMCalTriggerRecTrackAnalysisComponent::~AliEMCalTriggerRecTrackAnalysisComponent() {
+  /*
+   * Destructor, taking care of the track selection
+   */
+  if(fTrackSelection) delete fTrackSelection;
+}
+
+//______________________________________________________________________________
+void AliEMCalTriggerRecTrackAnalysisComponent::CreateHistos() {
+  /*
+   * Create histograms of the track analysis component. For each trigger class we have
+   * - tracks with esd information
+   * - tracks with MC information
+   * - tracks with clusters and esd information
+   * - tracks with clusters and MC information
+   */
+  // Create trigger definitions
+  std::map<std::string, std::string> triggerCombinations;
+  const char *triggernames[12] = {"MinBias", "EMCJHigh", "EMCJLow", "EMCGHigh",
+      "EMCGLow", "NoEMCal", "EMCHighBoth", "EMCHighGammaOnly", "EMCHighJetOnly",
+      "EMCLowBoth", "EMCLowGammaOnly", "EMCLowJetOnly"};
+  // Define names and titles for different triggers in the histogram container
+  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[0], "min. bias events"));
+  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[1], "jet-triggered events (high threshold)"));
+  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[2], "jet-triggered events (low threshold)"));
+  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[3], "gamma-triggered events (high threshold)"));
+  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[4], "gamma-triggered events (low threshold)"));
+  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[5], "non-EMCal-triggered events"));
+  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[6], "jet and gamma triggered events (high threshold)"));
+  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[7], "exclusively gamma-triggered events (high threshold)"));
+  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[8], "exclusively jet-triggered events (high threshold)"));
+  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[9], "jet and gamma triggered events (low threshold)"));
+  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[10], "exclusively gamma-triggered events (low threshold)"));
+  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[11], "exclusively-triggered events (low threshold)"));
+
+  // Create axis definitions
+  const AliEMCalTriggerBinningDimension *ptbinning = fBinning->GetBinning("pt"),
+      *etabinning = fBinning->GetBinning("eta"),
+      *phibinning = fBinning->GetBinning("phi"),
+      *vertexbinning = fBinning->GetBinning("vertex");
+
+  const TAxis *trackaxes[5] = {
+      DefineAxis("pt", ptbinning),
+      DefineAxis("eta", etabinning),
+      DefineAxis("phi", phibinning),
+      DefineAxis("zvertex", vertexbinning),
+      DefineAxis("mbtrigger", 2, -0.5, 1.5)
+  };
+
+  // Build histograms
+  for(std::map<std::string,std::string>::iterator it = triggerCombinations.begin(); it != triggerCombinations.end(); ++it){
+    const std::string name = it->first, &title = it->second;
+    fHistos->CreateTHnSparse(Form("hTrackHist%s", name.c_str()), Form("Track-based data for %s events", title.c_str()), 5, trackaxes, "s");
+    fHistos->CreateTHnSparse(Form("hTrackInAcceptanceHist%s", name.c_str()), Form("Track-based data for %s events  for tracks matched to EMCal clusters", title.c_str()), 5, trackaxes, "s");
+    fHistos->CreateTHnSparse(Form("hMCTrackHist%s", name.c_str()), Form("Track-based data for %s events with MC kinematics", title.c_str()), 5, trackaxes, "s");
+    fHistos->CreateTHnSparse(Form("hMCTrackInAcceptanceHist%s", name.c_str()), Form("Track-based data for %s events with MC kinematics for tracks matched to EMCal clusters", title.c_str()), 5, trackaxes, "s");
+  }
+
+  for(int iaxis = 0; iaxis < 5; iaxis++) delete trackaxes[iaxis];
+}
+
+//______________________________________________________________________________
+void AliEMCalTriggerRecTrackAnalysisComponent::Process(const AliEMCalTriggerEventData* const data) {
+  /*
+   * Run track loop on list of matching tracks
+   *
+   * @param data: the event data
+   */
+
+  std::vector<std::string> triggernames;
+  this->GetMachingTriggerNames(triggernames, fUsePatches);
+
+  AliVTrack *track(NULL);
+  AliVParticle *assocMC(NULL);
+  TIter trackIter(data->GetMatchedTrackContainer());
+  while((track = dynamic_cast<AliVTrack *>(trackIter()))){
+    // Apply track selection
+    assocMC = NULL;
+    if(fKineCuts && !fKineCuts->IsSelected(track)) continue;
+    if(fTrackSelection && !fTrackSelection->IsTrackAccepted(track)) continue;
+    if(fRequestMCtrue && data->GetMCEvent() && !(assocMC = IsMCTrueTrack(track, data->GetMCEvent()))) continue;
+
+    // Try to match the cluster
+    Bool_t hasCluster = kFALSE;
+    AliVCluster *clust(NULL);
+    if(track->GetEMCALcluster() >= 0 && (clust = dynamic_cast<AliVCluster *>(data->GetClusterContainer()->At(track->GetEMCALcluster()))))
+      hasCluster = kTRUE;
+
+    // Fill histograms
+    for(std::vector<std::string>::iterator name = triggernames.begin(); name != triggernames.end(); name++){
+      FillHistogram(Form("hTrackHist%s", name->c_str()), track, NULL, data->GetRecEvent(), kFALSE);
+      if(hasCluster) FillHistogram(Form("hTrackInAcceptanceHist%s", name->c_str()), track, NULL, data->GetRecEvent(), kFALSE);
+      if(assocMC){
+        FillHistogram(Form("hMCTrackHist%s", name->c_str()), track, NULL, data->GetRecEvent(), kTRUE);
+        if(hasCluster) FillHistogram(Form("hMCTrackInAcceptanceHist%s", name->c_str()), track, NULL, data->GetRecEvent(), kTRUE);
+      }
+    }
+  }
+}
+
+//______________________________________________________________________________
+AliVParticle * AliEMCalTriggerRecTrackAnalysisComponent::IsMCTrueTrack(
+    const AliVTrack* const trk, const AliMCEvent* evnt) const {
+  /*
+   * Check according to the associated MC information whether the track is a MC true track,
+   * and whether it is physical primary
+   *
+   * @param trk: track to check
+   * @param evnt: MC event information necessary for the check
+   *
+   * @return: the associated MC particle (NULL if not MC true)
+   */
+  int label = TMath::Abs(trk->GetLabel());
+  AliVParticle *mcpart = evnt->GetTrack(label);
+  if(!mcpart) return NULL;
+  if(!evnt->IsPhysicalPrimary(label)) return NULL;
+  return mcpart;
+}
+
+//______________________________________________________________________________
+void AliEMCalTriggerRecTrackAnalysisComponent::FillHistogram(
+    const TString& histname, const AliVTrack* const trk,
+    const AliVParticle* assocMC, const AliVEvent* const recev,
+    Bool_t useMCkine) {
+  /*
+   *
+   */
+  if(useMCkine && !assocMC) return;
+  double data[5];
+  data[0] = useMCkine ? TMath::Abs(assocMC->Pt()) : TMath::Abs(trk->Pt());
+  data[1] = useMCkine ? assocMC->Eta() : trk->Eta();
+  data[2] = useMCkine ? assocMC->Phi() : trk->Phi();
+  data[3] = recev->GetPrimaryVertex()->GetZ();
+  data[4] = fTriggerDecision->IsMinBias();
+  fHistos->FillTHnSparse(histname.Data(), data);
+}
+
+} /* namespace EMCalTriggerPtAnalysis */
diff --git a/PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerRecTrackAnalysisComponent.h b/PWGJE/EMCALJetTasks/UserTasks/AliEMCalTriggerRecTrackAnalysisComponent.h
new file mode 100644 (file)
index 0000000..731b579
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef ALIEMCALTRIGGERRECTRACKANALYSISCOMPONENT_H
+#define ALIEMCALTRIGGERRECTRACKANALYSISCOMPONENT_H
+/* Copyright(c) 1998-2014, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+// Author: Markus Fasel
+
+#include "AliEMCalTriggerTracksAnalysisComponent.h"
+
+class TString;
+class AliVParticle;
+class AliVTrack;
+class AliMCEvent;
+
+namespace EMCalTriggerPtAnalysis {
+
+class AliEMCalTriggerEventData;
+class AliEMCalPtTaskVTrackSelection;
+
+class AliEMCalTriggerRecTrackAnalysisComponent : public AliEMCalTriggerTracksAnalysisComponent {
+public:
+  AliEMCalTriggerRecTrackAnalysisComponent();
+  AliEMCalTriggerRecTrackAnalysisComponent(const char *name);
+  virtual ~AliEMCalTriggerRecTrackAnalysisComponent();
+
+  virtual void CreateHistos();
+  virtual void Process(const AliEMCalTriggerEventData * const data);
+
+  void SetSwapEta(Bool_t doSwap = kTRUE) { fSwapEta = doSwap; }
+  void SetUsePatches(Bool_t doUse = kTRUE) { fUsePatches = doUse; }
+  void SetRequestMCtrueTracks(Bool_t doRequest = kTRUE) { fRequestMCtrue = doRequest; }
+
+protected:
+  AliVParticle *IsMCTrueTrack(const AliVTrack *const trk, const AliMCEvent *evnt) const;
+  void FillHistogram(const TString &histname, const AliVTrack *const trk, const AliVParticle *assocMC, const AliVEvent * const recev, Bool_t useMCkine);
+
+  AliEMCalPtTaskVTrackSelection *   fTrackSelection;          // Track selection cuts used in the analysis
+  Bool_t                            fSwapEta;                 // Swap eta sign
+  Bool_t                            fUsePatches;              // Use patches for trigger decision
+  Bool_t                            fRequestMCtrue;           // Request MC true track
+
+  ClassDef(AliEMCalTriggerRecTrackAnalysisComponent, 1);      // Analysis component for charged tracks
+};
+
+} /* namespace EMCalTriggerPtAnalysis */
+
+#endif /* ALIEMCALTRIGGERRECTRACKANALYSISCOMPONENT_H */
index aea318723712694f4eff1661157afd79ccb216f9..79eae046086ec31b975a7f35edf5eead611b3542 100644 (file)
@@ -111,4 +111,19 @@ void AliEMCalTriggerTaskGroup::AddAnalysisComponent(AliEMCalTriggerTracksAnalysi
   fAnalysisComponents->Add(analysis);
 }
 
+//______________________________________________________________________________
+void EMCalTriggerPtAnalysis::AliEMCalTriggerTaskGroup::SetTriggerDecision(
+    const AliEMCalTriggerAnaTriggerDecision* trigger) {
+  /*
+   * Forward trigger decision to the analysis components
+   *
+   * @param trigger: the trigger decision
+   */
+  AliEMCalTriggerTracksAnalysisComponent *myana(NULL);
+  TIter compIter(fAnalysisComponents);
+  while((myana = dynamic_cast<AliEMCalTriggerTracksAnalysisComponent *>(compIter())))
+    myana->SetTriggerDecision(trigger);
+}
+
+
 } /* namespace EMCalTriggerPtAnalysis */
index df78f463d9a4aa85a7923aadae1ffdc8176421c4..beaa20a600f3883de22a331932c5c298a6ad2c3b 100644 (file)
@@ -9,6 +9,7 @@
 
 namespace EMCalTriggerPtAnalysis {
 
+class AliEMCalTriggerAnaTriggerDecision;
 class AliEMCalTriggerBinningComponent;
 class AliEMCalTriggerEventSelection;
 class AliEMCalTriggerTracksAnalysisComponent;
@@ -21,6 +22,7 @@ public:
 
   void SetEventSelection(const AliEMCalTriggerEventSelection *sel){ fEventSelection = sel; }
   void SetGlobalBinning(const AliEMCalTriggerBinningComponent *const binning) { fBinning = binning; }
+  void SetTriggerDecision(const AliEMCalTriggerAnaTriggerDecision *trigger);
   void AddAnalysisComponent(AliEMCalTriggerTracksAnalysisComponent * const analysis);
 
   TList * InitialiseAnalysisComponents();
index 9df998832edce3cdb89c5de1675c2dd46d42589d..6cc0d6d65a34cb62291615882255e0feff35b9e3 100644 (file)
  *
  *   Author: Markus Fasel
  */
+#include <TAxis.h>
+
+#include "AliEMCalTriggerAnaTriggerDecision.h"
+#include "AliEMCalTriggerBinningComponent.h"
 #include "AliEMCalTriggerTracksAnalysisComponent.h"
 
 ClassImp(EMCalTriggerPtAnalysis::AliEMCalTriggerTracksAnalysisComponent)
@@ -29,7 +33,8 @@ AliEMCalTriggerTracksAnalysisComponent::AliEMCalTriggerTracksAnalysisComponent()
   TNamed(),
   fHistos(NULL),
   fBinning(NULL),
-  fKineCuts(NULL)
+  fKineCuts(NULL),
+  fTriggerDecision(NULL)
 {
   /*
    * Dummy (I/O) constructor
@@ -49,7 +54,8 @@ AliEMCalTriggerTracksAnalysisComponent::AliEMCalTriggerTracksAnalysisComponent(c
   TNamed(name,""),
   fHistos(NULL),
   fBinning(NULL),
-  fKineCuts(NULL)
+  fKineCuts(NULL),
+  fTriggerDecision(NULL)
 {
   /*
    * Main constructor, to be called by the user
@@ -68,5 +74,72 @@ void AliEMCalTriggerTracksAnalysisComponent::CreateHistos() {
   fHistos->ReleaseOwner();
 }
 
+//______________________________________________________________________________
+TAxis* AliEMCalTriggerTracksAnalysisComponent::DefineAxis(const char* name, const AliEMCalTriggerBinningDimension* binning) {
+  /*
+   * Create and define axis
+   *
+   * @param name: Name of the axis
+   * @param binning: binning information
+   * @return: the new axis
+   */
+  TAxis *result = new TAxis(binning->GetNumberOfBins(), binning->GetBinLimits());
+  result->SetName(name);
+  return result;
+}
+
+//______________________________________________________________________________
+TAxis* AliEMCalTriggerTracksAnalysisComponent::DefineAxis(const char* name, int nbins, double min, double max) {
+  /*
+   * Create and define axis
+   *
+   * @param name: Name of the axis
+   * @param nbins: number of bins
+   * @param min: min. range
+   * @param max: max. range
+   * @return: the new axis
+   */
+  TAxis *result = new TAxis(nbins, min, max);
+  result->SetName(name);
+  return result;
+}
+
+//______________________________________________________________________________
+void AliEMCalTriggerTracksAnalysisComponent::GetMachingTriggerNames(std::vector<std::string>& triggernames, Bool_t usePatches) {
+  /*
+   * Get a set of names of trigger strings that is matching with the trigger decision.
+   *
+   * @param triggernames: output container for selected trigger names
+   * @param usePatches: determines whether we use the trigger decision from patches
+   */
+  triggernames.clear();
+  if(!fTriggerDecision) return;
+  if(fTriggerDecision->IsMinBias()) triggernames.push_back("MinBias");
+  if(fTriggerDecision->IsTriggered(AliEMCalTriggerAnaTriggerDecision::kTAEMCJHigh, usePatches)){
+    triggernames.push_back("EMCJHigh");
+    if(fTriggerDecision->IsTriggered(AliEMCalTriggerAnaTriggerDecision::kTAEMCGHigh, usePatches))
+      triggernames.push_back("EMCHighBoth");
+    else
+      triggernames.push_back("EMCHighJetOnly");
+  }
+  if(fTriggerDecision->IsTriggered(AliEMCalTriggerAnaTriggerDecision::kTAEMCJLow, usePatches)){
+    triggernames.push_back("EMCJLow");
+    if(fTriggerDecision->IsTriggered(AliEMCalTriggerAnaTriggerDecision::kTAEMCGLow, usePatches))
+      triggernames.push_back("EMCLowBoth");
+    else
+      triggernames.push_back("EMCLowJetOnly");
+  }
+  if(fTriggerDecision->IsTriggered(AliEMCalTriggerAnaTriggerDecision::kTAEMCGHigh, usePatches)){
+    triggernames.push_back("EMCGHigh");
+    if(!fTriggerDecision->IsTriggered(AliEMCalTriggerAnaTriggerDecision::kTAEMCJHigh, usePatches))
+      triggernames.push_back("EMCHighGammaOnly");
+  }
+  if(fTriggerDecision->IsTriggered(AliEMCalTriggerAnaTriggerDecision::kTAEMCGLow, usePatches)){
+    triggernames.push_back("EMCGLow");
+    if(!fTriggerDecision->IsTriggered(AliEMCalTriggerAnaTriggerDecision::kTAEMCJLow, usePatches))
+      triggernames.push_back("EMCLowGammaOnly");
+  }
+}
+
 } /* namespace EMCalTriggerPtAnalysis */
 
index b9989aad7fd1bef58d00793577e41a5573caf924..50fe17a5cfe970621f380590644a05840ed6c3f8 100644 (file)
@@ -4,12 +4,16 @@
  * See cxx source for full Copyright notice                               */
 
 // Author: Markus Fasel
+#include <vector>
+#include <string>
 #include <TNamed.h>
 #include "AliEMCalHistoContainer.h"
 
 namespace EMCalTriggerPtAnalysis {
 
+class AliEMCalTriggerAnaTriggerDecision;
 class AliEMCalTriggerBinningComponent;
+class AliEMCalTriggerBinningDimension;
 class AliEMCalTriggerEventData;
 class AliEMCalTriggerKineCuts;
 
@@ -25,11 +29,17 @@ public:
   THashList *GetHistList() const { return fHistos->GetListOfHistograms(); }
   void SetBinning(const AliEMCalTriggerBinningComponent * const binning) { fBinning = binning; }
   void SetKineCuts(const AliEMCalTriggerKineCuts * const cuts) { fKineCuts = cuts; }
+  void SetTriggerDecision(const AliEMCalTriggerAnaTriggerDecision *trigger) { fTriggerDecision = trigger; }
 
 protected:
+  TAxis *DefineAxis(const char *name, const AliEMCalTriggerBinningDimension *binning);
+  TAxis *DefineAxis(const char *name, int nbins, double min, double max);
+  void GetMachingTriggerNames(std::vector<std::string> &triggernames, Bool_t usePatches);
+
   AliEMCalHistoContainer                      *fHistos;
   const AliEMCalTriggerBinningComponent       *fBinning;
   const AliEMCalTriggerKineCuts               *fKineCuts;
+  const AliEMCalTriggerAnaTriggerDecision     *fTriggerDecision;
 
   ClassDef(AliEMCalTriggerTracksAnalysisComponent, 1)
 };
index 13535bd2383e88a645a91e8bb0e4c757df2074a3..c1505f1720f66346458de5d7168077c0c4bf3c89 100644 (file)
 #pragma link C++ class EMCalTriggerPtAnalysis::AliEMCalTriggerBinningDimension+;
 #pragma link C++ class EMCalTriggerPtAnalysis::AliEMCalTriggerBinningComponent+;
 #pragma link C++ class EMCalTriggerPtAnalysis::AliEMCalTriggerKineCuts+;
+#pragma link C++ class EMCalTriggerPtAnalysis::AliEMCalTriggerAnaTriggerDecision+;
 #pragma link C++ class EMCalTriggerPtAnalysis::AliEMCalTriggerMCParticleAnalysisComponent+;
+#pragma link C++ class EMCalTriggerPtAnalysis::AliEMCalTriggerClusterAnalysisComponent+;
+#pragma link C++ class EMCalTriggerPtAnalysis::AliEMCalTriggerRecTrackAnalysisComponent+;
 #pragma link C++ class AliAnalysisTaskEmcalTriggerTreeWriter+;
 
 #ifdef HAVE_FASTJET