CbmRoot
NicaCbmMCEvent.cxx
Go to the documentation of this file.
1 /*
2  * NicaCbmMCEvent.cxx
3  *
4  * Created on: 20 wrz 2018
5  * Author: Daniel Wielanek
6  * E-mail: daniel.wielanek@gmail.com
7  * Warsaw University of Technology, Faculty of Physics
8  */
9 #include "NicaCbmMCEvent.h"
10 #include "CbmMCTrack.h"
11 #include "FairRootManager.h"
13 #include "NicaCbmMCTrack.h"
14 
15 NicaCbmMCEvent::NicaCbmMCEvent() : NicaMCEvent("NicaCbmMCTrack") {
16  fSource = new NicaCbmMCEventInterface();
17 }
18 
20  // TODO Auto-generated destructor stub
21 }
22 
24 
26  FairMCEventHeader* event =
27  (FairMCEventHeader*) ((NicaCbmMCEventInterface*) fSource)->fEvent;
28  TClonesArray* tracks =
29  (TClonesArray*) ((NicaCbmMCEventInterface*) fSource)->fCbmTracks;
30  fB = event->GetB();
31  fVertex->SetXYZT(event->GetX(), event->GetY(), event->GetZ(), event->GetT());
32  fTracks->Clear();
33  fTotalTracksNo = tracks->GetEntriesFast();
34  fTracks->ExpandCreateFast(fTotalTracksNo);
35  for (int i = 0; i < tracks->GetEntriesFast(); i++) {
36  CbmMCTrack* track = (CbmMCTrack*) tracks->UncheckedAt(i);
37  Double_t charge = CalculateCharge(track->GetPdgCode());
38  NicaCbmMCTrack* mc = (NicaCbmMCTrack*) fTracks->UncheckedAt(i);
39  mc->SetEvent(this);
40  mc->Update(track, charge);
41  mc->GetLink()->Clear();
42  mc->GetLink()->SetLink(0, i);
43  }
44 }
45 
47  : NicaMCEvent(other) {}
48 
50  FairRootManager* manager = FairRootManager::Instance();
51  Int_t header = manager->CheckBranch("MCEventHeader.")
52  + manager->CheckBranch("EventHeader.");
53  Int_t tracks = manager->CheckBranch("MCTrack");
54  if ((header + tracks) >= 2) { return kTRUE; }
55  return kFALSE;
56 }
NicaCbmMCTrack
Definition: NicaCbmMCTrack.h:15
NicaCbmMCEvent
Definition: NicaCbmMCEvent.h:13
CbmMCTrack::GetPdgCode
Int_t GetPdgCode() const
Definition: CbmMCTrack.h:70
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
NicaCbmMCEvent::ExistInTree
virtual Bool_t ExistInTree() const
Definition: NicaCbmMCEvent.cxx:49
NicaCbmMCEvent::NicaCbmMCEvent
NicaCbmMCEvent()
Definition: NicaCbmMCEvent.cxx:15
NicaCbmMCEvent::~NicaCbmMCEvent
virtual ~NicaCbmMCEvent()
Definition: NicaCbmMCEvent.cxx:19
tracks
TClonesArray * tracks
Definition: Analyze_matching.h:17
NicaCbmMCEventInterface.h
NicaCbmMCTrack.h
NicaCbmMCEvent.h
NicaCbmMCEvent::Update
virtual void Update()
Definition: NicaCbmMCEvent.cxx:25
CbmMCTrack.h
NicaCbmMCEvent::CreateSource
virtual void CreateSource()
Definition: NicaCbmMCEvent.cxx:23
CbmMCTrack
Definition: CbmMCTrack.h:34
NicaCbmMCEventInterface
Definition: NicaCbmMCEventInterface.h:17
NicaCbmMCTrack::Update
virtual void Update(CbmMCTrack *mc, Double_t charge)
Definition: NicaCbmMCTrack.cxx:15