1.E2*trk->GetPID(2), 1.E2*trk->GetPID(3), 1.E2*trk->GetPID(4), trk->GetLabel()));
if(GetName()){
- char id[6]; strncpy(id, GetName(), 6);
+ char id[6]; snprintf(id, 6, "%s", GetName());
SetName(Form("%s %s", id, AliPID::ParticleName(species)));
}
//______________________________________________________________________________
void AliEveTRDTrack::Load(Char_t *what) const
{
- TEveElement::List_ci itrklt=BeginChildren();
+// Spread downwards to tracklets the command "what"
+
+ const AliEveTRDTracklet* trklt(NULL);
+ TEveElement::List_ci itrklt=BeginChildren();
while(itrklt!=EndChildren()){
- dynamic_cast<const AliEveTRDTracklet*>(*itrklt)->Load(what);
+ if((trklt = dynamic_cast<const AliEveTRDTracklet*>(*itrklt))) trklt->Load(what);
itrklt++;
}
}
-
+//______________________________________________________________________________
AliEveTRDTrackletOnline::AliEveTRDTrackletOnline(AliTRDtrackletMCM *tracklet) :
TEveLine(),
fDetector(-1),
{
// Paint object.
+ AliEveTRDModule *module(NULL);
List_i ichmb = fChildren.begin();
while(ichmb != fChildren.end()){
- (dynamic_cast<AliEveTRDModule*>(*ichmb))->Paint(option);
+ if((module = dynamic_cast<AliEveTRDModule*>(*ichmb))) module->Paint(option);
ichmb++;
}
}
{
// Set model object.
- fM = dynamic_cast<AliEveTRDLoader*>(obj);
+ if(!(fM = dynamic_cast<AliEveTRDLoader*>(obj))) return;
fFile->SetEnabled(!fM->IsDataLinked());
fFile->SetText(gSystem->BaseName(fM->fFilename.Data()));
{
// Set model object.
- fM = dynamic_cast<AliEveTRDLoaderSim*>(obj);
+ if(!(fM = dynamic_cast<AliEveTRDLoaderSim*>(obj))) return;
Bool_t kRL = (fM->IsDataLinked()) ? kTRUE : kFALSE;
{
// Paint object.
+ AliEveTRDLoader *loader(NULL);
List_i ichmb = fChildren.begin();
while(ichmb != fChildren.end()){
- (dynamic_cast<AliEveTRDLoader*>(*ichmb))->Paint(option);
+ if((loader = dynamic_cast<AliEveTRDLoader*>(*ichmb))) loader->Paint(option);
ichmb++;
}
}
{
// Set model object.
- fM = dynamic_cast<AliEveTRDModule*>(obj);
+ if(!(fM = dynamic_cast<AliEveTRDModule*>(obj))) return;
if(AliEveTRDNode *node = dynamic_cast<AliEveTRDNode*>(fM)) node->UpdateNode();
fM->fRnrTracklets = kFALSE;
if(fDisplayTracks->IsDown()) fM->fRnrTracklets = kTRUE;
- if(dynamic_cast<AliEveTRDNode*>(fM)) (dynamic_cast<AliEveTRDNode*>(fM))->UpdateLeaves();
+ AliEveTRDNode *node(NULL);
+ if((node = dynamic_cast<AliEveTRDNode*>(fM))) node->UpdateLeaves();
gEve->Redraw3D();
}
{
// Paint object.
+ AliEveTRDModule *module(NULL);
List_i iter = fChildren.begin();
while(iter != fChildren.end()){
- (dynamic_cast<AliEveTRDModule*>(*iter))->Paint(option);
+ if((module = dynamic_cast<AliEveTRDModule*>(*iter))) module->Paint(option);
iter++;
}
}
// 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;
// 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;
- TString* procCmds = 0;
- AliEveTRDTrackListMacroType* mProcType = 0;
- if (procIterator->GetEntries() > 0) {
- procCmds = new TString[procIterator->GetEntries()];
- mProcType = new AliEveTRDTrackListMacroType[procIterator->GetEntries()];
- }
+ TString* procCmds = new TString[procIterator->GetEntries()];
+ AliEveTRDTrackListMacroType* mProcType = new AliEveTRDTrackListMacroType[procIterator->GetEntries()];
TString* selCmds(NULL);
- AliEveTRDTrackListMacroType* mSelType = 0;
+ AliEveTRDTrackListMacroType* mSelType(NULL);
if (selIterator->GetEntries() > 0) {
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(NULL);
AliEveTRDTrack* track2(NULL);
// 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
- 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;
+ memset(histos, 0, numHistoMacros*sizeof(TH1*));
//////////////////////////////////
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
// 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++;
}
// 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();
void SetCmd(const char* newCmd) // Sets the command that will be used to call this macro
{
memset(fCmd, '\0', sizeof(Char_t) * MAX_APPLY_COMMAND_LENGTH);
- sprintf(fCmd, "%s", newCmd);
+ snprintf(fCmd, MAX_APPLY_COMMAND_LENGTH, "%s", newCmd);
}
void SetName(const char* newName) // Sets the macro name (please use without ".C")
{
memset(fName, '\0', sizeof(Char_t) * MAX_MACRO_NAME_LENGTH);
- sprintf(fName, "%s", newName);
+ snprintf(fName, MAX_MACRO_NAME_LENGTH, "%s", newName);
}
void SetPath(const char* newPath) // Sets the path of the macro
{
memset(fPath, '\0', sizeof(Char_t) * MAX_MACRO_PATH_LENGTH);
- sprintf(fPath, "%s", newPath);
+ snprintf(fPath, MAX_MACRO_PATH_LENGTH, "%s", newPath);
}
void SetSelected(Bool_t selection) // Sets whether the macro is selected or not
{
DrawHistos();
}
- if (selIterator != 0) delete selIterator;
- selIterator = 0;
- if (procIterator != 0) delete procIterator;
- procIterator = 0;
+ delete selIterator;
+ delete procIterator;
- if (!success)
- {
+ if (!success) {
new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Error",
"AliEveTRDTrackList::ApplyProcessMacros experienced an error (cf. CINT-output)!",
kMBIconExclamation, kMBOk);
// accessed (and that it exists) and adds the macro to the macro list via AddMacro(...).
// You can use environment variables in the text field, e.g. "$ALICE_ROOT/Eve/alice-macro/myMacro.C".
+ Char_t bname[AliEveTRDTrackList::fkMaxMacroNameLength]; // allocate buffers
+
if (strlen(fteField->GetText()) != 0)
{
// Expand the pathname
Char_t* name = (Char_t*)strrchr(fteField->GetText(), '/');
// Current path
- if (name == NULL)
- {
- name = new Char_t[AliEveTRDTrackList::fkMaxMacroNameLength];
+ if (!name) {
+ name= bname;
memset(name, '\0', sizeof(Char_t) * AliEveTRDTrackList::fkMaxMacroNameLength);
- sprintf(name, "%s", fteField->GetText());
+ snprintf(name, AliEveTRDTrackList::fkMaxMacroNameLength, "%s", fteField->GetText());
// Add path to textfield -> Path is "./" -> Use length for the name + 2
Char_t pathname[AliEveTRDTrackList::fkMaxMacroNameLength + 2];
memset(pathname, '\0', sizeof(Char_t) * (AliEveTRDTrackList::fkMaxMacroNameLength + 2));
- sprintf(pathname, "./%s", fteField->GetText());
+ snprintf(pathname, AliEveTRDTrackList::fkMaxMacroNameLength + 2, "./%s", fteField->GetText());
fteField->SetText(pathname);
AddMacro(name);
- if (name != 0) delete [] name;
- name = 0;
}
// Different path
else
{
// Extract path
- Char_t* path = new Char_t[AliEveTRDTrackList::fkMaxMacroPathLength];
+ Char_t path[AliEveTRDTrackList::fkMaxMacroPathLength];
memset(path, '\0', sizeof(Char_t) * AliEveTRDTrackList::fkMaxMacroPathLength);
- strncpy(path, fteField->GetText(), strlen(fteField->GetText()) - strlen(name));
+ snprintf(path, strlen(fteField->GetText()) - strlen(name), "%s", fteField->GetText());
// Ignore the slash "/" in name
AddMacro(name + 1, path);
-
- if (path != 0) delete [] path;
- path = 0;
- }
+ }
}
else
{
{
// Removes the selected macros from the corresponding list.
- TList* iterator = new TList();
-
- ftlMacroList->GetSelectedEntries(iterator);
- fM->RemoveSelectedMacros(iterator);
+ TList iterator;
+ ftlMacroList->GetSelectedEntries(&iterator);
+ fM->RemoveSelectedMacros(&iterator);
- if (iterator != 0) delete iterator;
- iterator = new TList();
- ftlMacroSelList->GetSelectedEntries(iterator);
- fM->RemoveSelectedMacros(iterator);
+ iterator.Clear();
+ ftlMacroSelList->GetSelectedEntries(&iterator);
+ fM->RemoveSelectedMacros(&iterator);
// Selected macros are deleted from the list -> No selected entries left
fM->fMacroListSelected = 0;
-
UpdateMacroList();
-
- if (iterator != 0) delete iterator;
- iterator = 0;
}
//______________________________________________________