Add task writing EMCAL trigger information into a tree
authormfasel <mfasel@lbl.gov>
Wed, 26 Nov 2014 17:14:04 +0000 (18:14 +0100)
committermfasel <mfasel@lbl.gov>
Wed, 26 Nov 2014 17:14:04 +0000 (18:14 +0100)
===================================================================
1) Add Task creating the EMCAL trigger tree
2) Include the new task into the build
3) Add corresponding add macro

PWGJE/CMakelibPWGJEEMCALJetTasks.pkg
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalTriggerTreeWriter.cxx [new file with mode: 0644]
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalTriggerTreeWriter.h [new file with mode: 0644]
PWGJE/EMCALJetTasks/macros/AddTaskEmcalTriggerTreeWriter.C [new file with mode: 0644]
PWGJE/PWGJEEMCALJetTasksLinkDef.h

index 1ef5389..76781fc 100644 (file)
@@ -101,6 +101,7 @@ set ( SRCS
  EMCALJetTasks/UserTasks/AliEMCalPtTaskVTrackSelection.cxx
  EMCALJetTasks/UserTasks/AliEMCalPtTaskTrackSelectionESD.cxx
  EMCALJetTasks/UserTasks/AliEMCalPtTaskTrackSelectionAOD.cxx
+ EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalTriggerTreeWriter.cxx
 )
 
 # Add code that needs fastjet or FJWrapper here
