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"
41 ClassImp(AliAnalysisTaskTagCreator)
43 ////////////////////////////////////////////////////////////////////////
45 AliAnalysisTaskTagCreator::AliAnalysisTaskTagCreator():
55 // Default constructor
58 AliAnalysisTaskTagCreator::AliAnalysisTaskTagCreator(const char* name):
59 AliAnalysisTaskSE(name),
69 DefineOutput(1, TTree::Class());
72 void AliAnalysisTaskTagCreator::UserCreateOutputObjects()
74 // Create the output container
76 fTreeT = new TTree("T", "AOD Tags");
77 fRunTag = new AliRunTag();
78 TBranch * btag = fTreeT->Branch("AliTAG", "AliRunTag", &fRunTag);
79 btag->SetCompressionLevel(9);
80 fTagCreator = new AliAODTagCreator();
84 void AliAnalysisTaskTagCreator::Init()
89 void AliAnalysisTaskTagCreator::ConnectInputData(Option_t * /*option*/)
92 const char* turl = gSystem->Getenv("ALIEN_JDL_OUTPUTDIR");
95 if (sturl.Length() != 0) {
96 fAODFileName = "alien://";
98 fAODFileName += "/AliAOD.root";
102 void AliAnalysisTaskTagCreator::UserExec(Option_t */*option*/)
105 // Create Tags for the current event
106 AliEventTag* evtTag = new AliEventTag();
107 fTagCreator->FillEventTag(AODEvent(), evtTag);
108 // Reference to the input file
109 TString fturl, fturltemp, guid;
111 TString opt(fInputHandler->GetAnalysisType());
114 TFile *file = OutputTree()->GetCurrentFile();
115 const TUrl *url = file->GetEndpointUrl();
116 guid = file->GetUUID().AsString();
117 if (fAODFileName.Length() != 0) {
118 fturl = fAODFileName;
121 fturl = url->GetFile();
124 if (fRunTag->GetFileId(guid) == -1) {
125 AliFileTag *eftag = new AliFileTag();
127 eftag->SetGUID(guid);
128 if(fAODFileName.Length() != 0) {
130 eftag->SetTURL(fturl);
133 else eftag->SetPath(fturl);
135 fRunTag->AddFileTag(eftag);
139 fRunTag->AddEventTag(*evtTag);
144 void AliAnalysisTaskTagCreator::FinishTaskOutput()
146 // Terminate analysis
148 if (fInputHandler->GetRunTag()) fRunTag->CopyStandardContent(fInputHandler->GetRunTag());
152 Bool_t AliAnalysisTaskTagCreator::Notify()
154 // Notify file change
155 fInputHandler = (AliInputEventHandler*)
156 ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
161 void AliAnalysisTaskTagCreator::GetGUID(TString &guid) {
162 // Get the guid of the AliAOD.root file
163 ofstream myfile ("guid.txt");
164 if (myfile.is_open()) {
165 TFile *f = TFile::Open("AliAOD.root","read");
167 guid = f->GetUUID().AsString();
168 myfile << "AliAOD.root \t"<<f->GetUUID().AsString();
169 cout<<guid.Data()<<endl;
172 else cout<<"Input file not found"<<endl;
175 else cout<<"Output file can't be created..."<<endl;
180 void AliAnalysisTaskTagCreator::Terminate(Option_t */*option*/)
182 // Terminate analysis
184 if (fDebug > 1) printf("AnalysisTagCreator: Terminate() \n");