Project
Loading...
Searching...
No Matches
MCTrack.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#define BOOST_TEST_MODULE Test MCTrack class
13#define BOOST_TEST_MAIN
14#define BOOST_TEST_DYN_LINK
15#include <boost/test/unit_test.hpp>
18#include "TFile.h"
19#include "TParticle.h"
20#include "TMCProcess.h"
21
22using namespace o2;
23
25{
26 MCTrack track;
27
28 // auxiliary lookup table needed to fetch and set hit properties
29 std::vector<int> hitLUT(o2::detectors::DetID::nDetectors, -1);
30 // in this test we have a single fictional detector 1, which we map to
31 // the first bit
32 hitLUT[1] = 0;
33
34 // check properties on default constructed object
35 BOOST_CHECK(track.getStore() == false);
37 BOOST_CHECK(track.leftTrace(i, hitLUT) == false);
38 }
39 BOOST_CHECK(track.getNumDet() == 0);
40 BOOST_CHECK(track.hasHits() == false);
41
42 // check storing
43 track.setStore(true);
44 BOOST_CHECK(track.getStore() == true);
45 track.setStore(false);
46 BOOST_CHECK(track.getStore() == false);
47 track.setStore(true);
48 BOOST_CHECK(track.getStore() == true);
49
50 // set hit for first detector
51 BOOST_CHECK(track.leftTrace(1, hitLUT) == false);
52 track.setHit(hitLUT[1]);
53 BOOST_CHECK(track.hasHits() == true);
54 BOOST_CHECK(track.leftTrace(1, hitLUT) == true);
55 BOOST_CHECK(track.getNumDet() == 1);
56
57 // check process encoding
58 track.setProcess(TMCProcess::kPPrimary);
59 BOOST_CHECK(track.getProcess() == TMCProcess::kPPrimary);
60 track.setProcess(TMCProcess::kPTransportation);
61 BOOST_CHECK(track.getProcess() == TMCProcess::kPTransportation);
62
63 {
64 // serialize it
65 TFile f("MCTrackOut.root", "RECREATE");
66 f.WriteObject(&track, "MCTrack");
67 f.Close();
68 }
69
70 {
71 MCTrack* intrack = nullptr;
72 TFile f("MCTrackOut.root", "OPEN");
73 f.GetObject("MCTrack", intrack);
74 BOOST_CHECK(intrack->getStore() == true);
75 BOOST_CHECK(intrack->hasHits() == true);
76 }
77}
int32_t i
Definition of the MCTrack class.
int getProcess() const
get the production process (id) of this track
Definition MCTrack.h:230
bool leftTrace(Int_t iDet, std::vector< int > const &detIDtoBit) const
Definition MCTrack.h:189
int getNumDet() const
Definition MCTrack.h:199
void setStore(bool f)
Definition MCTrack.h:212
void setHit(Int_t iDetBit)
Definition MCTrack.h:174
bool getStore() const
Definition MCTrack.h:218
bool hasHits() const
determine if this track has hits
Definition MCTrack.h:220
void setProcess(int proc)
set process property
Definition MCTrack.h:222
static constexpr ID First
Definition DetID.h:94
static constexpr int nDetectors
number of defined detectors
Definition DetID.h:96
GLdouble f
Definition glcorearb.h:310
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
BOOST_AUTO_TEST_CASE(FlatHisto)
BOOST_CHECK(tree)