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():
52 // Default constructor
55 AliAnalysisTaskTagCreator::AliAnalysisTaskTagCreator(const char* name):
56 AliAnalysisTaskSE(name),
66 DefineOutput(1, TTree::Class());
69 void AliAnalysisTaskTagCreator::UserCreateOutputObjects()
71 // Create the output container
73 fTreeT = new TTree("T", "AOD Tags");
74 fRunTag = new AliRunTag();
75 TBranch * btag = fTreeT->Branch("AliTAG", "AliRunTag", &fRunTag);
76 btag->SetCompressionLevel(9);
77 fTagCreator = new AliAODTagCreator();
80 void AliAnalysisTaskTagCreator::Init()
85 void AliAnalysisTaskTagCreator::ConnectInputData(Option_t * /*option*/)
88 const char* turl = gSystem->Getenv("ALIEN_JDL_OUTPUTDIR");
91 if (sturl.Length() != 0) {
92 fAODFileName = "alien://";
94 fAODFileName += "/AliAOD.root";
98 void AliAnalysisTaskTagCreator::UserExec(Option_t */*option*/)
101 // Create Tags for the current event
102 AliEventTag* evtTag = new AliEventTag();
103 fTagCreator->FillEventTag(AODEvent(), evtTag);
104 // Reference to the input file
105 TString fturl, fturltemp, guid;
107 TString opt(fInputHandler->GetAnalysisType());
110 TFile *file = OutputTree()->GetCurrentFile();
111 const TUrl *url = file->GetEndpointUrl();
112 guid = file->GetUUID().AsString();
113 if (fAODFileName.Length() != 0) {
114 fturl = fAODFileName;
117 fturl = url->GetFile();
120 if (fRunTag->GetFileId(guid) == -1) {
121 AliFileTag *eftag = new AliFileTag();
123 eftag->SetGUID(guid);
124 if(fAODFileName.Length() != 0) {
126 eftag->SetTURL(fturl);
129 else eftag->SetPath(fturl);
131 fRunTag->AddFileTag(eftag);
135 fRunTag->AddEventTag(*evtTag);
140 void AliAnalysisTaskTagCreator::FinishTaskOutput()
142 // Terminate analysis
144 if (fInputHandler->GetRunTag()) fRunTag->CopyStandardContent(fInputHandler->GetRunTag());
148 Bool_t AliAnalysisTaskTagCreator::Notify()
150 // Notify file change
151 fInputHandler = (AliInputEventHandler*)
152 ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
157 void AliAnalysisTaskTagCreator::GetGUID(TString &guid) {
158 // Get the guid of the AliAOD.root file
159 ofstream myfile ("guid.txt");
160 if (myfile.is_open()) {
161 TFile *f = TFile::Open("AliAOD.root","read");
163 guid = f->GetUUID().AsString();
164 myfile << "AliAOD.root \t"<<f->GetUUID().AsString();
165 cout<<guid.Data()<<endl;
168 else cout<<"Input file not found"<<endl;
171 else cout<<"Output file can't be created..."<<endl;
176 void AliAnalysisTaskTagCreator::Terminate(Option_t */*option*/)
178 // Terminate analysis
180 if (fDebug > 1) printf("AnalysisTagCreator: Terminate() \n");