]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
New PID Classes
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 23 Aug 2012 16:36:39 +0000 (16:36 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 23 Aug 2012 16:36:39 +0000 (16:36 +0000)
Jens Wiechula
Pietro Antonioli

STEER/STEERBase/AliDetectorPID.cxx [new file with mode: 0644]
STEER/STEERBase/AliDetectorPID.h [new file with mode: 0644]
STEER/STEERBase/AliPIDValues.cxx [new file with mode: 0644]
STEER/STEERBase/AliPIDValues.h [new file with mode: 0644]

diff --git a/STEER/STEERBase/AliDetectorPID.cxx b/STEER/STEERBase/AliDetectorPID.cxx
new file mode 100644 (file)
index 0000000..2848714
--- /dev/null
@@ -0,0 +1,194 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+
+///////////////////////////////////////////////////////////////////////////
+//                       Detector PID                                    //
+//                                                                       //
+//                                                                       //
+/*
+
+This class is supposed to store the detector pid values for all detectors
+  and all particle species.
+It is meant to be used to buffer the PID values as a transient object in
+  AliESDtrack and AliAODTrack, respectively.
+The calculation filling and association to the track is done in
+  AliAnalysisTaskPID response.
+The idea of this object is to save computing time in an analysis train with
+  many analyses where access to pid is done often
+
+
+
+*/
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+#include "AliPIDValues.h"
+
+#include "AliDetectorPID.h"
+
+ClassImp(AliDetectorPID)
+
+
+AliDetectorPID::AliDetectorPID() :
+  TObject(),
+  fArrNsigmas("AliPIDValues",AliPIDResponse::kNdetectors),
+  fArrRawProbabilities("AliPIDValues",AliPIDResponse::kNdetectors)
+{
+  //
+  // default constructor
+  //
+  
+}
+
+//_______________________________________________________________________
+AliDetectorPID::AliDetectorPID(const AliDetectorPID &pid) :
+  TObject(pid),
+  fArrNsigmas(pid.fArrNsigmas),
+  fArrRawProbabilities(pid.fArrRawProbabilities)
+{
+  //
+  // copy constructor
+  //
+  
+}
+
+//_______________________________________________________________________
+AliDetectorPID::~AliDetectorPID()
+{
+  //
+  // destructor
+  //
+  fArrNsigmas.Delete();
+  fArrRawProbabilities.Delete();
+}
+
+//_______________________________________________________________________
+AliDetectorPID& AliDetectorPID::operator= (const AliDetectorPID &pid)
+{
+  //
+  // assignment operator
+  //
+  
+  if (this==&pid) return *this;
+
+  TObject::operator=(pid);
+  
+  fArrNsigmas.Clear();
+  fArrRawProbabilities.Clear();
+  
+  AliPIDValues *val=0x0;
+  for (Int_t idet=0; idet<(Int_t)AliPIDResponse::kNdetectors; ++idet){
+    val=static_cast<AliPIDValues*>(pid.fArrNsigmas.UncheckedAt(idet));
+    if (val) new (fArrNsigmas[idet]) AliPIDValues(*val);
+
+    val=static_cast<AliPIDValues*>(pid.fArrRawProbabilities.UncheckedAt(idet));
+    if (val) new (fArrRawProbabilities[idet]) AliPIDValues(*val);
+  }
+
+  return *this;
+}
+
+//_______________________________________________________________________
+void AliDetectorPID::SetRawProbability(AliPIDResponse::EDetector det, const Double_t prob[],
+                                       Int_t nspecies, AliPIDResponse::EDetPidStatus status)
+{
+  //
+  // set raw probabilities for nspecies for 'det'ector
+  //
+  
+  AliPIDValues *val=static_cast<AliPIDValues*>(fArrRawProbabilities.UncheckedAt(det));
+  if (!val)
+    val=new (fArrRawProbabilities[(Int_t)det]) AliPIDValues;
+
+  val->SetValues(prob,nspecies,status);
+}
+
+//_______________________________________________________________________
+void AliDetectorPID::SetNumberOfSigmas(AliPIDResponse::EDetector det, const Double_t nsig[], Int_t nspecies)
+{
+  //
+  // set number of sigmas for nspecies for 'det'ector
+  //
+  
+  AliPIDValues *val=static_cast<AliPIDValues*>(fArrNsigmas.UncheckedAt(det));
+  if (!val)
+    val=new (fArrNsigmas[(Int_t)det]) AliPIDValues;
+
+  val->SetValues(nsig,nspecies);
+}
+
+//_______________________________________________________________________
+AliPIDResponse::EDetPidStatus AliDetectorPID::GetRawProbability(AliPIDResponse::EDetector det, Double_t prob[], Int_t nspecies) const
+{
+  //
+  // get raw probabilities for nspecies for 'det'ector
+  //
+  
+  AliPIDValues *val=static_cast<AliPIDValues*>(fArrRawProbabilities.UncheckedAt((Int_t)det));
+  if (!val) {
+    for (Int_t i=0; i<nspecies; ++i) prob[i]=1.; //TODO: Is '1' the correct values or better 1/nspecies
+    return AliPIDResponse::kDetNoSignal;
+  }
+
+  return val->GetValues(prob,nspecies);
+}
+
+//_______________________________________________________________________
+void AliDetectorPID::GetNumberOfSigmas(AliPIDResponse::EDetector det, Double_t nsig[], Int_t nspecies) const
+{
+  //
+  // get number of sigmas for nspecies for detector 'det'
+  //
+  
+  AliPIDValues *val=static_cast<AliPIDValues*>(fArrNsigmas.UncheckedAt((Int_t)det));
+  if (!val) {
+    for (Int_t i=0; i<nspecies; ++i) nsig[i]=-999.;
+    return;
+  }
+
+  val->GetValues(nsig,nspecies);
+}
+
+//_______________________________________________________________________
+Double_t AliDetectorPID::GetRawProbability(AliPIDResponse::EDetector det, AliPID::EParticleType type) const
+{
+  //
+  // get 'det'ector raw probability for particle 'type'
+  //
+  
+  AliPIDValues *val=static_cast<AliPIDValues*>(fArrRawProbabilities.UncheckedAt((Int_t)det));
+  if (!val) {
+    return 0.; //TODO: Is '0' the correct value?
+  }
+  
+  return val->GetValue(type);
+}
+
+//_______________________________________________________________________
+Double_t AliDetectorPID::GetNumberOfSigmas(AliPIDResponse::EDetector det, AliPID::EParticleType type) const
+{
+  //
+  // get 'det'ector number of sigmas for particle 'type'
+  //
+  AliPIDValues *val=static_cast<AliPIDValues*>(fArrNsigmas.UncheckedAt((Int_t)det));
+  if (!val) {
+    return -999.; //TODO: Is '-999.' the correct value?
+  }
+  
+  return val->GetValue(type);
+}
+
+
diff --git a/STEER/STEERBase/AliDetectorPID.h b/STEER/STEERBase/AliDetectorPID.h
new file mode 100644 (file)
index 0000000..9cc2174
--- /dev/null
@@ -0,0 +1,43 @@
+#ifndef ALI_DETECTOR_PID_H
+#define ALI_DETECTOR_PID_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+//---------------------------------------------------------------//
+//      Class to store raw probabilities and nsigmas             //
+//        of all detectors                                       //
+//                                                               //
+//                                                               //
+//   Origin: Jens Wiechula, Uni Tuebingen, jens.wiechula@cern.ch //
+//---------------------------------------------------------------//
+
+#include <TObject.h>
+#include <TClonesArray.h>
+
+#include "AliPID.h"
+#include "AliPIDResponse.h"
+
+class AliDetectorPID : public TObject {
+public:
+  AliDetectorPID();
+  AliDetectorPID(const AliDetectorPID &pid);
+  virtual ~AliDetectorPID();
+  AliDetectorPID& operator= (const AliDetectorPID &pid);
+  
+  void SetRawProbability(AliPIDResponse::EDetector det, const Double_t prob[], Int_t nspecies, AliPIDResponse::EDetPidStatus status);
+  void SetNumberOfSigmas(AliPIDResponse::EDetector det, const Double_t nsig[], Int_t nspecies);
+
+  AliPIDResponse::EDetPidStatus GetRawProbability(AliPIDResponse::EDetector det, Double_t prob[], Int_t nspecies) const;
+  void GetNumberOfSigmas(AliPIDResponse::EDetector det, Double_t nsig[], Int_t nspecies) const;
+  
+  Double_t GetRawProbability(AliPIDResponse::EDetector det, AliPID::EParticleType type) const;
+  Double_t GetNumberOfSigmas(AliPIDResponse::EDetector det, AliPID::EParticleType type) const;
+private:
+  TClonesArray fArrNsigmas;          // array to store nsigma values of all detectors
+  TClonesArray fArrRawProbabilities; // array to strore raw probabilities of all detectors
+
+  ClassDef(AliDetectorPID,1);        //Store raw probabilities and nsigmas for all detectors
+};
+
+#endif
+
diff --git a/STEER/STEERBase/AliPIDValues.cxx b/STEER/STEERBase/AliPIDValues.cxx
new file mode 100644 (file)
index 0000000..0c4bbe2
--- /dev/null
@@ -0,0 +1,126 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+///////////////////////////////////////////////////////////////////////////
+//                       PID Values                                      //
+//                                                                       //
+//                                                                       //
+/*
+
+Class to store PID information for each particle species
+
+*/
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+
+#include "AliPIDValues.h"
+
+ClassImp(AliPIDValues)
+
+AliPIDValues::AliPIDValues() :
+  TObject(),
+  fPIDStatus(AliPIDResponse::kDetPidOk)
+{
+  //
+  // default constructor
+  //
+  Int_t nspecies=AliPID::kSPECIESCN;
+  for (Int_t i=0; i<nspecies; ++i) fValues[i]=0.;
+}
+
+//_______________________________________________________________________
+AliPIDValues::AliPIDValues(const AliPIDValues &val) :
+  TObject(val),
+  fPIDStatus(val.fPIDStatus)
+{
+  //
+  // copy constructor
+  //
+  Int_t nspecies=AliPID::kSPECIESCN;
+  for (Int_t i=0; i<nspecies; ++i) fValues[i]=val.fValues[i];
+}
+
+//_______________________________________________________________________
+AliPIDValues::AliPIDValues(Double_t val[], Int_t nspecies, AliPIDResponse::EDetPidStatus status) :
+  TObject(),
+  fPIDStatus(AliPIDResponse::kDetPidOk)
+{
+  //
+  // constructor with array of values
+  //
+  SetValues(val,nspecies,status);
+}
+
+//_______________________________________________________________________
+AliPIDValues& AliPIDValues::operator= (const AliPIDValues &val)
+{
+  //
+  // assignment operator
+  //
+  if (this!=&val){
+    TObject::operator=(val);
+    
+    Int_t nspecies=AliPID::kSPECIESCN;
+    for (Int_t i=0; i<nspecies; ++i) fValues[i]=val.fValues[i];
+    fPIDStatus=val.fPIDStatus;
+  }
+
+  return *this;
+}
+
+//_______________________________________________________________________
+void AliPIDValues::Copy(TObject &obj) const {
+  // this overwrites the virtual TObject::Copy()
+  // to allow run time copying without casting
+  // in AliPIDValues
+  
+  if(this==&obj)return;
+  AliPIDValues *robj = dynamic_cast<AliPIDValues*>(&obj);
+  if(!robj)return; // not AliPIDValues
+  *robj = *this;
+}
+
+//_______________________________________________________________________
+void AliPIDValues::SetValues(const Double_t val[], Int_t nspecies, AliPIDResponse::EDetPidStatus status)
+{
+  //
+  // set array of values
+  //
+  if (nspecies>AliPID::kSPECIESCN) nspecies=AliPID::kSPECIESCN;
+  for (Int_t i=0; i<nspecies; ++i) fValues[i]=val[i];
+  fPIDStatus=status;
+}
+
+//_______________________________________________________________________
+AliPIDResponse::EDetPidStatus AliPIDValues::GetValues(Double_t val[], Int_t nspecies) const
+{
+  //
+  // get array of values
+  //
+  if (nspecies>AliPID::kSPECIESCN) nspecies=AliPID::kSPECIESCN;
+  for (Int_t i=0; i<nspecies; ++i) val[i]=fValues[i];
+  return fPIDStatus;
+}
+
+//_______________________________________________________________________
+Double_t AliPIDValues::GetValue(AliPID::EParticleType type) const
+{
+  //
+  // get values for a specific particle type
+  //
+  return fValues[(Int_t)type];
+}
+
diff --git a/STEER/STEERBase/AliPIDValues.h b/STEER/STEERBase/AliPIDValues.h
new file mode 100644 (file)
index 0000000..e9f1e21
--- /dev/null
@@ -0,0 +1,43 @@
+#ifndef ALI_PID_VALUES_H
+#define ALI_PID_VALUES_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+//---------------------------------------------------------------//
+//        Base class for handling the pid response               //
+//        functions of all detectors                             //
+//        and give access to the nsigmas                         //
+//                                                               //
+//   Origin: Jens Wiechula, Uni Tuebingen, jens.wiechula@cern.ch //
+//---------------------------------------------------------------//
+
+#include <TObject.h>
+
+#include "AliPID.h"
+#include "AliPIDResponse.h"
+
+class AliPIDValues : public TObject {
+public:
+  AliPIDValues();
+  AliPIDValues(const AliPIDValues &val);
+  AliPIDValues(Double_t val[], Int_t nspecies, AliPIDResponse::EDetPidStatus status=AliPIDResponse::kDetPidOk);
+  
+  AliPIDValues& operator= (const AliPIDValues &val);
+  void Copy(TObject &obj) const;
+  
+  void SetValues(const Double_t val[], Int_t nspecies, AliPIDResponse::EDetPidStatus status=AliPIDResponse::kDetPidOk);
+  AliPIDResponse::EDetPidStatus GetValues(Double_t val[], Int_t nspecies) const;
+
+  Double_t GetValue(AliPID::EParticleType type) const;
+
+  void SetPIDStatus(AliPIDResponse::EDetPidStatus status) { fPIDStatus=status; }
+  AliPIDResponse::EDetPidStatus GetPIDStatus() const { return fPIDStatus; }
+  
+private:
+  Double32_t fValues[AliPID::kSPECIESCN];    //[0.,0.,8] PID values
+  AliPIDResponse::EDetPidStatus fPIDStatus;  //PID status of the detector
+
+  ClassDef(AliPIDValues,1);                  //Store PID values for each particle type
+};
+
+#endif