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>
29 #include <TGridResult.h>
33 #include "AliRunTag.h"
34 #include "AliEventTag.h"
35 #include "AliTagAnalysis.h"
36 #include "AliEventTagCuts.h"
40 ClassImp(AliTagAnalysis)
42 TChain *AliTagAnalysis::fgChain = 0;
44 //______________________________________________________________________________
45 AliTagAnalysis::AliTagAnalysis(): TObject()//local mode
47 //==============Default constructor for a AliTagAnalysis==================
51 //______________________________________________________________________________
52 AliTagAnalysis::~AliTagAnalysis()
54 //================Default destructor for a AliTagAnalysis=======================
57 //______________________________________________________________________________
58 void AliTagAnalysis::ChainLocalTags(const char *dirname) //local version
60 //Searches the entries of the provided direcory
61 //Chains the tags that are stored locally
62 fTagDirName = dirname;
65 TChain *fgChain = new TChain("T");
68 const char * tagPattern = "tag";
69 // Open the working directory
70 void * dirp = gSystem->OpenDirectory(fTagDirName);
71 const char * name = 0x0;
72 // Add all files matching *pattern* to the chain
73 while((name = gSystem->GetDirEntry(dirp)))
75 if (strstr(name,tagPattern))
77 fTagFilename = fTagDirName;
81 TFile * fTag = TFile::Open(fTagFilename);
82 if((!fTag) || (!fTag->IsOpen()))
84 AliError(Form("Tag file not opened!!!"));
87 fChain->Add(fTagFilename);
92 AliInfo(Form("Chained tag files: %d ",fChain->GetEntries()));
96 //______________________________________________________________________________
97 void AliTagAnalysis::ChainGridTags(TGridResult *res)
99 //Loops overs the entries of the TGridResult
100 //Chains the tags that are stored in the GRID
102 Int_t nEntries = ftagresult->GetEntries();
104 TChain *fgChain = new TChain("T");
107 TString gridname = "alien://";
110 for(Int_t i = 0; i < nEntries; i++)
112 alienUrl = ftagresult->GetKey(i,"turl");
113 TFile *f = TFile::Open(alienUrl,"READ");
114 fChain->Add(alienUrl);
121 //______________________________________________________________________________
122 TList *AliTagAnalysis::QueryTags(AliEventTagCuts *EvTagCuts)
124 //Queries the tag chain using the defined
125 //event tag cuts from the AliEventTagCuts object
126 AliInfo(Form("Querying the tags........"));
129 TList *list = new TList();
131 Int_t iAccepted = 0, evCounter = 0;
133 //Defining tag objects
134 AliRunTag *tag = new AliRunTag;
135 AliEventTag *evTag = new AliEventTag;
136 fChain->SetBranchAddress("AliTAG",&tag);
140 const char* guid = 0;
141 const char* turl = 0;
143 for(Int_t iTagFiles = 0; iTagFiles < fChain->GetEntries(); iTagFiles++)
145 TEventList *fEventList = new TEventList();
147 fChain->GetEntry(iTagFiles);
148 Int_t iEvents = tag->GetNEvents();
149 const TClonesArray *tagList = tag->GetEventTags();
150 for(Int_t i = 0; i < iEvents; i++)
152 evTag = (AliEventTag *) tagList->At(i);
153 size = evTag->GetSize();
154 md5 = evTag->GetMD5();
155 guid = evTag->GetGUID();
156 turl = evTag->GetTURL();
157 if(EvTagCuts->IsAccepted(evTag))
159 fEventList->Enter(i);
166 //adding a TFileInfo object to the list
168 list->Add(new TFileInfo(turl,size,guid,md5,-1,-1,-1,fEventList));
169 fEventList->Clear("");
172 AliInfo(Form("Accepted events: %d",iAccepted));