From: morsch Date: Thu, 27 Jan 2011 19:42:37 +0000 (+0000) Subject: Coverity fixes. X-Git-Url: http://git.uio.no/git/?a=commitdiff_plain;h=418e091f31ef997ccabfd6dfc4448dfc6e495c11;p=u%2Fmrichter%2FAliRoot.git Coverity fixes. --- diff --git a/EVGEN/AliGenFLUKAsource.cxx b/EVGEN/AliGenFLUKAsource.cxx deleted file mode 100644 index 92ace3eff93..00000000000 --- a/EVGEN/AliGenFLUKAsource.cxx +++ /dev/null @@ -1,307 +0,0 @@ -/************************************************************************** - * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * * - * Author: The ALICE Off-line Project. * - * Contributors are mentioned in the code where appropriate. * - * * - * Permission to use, copy, modify and distribute this software and its * - * documentation strictly for non-commercial purposes is hereby granted * - * without fee, provided that the above copyright notice appears in all * - * copies and that both the copyright notice and this permission notice * - * appear in the supporting documentation. The authors make no claims * - * about the suitability of this software for any purpose. It is * - * provided "as is" without express or implied warranty. * - **************************************************************************/ - -/* $Id$ */ - -// Read background particles from a FLUKA boundary source file -// This is a very special generator that works for background studies for the muon-spectrometer. -// The input files come from FLUKA simulations. -// Files can be chained. -// Author: andreas.morsch@cern.ch - -#include "AliGenFLUKAsource.h" -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "AliRun.h" - -ClassImp(AliGenFLUKAsource) - -AliGenFLUKAsource::AliGenFLUKAsource() - :AliGenerator(-1), - fIkine(6), - fAgeMax(1.e-5), - fAddWeight(1.), - fZshift(0.), - fFrac(0.), - fSourceId(-1), - fFileName(0), - fTreeChain(0), - fTreeFluka(0), - fIp(0.), - fIpp(0.), - fXi(0.), - fYi(0.), - fZi(0.), - fPx(0.), - fPy(0.), - fPz(0.), - fEkin(0.), - fZv(0.), - fRv(0.), - fItra(0.), - fIgas(0.), - fWgt(0.), - fEtag(0.), - fPtg(0.), - fAge(0.) -{ - // Constructor - fName="FLUKA"; - fTitle="FLUKA Boundary Source"; - // Read in all particle types by default - // Set maximum admitted age of particles to 1.e-05 by default - // Do not add weight - // Shift the z-coordinate of the impact point by 4.5 cm only if it reads - // from specific boundary source to the chamber (fZshift=4.5;),else there - // is no need to shift as it reads boundary source for the whole volume of - // the Muon Arm; the default value corresponds to boundary source for the - // whole volume of the MUON Arm - // Set the default file - fTreeChain = new TChain("h1"); -// -// Read all particles - fNpart=-1; -} - -AliGenFLUKAsource::AliGenFLUKAsource(Int_t npart) - :AliGenerator(npart), - fIkine(6), - fAgeMax(1.e-5), - fAddWeight(1.), - fZshift(0.), - fFrac(0.), - fSourceId(-1), - fFileName(""), - fTreeChain(new TChain("h1")), - fTreeFluka(0), - fIp(0.), - fIpp(0.), - fXi(0.), - fYi(0.), - fZi(0.), - fPx(0.), - fPy(0.), - fPz(0.), - fEkin(0.), - fZv(0.), - fRv(0.), - fItra(0.), - fIgas(0.), - fWgt(0.), - fEtag(0.), - fPtg(0.), - fAge(0.) -{ - // Constructor - fName = "FLUKA"; - fTitle = "FLUKA Boundary Source"; -} - -//____________________________________________________________ -AliGenFLUKAsource::~AliGenFLUKAsource() -{ -// Destructor - if (fTreeFluka) delete fTreeFluka; - if (fTreeChain) delete fTreeChain; -} - -void AliGenFLUKAsource::AddFile(const Text_t *filename) -{ -// Add a file to the chain - fTreeChain->Add(filename); - -} - - -//____________________________________________________________ -void AliGenFLUKAsource::FlukaInit() -{ -// Set branch addresses of data entries - TChain *h2=fTreeChain; -//Set branch addresses - h2->SetBranchAddress("Ip",&fIp); - h2->SetBranchAddress("Ipp",&fIpp); - h2->SetBranchAddress("Xi",&fXi); - h2->SetBranchAddress("Yi",&fYi); - h2->SetBranchAddress("Zi",&fZi); - h2->SetBranchAddress("Px",&fPx); - h2->SetBranchAddress("Py",&fPy); - h2->SetBranchAddress("Pz",&fPz); - h2->SetBranchAddress("Ekin",&fEkin); - h2->SetBranchAddress("Zv",&fZv); - h2->SetBranchAddress("Rv",&fRv); - h2->SetBranchAddress("Itra",&fItra); - h2->SetBranchAddress("Igas",&fIgas); - h2->SetBranchAddress("Wgt",&fWgt); - h2->SetBranchAddress("Etag",&fEtag); - h2->SetBranchAddress("Ptg",&fPtg); - h2->SetBranchAddress("Age",&fAge); -} - -//____________________________________________________________ -void AliGenFLUKAsource::Generate() -{ -// Generate one event - - const Int_t kIfluge[28]={kProton, kProtonBar, kElectron, kPositron, - kNuE, kNuEBar, kGamma, kNeutron, kNeutronBar, - kMuonPlus, kMuonMinus, kK0Long , kPiPlus, kPiMinus, - kKPlus, kKMinus, kLambda0, kLambda0Bar, kK0Short, - kSigmaMinus, kSigmaPlus, kSigma0, kPi0, kK0, kK0Bar, - 0,kNuMu,kNuMuBar}; - Float_t polar[3]= {0,0,0}; - // - Float_t origin[3]; - Float_t p[3]; - Float_t prwn; - Float_t wgt, fwgt; - Float_t phi; - Float_t amass; - Int_t iwgt; - Int_t i, j, part, nt; - static Int_t irwn=0; - // - Float_t random[2]; - // - FlukaInit(); - TChain *h2=fTreeChain; - Int_t nentries = (Int_t) h2->GetEntries(); - if (fNpart == -1) fNpart=Int_t(nentries*fFrac); - - - // loop over number of particles - Int_t nb=0; - Int_t ev=gMC->CurrentEvent(); - for (i=0; iGetEvent(entry); - if (irwn > nentries) { - printf("No more entries in the FLUKA boundary source file\n"); - TFile *pFile=0; - // Get AliRun object or create it - if (!gAlice) { - gAlice = (AliRun*)pFile->Get("gAlice"); - if (gAlice) printf("AliRun object found on file\n"); - if (!gAlice) gAlice = new AliRun("gAlice","Alice test program"); - } - TTree *fAli=AliRunLoader::Instance()->TreeK(); - if (fAli) pFile =fAli->GetCurrentFile(); - pFile->cd(); - printf("Generate - I'm out \n"); - return; - } - - Int_t ifip = Int_t(fIp); - - - if (fSourceId != -1 && fIgas !=fSourceId) { - irwn++; - continue; - } - - if (ifip > 28 || ifip < 0) { - irwn++; - continue; - } - - if ((ifip != fIkine && fIkine != kAll && fIkine != kCharged - && fIkine != 10) || fAge > fAgeMax){ - irwn++; - continue; - } else if (fIkine == kCharged) { - if (ifip == 7 || ifip == 8 || fAge > fAgeMax) { - irwn++; - continue; - } - } else if (fIkine == kNoNeutron) { - if (ifip == 8 || fAge > fAgeMax) { - irwn++; - continue; - } - } - - - irwn++; -// -// PDG code from FLUKA particle type (ifip) - part=kIfluge[int(ifip)-1]; -// -// Calculate momentum from kinetic energy and mass of the particle -#if ROOT_VERSION_CODE > 197895 - amass = gMC->ParticleMass(part); -#else - amass = (TDatabasePDG::Instance())->GetParticle(part)->Mass(); -#endif - prwn=fEkin*sqrt(1. + 2.*amass/fEkin); - - - origin[0]=fYi; - origin[1]=fXi; - origin[2]=fZi; - - p[0]=fPy*prwn; - p[1]=fPx*prwn; - p[2]=fPz*prwn; - - //handle particle weight correctly - wgt = (part == 13) ? fWgt*fAddWeight : fWgt; - iwgt=Int_t(wgt); - fwgt=wgt-Float_t(iwgt); - Rndm(random,2); - if (random[0] < fwgt) iwgt++; - if (part==1 && iwgt>100) iwgt=100; - Int_t nstack=0; - for (j=0; jGet("gAlice"); - if (gAlice) printf("AliRun object found on file\n"); - if (!gAlice) gAlice = new AliRun("gAlice","Alice test program"); - } - TTree *fAli=AliRunLoader::Instance()->TreeK(); - if (fAli) pFile =fAli->GetCurrentFile(); - pFile->cd(); -} - - - - - - diff --git a/EVGEN/AliGenFLUKAsource.h b/EVGEN/AliGenFLUKAsource.h deleted file mode 100644 index bc04dd7eba7..00000000000 --- a/EVGEN/AliGenFLUKAsource.h +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef ALIGENFLUKASOURCE_H -#define ALIGENFLUKASOURCE_H -/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * See cxx source for full Copyright notice */ - -/* $Id$ */ - - -// Read background particles from a FLUKA boundary source file -// This is a very special generator that works for background studies for the muon-spectrometer -// Ask: andreas.morsch@cern.ch - -#include "AliGenerator.h" -class TChain; -class TTree; -class AliGenFLUKAsource : public AliGenerator - -{ -public: - enum constants {kAll = 6, kGammas = 7, kNeutrons = 8, kCharged = 9, kNoNeutron = 10}; - - AliGenFLUKAsource(); - AliGenFLUKAsource(Int_t npart); - virtual ~AliGenFLUKAsource(); - // Initialise - virtual void Init() {} - // Initialise fluka data - virtual void FlukaInit(); - // choose particle type - virtual void SetPartFlag(Int_t ikine) {fIkine=ikine;} - // set time cut - virtual void SetAgeMax(Float_t agemax) {fAgeMax=agemax;} - // use additional weight on neutrals - virtual void SetAddWeight(Float_t addwgt) {fAddWeight=addwgt;} - // z-shift of vertex - virtual void SetZshift(Float_t zshift) {fZshift=zshift;} - // set file name of data file - virtual void SetFileName(const Text_t *filname) {fFileName=filname;} - // set source - virtual void SetSourceId(Int_t id=-1){fSourceId=id;} - // add a new source file - virtual void AddFile(const Text_t *filname) ; - // read only fraction of data - virtual void SetFraction(Float_t frac=1.){fFrac=frac;} - // generate event - virtual void Generate(); - - protected: - - Int_t fIkine; // Flag to choose type of particles to be read - Float_t fAgeMax; // Maximum age of particle - Float_t fAddWeight; // Add weight for neutrons - Float_t fZshift; // Shift the Z of impact point by this quantity - Float_t fFrac; // Fraction of file that corresponds to one event - Int_t fSourceId; // Source identifier (-1: all sources) - - - const Text_t *fFileName; //!Choose the file - TChain *fTreeChain; //file chaining - TTree *fTreeFluka; //pointer to the TTree -//Declaration of variables read from the file -- TTree type - Float_t fIp; // Particle type - Float_t fIpp; // Primary particle type - Float_t fXi; // x-Impact - Float_t fYi; // y-Impact - Float_t fZi; // z-Impact - Float_t fPx; // Direction cosine x - Float_t fPy; // Direction cosine y - Float_t fPz; // Direction cosine z - Float_t fEkin; // Kinetic energy - Float_t fZv; // z-Position of particle vertex - Float_t fRv; // r-Position of particle vertex - Float_t fItra; // Primary track number - Float_t fIgas; // Volume identifier - Float_t fWgt; // Particle weight - Float_t fEtag; // Pseudorapidity of primary particle - Float_t fPtg; // Pt of primary particle - Float_t fAge; // Time of flight - - private: - AliGenFLUKAsource(const AliGenFLUKAsource &FLUKAsource); - AliGenFLUKAsource & operator=(const AliGenFLUKAsource & rhs); - - ClassDef(AliGenFLUKAsource,1) //Boundary source -}; -#endif - - - - - - diff --git a/EVGEN/AliGenHalo.cxx b/EVGEN/AliGenHalo.cxx index b824e301666..df5dfb754ea 100644 --- a/EVGEN/AliGenHalo.cxx +++ b/EVGEN/AliGenHalo.cxx @@ -31,6 +31,7 @@ #include "AliGenHalo.h" #include "AliRun.h" +#include "AliLog.h" ClassImp(AliGenHalo) @@ -124,6 +125,7 @@ void AliGenHalo::Init() printf("\n File %s opened for reading, %p ! \n ", fFileName.Data(), (void*)fFile); } else { printf("\n Opening of file %s failed, %p ! \n ", fFileName.Data(), (void*)fFile); + return; } if (fNskip > 0) { @@ -156,8 +158,14 @@ void AliGenHalo::Init() Fatal("Init()", "No gas pressure file for given run period !"); } - - FILE* file = fopen(name, "r"); + + FILE* file = 0; + if (name) file = fopen(name, "r"); + if (!file) { + AliError("No gas pressure file"); + return; + } + Float_t z; Int_t i; Float_t p[5]; diff --git a/EVGEN/AliGenHaloProtvino.cxx b/EVGEN/AliGenHaloProtvino.cxx index 5234b8d15e9..bdbfc30fa56 100644 --- a/EVGEN/AliGenHaloProtvino.cxx +++ b/EVGEN/AliGenHaloProtvino.cxx @@ -123,8 +123,13 @@ void AliGenHaloProtvino::Init() Fatal("Init()", "No gas pressure file for given run period !"); } + FILE* file = 0; + if (name) file = fopen(name, "r"); + if (!file) { + AliError("No gas pressure file"); + return; + } - FILE* file = fopen(name, "r"); Float_t z; Int_t i; Float_t p[5]; diff --git a/EVGEN/AliGenMUONCocktailpp.cxx b/EVGEN/AliGenMUONCocktailpp.cxx index 7eee793d8b2..44f37baed0b 100644 --- a/EVGEN/AliGenMUONCocktailpp.cxx +++ b/EVGEN/AliGenMUONCocktailpp.cxx @@ -308,7 +308,11 @@ void AliGenMUONCocktailpp::CreateCocktail() genupsilonP = new AliGenParam(1, AliGenMUONlib::kUpsilonP, "CDF pp", "UpsilonP"); genupsilonPP = new AliGenParam(1, AliGenMUONlib::kUpsilonPP, "CDF pp", "UpsilonPP"); + } else { + AliError("Initialisation failed"); + return; } + AddReso2Generator(nameJpsi,genjpsi,sigmajpsi,fJpsiPol); AddReso2Generator(nameChic1,genchic2,sigmachic1,fChic2Pol); @@ -408,9 +412,11 @@ void AliGenMUONCocktailpp::AddReso2Generator(Char_t* nameReso, decReso = new AliDecayerPolarized(polReso,AliDecayerPolarized::kHelicity,AliDecayerPolarized::kMuon); AliInfo(Form("******Reference frame: %s, alpha: %f","Helicity",polReso)); } - decReso->SetForceDecay(kAll); - decReso->Init(); - genReso->SetDecayer(decReso); + if (decReso) { + decReso->SetForceDecay(kAll); + decReso->Init(); + genReso->SetDecayer(decReso); + } } AddGenerator(genReso,nameReso,ratioReso); // Adding Generator diff --git a/EVGEN/AliGenSTRANGElib.cxx b/EVGEN/AliGenSTRANGElib.cxx index 572e027ae40..ba962f304e8 100644 --- a/EVGEN/AliGenSTRANGElib.cxx +++ b/EVGEN/AliGenSTRANGElib.cxx @@ -37,7 +37,6 @@ /* $Id$ */ #include -#include #include #include "AliGenSTRANGElib.h" diff --git a/EVGEN/AliGenSTRANGElib.h b/EVGEN/AliGenSTRANGElib.h index 551b988908c..5b9989d6050 100644 --- a/EVGEN/AliGenSTRANGElib.h +++ b/EVGEN/AliGenSTRANGElib.h @@ -21,7 +21,7 @@ class AliGenSTRANGElib : public AliGenLib { public: - enum constants{kKaon, kPhi, kLambda, kLambda1520=3124}; + enum constants{kKaon, kPhi, kLambda, kLambda1520=3124, kOmegaMinus = 3334, kXiMinus = 3312}; GenFunc GetPt(Int_t param, const char* tname=0) const; GenFunc GetY (Int_t param, const char* tname=0) const; GenFuncIp GetIp(Int_t param, const char* tname=0) const; diff --git a/EVGEN/AliOmegaDalitz.cxx b/EVGEN/AliOmegaDalitz.cxx index e8a4dd29fd8..a8fbdb358ea 100644 --- a/EVGEN/AliOmegaDalitz.cxx +++ b/EVGEN/AliOmegaDalitz.cxx @@ -97,10 +97,6 @@ void AliOmegaDalitz::Init() if ( q <= 4.0 * epsilon ) { AliFatal("Error in calculating Dalitz mass histogram binning!"); - if ( idecay == 1 ) - fEPMass = 0; - else - fMPMass = 0; } kwHelp = (1.0 + q / (1.0 - delta)) * (1.0 + q / (1.0 - delta)) diff --git a/EVGEN/CMakelibEVGEN.pkg b/EVGEN/CMakelibEVGEN.pkg index 56e54d65a7c..2ee16fef0b4 100644 --- a/EVGEN/CMakelibEVGEN.pkg +++ b/EVGEN/CMakelibEVGEN.pkg @@ -25,7 +25,7 @@ # SHLIBS - Shared Libraries and objects for linking (Executables only) # #--------------------------------------------------------------------------------# -set ( SRCS AliGenHIJINGpara.cxx AliGenBox.cxx AliGenFixed.cxx AliGenCocktail.cxx AliGenCocktailAfterBurner.cxx AliGenFLUKAsource.cxx AliGenLib.cxx AliGenMUONlib.cxx AliGenHMPIDlib.cxx AliGenParam.cxx AliDimuCombinator.cxx AliGenHalo.cxx AliGenHaloProtvino.cxx AliGenExtFile.cxx AliGenScan.cxx AliGenPHOSlib.cxx AliGenDoubleScan.cxx AliGenCocktailEntry.cxx AliGenGSIlib.cxx AliGenEMlib.cxx AliGenPMDlib.cxx AliGenMC.cxx AliGenReader.cxx AliGenReaderCwn.cxx AliGenReaderTreeK.cxx AliGenReaderEcalHijing.cxx AliGenReaderEcalJets.cxx AliGenHIJINGparaBa.cxx AliGeVSimParticle.cxx AliGenGeVSim.cxx AliGenThetaSlice.cxx AliGenSTRANGElib.cxx AliGenBeamGas.cxx AliGenAfterBurnerFlow.cxx AliGenSlowNucleons.cxx AliSlowNucleonModel.cxx AliSlowNucleonModelExp.cxx AliGenMUONCocktail.cxx AliGenMUONCocktailpp.cxx AliGenEMCocktail.cxx AliGenHBTosl.cxx AliGenReaderEMD.cxx AliDecayerPolarized.cxx AliGenCorrHF.cxx AliGenCosmicsParam.cxx AliGenKrypton.cxx AliGenThermalPhotons.cxx AliGenPromptPhotons.cxx AliGenPileup.cxx AliGenFunction.cxx AliGenTHnSparse.cxx AliOmegaDalitz.cxx AliGenDeuteron.cxx AliGenReaderSL.cxx) +set ( SRCS AliGenHIJINGpara.cxx AliGenBox.cxx AliGenFixed.cxx AliGenCocktail.cxx AliGenCocktailAfterBurner.cxx AliGenLib.cxx AliGenMUONlib.cxx AliGenHMPIDlib.cxx AliGenParam.cxx AliDimuCombinator.cxx AliGenHalo.cxx AliGenHaloProtvino.cxx AliGenExtFile.cxx AliGenScan.cxx AliGenPHOSlib.cxx AliGenDoubleScan.cxx AliGenCocktailEntry.cxx AliGenGSIlib.cxx AliGenEMlib.cxx AliGenPMDlib.cxx AliGenMC.cxx AliGenReader.cxx AliGenReaderCwn.cxx AliGenReaderTreeK.cxx AliGenReaderEcalHijing.cxx AliGenReaderEcalJets.cxx AliGenHIJINGparaBa.cxx AliGeVSimParticle.cxx AliGenGeVSim.cxx AliGenThetaSlice.cxx AliGenSTRANGElib.cxx AliGenBeamGas.cxx AliGenAfterBurnerFlow.cxx AliGenSlowNucleons.cxx AliSlowNucleonModel.cxx AliSlowNucleonModelExp.cxx AliGenMUONCocktail.cxx AliGenMUONCocktailpp.cxx AliGenEMCocktail.cxx AliGenHBTosl.cxx AliGenReaderEMD.cxx AliDecayerPolarized.cxx AliGenCorrHF.cxx AliGenCosmicsParam.cxx AliGenKrypton.cxx AliGenThermalPhotons.cxx AliGenPromptPhotons.cxx AliGenPileup.cxx AliGenFunction.cxx AliGenTHnSparse.cxx AliOmegaDalitz.cxx AliGenDeuteron.cxx AliGenReaderSL.cxx) string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" ) diff --git a/EVGEN/EVGENLinkDef.h b/EVGEN/EVGENLinkDef.h index 9735fb687f4..8b90e102952 100644 --- a/EVGEN/EVGENLinkDef.h +++ b/EVGEN/EVGENLinkDef.h @@ -30,7 +30,6 @@ #pragma link C++ class AliGenLib+; #pragma link C++ class AliGenMUONlib+; #pragma link C++ class AliGenHMPIDlib+; -#pragma link C++ class AliGenFLUKAsource+; #pragma link C++ class AliGenHalo+; #pragma link C++ class AliGenHaloProtvino+; #pragma link C++ class AliDimuCombinator+;