Skip to content

Commit

Permalink
Retagging v4-17-Rev-22
Browse files Browse the repository at this point in the history
  • Loading branch information
hristov committed Dec 16, 2009
2 parents 82e5f6f + 4a5e580 commit 47a200b
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 113 deletions.
7 changes: 4 additions & 3 deletions STEER/AliDetectorTag.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ AliDetectorTag::AliDetectorTag() :
//___________________________________________________________________________
AliDetectorTag::AliDetectorTag(const AliDetectorTag & detTag) :
TObject(detTag),
fDetectorArray(detTag.fDetectorArray),
fDetectorArray(new TObjArray(*detTag.fDetectorArray)),
fMask(detTag.fMask),
fITSSPD(detTag.fITSSPD),
fITSSDD(detTag.fITSSDD),
Expand Down Expand Up @@ -85,7 +85,7 @@ AliDetectorTag & AliDetectorTag::operator=(const AliDetectorTag &detTag) {
if (this != &detTag) {
TObject::operator=(detTag);

fDetectorArray = detTag.fDetectorArray;
fDetectorArray = new TObjArray(*detTag.fDetectorArray);
fMask = detTag.fMask;
fITSSPD = detTag.fITSSPD;
fITSSDD = detTag.fITSSDD;
Expand All @@ -110,7 +110,8 @@ AliDetectorTag & AliDetectorTag::operator=(const AliDetectorTag &detTag) {
//___________________________________________________________________________
AliDetectorTag::~AliDetectorTag() {
// Destructor
delete fDetectorArray;
if (fDetectorArray)
delete fDetectorArray;
}

//___________________________________________________________________________
Expand Down
2 changes: 1 addition & 1 deletion STEER/AliMagF.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ AliMagF* AliMagF::CreateFieldMap(Float_t l3Cur, Float_t diCur, Int_t convention,
else {
if (TMath::Abs((sclL3=l3Cur/l3NominalCurrent1)-1.) < tolerance) map = k5kG;
else if (TMath::Abs((sclL3=l3Cur/l3NominalCurrent2)-1.) < tolerance) map = k2kG;
else if (l3Cur <= zero) { sclL3 = 0; map = k5kGUniform;}
else if (l3Cur <= zero && diCur<=zero) { sclL3=0; sclDip=0; map = k5kGUniform;}
else {
AliErrorGeneral("AliMagF",Form("Wrong L3 current (%f A)!",l3Cur));
return 0;
Expand Down
4 changes: 3 additions & 1 deletion STEER/AliQA.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,13 @@ AliQA::AliQA() :
AliQA::AliQA(const AliQA& qa) :
TNamed(qa),
fNdet(qa.fNdet),
fQA(qa.fQA),
fQA(new ULong_t[qa.fNdet]),
fDet(qa.fDet),
fTask(qa.fTask)
{
// cpy ctor
for (Int_t index = 0 ; index < fNdet ; index++)
fQA[index] = qa.fQA[index] ;
}

//_____________________________________________________________________________
Expand Down
6 changes: 6 additions & 0 deletions STEER/AliRunTag.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,10 @@ void AliRunTag::Clear(const char *) {
fNumEvents = 0;
fDetectorTag.Clear();
fNumDetectors = 0;
if ( fQAArray )
delete [] fQAArray ;
fQALength=0;
if ( fEventSpecies )
delete [] fEventSpecies ;
fESLength=0;
}
228 changes: 120 additions & 108 deletions prod/LHC09d1/tag.C
Original file line number Diff line number Diff line change
@@ -1,108 +1,120 @@
void tag() {
const char* turl = gSystem->Getenv("ALIEN_JDL_OUTPUTDIR");
TString fESDFileName = "alien://";
fESDFileName += turl;
fESDFileName += "/AliESDs.root";

TString fGUID = 0;
GetGUID(fGUID);

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

UpdateTag(fAliroot,fRoot,fGeant,fESDFileName,fGUID);
}

//_____________________________________//
GetVersions(TString &fAliroot, TString &froot, TString &fgeant) {
const char* fver = gSystem->Getenv("ALIEN_JDL_PACKAGES");
TString fS = fver;
Int_t fFirst = fS.First("#");

while(fFirst != -1) {
Int_t fTotalLength = fS.Length();
TString tmp = fS;
TString fS1 = fS(0,fFirst);
tmp = fS(fFirst+2,fTotalLength);
fS = tmp;

if(fS1.Contains("Root")) fAliroot = fS1;
if(fS1.Contains("ROOT")) froot = fS1;
if(fS1.Contains("GEANT")) fgeant = fS1;

if(tmp.Contains("Root")) fAliroot = tmp;
if(tmp.Contains("ROOT")) froot = tmp;
if(tmp.Contains("GEANT")) fgeant = tmp;

fFirst = tmp.First("#");
}
}

//_____________________________________//
GetGUID(TString &guid) {
ofstream myfile ("guid.txt");
if (myfile.is_open()) {
TFile *f = TFile::Open("AliESDs.root","read");
if(f->IsOpen()) {
guid = f->GetUUID().AsString();
myfile << "AliESDs.root \t"<<f->GetUUID().AsString();
cout<<guid.Data()<<endl;
myfile.close();
}
else cout<<"Input file not found"<<endl;
}
else cout<<"Output file can't be created..."<<endl;
}


//_____________________________________//
Bool_t UpdateTag(TString faliroot, TString froot, TString fgeant, TString turl, TString guid) {
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))) {
if (strstr(name,tagPattern)) {
TFile *f = TFile::Open(name,"read") ;

AliRunTag *tag = new AliRunTag;
AliEventTag *evTag = new AliEventTag;
TTree *fTree = (TTree *)f->Get("T");
fTree->SetBranchAddress("AliTAG",&tag);

//Defining new tag objects
AliRunTag *newTag = new AliRunTag();
TTree ttag("T","A Tree with event tags");
TBranch * btag = ttag.Branch("AliTAG", &newTag);
btag->SetCompressionLevel(9);
for(Int_t iTagFiles = 0; iTagFiles < fTree->GetEntries(); iTagFiles++) {
fTree->GetEntry(iTagFiles);
newTag->SetRunId(tag->GetRunId());
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);
}
ttag.Fill();
newTag->Clear();
}//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;
}
void tag() {
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);
}

//_____________________________________//
GetVersions(TString &fAliroot, TString &froot, TString &fgeant) {
const char* fver = gSystem->Getenv("ALIEN_JDL_PACKAGES");
TString fS = fver;
Int_t fFirst = fS.First("#");

while(fFirst != -1) {
Int_t fTotalLength = fS.Length();
TString tmp = fS;
TString fS1 = fS(0,fFirst);
tmp = fS(fFirst+2,fTotalLength);
fS = tmp;

if(fS1.Contains("Root")) fAliroot = fS1;
if(fS1.Contains("ROOT")) froot = fS1;
if(fS1.Contains("GEANT")) fgeant = fS1;

if(tmp.Contains("Root")) fAliroot = tmp;
if(tmp.Contains("ROOT")) froot = tmp;
if(tmp.Contains("GEANT")) fgeant = tmp;

fFirst = tmp.First("#");
}
}

//_____________________________________//
GetGUID(TString &guid) {
ofstream myfile ("guid.txt");
if (myfile.is_open()) {
TFile *f = TFile::Open("AliESDs.root","read");
if(f && !f->IsZombie() && f->IsOpen()) {
guid = f->GetUUID().AsString();
myfile << "AliESDs.root \t"<<f->GetUUID().AsString();
cout<<guid.Data()<<endl;
myfile.close();
}
else cout<<"Input file not found"<<endl;
}
else cout<<"Output file can't be created..."<<endl;
}


//_____________________________________//
Bool_t UpdateTag(TString faliroot, TString froot, TString fgeant, TString turl, TString guid) {
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 = 0x0;
AliEventTag *evTag = 0x0;
TTree *fTree = (TTree *)f->Get("T");
if (!fTree) { f->Close(); continue; }
fTree->SetBranchAddress("AliTAG",&tag);

//Defining new tag objects
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 = new AliRunTag(*tag);
newTag->SetAlirootVersion(faliroot);
newTag->SetRootVersion(froot);
newTag->SetGeant3Version(fgeant);
TClonesArray *tagList = newTag->GetEventTags();
cout << "Found " << tagList->GetEntries() << " tags" << endl;
for(Int_t j = 0; j < tagList->GetEntries(); j++) {
evTag = (AliEventTag *) tagList->At(j);
evTag->SetTURL(turl);
evTag->SetGUID(guid);
}
ttag.Fill();

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

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

}//pattern check
}//directory loop
return kTRUE;
}

0 comments on commit 47a200b

Please sign in to comment.