From 4adf1b4cf12ca91418902682205e8cf86db335b1 Mon Sep 17 00:00:00 2001 From: ihrivnac Date: Thu, 15 Jan 2015 15:04:16 +0100 Subject: [PATCH] Fixing Coverity defects --- MUON/MUONcalign/AliMUONAlignmentTask.cxx | 5 +++ MUON/MUONevaluation/AliMUONCheck.cxx | 4 +-- MUON/MUONevaluation/AliMUONTrackLight.cxx | 38 ++++++++++++++++++++++- MUON/MUONevaluation/AliMUONTrackLight.h | 8 ++--- 4 files changed, 48 insertions(+), 7 deletions(-) diff --git a/MUON/MUONcalign/AliMUONAlignmentTask.cxx b/MUON/MUONcalign/AliMUONAlignmentTask.cxx index dc0961283f9..80734ecfaa2 100644 --- a/MUON/MUONcalign/AliMUONAlignmentTask.cxx +++ b/MUON/MUONcalign/AliMUONAlignmentTask.cxx @@ -529,6 +529,11 @@ void AliMUONAlignmentTask::NotifyRun() // propagete to Alignment class // and printout AliMagF* magF = dynamic_cast( TGeoGlobalMagField::Instance()->GetField() ); + if ( !magF ) { + AliError( "Failed to get field" ); + return; + } + fBFieldOn = TMath::Abs( magF->GetFactorDip() ) > 1e-5; fAlign->SetBFieldOn( fBFieldOn ); AliInfo( Form( "Dipole magnetic field factor: %.2f", magF->GetFactorDip() ) ); diff --git a/MUON/MUONevaluation/AliMUONCheck.cxx b/MUON/MUONevaluation/AliMUONCheck.cxx index c63bf9a424e..0ae52324e8d 100644 --- a/MUON/MUONevaluation/AliMUONCheck.cxx +++ b/MUON/MUONevaluation/AliMUONCheck.cxx @@ -811,11 +811,11 @@ AliMUONCheck::CheckOccupancy(Bool_t perDetEle) const dEoccupancyBending[ichamber][idetele], dEoccupancyNonBending[ichamber][idetele]); - if ( dEchannelsBending[ichamber][idetele] != 0 && dEchannelsBending[ichamber][idetele] !=0 ) { + if ( dEchannelsBending[ichamber][idetele] != 0 && dEchannelsNonBending[ichamber][idetele] !=0 ) { printf(">>> DetEle %4d Occupancy Bending %5.2f %% Occupancy NonBending %5.2f %% \n", idetele+100*(ichamber+1), 100.*((Float_t) dEoccupancyBending[ichamber][idetele])/((Float_t) dEchannelsBending[ichamber][idetele]), - 100.*((Float_t) dEoccupancyNonBending[ichamber][idetele])/((Float_t) dEchannelsBending[ichamber][idetele])); + 100.*((Float_t) dEoccupancyNonBending[ichamber][idetele])/((Float_t) dEchannelsNonBending[ichamber][idetele])); } } } diff --git a/MUON/MUONevaluation/AliMUONTrackLight.cxx b/MUON/MUONevaluation/AliMUONTrackLight.cxx index 1dd51a4d858..1040c742a69 100644 --- a/MUON/MUONevaluation/AliMUONTrackLight.cxx +++ b/MUON/MUONevaluation/AliMUONTrackLight.cxx @@ -418,8 +418,44 @@ Bool_t AliMUONTrackLight::IsParentPionOrKaon(Int_t idparent){ } //==================================== Bool_t AliMUONTrackLight::IsDiquark(Int_t pdg) const{ - /// check if the provided pdg code corresponds to a diquark + /// check if the provided pdg code corresponds to a diquark pdg = TMath::Abs(pdg); if((pdg > 1000) && (pdg%100 < 10)) return kTRUE; else return kFALSE; } +//==================================== +void AliMUONTrackLight::SetParentPDGCode(Int_t index, Int_t pdg) { + /// Set hadronised parents and grandparents + if ( index < fgkNParentsMax ) { + fParentPDGCode[index] = pdg; + } else { + AliErrorStream() << "Index outside the array size." << std::endl; + } +} +//==================================== +void AliMUONTrackLight::SetParentPythiaLine(Int_t index, Int_t line) { + /// Set line of Pythia output for hadronised parents & grandparents + if ( index < fgkNParentsMax ) { + fParentPythiaLine[index] = line; + } else { + AliErrorStream() << "Index outside the array size." << std::endl; + } +} +//==================================== +void AliMUONTrackLight::SetQuarkPDGCode(Int_t index, Int_t pdg){ + /// Set pdg of the string [0], quarks/gluons [1,2], sometimes proton [3] + if ( index < 4 ) { + fQuarkPDGCode[index] = pdg; + } else { + AliErrorStream() << "Index outside the array size." << std::endl; + } +} +//==================================== +void AliMUONTrackLight::SetQuarkPythiaLine(Int_t index, Int_t line){ + /// Set line of Pythia output for string [0] and quarks [1,2], sometimes proton [3] + if ( index < 4 ) { + fQuarkPythiaLine[index] = line; + } else { + AliErrorStream() << "Index outside the array size." << std::endl; + } +} diff --git a/MUON/MUONevaluation/AliMUONTrackLight.h b/MUON/MUONevaluation/AliMUONTrackLight.h index dc976cac554..be4f2575aba 100644 --- a/MUON/MUONevaluation/AliMUONTrackLight.h +++ b/MUON/MUONevaluation/AliMUONTrackLight.h @@ -129,13 +129,13 @@ protected: /// Set flag for oscillation void SetOscillation(Bool_t oscillation) { fOscillation = oscillation; } /// Set hadronised parents and grandparents - void SetParentPDGCode(Int_t index, Int_t pdg) { fParentPDGCode[index] = pdg; } + void SetParentPDGCode(Int_t index, Int_t pdg); /// Set line of Pythia output for hadronised parents & grandparents - void SetParentPythiaLine(Int_t index, Int_t line) { fParentPythiaLine[index] = line; } + void SetParentPythiaLine(Int_t index, Int_t line); /// Set pdg of the string [0], quarks/gluons [1,2], sometimes proton [3] - void SetQuarkPDGCode(Int_t index, Int_t pdg){ fQuarkPDGCode[index] = pdg; } + void SetQuarkPDGCode(Int_t index, Int_t pdg); /// Set line of Pythia output for string [0] and quarks [1,2], sometimes proton [3] - void SetQuarkPythiaLine(Int_t index, Int_t line){ fQuarkPythiaLine[index] = line; } + void SetQuarkPythiaLine(Int_t index, Int_t line); void ResetQuarkInfo(); ClassDef(AliMUONTrackLight,1) /// Muon Track for analysis -- 2.39.3