]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - JETAN/AliJetKineReader.cxx
Coeverity fixes, changed hard-coded track eta of 0.9 for the cluster task, do not...
[u/mrichter/AliRoot.git] / JETAN / AliJetKineReader.cxx
index 20b33e52d002ae61c514e9b88e03331a3e9a659d..4fd19fb1b806e1e4b63286d8f6c3c3f4c08a159a 100644 (file)
@@ -30,6 +30,7 @@
 #include <TRandom.h>
 // From AliRoot ...
 #include "AliAODJet.h"
+#include "AliPDG.h"
 #include "AliJetKineReaderHeader.h"
 #include "AliJetKineReader.h"
 #include "AliMCEventHandler.h"
@@ -55,7 +56,10 @@ AliJetKineReader::AliJetKineReader():
 AliJetKineReader::~AliJetKineReader()
 {
   // Destructor
-  delete fAliHeader;
+    if (fAliHeader) {
+       delete fAliHeader;
+       fAliHeader = 0;
+    }
 }
 
 //____________________________________________________________________________
@@ -107,6 +111,15 @@ Bool_t AliJetKineReader::FillMomentumArray()
        Float_t p0      = p;
        Float_t eta     = part->Eta();
        Float_t phi     = part->Phi();
+
+
+       if (((AliJetKineReaderHeader*)fReaderHeader)->ChargedOnly()) {
+           // Charged particles only
+           Float_t charge = 
+               TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
+           if (charge == 0)               continue;
+       } // End charged only
+
        
        // Fast simulation of TPC if requested
        if (((AliJetKineReaderHeader*)fReaderHeader)->FastSimTPC()) {
@@ -140,7 +153,23 @@ Bool_t AliJetKineReader::FillMomentumArray()
        Float_t px = r * part->Px(); 
        Float_t py = r * part->Py(); 
        Float_t pz = r * part->Pz();
-       Float_t m  = part->GetMass();
+       TParticlePDG *pPDG = part->GetPDG();
+       Float_t m = 0;
+       if(!pPDG){
+         // this is very rare...
+         // Is avoided by AliPDG::AddParticlesToPdgDataBase();
+         // but this should be called only once... (how in proof?)
+         // Calucluate mass with unsmeared momentum values
+         m  = part->Energy()*part->Energy() - 
+           (px * px + py * py + pz * pz)/r/r; 
+         if(m>0)m = TMath::Sqrt(m);
+         else m = 0;
+         AliInfo(Form("Unknown Particle using %d calculated mass m = %3.3f",part->GetPdgCode(),m));
+
+       }
+       else{
+         m  = pPDG->Mass();
+       }
        Float_t e  = TMath::Sqrt(px * px + py * py + pz * pz + m * m);
        p4 = TLorentzVector(px, py, pz, e);
        if ( (p4.Eta()>etaMax) || (p4.Eta()<etaMin)) continue;
@@ -248,7 +277,7 @@ TClonesArray*  AliJetKineReader::GetGeneratedJets()
     return fGenJets;
 }
 
-void AliJetKineReader::SetInputEvent(TObject* /*esd*/, TObject* /*aod*/, TObject* mc)
+void AliJetKineReader::SetInputEvent(const TObject* /*esd*/, const TObject* /*aod*/, const TObject* mc)
 {
     // Connect the input event
     fMCEvent = (AliMCEvent*) mc;