]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ANALYSIS/AliAnalysisTaskTagCreator.cxx
Added wagon configuration macros. To be adopted by responsables and moved to PWGn...
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisTaskTagCreator.cxx
CommitLineData
7e27c6e3 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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/* $Id$ */
17
18#include <TChain.h>
19#include <TTree.h>
20#include <TString.h>
21#include <TFile.h>
22
23#include "AliAnalysisTaskTagCreator.h"
24#include "AliAnalysisManager.h"
25#include "AliESDEvent.h"
26#include "AliAODEvent.h"
27#include "AliESDInputHandler.h"
28#include "AliAODHandler.h"
29#include "AliRunTag.h"
30#include "AliEventTag.h"
31#include "AliAODTagCreator.h"
32#include "AliLog.h"
33
34ClassImp(AliAnalysisTaskTagCreator)
35
36////////////////////////////////////////////////////////////////////////
37
38AliAnalysisTaskTagCreator::AliAnalysisTaskTagCreator():
39 AliAnalysisTaskSE(),
e7c71df0 40 fCreateTags(kFALSE),
7e27c6e3 41 fFirstFile(kTRUE),
42 fRunTag(0),
43 fTreeT(0),
44 fTagCreator(0)
45{
46 // Default constructor
47}
48
49AliAnalysisTaskTagCreator::AliAnalysisTaskTagCreator(const char* name):
50 AliAnalysisTaskSE(name),
e7c71df0 51 fCreateTags(kFALSE),
7e27c6e3 52 fFirstFile(kTRUE),
53 fRunTag(0),
54 fTreeT(0),
55 fTagCreator(0)
56{
57 // Constructor
58 DefineOutput(1, TTree::Class());
59}
60
61void AliAnalysisTaskTagCreator::UserCreateOutputObjects()
62{
63// Create the output container
64 OpenFile(1);
65 fTreeT = new TTree("T", "AOD Tags");
66 fRunTag = new AliRunTag();
67 TBranch * btag = fTreeT->Branch("AliTAG", "AliRunTag", &fRunTag);
68 btag->SetCompressionLevel(9);
69 fTagCreator = new AliAODTagCreator();
70}
71
72void AliAnalysisTaskTagCreator::Init()
73{
74 // Initialization
75 if (fDebug > 1) AliInfo("Init() \n");
76 // Call configuration file
77}
78
79
80void AliAnalysisTaskTagCreator::UserExec(Option_t */*option*/)
81{
82 // Create Tags for the current event
83 AliEventTag* evtTag = new AliEventTag();
84 fTagCreator->FillEventTag(AODEvent(), evtTag);
85 // Reference to the input file
86 TString fturl, fturltemp, fguid;
87
88 TString opt(fInputHandler->GetAnalysisType());
89 opt.ToLower();
90
91 TFile *file = OutputTree()->GetCurrentFile();
92 const TUrl *url = file->GetEndpointUrl();
93 fguid = file->GetUUID().AsString();
94 if (opt.Contains("grid")) {
95 fturltemp = "alien://"; fturltemp += url->GetFile();
96 fturl = fturltemp(0,fturltemp.Index(".root",5,0,TString::kExact)+5);
97 } else {
98 fturl = url->GetFile();
99 }
100 evtTag->SetEventId(fInputHandler->GetReadEntry() + 1);
101 evtTag->SetGUID(fguid);
102 if(opt.Contains("grid")) {
103 evtTag->SetMD5(0);
104 evtTag->SetTURL(fturl);
105 evtTag->SetSize(0);
106 }
107 else evtTag->SetPath(fturl);
108 //
109 // Add the event tag
110 fRunTag->AddEventTag(*evtTag);
111 PostData(1, fTreeT);
112}
113
114
115void AliAnalysisTaskTagCreator::FinishTaskOutput()
116{
117// Terminate analysis
118//
119 if (fInputHandler->GetRunTag()) fRunTag->CopyStandardContent(fInputHandler->GetRunTag());
120 fTreeT->Fill();
121}
122
123Bool_t AliAnalysisTaskTagCreator::Notify()
124{
125 // Notify file change
126 if (!fFirstFile) {
127 if (fInputHandler->GetRunTag()) fRunTag->CopyStandardContent(fInputHandler->GetRunTag());
128 fTreeT->Fill();
129 fRunTag->Clear();
130 } else {
131 fFirstFile = kFALSE;
132 }
f9f9c880 133 return kTRUE;
7e27c6e3 134}
135
136
137void AliAnalysisTaskTagCreator::Terminate(Option_t */*option*/)
138{
139// Terminate analysis
140//
141 if (fDebug > 1) printf("AnalysisTagCreator: Terminate() \n");
142}
143