Skip to content

Commit

Permalink
Reduce number of calls to TObjArray->At and TObjArray->operator[]
Browse files Browse the repository at this point in the history
 * TObjArray->operator[] is a virtual function call; replaced this
   in critical places by TObjArray->UncheckedAt()
 * equally replaced TObjArray->At() by TObjArray->UncheckedAt() in some
   critical places
  • Loading branch information
sawenzel committed Jul 6, 2016
1 parent 0564e32 commit 0557dfe
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
6 changes: 3 additions & 3 deletions EMCAL/EMCALbase/AliEMCALSDigitizer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ void AliEMCALSDigitizer::Digitize(Option_t *option)
Int_t nHit = fHits->GetEntriesFast();
for(iHit = 0; iHit< nHit;iHit++){

AliEMCALHit * hit = dynamic_cast<AliEMCALHit*>(fHits->At(iHit)) ;
AliEMCALHit * hit = static_cast<AliEMCALHit*>(fHits->UncheckedAt(iHit)) ;
AliEMCALDigit * curSDigit = 0 ;
AliEMCALDigit * sdigit = 0 ;
Bool_t newsdigit = kTRUE;
Expand Down Expand Up @@ -325,7 +325,7 @@ void AliEMCALSDigitizer::Digitize(Option_t *option)

if(curSDigit != 0){
for(Int_t check= 0; check < nSdigits ; check++) {
sdigit = dynamic_cast<AliEMCALDigit *>(sdigits->At(check)) ;
sdigit = static_cast<AliEMCALDigit *>(sdigits->UncheckedAt(check)) ;
if(sdigit){
if( sdigit->GetId() == curSDigit->GetId()) { // Are we in the same ECAL tower ?
*sdigit = *sdigit + *curSDigit;
Expand Down Expand Up @@ -360,7 +360,7 @@ void AliEMCALSDigitizer::Digitize(Option_t *option)
fSDigitsInRun += nSdigits ;

for (iSDigit = 0 ; iSDigit < sdigits->GetEntriesFast() ; iSDigit++) {
AliEMCALDigit * sdigit = dynamic_cast<AliEMCALDigit *>(sdigits->At(iSDigit)) ;
AliEMCALDigit * sdigit = static_cast<AliEMCALDigit *>(sdigits->UncheckedAt(iSDigit)) ;
if(sdigit)sdigit->SetIndexInList(iSDigit) ;
else AliFatal("sdigit is NULL!");
}
Expand Down
2 changes: 1 addition & 1 deletion ITS/ITSsim/AliITSDetTypeSim.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ AliITSsegmentation* AliITSDetTypeSim::GetSegmentationModel(Int_t dettype) const{
Warning("GetSegmentationModel","fSegmentation is 0!");
return 0;
}
return (AliITSsegmentation*)(fSegmentation->At(dettype));
return (AliITSsegmentation*)(fSegmentation->UncheckedAt(dettype));
}
//_______________________________________________________________________
AliITSsegmentation* AliITSDetTypeSim::GetSegmentationModelByModule(Int_t module) const{
Expand Down
6 changes: 3 additions & 3 deletions STEER/STEER/AliMC.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ void AliMC::PreTrack()
AliModule *module;

for (Int_t i = 0; i <= gAlice->GetNdets(); i++)
if ((module = static_cast<AliModule *>(dets[i])))
if ((module = static_cast<AliModule *>(dets.UncheckedAt(i))))
module->PreTrack();
}

Expand Down Expand Up @@ -1074,7 +1074,7 @@ void AliMC::Stepping()
}

//Call the appropriate stepping routine;
AliModule *det = static_cast<AliModule*>(gAlice->Modules()->At(id));
AliModule *det = static_cast<AliModule*>(gAlice->Modules()->UncheckedAt(id));
if(det && det->StepManagerIsEnabled()) {
det->StepManager();
}
Expand Down Expand Up @@ -1299,7 +1299,7 @@ void AliMC::PostTrack()
AliModule *module;

for(Int_t i=0; i<=gAlice->GetNdets(); i++)
if((module = static_cast<AliModule*>(dets[i])))
if((module = static_cast<AliModule*>(dets.UncheckedAt(i))))
module->PostTrack();
}

Expand Down
14 changes: 10 additions & 4 deletions STEER/STEER/AliQADataMaker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,10 @@ Int_t AliQADataMaker::FillData(TObjArray ** list, Int_t index, double x)
int count = 0;
if (arr) {
count = arr->GetEntriesFast();
for (int ih=count;ih--;) if ((TH1*)arr->At(ih)) ((TH1*)arr->At(ih))->Fill(x);
for (int ih=count;ih--;){
TH1 *histo = (TH1*)arr->UncheckedAt(ih);
if (histo) histo->Fill(x);
}
}
return count;
}
Expand All @@ -541,7 +544,10 @@ Int_t AliQADataMaker::FillData(TObjArray ** list, Int_t index, double x, double
int count = 0;
if (arr) {
count = arr->GetEntriesFast();
for (int ih=count;ih--;) if ((TH1*)arr->At(ih)) ((TH1*)arr->At(ih))->Fill(x,y);
for (int ih=count;ih--;){
TH1 *histo=(TH1*)arr->UncheckedAt(ih);
if (histo) histo->Fill(x,y);
}
}
return count;
}
Expand Down Expand Up @@ -680,8 +686,8 @@ TH1* AliQADataMaker::GetData(TObjArray ** list, const Int_t index, int cloneID)
if (!data) return 0;
Bool_t orig = cloneID<0 || cloneID==GetNTrigClasses();
if (data->TestBit(AliQAv1::GetClonedBit())) {
if (orig) return data->TestBit(AliQAv1::GetOrigHistoKeptBit()) ? (TH1*)((TObjArray*)data)->At(GetNTrigClasses()) : 0;
else return (TH1*)((TObjArray*)data)->At(cloneID); // there was a cloning
if (orig) return data->TestBit(AliQAv1::GetOrigHistoKeptBit()) ? (TH1*)((TObjArray*)data)->UncheckedAt(GetNTrigClasses()) : 0;
else return (TH1*)((TObjArray*)data)->UncheckedAt(cloneID); // there was a cloning
}
//
// not cloned, is the original histo requested?
Expand Down
4 changes: 2 additions & 2 deletions TPC/TPCsim/AliTPCTrackHitsV2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -762,14 +762,14 @@ Bool_t AliTPCTrackHitsV2::Next()

fCurrentHit->SetStackIndex(fCurrentHit->GetStackIndex()+1);

AliTrackHitsParamV2 *param = (AliTrackHitsParamV2 *)fArray->At(fCurrentHit->GetParamIndex());
AliTrackHitsParamV2 *param = (AliTrackHitsParamV2 *)fArray->UncheckedAt(fCurrentHit->GetParamIndex());
if (fCurrentHit->GetStackIndex()>=param->GetNHits()){
fCurrentHit->SetParamIndex(fCurrentHit->GetParamIndex()+1);
if (fCurrentHit->GetParamIndex()>=fArray->GetEntriesFast()){
fCurrentHit->SetStatus(kFALSE);
return kFALSE;
}
param = (AliTrackHitsParamV2 *)fArray->At(fCurrentHit->GetParamIndex());
param = (AliTrackHitsParamV2 *)fArray->UncheckedAt(fCurrentHit->GetParamIndex());
fCurrentHit->SetStackIndex(0);
fCurrentHit->SetR(param->GetR());
}
Expand Down

0 comments on commit 0557dfe

Please sign in to comment.