]>
Commit | Line | Data |
---|---|---|
f8b7a926 | 1 | void Tag() { |
2 | const char* turl = gSystem->Getenv("ALIEN_JDL_OUTPUTDIR"); | |
3 | ||
4 | gSystem->Load("libNet.so"); | |
5 | // gSystem->Load("libMonaLisa.so"); | |
6 | // new TMonaLisaWriter(0, "GridAliRoot-tag.C", 0, 0, "global"); | |
7 | ||
8 | TString fESDFileName = "alien://"; | |
9 | fESDFileName += turl; | |
10 | fESDFileName += "/AliESDs.root"; | |
11 | ||
12 | TString fGUID = 0; | |
13 | GetGUID(fGUID); | |
14 | ||
15 | gEnv->Print(); | |
16 | ||
17 | TString fAliroot, fRoot, fGeant; | |
18 | GetVersions(fAliroot,fRoot,fGeant); | |
19 | ||
20 | TString fPeriod, fPass, fName; | |
21 | GetProductionInfo(fPeriod, fPass, fName); | |
22 | ||
23 | UpdateTag(fAliroot,fRoot,fGeant,fESDFileName,fGUID,fPeriod,fPass,fName); | |
24 | } | |
25 | ||
26 | //_____________________________________// | |
27 | GetProductionInfo(TString &fPeriod, TString &fPass, TString &fName) { | |
28 | const char* turl = gSystem->Getenv("ALIEN_JDL_OUTPUTDIR"); | |
29 | ||
30 | TString fS = turl; | |
31 | TObjArray *fDirs = fS.Tokenize("/"); | |
32 | ||
33 | for (int iter=0; iter<fDirs->GetEntries(); iter++) { | |
34 | TString fDir = ((TObjString *) fDirs->At(iter))->String(); | |
35 | ||
36 | if (fDir.Contains("LHC")) fPeriod = fDir; | |
37 | if (fDir.Contains("pass")) fPass = fDir; | |
38 | } | |
39 | fName = fPeriod+"."+fPass; | |
40 | } | |
41 | ||
42 | //_____________________________________// | |
43 | GetVersions(TString &fAliroot, TString &froot, TString &fgeant) { | |
44 | const char* fver = gSystem->Getenv("ALIEN_JDL_PACKAGES"); | |
45 | TString fS = fver; | |
46 | Int_t fFirst = fS.First("#"); | |
47 | ||
48 | while(fFirst != -1) { | |
49 | Int_t fTotalLength = fS.Length(); | |
50 | TString tmp = fS; | |
51 | TString fS1 = fS(0,fFirst); | |
52 | tmp = fS(fFirst+2,fTotalLength); | |
53 | fS = tmp; | |
54 | ||
55 | if(fS1.Contains("Root")) fAliroot = fS1; | |
56 | if(fS1.Contains("ROOT")) froot = fS1; | |
57 | if(fS1.Contains("GEANT")) fgeant = fS1; | |
58 | ||
59 | if(tmp.Contains("Root")) fAliroot = tmp; | |
60 | if(tmp.Contains("ROOT")) froot = tmp; | |
61 | if(tmp.Contains("GEANT")) fgeant = tmp; | |
62 | ||
63 | fFirst = tmp.First("#"); | |
64 | } | |
65 | } | |
66 | ||
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; | |
76 | myfile.close(); | |
77 | } | |
78 | else cout<<"Input file not found"<<endl; | |
79 | } | |
80 | else cout<<"Output file can't be created..."<<endl; | |
81 | } | |
82 | ||
83 | ||
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; | |
89 | ||
90 | const TString tagPattern = "tag.root"; | |
91 | // Open the working directory | |
92 | TSystemDirectory dir(".", gSystem->pwd()); | |
93 | TIter next(dir.GetListOfFiles()); | |
94 | TSystemFile* file = 0; | |
95 | // Add all files matching *pattern* to the chain | |
96 | while ((file = static_cast<TSystemFile*>(next()))) { | |
97 | TString name(file->GetName()); | |
98 | if (!name.Contains(tagPattern)) continue; | |
99 | ||
100 | TFile* f = TFile::Open(name,"read") ; | |
101 | AliRunTag* tag = 0x0; | |
102 | AliFileTag* flTag = 0x0; | |
103 | TTree* fTree = (TTree *)f->Get("T"); | |
104 | if (!fTree) { | |
105 | f->Close(); | |
106 | continue; | |
107 | } | |
108 | fTree->SetBranchAddress("AliTAG",&tag); | |
109 | ||
110 | //Defining new tag objects | |
111 | AliRunTag* newTag = 0x0; | |
112 | TTree ttag("T","A Tree with event tags"); | |
113 | TBranch* btag = ttag.Branch("AliTAG", &newTag); | |
114 | btag->SetCompressionLevel(9); | |
115 | ||
116 | Printf(">>>>> Found %d entries....",fTree->GetEntries()); | |
117 | ||
118 | for (Int_t iTagFiles = 0; iTagFiles < fTree->GetEntries(); iTagFiles++) { | |
119 | fTree->GetEntry(0); | |
120 | newTag = new AliRunTag(*tag); | |
121 | newTag->SetAlirootVersion(faliroot); | |
122 | newTag->SetRootVersion(froot); | |
123 | newTag->SetGeant3Version(fgeant); | |
124 | newTag->SetLHCPeriod(fperiod); | |
125 | newTag->SetReconstructionPass(fpass); | |
126 | newTag->SetProductionName(fname); | |
127 | Printf("Found %d file tags",newTag->GetNFiles()); | |
128 | for(Int_t j = 0; j < newTag->GetNFiles(); j++) { | |
129 | flTag = (AliFileTag *) newTag->GetFileTag(j); | |
130 | flTag->SetTURL(turl); | |
131 | flTag->SetGUID(guid); | |
132 | } | |
133 | ttag.Fill(); | |
134 | ||
135 | delete tag; | |
136 | delete newTag; | |
137 | }//tag file loop | |
138 | ||
139 | TFile* ftag = TFile::Open(name, "recreate"); | |
140 | ftag->cd(); | |
141 | ttag.Write(); | |
142 | ftag->Close(); | |
143 | }//directory loop | |
144 | return kTRUE; | |
145 | } | |
146 | ||
147 | // | |
148 | // EOF | |
149 | // |