]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSFastRecParticle.cxx
Compilation warnings fixed
[u/mrichter/AliRoot.git] / PHOS / AliPHOSFastRecParticle.cxx
index 177d018993b01270e00575ac20a912c5c07898f2..d2b8cfa7ca472e8495f9bdc5c96a062f99676091 100644 (file)
 //_________________________________________________________________________
 //  A  Particle modified by PHOS response and produced by AliPHOSvFast
 //  To become a general class of AliRoot ?    
-//               
+//--
+//  This is also a base class for AliPHOSRecParticle produced by AliPHOSPIDv1
+//  The rec.particle type is to be defined by AliPHOSvFast or AliPHOSPIDv1
+//--
 //*-- Author: Yves Schutz (SUBATECH)
 
 // --- ROOT system ---
 
 // --- Standard library ---
 
-#include <iostream.h>
-
 // --- AliRoot header files ---
 
 #include "AliPHOSFastRecParticle.h"
 
 ClassImp(AliPHOSFastRecParticle) ; 
 
+//____________________________________________________________________________
+AliPHOSFastRecParticle::AliPHOSFastRecParticle() : TParticle()
+{
+  // ctor
+  fType = 0 ; 
+}
+
 //____________________________________________________________________________
  AliPHOSFastRecParticle::AliPHOSFastRecParticle(const AliPHOSFastRecParticle & rp)
