2 const char* turl = gSystem->Getenv("ALIEN_JDL_OUTPUTDIR");
4 gSystem->Load("libNet");
5 // gSystem->Load("libMonaLisa");
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 TString fPeriod, fPass, fName;
21 GetProductionInfo(fPeriod, fPass, fName);
23 UpdateTag(fAliroot,fRoot,fGeant,fESDFileName,fGUID,fPeriod,fPass,fName);
26 //_____________________________________//
27 GetProductionInfo(TString &fPeriod, TString &fPass, TString &fName) {
28 const char* turl = gSystem->Getenv("ALIEN_JDL_OUTPUTDIR");
31 TObjArray *fDirs = fS.Tokenize("/");
33 for (int iter=0; iter<fDirs->GetEntries(); iter++) {
34 TString fDir = ((TObjString *) fDirs->At(iter))->String();
36 if (fDir.Contains("LHC")) fPeriod = fDir;
37 if (fDir.Contains("pass")) fPass = fDir;
39 fName = fPeriod+"."+fPass;
42 //_____________________________________//
43 GetVersions(TString &fAliroot, TString &froot, TString &fgeant) {
44 const char* fver = gSystem->Getenv("ALIEN_JDL_PACKAGES");
46 Int_t fFirst = fS.First("#");
49 Int_t fTotalLength = fS.Length();
51 TString fS1 = fS(0,fFirst);
52 tmp = fS(fFirst+2,fTotalLength);
55 if(fS1.Contains("Root")) fAliroot = fS1;
56 if(fS1.Contains("ROOT")) froot = fS1;
57 if(fS1.Contains("GEANT")) fgeant = fS1;
59 if(tmp.Contains("Root")) fAliroot = tmp;
60 if(tmp.Contains("ROOT")) froot = tmp;
61 if(tmp.Contains("GEANT")) fgeant = tmp;
63 fFirst = tmp.First("#");
67 //_____________________________________//
68 GetGUID(TString &guid) {
69 ofstream myfile ("guid.txt");
70 if (myfile.is_open()) {
71 TFile *f = TFile::Open("AliESDs.root","read");
72 if(f && !f->IsZombie() && f->IsOpen()) {
73 guid = f->GetUUID().AsString();
74 myfile << "AliESDs.root \t"<<f->GetUUID().AsString();
75 cout<<guid.Data()<<endl;
78 else cout<<"Input file not found"<<endl;
80 else cout<<"Output file can't be created..."<<endl;
84 //_____________________________________//
85 Bool_t UpdateTag(TString faliroot, TString froot, TString fgeant,
86 TString turl, TString guid,
87 TString fperiod, TString fpass, TString fname) {
88 cout<<"> Updating tags...."<<endl;
90 const char * tagPattern = "tag.root";
91 // Open the working directory
92 void * dirp = gSystem->OpenDirectory(gSystem->pwd());
93 const char * name = 0x0;
94 // Add all files matching *pattern* to the chain
95 while((name = gSystem->GetDirEntry(dirp))) {
96 cout<<">>> Adding to chain file " << name << "...." << endl;
97 if (strstr(name,tagPattern)) {
98 TFile *f = TFile::Open(name,"read") ;
100 AliRunTag *tag = 0x0;
101 AliFileTag *flTag = 0x0;
102 TTree *fTree = (TTree *)f->Get("T");
103 if (!fTree) { f->Close(); continue; }
104 fTree->SetBranchAddress("AliTAG",&tag);
106 //Defining new tag objects
107 AliRunTag *newTag = 0x0;
108 TTree ttag("T","A Tree with event tags");
109 TBranch * btag = ttag.Branch("AliTAG", &newTag);
110 btag->SetCompressionLevel(9);
112 cout<<">>>>> Found " << fTree->GetEntries() << " entries...." << endl;
113 for(Int_t iTagFiles = 0; iTagFiles < fTree->GetEntries(); iTagFiles++) {
115 newTag = new AliRunTag(*tag);
116 newTag->SetAlirootVersion(faliroot);
117 newTag->SetRootVersion(froot);
118 newTag->SetGeant3Version(fgeant);
119 newTag->SetLHCPeriod(fperiod);
120 newTag->SetReconstructionPass(fpass);
121 newTag->SetProductionName(fname);
122 cout << "Found " << newTag->GetNFiles() << " file tags" << endl;
123 for(Int_t j = 0; j < newTag->GetNFiles(); j++) {
124 flTag = (AliFileTag *) newTag->GetFileTag(j);
125 flTag->SetTURL(turl);
126 flTag->SetGUID(guid);
134 TFile* ftag = TFile::Open(name, "recreate");