--- /dev/null
+/**************************************************************************
+ * 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);
+}
+
--- /dev/null
+/* 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_ */
--- /dev/null
+#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;
+}