+   : TParticle(rp)
 {
   // copy ctor
 
-  fType        = rp.fType ; 
+  fType        = rp.fType ;
   fPdgCode     = rp.fPdgCode;
   fStatusCode  = rp.fStatusCode;
   fMother[0]   = rp.fMother[0];
@@ -69,7 +78,7 @@ ClassImp(AliPHOSFastRecParticle) ;
  
   TParticle & pnoconst = (TParticle &)(pp) ;
   AliPHOSFastRecParticle & p = (AliPHOSFastRecParticle &)(pnoconst) ;
-
+  fType        = 0  ;
   fPdgCode     = p.fPdgCode;
   fStatusCode  = p.fStatusCode;
   fMother[0]   = p.fMother[0];
@@ -124,12 +133,12 @@ void AliPHOSFastRecParticle::ExecuteEvent(Int_t event, Int_t px, Int_t py)
 {
   //  Execute action corresponding to one event
   //  This member function is called when a AliPHOSFastRecParticle is clicked with the locator
-     
+  
   if (!gPad->IsEditable()) 
     return ;
-
+  
   static TPaveText * clustertext = 0 ; 
-
+  
   switch (event) {
     
   case kButton1Down: {
@@ -155,38 +164,281 @@ void AliPHOSFastRecParticle::ExecuteEvent(Int_t event, Int_t px, Int_t py)
     break ;
   }
   }
+  
 }
 
 //____________________________________________________________________________
-TString AliPHOSFastRecParticle::Name()
+Bool_t AliPHOSFastRecParticle::IsPhoton(TString purity) const
 {
-  // Returns the name of the particle type
-  
+  // Rec.Particle is a photon if it has a photon-like shape, fast and neutral
+  // photon-like shape is defined with a purity "low", "medium" or "high"
+
+  purity.ToLower();
+  Bool_t photonLike = kFALSE;
+  if      (purity == "low"   ) photonLike = TestPIDBit(6);
+  else if (purity == "medium") photonLike = TestPIDBit(7);
+  else if (purity == "high"  ) photonLike = TestPIDBit(8);
+  else Error("IsPhoton","Wrong purity type: \'%s\'",purity.Data());
+  if (photonLike                                   && //  photon by PCA
+      (TestPIDBit(5)||TestPIDBit(4)||TestPIDBit(3))&& //  fast by TOF
+      (TestPIDBit(2)||TestPIDBit(1)||TestPIDBit(0)))  //  neutral by CPV
+    return kTRUE ;
+  else
+    return kFALSE;
+}
+
+//____________________________________________________________________________
+Bool_t AliPHOSFastRecParticle::IsPi0(TString purity) const
+{
+  // Rec.Particle is a pi0 if it has a pi0-like shape, fast and neutral
+  // pi0-like shape is defined with a purity "low", "medium" or "high"
+
+  purity.ToLower();
+  Bool_t pi0Like = kFALSE;
+  if      (purity == "low"   ) pi0Like = TestPIDBit(9);
+  else if (purity == "medium") pi0Like = TestPIDBit(10);
+  else if (purity == "high"  ) pi0Like = TestPIDBit(11);
+  else Error("IsPi0","Wrong purity type: %s",purity.Data());
+  if (pi0Like                                      && //  pi0 by PCA
+      (TestPIDBit(5)||TestPIDBit(4)||TestPIDBit(3))&& //  fast by TOF
+      (TestPIDBit(2)||TestPIDBit(1)||TestPIDBit(0)))  //  neutral by CPV
+    return kTRUE ;
+  else
+    return kFALSE;
+}
+
+//____________________________________________________________________________
+Bool_t AliPHOSFastRecParticle::IsElectron(TString purity) const
+{
+  // Rec.Particle is an electron if it has a photon-like shape, fast and charged
+  // photon-like shape is defined with a purity "low", "medium" or "high"
+
+  purity.ToLower();
+  Bool_t photonLike = kFALSE;
+  if      (purity == "low"   ) photonLike = TestPIDBit(6);
+  else if (purity == "medium") photonLike = TestPIDBit(7);
+  else if (purity == "high"  ) photonLike = TestPIDBit(8);
+  else Error("IsElectron","Wrong purity type: %s",purity.Data());
+  if (photonLike                                   && //  photon by PCA
+      (TestPIDBit(5)||TestPIDBit(4)||TestPIDBit(3))&& //  fast by TOF
+     !(TestPIDBit(2)||TestPIDBit(1)||TestPIDBit(0)))  //  charged by CPV
+    return kTRUE ;
+  else
+    return kFALSE;
+}
+
+//____________________________________________________________________________
+Bool_t AliPHOSFastRecParticle::IsHardPhoton() const
+{
+  // Rec.Particle is a hard photon (E > 30 GeV) if its second moment M2x
+  // corresponds to photons
+  if (TestPIDBit(12))
+    return kTRUE;
+  else
+    return kFALSE;
+}
+
+//____________________________________________________________________________
+Bool_t AliPHOSFastRecParticle::IsHardPi0() const
+{
+  // Rec.Particle is a hard pi0 (E > 30 GeV) if its second moment M2x
+  // corresponds to pi0
+  if (TestPIDBit(13))
+    return kTRUE;
+  else
+    return kFALSE;
+}
+
+//____________________________________________________________________________
+Bool_t AliPHOSFastRecParticle::IsHadron() const
+{
+  // Rec.Particle is an hadron if it does not look like
+  // a low-purity photon nor low-purity pi0
+
+  if ( !TestPIDBit(6) && !TestPIDBit(9) )             // not photon nor pi0
+    return kTRUE ;
+  else
+    return kFALSE;
+}
+
+//____________________________________________________________________________
+Bool_t AliPHOSFastRecParticle::IsChargedHadron() const
+{
+  // Rec.Particle is a charged hadron if it does not look like
+  // a low-purity photon nor low-purity pi0 and is low-purity charged
+
+  if ( !TestPIDBit(6) && !TestPIDBit(9) &&            // not photon nor pi0
+       !TestPIDBit(2))                                // charged by CPV
+    return kTRUE ;
+  else
+    return kFALSE;
+}
+
+//____________________________________________________________________________
+Bool_t AliPHOSFastRecParticle::IsNeutralHadron() const
+{
+  // Rec.Particle is a neutral hadron if it does not look like
+  // a low-purity photon nor low-purity pi0 and is high-purity neutral
+
+  if ( !TestPIDBit(6) && !TestPIDBit(9) &&            // not photon nor pi0
+        TestPIDBit(2))                                // neutral by CPV
+    return kTRUE ;
+  else
+    return kFALSE;
+}
+
+//____________________________________________________________________________
+Bool_t AliPHOSFastRecParticle::IsFastChargedHadron() const
+{
+  // Rec.Particle is a fast charged hadron if it does not look like
+  // a low-purity photon nor low-purity pi0, is low-purity charged
+  // and is high-purity fast
+
+  if ( !TestPIDBit(6) && !TestPIDBit(9) &&            // not photon nor pi0
+       !TestPIDBit(2) &&                              // charged by CPV
+        TestPIDBit(5))                                // fast by TOF
+    return kTRUE ;
+  else
+    return kFALSE;
+}
+
+//____________________________________________________________________________
+Bool_t AliPHOSFastRecParticle::IsSlowChargedHadron() const
+{
+  // Rec.Particle is a slow neutral hadron if it does not look like
+  // a low-purity photon nor low-purity pi0, is high-purity neutral
+  // and is not high-purity fast
+
+  if ( !TestPIDBit(6) && !TestPIDBit(9) &&            // not photon nor pi0
+       !TestPIDBit(2) &&                              // charged by CPV
+       !TestPIDBit(5))                                // slow by TOF
+    return kTRUE ;
+  else
+    return kFALSE;
+
+}
+
+//____________________________________________________________________________
+Bool_t AliPHOSFastRecParticle::IsFastNeutralHadron() const
+{
+  // Rec.Particle is a fast neutral hadron if it does not look like
+  // a low-purity photon nor low-purity pi0, is high-purity neutral
+  // and is high-purity fast
+
+  if ( !TestPIDBit(6) && !TestPIDBit(9) &&            // not photon nor pi0
+        TestPIDBit(2) &&                              // neutral by CPV
+        TestPIDBit(5))                                // fast by TOF
+    return kTRUE ;
+  else
+    return kFALSE;
+}
+
+//____________________________________________________________________________
+Bool_t AliPHOSFastRecParticle::IsSlowNeutralHadron() const
+{
+  // Rec.Particle is a slow neutral hadron if it does not look like
+  // a low-purity photon nor low-purity pi0, is high-purity neutral
+  // and is not high-purity fast
+
+  if ( !TestPIDBit(6) && !TestPIDBit(9) &&            // not photon nor pi0
+        TestPIDBit(2) &&                              // neutral by CPV
+       !TestPIDBit(5))                                // slow by TOF
+    return kTRUE ;
+  else
+    return kFALSE;
+}
+
+//____________________________________________________________________________
+TString AliPHOSFastRecParticle::Name() const
+{
+  // Returns the name of the particle type (only valid if PIDv1 is employed)
+
   TString  name ; 
-  switch (fType) {
-  case kGAMMA:
-    name = "PHOTON" ;
-    break ; 
-   case kELECTRON:
-     name = "ELECTRON" ;
-    break ; 
-   case kCHARGEDHA:
-    name = "CHARGED_HA" ;
-    break ; 
-  case kNEUTRALHA:
-    name = "NEUTRAL_HA" ; 
-    break ; 
-  case kNEUTRALEM:
-    name = "NEUTRAL_EM" ; 
-    break ; 
-  case kGAMMAHA:
-    name = "PHOTON_HA" ; 
-    break ; 
 
+  name = "Undefined particle" ;
+  
+  if      (IsPhoton("low"))
+    name = "Photon low purity ";
+  else if (IsPhoton("medium"))
+    name = "Photon medium purity";
+  else if (IsPhoton("high"))
+    name = "Photon high purity ";
+
+  if      (IsPi0("low"))
+    name += "Pi0 low purity ";
+  else if (IsPi0("medium"))
+    name += "Pi0 medium purity ";
+  else if (IsPi0("high"))
+    name += "Pi0 high purity ";
+
+  if      (IsElectron("low"))
+    name += "Electron low purity ";
+  else if (IsElectron("medium"))
+    name += "Electron medium purity ";
+  else if (IsElectron("high"))
+    name += "Electron high purity ";
+
+  if     (IsHadron()) {
+    name = "hadron";
+    if      (IsChargedHadron()) {
+      name.Prepend("charged ");
+      if      (IsFastChargedHadron())
+       name.Prepend("fast ");
+      else if (IsSlowChargedHadron())
+       name.Prepend("slow ");
+    }
+    else if (IsNeutralHadron()) {
+      name.Prepend("neutral ");
+      if      (IsFastNeutralHadron())
+       name.Prepend("fast ");
+      else if (IsSlowNeutralHadron())
+       name.Prepend("slow ");
+    }
   }
+
   return name ; 
 }
 
+
+//______________________________________________________________________________
+void AliPHOSFastRecParticle::SetType(Int_t type) { 
+  // sets the particle type 
+  // bit-mask of the particle type means the following:
+  // bits 0,1,2   - neutral particle with low, medium and high purity
+  // bits 3.4,5   - fast particle with low, medium and high purity
+  // bits 6.7,8   - photon shower with low, medium and high purity
+  // bits 9,10,11 - hard-pi0 shower with low, medium and high purity
+
+  fType = type ; 
+  
+  if((type == 127) || (fType == 511) || (fType == 255) ||(fType == 383)||(fType == 447)){
+    fPdgCode = 22 ; 
+    return ;
+  }
+  
+  if ((fType == 63)|| ((fType < 8)&&(fType > 0)) ){
+    fPdgCode = 2112 ; 
+    return ;
+  }
+  if ( ((fType == 504) || (fType == 505) ||(fType == 248)||(fType == 249)||(fType == 120)||(fType == 121)) ){
+    fPdgCode = 11 ; 
+    return ;
+  }
+  if ((fType == 448) || (fType == 449) ||(fType == 192)||(fType == 193)||(fType == 64)||(fType == 64)){
+    fPdgCode = 13 ; 
+    return ;
+  }
+  if((fType == 56)||(fType == 57)){
+    fPdgCode = 211 ; 
+    return ;
+  }
+  if (fType == 0){
+    fPdgCode = 2212 ; 
+    return ;
+  }
+
+}          
+
 //______________________________________________________________________________
 void AliPHOSFastRecParticle::Paint(Option_t *)
 {
@@ -209,13 +461,24 @@ void AliPHOSFastRecParticle::Paint(Option_t *)
 }
 
 //____________________________________________________________________________
-void AliPHOSFastRecParticle::Print(const char * opt)
+void AliPHOSFastRecParticle::Print(Option_t * opt)const
 {
   // Print the type, energy and momentum of the reconstructed particle
-  
-  cout << "AliPHOSFastRecParticle > " << "type is  " << Name() << endl 
-       << "                     " << "Energy = " << fE << endl 
-       << "                     " << "Px     = " << fPx << endl 
-       << "                     " << "Py     = " << fPy << endl 
-       << "                     " << "Pz     = " << fPz << endl ; 
+
+  TString message ; 
+  message  = "\n   PID bits are %d%d%d %d%d%d %d%d%d %d%d%d" ; 
+  message += ", type is \"%s\"\n" ; 
+  message += "   (E,Px,Py,Pz) = (% .3e, % .3e, % .3e, % .3e) GeV\n" ; 
+  Info("Print", message.Data(), 
+       TestPIDBit(0),TestPIDBit(1),
+       TestPIDBit(2),TestPIDBit(3),
+       TestPIDBit(4),TestPIDBit(5),
+       TestPIDBit(6),TestPIDBit(7),
+       TestPIDBit(8),TestPIDBit(9),
+       TestPIDBit(10),TestPIDBit(11),
+       Name().Data(), 
+       Energy(), 
+       Px(), 
+       Py(),
+       Pz() ); 
 }