1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include <Riostream.h>
26 #include "AliAnalysisTaskTagCreator.h"
27 #include "AliAnalysisManager.h"
28 #include "AliESDEvent.h"
29 #include "AliAODEvent.h"
30 #include "AliESDInputHandler.h"
31 #include "AliAODHandler.h"
32 #include "AliRunTag.h"
33 #include "AliEventTag.h"
34 #include "AliAODTagCreator.h"
38 ClassImp(AliAnalysisTaskTagCreator)
40 ////////////////////////////////////////////////////////////////////////
42 AliAnalysisTaskTagCreator::AliAnalysisTaskTagCreator():
51 // Default constructor
54 AliAnalysisTaskTagCreator::AliAnalysisTaskTagCreator(const char* name):
55 AliAnalysisTaskSE(name),
64 DefineOutput(1, TTree::Class());
67 void AliAnalysisTaskTagCreator::UserCreateOutputObjects()
69 // Create the output container
71 fTreeT = new TTree("T", "AOD Tags");
72 fRunTag = new AliRunTag();
73 TBranch * btag = fTreeT->Branch("AliTAG", "AliRunTag", &fRunTag);
74 btag->SetCompressionLevel(9);
75 fTagCreator = new AliAODTagCreator();
78 void AliAnalysisTaskTagCreator::Init()
83 void AliAnalysisTaskTagCreator::ConnectInputData(Option_t * /*option*/)
86 const char* turl = gSystem->Getenv("ALIEN_JDL_OUTPUTDIR");
88 fAODFileName = "alien://";
90 fAODFileName += "/AliAOD.root";
94 void AliAnalysisTaskTagCreator::UserExec(Option_t */*option*/)
97 // Create Tags for the current event
98 AliEventTag* evtTag = new AliEventTag();
99 fTagCreator->FillEventTag(AODEvent(), evtTag);
100 // Reference to the input file
101 TString fturl, fturltemp, fguid;
103 TString opt(fInputHandler->GetAnalysisType());
106 TFile *file = OutputTree()->GetCurrentFile();
107 const TUrl *url = file->GetEndpointUrl();
108 fguid = file->GetUUID().AsString();
109 if (fAODFileName.Length() != 0) {
110 fturl = fAODFileName;
113 fturl = url->GetFile();
116 evtTag->SetGUID(fguid);
117 if(fAODFileName.Length() != 0) {
119 evtTag->SetTURL(fturl);
122 else evtTag->SetPath(fturl);
125 fRunTag->AddEventTag(*evtTag);
130 void AliAnalysisTaskTagCreator::FinishTaskOutput()
132 // Terminate analysis
134 if (fInputHandler->GetRunTag()) fRunTag->CopyStandardContent(fInputHandler->GetRunTag());
138 Bool_t AliAnalysisTaskTagCreator::Notify()
140 // Notify file change
141 fInputHandler = (AliInputEventHandler*)
142 ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
145 if (fInputHandler->GetRunTag()) fRunTag->CopyStandardContent(fInputHandler->GetRunTag());
155 void AliAnalysisTaskTagCreator::GetGUID(TString &guid) {
156 // Get the guid of the AliAOD.root file
157 ofstream myfile ("guid.txt");
158 if (myfile.is_open()) {
159 TFile *f = TFile::Open("AliAOD.root","read");
161 guid = f->GetUUID().AsString();
162 myfile << "AliAOD.root \t"<<f->GetUUID().AsString();
163 cout<<guid.Data()<<endl;
166 else cout<<"Input file not found"<<endl;
168 else cout<<"Output file can't be created..."<<endl;
173 void AliAnalysisTaskTagCreator::Terminate(Option_t */*option*/)
175 // Terminate analysis
177 if (fDebug > 1) printf("AnalysisTagCreator: Terminate() \n");