Since it contains fixes of coding rule violations, all classes are involved. Further...
[u/mrichter/AliRoot.git] / PWG3 / hfe / AliHFEpidBase.cxx
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 *                                                                        *
4 * Author: The ALICE Off-line Project.                                    *
5 * Contributors are mentioned in the code where appropriate.              *
6 *                                                                        *
7 * Permission to use, copy, modify and distribute this software and its   *
8 * documentation strictly for non-commercial purposes is hereby granted   *
9 * without fee, provided that the above copyright notice appears in all   *
10 * copies and that both the copyright notice and this permission notice   *
11 * appear in the supporting documentation. The authors make no claims     *
12 * about the suitability of this software for any purpose. It is          *
13 * provided "as is" without express or implied warranty.                  *
14 **************************************************************************/
15 /************************************************************************
16  *                                                                      *
17  * Abstract PID base class for Detector PID classes                     *
18  * Supplies detector PID classes with basic informations (i.e. Debug    *
19  * Level)                                                               *
20  *                                                                      *
21  * Authors:                                                             *
22  *   Markus Fasel <M.Fasel@gsi.de>                                      *
23  *                                                                      *
24  ************************************************************************/
25 #include <TParticle.h>
26
27 #include "AliESDtrack.h"
28 #include "AliMCParticle.h"
29 #include "AliMCEvent.h"
30
31 #include "AliHFEpidBase.h"
32
33 ClassImp(AliHFEpidBase)
34
35 //___________________________________________________________________
36 AliHFEpidBase::AliHFEpidBase(const Char_t *name):
37   TNamed(name, ""),
38   fMCEvent(0x0),
39   fDebugLevel(0)
40 {
41   //
42   // Default constructor
43   //
44 }
45
46 //___________________________________________________________________
47 AliHFEpidBase::AliHFEpidBase(const AliHFEpidBase &c):
48   TNamed(),
49   fMCEvent(0x0),
50   fDebugLevel(0)
51 {
52   //
53   //Copy constructor
54   //
55   c.Copy(*this);
56 }
57
58 //___________________________________________________________________
59 AliHFEpidBase &AliHFEpidBase::operator=(const AliHFEpidBase &ref){
60   //
61   // Assignment operator
62   //
63   if(this != &ref){
64     ref.Copy(*this);
65   }
66
67   return *this;
68 }
69
70 //___________________________________________________________________
71 void AliHFEpidBase::Copy(TObject &ref) const {
72   AliHFEpidBase &target = dynamic_cast<AliHFEpidBase &>(ref);
73
74   target.fMCEvent = fMCEvent;
75   target.fDebugLevel = fDebugLevel;
76
77   TNamed::Copy(ref);
78 }
79
80 //___________________________________________________________________
81 Int_t AliHFEpidBase::GetPdgCode(AliVParticle *track){
82   //
83   // returns the MC PDG code of the particle species
84   //
85   if(!fMCEvent) return 0;
86   AliMCParticle *mctrack = 0x0;
87   if(TString(track->IsA()->GetName()).CompareTo("AliESDtrack") == 0)
88     mctrack = fMCEvent->GetTrack(TMath::Abs((dynamic_cast<AliESDtrack *>(track))->GetLabel()));
89   else if(TString(track->IsA()->GetName()).CompareTo("AliMCParticle") == 0)
90     mctrack = dynamic_cast<AliMCParticle *>(track);
91   if(!mctrack) return 0;
92   return mctrack->Particle()->GetPdgCode();
93 }