]>
Commit | Line | Data |
---|---|---|
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 | ||
34 | ClassImp(AliAnalysisTaskTagCreator) | |
35 | ||
36 | //////////////////////////////////////////////////////////////////////// | |
37 | ||
38 | AliAnalysisTaskTagCreator::AliAnalysisTaskTagCreator(): | |
39 | AliAnalysisTaskSE(), | |
40 | fFirstFile(kTRUE), | |
41 | fRunTag(0), | |
42 | fTreeT(0), | |
43 | fTagCreator(0) | |
44 | { | |
45 | // Default constructor | |
46 | } | |
47 | ||
48 | AliAnalysisTaskTagCreator::AliAnalysisTaskTagCreator(const char* name): | |
49 | AliAnalysisTaskSE(name), | |
50 | fFirstFile(kTRUE), | |
51 | fRunTag(0), | |
52 | fTreeT(0), | |
53 | fTagCreator(0) | |
54 | { | |
55 | // Constructor | |
56 | DefineOutput(1, TTree::Class()); | |
57 | } | |
58 | ||
59 | void AliAnalysisTaskTagCreator::UserCreateOutputObjects() | |
60 | { | |
61 | // Create the output container | |
62 | OpenFile(1); | |
63 | fTreeT = new TTree("T", "AOD Tags"); | |
64 | fRunTag = new AliRunTag(); | |
65 | TBranch * btag = fTreeT->Branch("AliTAG", "AliRunTag", &fRunTag); | |
66 | btag->SetCompressionLevel(9); | |
67 | fTagCreator = new AliAODTagCreator(); | |
68 | } | |
69 | ||
70 | void AliAnalysisTaskTagCreator::Init() | |
71 | { | |
72 | // Initialization | |
73 | if (fDebug > 1) AliInfo("Init() \n"); | |
74 | // Call configuration file | |
75 | } | |
76 | ||
77 | ||
78 | void AliAnalysisTaskTagCreator::UserExec(Option_t */*option*/) | |
79 | { | |
80 | // Create Tags for the current event | |
81 | AliEventTag* evtTag = new AliEventTag(); | |
82 | fTagCreator->FillEventTag(AODEvent(), evtTag); | |
83 | // Reference to the input file | |
84 | TString fturl, fturltemp, fguid; | |
85 | ||
86 | TString opt(fInputHandler->GetAnalysisType()); | |
87 | opt.ToLower(); | |
88 | ||
89 | TFile *file = OutputTree()->GetCurrentFile(); | |
90 | const TUrl *url = file->GetEndpointUrl(); | |
91 | fguid = file->GetUUID().AsString(); | |
92 | if (opt.Contains("grid")) { | |
93 | fturltemp = "alien://"; fturltemp += url->GetFile(); | |
94 | fturl = fturltemp(0,fturltemp.Index(".root",5,0,TString::kExact)+5); | |
95 | } else { | |
96 | fturl = url->GetFile(); | |
97 | } | |
98 | evtTag->SetEventId(fInputHandler->GetReadEntry() + 1); | |
99 | evtTag->SetGUID(fguid); | |
100 | if(opt.Contains("grid")) { | |
101 | evtTag->SetMD5(0); | |
102 | evtTag->SetTURL(fturl); | |
103 | evtTag->SetSize(0); | |
104 | } | |
105 | else evtTag->SetPath(fturl); | |
106 | // | |
107 | // Add the event tag | |
108 | fRunTag->AddEventTag(*evtTag); | |
109 | PostData(1, fTreeT); | |
110 | } | |
111 | ||
112 | ||
113 | void AliAnalysisTaskTagCreator::FinishTaskOutput() | |
114 | { | |
115 | // Terminate analysis | |
116 | // | |
117 | if (fInputHandler->GetRunTag()) fRunTag->CopyStandardContent(fInputHandler->GetRunTag()); | |
118 | fTreeT->Fill(); | |
119 | } | |
120 | ||
121 | Bool_t AliAnalysisTaskTagCreator::Notify() | |
122 | { | |
123 | // Notify file change | |
124 | if (!fFirstFile) { | |
125 | if (fInputHandler->GetRunTag()) fRunTag->CopyStandardContent(fInputHandler->GetRunTag()); | |
126 | fTreeT->Fill(); | |
127 | fRunTag->Clear(); | |
128 | } else { | |
129 | fFirstFile = kFALSE; | |
130 | } | |
f9f9c880 | 131 | return kTRUE; |
7e27c6e3 | 132 | } |
133 | ||
134 | ||
135 | void AliAnalysisTaskTagCreator::Terminate(Option_t */*option*/) | |
136 | { | |
137 | // Terminate analysis | |
138 | // | |
139 | if (fDebug > 1) printf("AnalysisTagCreator: Terminate() \n"); | |
140 | } | |
141 |