diff --git a/PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalTriggerTreeWriter.cxx b/PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalTriggerTreeWriter.cxx
new file mode 100644 (file)
index 0000000..e0709ac
--- /dev/null
@@ -0,0 +1,105 @@
+/**************************************************************************
+ * Copyright(c) 1998-2007, 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.                  *
+ **************************************************************************/
+/*
+ * A small task dumping all EMCal trigger related information into a TTree
+ *      Author: Markus Fasel
+ */
+#include <iostream>
+#include <string>
+#include <TMath.h>
+#include <TTree.h>
+
+#include "AliInputEventHandler.h"
+#include "AliVTrack.h"
+#include "AliVCluster.h"
+
+#include "AliAnalysisTaskEmcalTriggerTreeWriter.h"
+
+AliAnalysisTaskEmcalTriggerTreeWriter::AliAnalysisTaskEmcalTriggerTreeWriter():
+       AliAnalysisTaskSE(),
+       fOutputTree(NULL),
+       fOutputInfo()
+{
+       /*
+        * Dummy constructor
+        */
+}
+
+AliAnalysisTaskEmcalTriggerTreeWriter::AliAnalysisTaskEmcalTriggerTreeWriter(const char *name):
+       AliAnalysisTaskSE(name),
+       fOutputTree(NULL),
+       fOutputInfo()
+{
+       /*
+        * Constructor
+        */
+       DefineOutput(1,TTree::Class());
+}
+
+AliAnalysisTaskEmcalTriggerTreeWriter::~AliAnalysisTaskEmcalTriggerTreeWriter() {
+       /*
+        * Destructor
+        */
+       if(fOutputTree) delete fOutputTree;
+}
+
+void AliAnalysisTaskEmcalTriggerTreeWriter::UserCreateOutputObjects() {
+       /*
+        * Create output tree, with two branches, one for the tracks matched and one for the clusters
+        */
+
+       // Build the tree
+       OpenFile(1);
+       fOutputTree = new TTree("EMCalTree", "A tree with emcal information");
+       fOutputTree->Branch("run", &fOutputInfo.fRun, "pdg/I");
+       fOutputTree->Branch("col", &fOutputInfo.fCol, "col/I");
+       fOutputTree->Branch("row", &fOutputInfo.fRow, "isUnique/i");
+       fOutputTree->Branch("NL0Times", &fOutputInfo.fNL0Times, "NL0Times/I");
+       fOutputTree->Branch("Level0Times", fOutputInfo.fLevel0Times, "Level0Times[10]/I");
+       fOutputTree->Branch("ADC", &fOutputInfo.fADC, "ADC/I");
+       fOutputTree->Branch("Amplitude", &fOutputInfo.fAmplitude, "Amplitude/F");
+       fOutputTree->Branch("Time", &fOutputInfo.fTime, "Time/F");
+       fOutputTree->Branch("TriggerBits", &fOutputInfo.fTriggerBits, "TriggerBits/I");
+       fOutputTree->Branch("L1Threshold", &fOutputInfo.fL1Threshold, "L1Threshold/I");
+       fOutputTree->Branch("L1V0", &fOutputInfo.fL1V0, "L1V0/I");
+       PostData(1, fOutputTree);
+}
+
+void AliAnalysisTaskEmcalTriggerTreeWriter::UserExec(Option_t *) {
+       /*
+        * Build the tree
+        */
+
+       AliVCaloTrigger *emctrigger = fInputEvent->GetCaloTrigger(strcmp(fInputHandler->GetDataType(), "ESD" ) == 0 ? "EMCALTrigger" : "EMCALTrigger");
+       emctrigger->Reset();
+       while(emctrigger->Next()){
+               fOutputInfo.Reset();
+               fOutputInfo.fRun = fInputEvent->GetRunNumber();
+               emctrigger->GetPosition(fOutputInfo.fCol, fOutputInfo.fRow);
+               emctrigger->GetNL0Times(fOutputInfo.fNL0Times);
+               if(fOutputInfo.fNL0Times > 0 && fOutputInfo.fNL0Times < 10)
+                       emctrigger->GetL0Times(fOutputInfo.fLevel0Times);
+               emctrigger->GetL1TimeSum(fOutputInfo.fADC);
+               emctrigger->GetAmplitude(fOutputInfo.fAmplitude);
+               emctrigger->GetL1V0(fOutputInfo.fL1V0);
+               emctrigger->GetTriggerBits(fOutputInfo.fTriggerBits);
+               emctrigger->GetTime(fOutputInfo.fTime);
+               emctrigger->GetL1Threshold(fOutputInfo.fL1Threshold);
+               fOutputTree->Fill();
+       }
+
+       PostData(1, fOutputTree);
+}
+
diff --git a/PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalTriggerTreeWriter.h b/PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalTriggerTreeWriter.h
new file mode 100644 (file)
index 0000000..23a56fb
--- /dev/null
@@ -0,0 +1,59 @@
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+/*
+ * A small task dumping all EMCal trigger related information into a TTree
+ *      Author: Markus Fasel
+ */
+
+#ifndef ALIANALYSISTASKEMCALTRIGGERTREEWRITER_H_
+#define ALIANALYSISTASKEMCALTRIGGERTREEWRITER_H_
+
+#include "AliAnalysisTaskSE.h"
+
+class TTree;
+
+class AliAnalysisTaskEmcalTriggerTreeWriter : public AliAnalysisTaskSE {
+public:
+       AliAnalysisTaskEmcalTriggerTreeWriter();
+       AliAnalysisTaskEmcalTriggerTreeWriter(const char *name);
+       virtual ~AliAnalysisTaskEmcalTriggerTreeWriter();
+
+       virtual void UserCreateOutputObjects();
+       virtual void UserExec(Option_t *);
+
+private:
+       struct TriggerInfo{
+               Int_t fRun;
+               Int_t fCol;
+               Int_t fRow;
+               Int_t fNL0Times;
+               Int_t fLevel0Times[10];
+               Int_t fADC;
+               Float_t fAmplitude;
+               Float_t fTime;
+               Int_t fTriggerBits;
+               Int_t fL1Threshold;
+               Int_t fL1V0;
+
+               TriggerInfo():
+                       fRun(0),
+                       fCol(0), fRow(0),
+                       fNL0Times(0), fADC(0), fAmplitude(0.),
+                       fTime(0), fTriggerBits(0), fL1Threshold(0), fL1V0(0)
+               {
+                       memset(fLevel0Times, 0, sizeof(Int_t) * 10);
+               }
+               void Reset(){
+                       fRun = 0; fCol = 0; fRow = 0;
+                       fNL0Times = 0; fADC = 0; fAmplitude = 0.;
+                       fTime = 0.; fTriggerBits = 0; fL1Threshold = 0; fL1V0 = 0;
+                       memset(fLevel0Times, 0, sizeof(Int_t) * 10);
+               }
+       };
+       TTree *fOutputTree;                                             //! Output tree with tracks
+       TriggerInfo fOutputInfo;                                        // Track Info for the tree
+
+       ClassDef(AliAnalysisTaskEmcalTriggerTreeWriter, 1)
+};
+
+#endif /* ALIANALYSISTASKEMCALTRIGGERTREEWRITER_H_ */
diff --git a/PWGJE/EMCALJetTasks/macros/AddTaskEmcalTriggerTreeWriter.C b/PWGJE/EMCALJetTasks/macros/AddTaskEmcalTriggerTreeWriter.C
new file mode 100644 (file)
index 0000000..5438ae4
--- /dev/null
@@ -0,0 +1,35 @@
+#if !defined (__CINT__) || defined (__MAKECINT__)
+#include "AliAnalysisManager.h"
+#include "AliAnalysisTaskPtEMCalTrigger.h"
+#include "AliESDtrackCuts.h"
+#include <TList.h>
+#include <TString.h>
+#endif
+
+AliAnalysisTask* AddTaskEmcalTriggerTreeWriter(){
+        AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+         
+        if (!mgr) {
+             ::Error("AddTaskPtEMCalTrigger", "No analysis manager to connect to.");
+             return NULL;
+        }
+         
+        if (!mgr->GetInputEventHandler()) {
+             ::Error("AddTaskPtEMCalTrigger", "This task requires an input event handler");
+             return NULL;
+        }
+        
+        AliAnalysisTaskEmcalTriggerTreeWriter *treewriter = new AliAnalysisTaskEmcalTriggerTreeWriter("TriggerTreewriterTask");
+        //pttriggertask->SelectCollisionCandidates(AliVEvent::kINT7 | AliVEvent::kEMC7);                          // Select both INT7 or EMC7 triggered events
+        treewriter->SelectCollisionCandidates(AliVEvent::kAny);
+        mgr->AddTask(treewriter);
+
+        AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
+        AliAnalysisDataContainer *coutputTree = mgr->CreateContainer("EMCalTriggerTree", TTree::Class(),    AliAnalysisManager::kOutputContainer, "EMCalTriggerTree.root");
+   
+        //Connect input/output
+        mgr->ConnectInput(treewriter, 0, cinput);
+        mgr->ConnectOutput(treewriter, 1, coutputTree);
+           
+        return treewriter;
+}
index 48a437e..76e679a 100644 (file)
@@ -88,6 +88,7 @@
 #pragma link C++ class EMCalTriggerPtAnalysis::AliEMCalPtTaskVTrackSelection+;
 #pragma link C++ class EMCalTriggerPtAnalysis::AliEMCalPtTaskTrackSelectionESD+;
 #pragma link C++ class EMCalTriggerPtAnalysis::AliEMCalPtTaskTrackSelectionAOD+;
+#pragma link C++ class AliAnalysisTaskEmcalTriggerTreeWriter+;
 
 #ifdef HAVE_FASTJET
 #pragma link C++ class AliEmcalJetTask+;