1 /**************************************************************************
2 * Author: Panos Christakoglou. *
3 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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 //-----------------------------------------------------------------
26 #include <TEventList.h>
27 #include <TFileInfo.h>
30 #include <TGridResult.h>
34 #include "AliRunTag.h"
35 #include "AliEventTag.h"
36 #include "AliTagAnalysis.h"
37 #include "AliEventTagCuts.h"
41 ClassImp(AliTagAnalysis)
43 TChain *AliTagAnalysis::fgChain = 0;
45 //______________________________________________________________________________
46 AliTagAnalysis::AliTagAnalysis(): TObject()//local mode
48 //==============Default constructor for a AliTagAnalysis==================
52 //______________________________________________________________________________
53 AliTagAnalysis::~AliTagAnalysis()
55 //================Default destructor for a AliTagAnalysis=======================
58 //______________________________________________________________________________
59 void AliTagAnalysis::ChainLocalTags(const char *dirname) //local version
61 //Searches the entries of the provided direcory
62 //Chains the tags that are stored locally
63 fTagDirName = dirname;
66 TChain *fgChain = new TChain("T");
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)))
76 if (strstr(name,tagPattern))
78 fTagFilename = fTagDirName;
82 TFile * fTag = TFile::Open(fTagFilename);
83 if((!fTag) || (!fTag->IsOpen()))
85 AliError(Form("Tag file not opened!!!"));
88 fChain->Add(fTagFilename);
93 AliInfo(Form("Chained tag files: %d ",fChain->GetEntries()));
97 //______________________________________________________________________________
98 void AliTagAnalysis::ChainGridTags(TGridResult *res)
100 //Loops overs the entries of the TGridResult
101 //Chains the tags that are stored in the GRID
103 Int_t nEntries = ftagresult->GetEntries();
105 TChain *fgChain = new TChain("T");
108 TString gridname = "alien://";
111 for(Int_t i = 0; i < nEntries; i++)
113 alienUrl = ftagresult->GetKey(i,"turl");
114 TFile *f = TFile::Open(alienUrl,"READ");
115 fChain->Add(alienUrl);
122 //______________________________________________________________________________
123 TList *AliTagAnalysis::QueryTags(AliEventTagCuts *EvTagCuts)
125 //Queries the tag chain using the defined
126 //event tag cuts from the AliEventTagCuts object
127 AliInfo(Form("Querying the tags........"));
130 TList *list = new TList();
132 Int_t iAccepted = 0, evCounter = 0;
134 //Defining tag objects
135 AliRunTag *tag = new AliRunTag;
136 AliEventTag *evTag = new AliEventTag;
137 fChain->SetBranchAddress("AliTAG",&tag);
141 const char* guid = 0;
142 const char* turl = 0;
144 for(Int_t iTagFiles = 0; iTagFiles < fChain->GetEntries(); iTagFiles++)
146 TEventList *fEventList = new TEventList();
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++)
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))
160 fEventList->Enter(i);
167 //adding a TFileInfo object to the list
169 list->Add(new TFileInfo(turl,size,guid,md5,-1,-1,-1,fEventList));
170 fEventList->Clear("");
173 AliInfo(Form("Accepted events: %d",iAccepted));