]>
Commit | Line | Data |
---|---|---|
c7e89ea3 | 1 | /************************************************************************** |
2 | * Author: Panos Christakoglou. * | |
3 | * Contributors are mentioned in the code where appropriate. * | |
4 | * * | |
5 | * Permission to use, copy, modify and distribute this software and its * | |
6 | * documentation strictly for non-commercial purposes is hereby granted * | |
7 | * without fee, provided that the above copyright notice appears in all * | |
8 | * copies and that both the copyright notice and this permission notice * | |
9 | * appear in the supporting documentation. The authors make no claims * | |
10 | * about the suitability of this software for any purpose. It is * | |
11 | * provided "as is" without express or implied warranty. * | |
12 | **************************************************************************/ | |
13 | ||
14 | /* $Id$ */ | |
15 | ||
16 | //----------------------------------------------------------------- | |
17 | // AliTagAnalysis class | |
18 | // This is the class to deal with the tag analysis | |
19 | // Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch | |
20 | //----------------------------------------------------------------- | |
21 | ||
22 | //ROOT | |
23 | #include <TSystem.h> | |
24 | #include <TChain.h> | |
25 | #include <TFile.h> | |
26 | #include <TEventList.h> | |
f95f7fb5 | 27 | #include <TFileInfo.h> |
c7e89ea3 | 28 | |
29 | //ROOT-AliEn | |
30 | #include <TGridResult.h> | |
31 | ||
32 | #include "AliLog.h" | |
33 | ||
34 | #include "AliRunTag.h" | |
35 | #include "AliEventTag.h" | |
36 | #include "AliTagAnalysis.h" | |
37 | #include "AliEventTagCuts.h" | |
38 | ||
39 | class TTree; | |
40 | ||
41 | ClassImp(AliTagAnalysis) | |
42 | ||
43 | TChain *AliTagAnalysis::fgChain = 0; | |
44 | ||
45 | //______________________________________________________________________________ | |
46 | AliTagAnalysis::AliTagAnalysis(): TObject()//local mode | |
47 | { | |
48 | //==============Default constructor for a AliTagAnalysis================== | |
49 | ftagresult = 0; | |
50 | } | |
51 | ||
52 | //______________________________________________________________________________ | |
53 | AliTagAnalysis::~AliTagAnalysis() | |
54 | { | |
55 | //================Default destructor for a AliTagAnalysis======================= | |
56 | } | |
57 | ||
58 | //______________________________________________________________________________ | |
59 | void AliTagAnalysis::ChainLocalTags(const char *dirname) //local version | |
60 | { | |
61 | //Searches the entries of the provided direcory | |
62 | //Chains the tags that are stored locally | |
63 | fTagDirName = dirname; | |
64 | TString fTagFilename; | |
65 | ||
66 | TChain *fgChain = new TChain("T"); | |
67 | fChain = fgChain; | |
68 | ||
69 | const char * tagPattern = "tag"; | |
70 | // Open the working directory | |
71 | void * dirp = gSystem->OpenDirectory(fTagDirName); | |
72 | const char * name = 0x0; | |
73 | // Add all files matching *pattern* to the chain | |
74 | while((name = gSystem->GetDirEntry(dirp))) | |
75 | { | |
76 | if (strstr(name,tagPattern)) | |
77 | { | |
78 | fTagFilename = fTagDirName; | |
79 | fTagFilename += "/"; | |
80 | fTagFilename += name; | |
81 | ||
82 | TFile * fTag = TFile::Open(fTagFilename); | |
83 | if((!fTag) || (!fTag->IsOpen())) | |
84 | { | |
85 | AliError(Form("Tag file not opened!!!")); | |
86 | continue; | |
87 | } | |
88 | fChain->Add(fTagFilename); | |
89 | fTag->Close(); | |
90 | delete fTag; | |
91 | }//pattern check | |
92 | }//directory loop | |
93 | AliInfo(Form("Chained tag files: %d ",fChain->GetEntries())); | |
94 | } | |
95 | ||
96 | ||
97 | //______________________________________________________________________________ | |
98 | void AliTagAnalysis::ChainGridTags(TGridResult *res) | |
99 | { | |
100 | //Loops overs the entries of the TGridResult | |
101 | //Chains the tags that are stored in the GRID | |
102 | ftagresult = res; | |
103 | Int_t nEntries = ftagresult->GetEntries(); | |
104 | ||
105 | TChain *fgChain = new TChain("T"); | |
106 | fChain = fgChain; | |
107 | ||
108 | TString gridname = "alien://"; | |
109 | TString alienUrl; | |
110 | ||
111 | for(Int_t i = 0; i < nEntries; i++) | |
112 | { | |
113 | alienUrl = ftagresult->GetKey(i,"turl"); | |
114 | TFile *f = TFile::Open(alienUrl,"READ"); | |
115 | fChain->Add(alienUrl); | |
116 | //f->Close(); | |
117 | delete f; | |
118 | }//grid result loop | |
119 | } | |
120 | ||
121 | ||
122 | //______________________________________________________________________________ | |
123 | TList *AliTagAnalysis::QueryTags(AliEventTagCuts *EvTagCuts) | |
124 | { | |
125 | //Queries the tag chain using the defined | |
126 | //event tag cuts from the AliEventTagCuts object | |
127 | AliInfo(Form("Querying the tags........")); | |
128 | ||
129 | //file info list | |
130 | TList *list = new TList(); | |
131 | ||
132 | Int_t iAccepted = 0, evCounter = 0; | |
133 | ||
134 | //Defining tag objects | |
135 | AliRunTag *tag = new AliRunTag; | |
136 | AliEventTag *evTag = new AliEventTag; | |
137 | fChain->SetBranchAddress("AliTAG",&tag); | |
138 | ||
139 | Long64_t size = -1; | |
140 | const char* md5 = 0; | |
141 | const char* guid = 0; | |
142 | const char* turl = 0; | |
143 | ||
144 | for(Int_t iTagFiles = 0; iTagFiles < fChain->GetEntries(); iTagFiles++) | |
145 | { | |
146 | TEventList *fEventList = new TEventList(); | |
147 | evCounter = 0; | |
148 | fChain->GetEntry(iTagFiles); | |
149 | Int_t iEvents = tag->GetNEvents(); | |
150 | const TClonesArray *tagList = tag->GetEventTags(); | |
151 | for(Int_t i = 0; i < iEvents; i++) | |
152 | { | |
153 | evTag = (AliEventTag *) tagList->At(i); | |
154 | size = evTag->GetSize(); | |
155 | md5 = evTag->GetMD5(); | |
156 | guid = evTag->GetGUID(); | |
157 | turl = evTag->GetTURL(); | |
158 | if(EvTagCuts->IsAccepted(evTag)) | |
159 | { | |
160 | fEventList->Enter(i); | |
161 | evCounter++; | |
162 | ||
163 | iAccepted++; | |
164 | } | |
165 | }//event loop | |
166 | ||
167 | //adding a TFileInfo object to the list | |
168 | if(evCounter != 0) | |
169 | list->Add(new TFileInfo(turl,size,guid,md5,-1,-1,-1,fEventList)); | |
170 | fEventList->Clear(""); | |
171 | delete fEventList; | |
172 | }//tag file loop | |
173 | AliInfo(Form("Accepted events: %d",iAccepted)); | |
174 | ||
175 | return list; | |
176 | } | |
177 | ||
178 |