Skip to content

Commit

Permalink
Updating test/QA/tag.C
Browse files Browse the repository at this point in the history
From AliEn: /alice/cern.ch/user/p/pwg_pp/DataProcessingTimingLHC15o/ppass/tag.C
  • Loading branch information
dberzano committed Feb 9, 2016
1 parent 65b062c commit e754580
Showing 1 changed file with 61 additions and 19 deletions.
80 changes: 61 additions & 19 deletions test/QA/tag.C
Original file line number Diff line number Diff line change
@@ -1,16 +1,50 @@
void tag() {

TStopwatch st;

const char* turl = gSystem->Getenv("ALIEN_JDL_OUTPUTDIR");

gSystem->Load("libNet.so");
// gSystem->Load("libMonaLisa.so");
// new TMonaLisaWriter(0, "GridAliRoot-tag.C", 0, 0, "global");

TString fESDFileName = "alien://";
fESDFileName += turl;
fESDFileName += "/AliESDs.root";

TString fGUID = 0;
GetGUID(fGUID);

gEnv->Print();

TString fAliroot, fRoot, fGeant;
GetVersions(fAliroot,fRoot,fGeant);

UpdateTag(fAliroot,fRoot,fGeant,fESDFileName,fGUID);
TString fPeriod, fPass, fName;
GetProductionInfo(fPeriod, fPass, fName);
//
UpdateTag(fAliroot,fRoot,fGeant,fESDFileName,fGUID,fPeriod,fPass,fName);

st.Stop();
Printf("Printing time for tag creation");
st.Print();

}

//_____________________________________//
GetProductionInfo(TString &fPeriod, TString &fPass, TString &fName) {
const char* turl = gSystem->Getenv("ALIEN_JDL_OUTPUTDIR");

TString fS = turl;
TObjArray *fDirs = fS.Tokenize("/");

for (int iter=0; iter<fDirs->GetEntries(); iter++) {
TString fDir = ((TObjString *) fDirs->At(iter))->String();

if (fDir.Contains("LHC")) fPeriod = fDir;
if (fDir.Contains("pass")) fPass = fDir;
}
fName = fPeriod+"."+fPass;
}

//_____________________________________//
Expand Down Expand Up @@ -43,7 +77,7 @@ GetGUID(TString &guid) {
ofstream myfile ("guid.txt");
if (myfile.is_open()) {
TFile *f = TFile::Open("AliESDs.root","read");
if(f->IsOpen()) {
if(f && !f->IsZombie() && f->IsOpen()) {
guid = f->GetUUID().AsString();
myfile << "AliESDs.root \t"<<f->GetUUID().AsString();
cout<<guid.Data()<<endl;
Expand All @@ -56,52 +90,60 @@ GetGUID(TString &guid) {


//_____________________________________//
Bool_t UpdateTag(TString faliroot, TString froot, TString fgeant, TString turl, TString guid) {
cout<<"Updating tags....."<<endl;
Bool_t UpdateTag(TString faliroot, TString froot, TString fgeant,
TString turl, TString guid,
TString fperiod, TString fpass, TString fname) {
cout<<"> Updating tags...."<<endl;

const char * tagPattern = "tag.root";
// Open the working directory
void * dirp = gSystem->OpenDirectory(gSystem->pwd());
const char * name = 0x0;
// Add all files matching *pattern* to the chain
while((name = gSystem->GetDirEntry(dirp))) {
cout<<">>> Adding to chain file " << name << "...." << endl;
if (strstr(name,tagPattern)) {
TFile *f = TFile::Open(name,"read") ;

AliRunTag *tag = new AliRunTag;
AliEventTag *evTag = new AliEventTag;
AliRunTag *tag = 0x0;
AliFileTag *flTag = 0x0;
TTree *fTree = (TTree *)f->Get("T");
if (!fTree) { f->Close(); continue; }
fTree->SetBranchAddress("AliTAG",&tag);

//Defining new tag objects
AliRunTag *newTag = new AliRunTag();
AliRunTag *newTag = 0x0;
TTree ttag("T","A Tree with event tags");
TBranch * btag = ttag.Branch("AliTAG", &newTag);
btag->SetCompressionLevel(9);

cout<<">>>>> Found " << fTree->GetEntries() << " entries...." << endl;
for(Int_t iTagFiles = 0; iTagFiles < fTree->GetEntries(); iTagFiles++) {
fTree->GetEntry(iTagFiles);
newTag->SetRunId(tag->GetRunId());
fTree->GetEntry(0);
newTag = new AliRunTag(*tag);
newTag->SetAlirootVersion(faliroot);
newTag->SetRootVersion(froot);
newTag->SetGeant3Version(fgeant);
const TClonesArray *tagList = tag->GetEventTags();
for(Int_t j = 0; j < tagList->GetEntries(); j++) {
evTag = (AliEventTag *) tagList->At(j);
evTag->SetTURL(turl);
evTag->SetGUID(guid);
newTag->AddEventTag(*evTag);
}
newTag->SetLHCPeriod(fperiod);
newTag->SetReconstructionPass(fpass);
newTag->SetProductionName(fname);
cout << "Found " << newTag->GetNFiles() << " file tags" << endl;
for(Int_t j = 0; j < newTag->GetNFiles(); j++) {
flTag = (AliFileTag *) newTag->GetFileTag(j);
flTag->SetTURL(turl);
flTag->SetGUID(guid);
}
ttag.Fill();
newTag->Clear();

delete tag;
delete newTag;
}//tag file loop

TFile* ftag = TFile::Open(name, "recreate");
ftag->cd();
ttag.Write();
ftag->Close();

delete tag;
delete newTag;
}//pattern check
}//directory loop
return kTRUE;
Expand Down

0 comments on commit e754580

Please sign in to comment.