2 const char* turl = gSystem->Getenv("ALIEN_JDL_OUTPUTDIR");
4 gSystem->Load("libNet.so");
5 gSystem->Load("libMonaLisa.so");
6 new TMonaLisaWriter(0, "GridAliRoot-tag.C", 0, 0, "global");
8 TString fESDFileName = "alien://";
10 fESDFileName += "/AliESDs.root";
17 TString fAliroot, fRoot, fGeant;
18 GetVersions(fAliroot,fRoot,fGeant);
20 UpdateTag(fAliroot,fRoot,fGeant,fESDFileName,fGUID);
23 //_____________________________________//
24 GetVersions(TString &fAliroot, TString &froot, TString &fgeant) {
25 const char* fver = gSystem->Getenv("ALIEN_JDL_PACKAGES");
27 Int_t fFirst = fS.First("#");
30 Int_t fTotalLength = fS.Length();
32 TString fS1 = fS(0,fFirst);
33 tmp = fS(fFirst+2,fTotalLength);
36 if(fS1.Contains("Root")) fAliroot = fS1;
37 if(fS1.Contains("ROOT")) froot = fS1;
38 if(fS1.Contains("GEANT")) fgeant = fS1;
40 if(tmp.Contains("Root")) fAliroot = tmp;
41 if(tmp.Contains("ROOT")) froot = tmp;
42 if(tmp.Contains("GEANT")) fgeant = tmp;
44 fFirst = tmp.First("#");
48 //_____________________________________//
49 GetGUID(TString &guid) {
50 ofstream myfile ("guid.txt");
51 if (myfile.is_open()) {
52 TFile *f = TFile::Open("AliESDs.root","read");
53 if(f && !f->IsZombie() && f->IsOpen()) {
54 guid = f->GetUUID().AsString();
55 myfile << "AliESDs.root \t"<<f->GetUUID().AsString();
56 cout<<guid.Data()<<endl;
59 else cout<<"Input file not found"<<endl;
61 else cout<<"Output file can't be created..."<<endl;
65 //_____________________________________//
66 Bool_t UpdateTag(TString faliroot, TString froot, TString fgeant, TString turl, TString guid) {
67 cout<<"> Updating tags...."<<endl;
69 const char * tagPattern = "tag.root";
70 // Open the working directory
71 void * dirp = gSystem->OpenDirectory(gSystem->pwd());
72 const char * name = 0x0;
73 // Add all files matching *pattern* to the chain
74 while((name = gSystem->GetDirEntry(dirp))) {
75 cout<<">>> Adding to chain file " << name << "...." << endl;
76 if (strstr(name,tagPattern)) {
77 TFile *f = TFile::Open(name,"read") ;
80 AliEventTag *evTag = 0x0;
81 TTree *fTree = (TTree *)f->Get("T");
82 if (!fTree) { f->Close(); continue; }
83 fTree->SetBranchAddress("AliTAG",&tag);
85 //Defining new tag objects
86 AliRunTag *newTag = 0x0;
87 TTree ttag("T","A Tree with event tags");
88 TBranch * btag = ttag.Branch("AliTAG", &newTag);
89 btag->SetCompressionLevel(9);
91 cout<<">>>>> Found " << fTree->GetEntries() << " entries...." << endl;
92 for(Int_t iTagFiles = 0; iTagFiles < fTree->GetEntries(); iTagFiles++) {
93 fTree->GetEntry(iTagFiles);
94 newTag = new AliRunTag(*tag);
95 newTag->SetAlirootVersion(faliroot);
96 newTag->SetRootVersion(froot);
97 newTag->SetGeant3Version(fgeant);
98 TClonesArray *tagList = newTag->GetEventTags();
99 cout << "Found " << tagList->GetEntries() << " tags" << endl;
100 for(Int_t j = 0; j < tagList->GetEntries(); j++) {
101 evTag = (AliEventTag *) tagList->At(j);
102 evTag->SetTURL(turl);
103 evTag->SetGUID(guid);
111 TFile* ftag = TFile::Open(name, "recreate");