Fixing bugs in FMD reconstruction. Everything should work now
[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 }
7e27c6e3 100 evtTag->SetGUID(fguid);
101 if(opt.Contains("grid")) {
9b4aee57 102 evtTag->SetMD5("");
7e27c6e3 103 evtTag->SetTURL(fturl);
104 evtTag->SetSize(0);
105 }
106 else evtTag->SetPath(fturl);
107 //
108 // Add the event tag
109 fRunTag->AddEventTag(*evtTag);
110 PostData(1, fTreeT);
111}
112
113
114void AliAnalysisTaskTagCreator::FinishTaskOutput()
115{
116// Terminate analysis
117//
118 if (fInputHandler->GetRunTag()) fRunTag->CopyStandardContent(fInputHandler->GetRunTag());
119 fTreeT->Fill();
120}
121
122Bool_t AliAnalysisTaskTagCreator::Notify()
123{
124 // Notify file change
125 if (!fFirstFile) {
126 if (fInputHandler->GetRunTag()) fRunTag->CopyStandardContent(fInputHandler->GetRunTag());
127 fTreeT->Fill();
128 fRunTag->Clear();
129 } else {
130 fFirstFile = kFALSE;
131 }
f9f9c880 132 return kTRUE;
7e27c6e3 133}
134
135
136void AliAnalysisTaskTagCreator::Terminate(Option_t */*option*/)
137{
138// Terminate analysis
139//
140 if (fDebug > 1) printf("AnalysisTagCreator: Terminate() \n");
141}
142