]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalTriggerTreeWriter.cxx
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / UserTasks / AliAnalysisTaskEmcalTriggerTreeWriter.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15 /*
16  * A small task dumping all EMCal trigger related information into a TTree
17  *      Author: Markus Fasel
18  */
19 #include <iostream>
20 #include <string>
21 #include <TMath.h>
22 #include <TTree.h>
23
24 #include "AliInputEventHandler.h"
25 #include "AliVTrack.h"
26 #include "AliVCluster.h"
27
28 #include "AliAnalysisTaskEmcalTriggerTreeWriter.h"
29
30 AliAnalysisTaskEmcalTriggerTreeWriter::AliAnalysisTaskEmcalTriggerTreeWriter():
31         AliAnalysisTaskSE(),
32         fOutputTree(NULL),
33         fOutputInfo()
34 {
35         /*
36          * Dummy constructor
37          */
38 }
39
40 AliAnalysisTaskEmcalTriggerTreeWriter::AliAnalysisTaskEmcalTriggerTreeWriter(const char *name):
41         AliAnalysisTaskSE(name),
42         fOutputTree(NULL),
43         fOutputInfo()
44 {
45         /*
46          * Constructor
47          */
48         DefineOutput(1,TTree::Class());
49 }
50
51 AliAnalysisTaskEmcalTriggerTreeWriter::~AliAnalysisTaskEmcalTriggerTreeWriter() {
52         /*
53          * Destructor
54          */
55         if(fOutputTree) delete fOutputTree;
56 }
57
58 void AliAnalysisTaskEmcalTriggerTreeWriter::UserCreateOutputObjects() {
59         /*
60          * Create output tree, with two branches, one for the tracks matched and one for the clusters
61          */
62
63         // Build the tree
64         OpenFile(1);
65         fOutputTree = new TTree("EMCalTree", "A tree with emcal information");
66         fOutputTree->Branch("run", &fOutputInfo.fRun, "pdg/I");
67         fOutputTree->Branch("col", &fOutputInfo.fCol, "col/I");
68         fOutputTree->Branch("row", &fOutputInfo.fRow, "isUnique/i");
69         fOutputTree->Branch("NL0Times", &fOutputInfo.fNL0Times, "NL0Times/I");
70         fOutputTree->Branch("Level0Times", fOutputInfo.fLevel0Times, "Level0Times[10]/I");
71         fOutputTree->Branch("ADC", &fOutputInfo.fADC, "ADC/I");
72         fOutputTree->Branch("Amplitude", &fOutputInfo.fAmplitude, "Amplitude/F");
73         fOutputTree->Branch("Time", &fOutputInfo.fTime, "Time/F");
74         fOutputTree->Branch("TriggerBits", &fOutputInfo.fTriggerBits, "TriggerBits/I");
75         fOutputTree->Branch("L1Threshold", &fOutputInfo.fL1Threshold, "L1Threshold/I");
76         fOutputTree->Branch("L1V0", &fOutputInfo.fL1V0, "L1V0/I");
77         PostData(1, fOutputTree);
78 }
79
80 void AliAnalysisTaskEmcalTriggerTreeWriter::UserExec(Option_t *) {
81         /*
82          * Build the tree
83          */
84
85         AliVCaloTrigger *emctrigger = fInputEvent->GetCaloTrigger(strcmp(fInputHandler->GetDataType(), "ESD" ) == 0 ? "EMCALTrigger" : "EMCALTrigger");
86         emctrigger->Reset();
87         while(emctrigger->Next()){
88                 fOutputInfo.Reset();
89                 fOutputInfo.fRun = fInputEvent->GetRunNumber();
90                 emctrigger->GetPosition(fOutputInfo.fCol, fOutputInfo.fRow);
91                 emctrigger->GetNL0Times(fOutputInfo.fNL0Times);
92                 if(fOutputInfo.fNL0Times > 0 && fOutputInfo.fNL0Times < 10)
93                         emctrigger->GetL0Times(fOutputInfo.fLevel0Times);
94                 emctrigger->GetL1TimeSum(fOutputInfo.fADC);
95                 emctrigger->GetAmplitude(fOutputInfo.fAmplitude);
96                 emctrigger->GetL1V0(fOutputInfo.fL1V0);
97                 emctrigger->GetTriggerBits(fOutputInfo.fTriggerBits);
98                 emctrigger->GetTime(fOutputInfo.fTime);
99                 emctrigger->GetL1Threshold(fOutputInfo.fL1Threshold);
100                 fOutputTree->Fill();
101         }
102
103         PostData(1, fOutputTree);
104 }
105