-// Author: Benjamin Hess 25/09/2008
+// Author: Benjamin Hess 29/01/2010
/*************************************************************************
- * Copyright (C) 2008-2009, Alexandru Bercuci, Benjamin Hess. *
+ * Copyright (C) 2009-2010, Alexandru Bercuci, Benjamin Hess. *
* All rights reserved. *
*************************************************************************/
+
//////////////////////////////////////////////////////////////////////////
// //
// AliEveTRDTrackList //
#include <AliTRDReconstructor.h>
-#include <EveDet/AliEveTRDTrackList.h>
#include <EveDet/AliEveTRDTrackList.h>
#include <EveDet/AliEveTRDTrackListEditor.h>
#include <../PWG1/TRD/AliTRDrecoTask.h>
-#include <../PWG1/TRD/macros/AliTRDperformanceTrain.h>
+#include <../PWG1/TRD/AliTRDpwg1Helper.h>
ClassImp(AliEveTRDTrackList)
// Expand the path and create the pathname
Char_t* systemPath = gSystem->ExpandPathName(path);
- sprintf(pathname, "%s/%s", systemPath, nameC);
+ snprintf(pathname, fkMaxMacroPathNameLength, "%s/%s", systemPath, nameC);
delete systemPath;
systemPath = 0;
gROOT->ProcessLineSync(Form(".L %s+%c", pathname, forceReload ? '+' : ' '));
+ // We need this line... otherwise, in some cases, there will be problems concerning ACLIC
+ gROOT->ProcessLineSync(Form(".L %s", pathname));
+
AliEveTRDTrackListMacroType type = GetMacroType(name, kFALSE);
// Clean up again
{
// Adds standard macros to the macro list.
- // Add your standard macros here, e.g.:
+ // Add your standard macros here, e.g.:
// To add a macro use:
// AddMacro("$(ALICE_ROOT)/myFolder", "myMacroName.C");
// -> If the file does not exist, nothing happens. So if you want to handle this,
// use the return value of AddMacro (NOT_EXIST_ERROR is returned, if file does not exist)
// (-> You can also check for other return values (see AddMacro(...)))
- if(gSystem->Load("libANALYSIS.so")<0) return;
- if(gSystem->Load("libTRDqaRec.so")<0) return;
- AliTRDrecoTask *task = 0x0;
- TList *fPlots = 0x0;
- for(Int_t it=2; it<NTRDQATASKS; it++){
- TClass c(fgkTRDtaskClassName[it]);
+ const Char_t *libs[] = {"libANALYSIS.so", "libANALYSISalice.so", "libTENDER.so", "libPWG1.so"};
+ Int_t nlibs = static_cast<Int_t>(sizeof(libs)/sizeof(Char_t *));
+ for(Int_t ilib=0; ilib<nlibs; ilib++){
+ if(gSystem->Load(libs[ilib]) >= 0) continue;
+ AliError(Form("Fail loading %s.", libs[ilib]));
+ return;
+ }
+
+ const Char_t *fgkTRDPWG1taskClassName[AliTRDpwg1Helper::kNTRDQATASKS] = {
+ "AliTRDcheckESD"
+ ,"AliTRDinfoGen"
+ ,"AliTRDcheckDET"
+ ,"AliTRDefficiency"
+ ,"AliTRDresolution"
+ ,"AliTRDcheckPID"
+ ,"AliTRDv0Monitor"
+ };
+ AliTRDrecoTask *task(NULL);
+ TList *fPlots(NULL);
+ for(Int_t it=2; it<AliTRDpwg1Helper::kNTRDQATASKS; it++){
+ TClass c(fgkTRDPWG1taskClassName[it]);
task = (AliTRDrecoTask*)c.New();
task->SetMCdata(kFALSE);
if(!(fPlots = task->GetPlotFunctors())){
}
// export task to CINT and add functions
- gROOT->ProcessLine(Form("%s* %s = (%s*)0x%lx;", fgkTRDtaskClassName[it], task->GetName(), fgkTRDtaskClassName[it], (void*)task));
+ gROOT->ProcessLine(Form("%s* %s = (%s*)%p;", fgkTRDPWG1taskClassName[it], task->GetName(), fgkTRDPWG1taskClassName[it], (void*)task));
TIter iter(fPlots); TMethodCall *m = 0x0;
while((m = dynamic_cast<TMethodCall*>(iter()))){
AddMacroFast("", Form("%s->%s", task->GetName(), m->GetMethodName()), kSingleTrackHisto);
}
}
+
//______________________________________________________
Bool_t AliEveTRDTrackList::ApplyProcessMacros(const TList* selIterator, const TList* procIterator)
{
// A.B. gROOT->Reset();
// Clear old data and re-allocate
- if (fDataTree == 0x0){
+ if (!fDataTree){
TDirectory *cwd = gDirectory;
fDataTree = new TTreeSRedirector(Form("/tmp/TRD.TrackListMacroData_%s.root", gSystem->Getenv("USER")));
cwd->cd();
TMacroData* macro = 0;
- Char_t** procCmds = 0;
- AliEveTRDTrackListMacroType* mProcType = 0;
- if (procIterator->GetEntries() > 0) {
- procCmds = new Char_t*[procIterator->GetEntries()];
- mProcType = new AliEveTRDTrackListMacroType[procIterator->GetEntries()];
- }
+ TString* procCmds = new TString[procIterator->GetEntries()];
+ AliEveTRDTrackListMacroType* mProcType = new AliEveTRDTrackListMacroType[procIterator->GetEntries()];
- Char_t** selCmds = 0;
- AliEveTRDTrackListMacroType* mSelType = 0;
+ TString* selCmds(NULL);
+ AliEveTRDTrackListMacroType* mSelType(NULL);
if (selIterator->GetEntries() > 0) {
- selCmds = new Char_t*[selIterator->GetEntries()];
+ selCmds = new TString[selIterator->GetEntries()];
mSelType = new AliEveTRDTrackListMacroType[selIterator->GetEntries()];
}
AliEveTRDTrackListMacroType macroType = kUnknown;
Int_t numHistoMacros = 0;
- TH1** histos = 0;
+ TH1** histos(NULL);
- AliEveTRDTrack* track1 = 0;
- AliEveTRDTrack* track2 = 0;
+ AliEveTRDTrack* track1(NULL);
+ AliEveTRDTrack* track2(NULL);
// Collect the commands for each process macro and add them to "data-from-list"
for (Int_t i = 0; i < procIterator->GetEntries(); i++){
- procCmds[i] = new Char_t[(fkMaxMacroPathNameLength + fkMaxApplyCommandLength)];
- memset(procCmds[i], '\0', sizeof(Char_t) * (fkMaxMacroNameLength + fkMaxApplyCommandLength));
-
macro = (TMacroData*)fMacroList->GetValue(procIterator->At(i)->GetTitle());
if (!macro){
mProcType[i] = macroType;
numHistoMacros++;
// Create the command
- sprintf(procCmds[i], macro->GetCmd());
+ procCmds[i] = macro->GetCmd();
// Add to "data-from-list" -> Mark as a histo macro with the substring "(histo macro)"
fDataFromMacroList->Add(new TObjString(Form("%s (histo macro)", macro->GetName())));
} else if (macroType == kSingleTrackAnalyse || macroType == kCorrelTrackAnalyse) {
mProcType[i] = macroType;
// Create the command
- sprintf(procCmds[i], macro->GetCmd());
+ procCmds[i] = macro->GetCmd();
// Add to "data-from-list"
fDataFromMacroList->Add(new TObjString(macro->GetName()));
// Collect the commands for each selection macro and add them to "data-from-list"
for (Int_t i = 0; i < selIterator->GetEntries(); i++){
- selCmds[i] = new Char_t[(fkMaxMacroPathNameLength + fkMaxApplyCommandLength)];
- memset(selCmds[i], '\0', sizeof(Char_t) * (fkMaxMacroNameLength + fkMaxApplyCommandLength));
-
macro = (TMacroData*)fMacroList->GetValue(selIterator->At(i)->GetTitle());
if (!macro){
// Single track select macro
if (macroType == kSingleTrackSelect) {
// Has already been processed by ApplySTSelectionMacros(...)
- mSelType[i] = macroType;
+ if(mSelType) mSelType[i] = macroType;
}
// Correlated tracks select macro
else if (macroType == kCorrelTrackSelect) {
- mSelType[i] = macroType;
+ if(mSelType) mSelType[i] = macroType;
// Create the command
- sprintf(selCmds[i], macro->GetCmd());
+ if(selCmds) selCmds[i] = macro->GetCmd();
} else {
Error("Apply process macros",
Form("Macro list corrupted: Macro \"%s/%s.C\" is not registered as a selection macro!",
macro->GetPath(), macro->GetName()));
- mSelType[i] = kUnknown;
+ if(mSelType) mSelType[i] = kUnknown;
}
}
// Allocate memory for the histograms
- if (numHistoMacros > 0) histos = new TH1*[numHistoMacros];
- for (Int_t i = 0; i < numHistoMacros; i++) histos[i] = 0x0;
-
+ if (numHistoMacros > 0){
+ histos = new TH1*[numHistoMacros];
+ memset(histos, 0, numHistoMacros*sizeof(TH1*));
+ }
//////////////////////////////////
// WALK THROUGH THE LIST OF TRACKS
if (!track1->GetRnrState()) continue;
// Cast to AliTRDtrackV1
- gROOT->ProcessLineSync(Form("AliEveTRDTrack *automaticTrack = (AliEveTRDTrack*)0x%xl;", track1));
+ gROOT->ProcessLineSync(Form("AliEveTRDTrack *automaticTrack = (AliEveTRDTrack*)%p;", (void*)track1));
gROOT->ProcessLineSync("AliTRDtrackV1* automaticTrackV1_1 = (AliTRDtrackV1*)automaticTrack->GetUserData();");
// Collect data for each macro
for (Int_t i = 0, histoIndex = 0; i < procIterator->GetEntries(); i++){
// Single track histo
if (mProcType[i] == kSingleTrackHisto){
- histos[histoIndex++] = (TH1*)gROOT->ProcessLineSync(procCmds[i]);
+ if(histos) histos[histoIndex++] = (TH1*)gROOT->ProcessLineSync(procCmds[i]);
// Correlated tracks histo
} else if (mProcType[i] == kCorrelTrackHisto) {
// Loop over all pairs behind the current one - together with the other loop this will be a loop
// over all pairs. We have a pair of tracks, if and only if both tracks of the pair are selected (Rnr-state)
// and are not equal.
- // The correlated tracks process macro will applied to all pairs that will be additionally selected by
+ // The correlated tracks process macro will be applied to all pairs that will be additionally selected by
// all correlated tracks selection macros.
TEveElement::List_i iter2 = iter;
iter2++;
if (!track2->GetRnrState()) continue;
// Cast to AliTRDtrackV1
- gROOT->ProcessLineSync(Form("AliEveTRDTrack *automaticTrack = (AliEveTRDTrack*)0x%xl;", track2));
+ gROOT->ProcessLineSync(Form("AliEveTRDTrack *automaticTrack = (AliEveTRDTrack*)%p;", (void*)track2));
gROOT->ProcessLineSync("AliTRDtrackV1* automaticTrackV1_2 = (AliTRDtrackV1*)automaticTrack->GetUserData();");
// Select track by default (so it will be processed, if there are no correlated tracks selection macros!)
selectedByCorrSelMacro = kTRUE;
for (Int_t j = 0; j < selIterator->GetEntries(); j++){
- if (mSelType[j] == kCorrelTrackSelect){
+ if (mSelType && mSelType[j] == kCorrelTrackSelect){
selectedByCorrSelMacro = (Bool_t)gROOT->ProcessLineSync(selCmds[j]);
if (!selectedByCorrSelMacro) break;
}
// If the pair has not been selected by the correlated tracks selection macros, skip it!
if (!selectedByCorrSelMacro) continue;
- histos[histoIndex] = (TH1*)gROOT->ProcessLineSync(procCmds[i]);
+ if(histos) histos[histoIndex] = (TH1*)gROOT->ProcessLineSync(procCmds[i]);
}
histoIndex++;
}
// Loop over all pairs behind the current one - together with the other loop this will be a loop
// over all pairs. We have a pair of tracks, if and only if both tracks of the pair are selected (Rnr-state)
// and are not equal.
- // The correlated tracks process macro will applied to all pairs that will be additionally selected by
+ // The correlated tracks process macro will be applied to all pairs that will be additionally selected by
// all correlated tracks selection macros.
TEveElement::List_i iter2 = iter;
iter2++;
if (!track2->GetRnrState()) continue;
// Cast to AliTRDtrackV1
- gROOT->ProcessLineSync(Form("AliEveTRDTrack *automaticTrack = (AliEveTRDTrack*)0x%xl;", track2));
+ gROOT->ProcessLineSync(Form("AliEveTRDTrack *automaticTrack = (AliEveTRDTrack*)%p;", (void*)track2));
gROOT->ProcessLineSync("AliTRDtrackV1* automaticTrackV1_2 = (AliTRDtrackV1*)automaticTrack->GetUserData();");
// Select track by default (so it will be processed, if there are no correlated tracks selection macros!)
selectedByCorrSelMacro = kTRUE;
for (Int_t j = 0; j < selIterator->GetEntries(); j++) {
- if (mSelType[j] == kCorrelTrackSelect) {
+ if (mSelType && mSelType[j] == kCorrelTrackSelect) {
selectedByCorrSelMacro = (Bool_t)gROOT->ProcessLineSync(selCmds[j]);
if (!selectedByCorrSelMacro) break;
}
}
}
- if (fDataTree != 0) delete fDataTree;
- fDataTree = 0;
+ if (fDataTree) delete fDataTree;
+ fDataTree = NULL;
- if (procCmds != 0) delete [] procCmds;
- procCmds = 0;
- if (mProcType != 0) delete mProcType;
- mProcType = 0;
+ if (procCmds) delete [] procCmds;
+ procCmds = NULL;
+ if (mProcType) delete [] mProcType;
+ mProcType = NULL;
- if (selCmds != 0) delete [] selCmds;
- selCmds = 0;
- if (mSelType != 0) delete mSelType;
- mSelType = 0;
+ if (selCmds) delete [] selCmds;
+ selCmds = NULL;
+ if (mSelType) delete [] mSelType;
+ mSelType = NULL;
- if (histos != 0) delete [] histos;
- histos = 0;
+ if (histos) delete [] histos;
+ histos = NULL;
// Clear root
// A.B. gROOT->Reset();
// Clear root
// A.B. gROOT->Reset();
- // Select all tracks at first. A track is then deselect, if at least one selection macro
- // returns kFALSE for this track
- // Enable all tracks (Note: EnableListElements(..) will call "ElementChanged", which will cause unforeseen behavior!)
+ // Select all tracks at first. A track is then deselected, if at least one selection macro
+ // returns kFALSE for this track.
+ // Enable all tracks (Note: EnableListElements(..) will call "ElementChanged", which will cause unforeseen behaviour!)
for (TEveElement::List_i iter = this->BeginChildren(); iter != this->EndChildren(); ++iter) ((TEveElement*)(*iter))->SetRnrState(kTRUE);
SetRnrState(kTRUE);
if (!track1->GetRnrState()) continue;
// Cast to AliTRDtrackV1
- gROOT->ProcessLineSync(Form("AliEveTRDTrack *automaticTrack = (AliEveTRDTrack*)0x%xl;", track1));
+ gROOT->ProcessLineSync(Form("AliEveTRDTrack *automaticTrack = (AliEveTRDTrack*)%p;", (void*)track1));
gROOT->ProcessLineSync("AliTRDtrackV1* automaticTrackV1_1 = (AliTRDtrackV1*)automaticTrack->GetUserData();");
selectedByMacro = (Bool_t)gROOT->ProcessLineSync(macro->GetCmd());
track1->SetRnrState(selectedByMacro && track1->GetRnrState());
if (strstr(f->GetMangledName(), "oPconstsPAliTRDtrackV1mUsP") != 0x0 &&
strstr(f->GetMangledName(), "cOconstsPAliTRDtrackV1mUsP") != 0x0)
{
- // Single track select macro?
+ // Correlated track select macro?
if (!strcmp(f->GetReturnTypeName(), "Bool_t"))
{
type = kCorrelTrackSelect;
}
- // single track histo macro?
+ // Correlated track histo macro?
else if (!strcmp(f->GetReturnTypeName(), "TH1*"))
{
type = kCorrelTrackHisto;