ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
FPGATrackSimReadRawRandomHitsTool Class Reference

#include <FPGATrackSimReadRawRandomHitsTool.h>

Inheritance diagram for FPGATrackSimReadRawRandomHitsTool:
Collaboration diagram for FPGATrackSimReadRawRandomHitsTool:

Public Member Functions

 FPGATrackSimReadRawRandomHitsTool (const std::string &, const std::string &, const IInterface *)
 
virtual ~FPGATrackSimReadRawRandomHitsTool ()=default
 
virtual StatusCode initialize () override
 
virtual StatusCode readData (FPGATrackSimEventInputHeader *header, bool &last) override
 
virtual StatusCode writeData (FPGATrackSimEventInputHeader *header) override
 
virtual StatusCode finalize () override
 
StatusCode readData (FPGATrackSimEventInputHeader *header, bool &last, bool doReset)
 
 FPGATrackSimReadRawRandomHitsTool (const std::string &, const std::string &, const IInterface *)
 
virtual ~FPGATrackSimReadRawRandomHitsTool ()=default
 
virtual StatusCode initialize () override
 
virtual StatusCode readData (FPGATrackSimEventInputHeader *header, bool &last) override
 
virtual StatusCode writeData (FPGATrackSimEventInputHeader *header) override
 
virtual StatusCode finalize () override
 
StatusCode readData (FPGATrackSimEventInputHeader *header, bool &last, bool doReset)
 

Private Attributes

StringProperty m_inpath {this, "InFileName", "httsim_smartwrapper.root", "input path"}
 
unsigned m_entry = 0
 
unsigned int m_nEntries = 0U
 

Detailed Description

Definition at line 16 of file FPGATrackSimInput/FPGATrackSimReadRawRandomHitsTool.h.

Constructor & Destructor Documentation

◆ FPGATrackSimReadRawRandomHitsTool() [1/2]

FPGATrackSimReadRawRandomHitsTool::FPGATrackSimReadRawRandomHitsTool ( const std::string &  algname,
const std::string &  name,
const IInterface *  ifc 
)

Definition at line 9 of file FPGATrackSimReadRawRandomHitsTool.cxx.

9  :
10  base_class(algname,name,ifc) {}

◆ ~FPGATrackSimReadRawRandomHitsTool() [1/2]

virtual FPGATrackSimReadRawRandomHitsTool::~FPGATrackSimReadRawRandomHitsTool ( )
virtualdefault

◆ FPGATrackSimReadRawRandomHitsTool() [2/2]

FPGATrackSimReadRawRandomHitsTool::FPGATrackSimReadRawRandomHitsTool ( const std::string &  ,
const std::string &  ,
const IInterface *   
)

◆ ~FPGATrackSimReadRawRandomHitsTool() [2/2]

virtual FPGATrackSimReadRawRandomHitsTool::~FPGATrackSimReadRawRandomHitsTool ( )
virtualdefault

Member Function Documentation

◆ finalize() [1/2]

StatusCode FPGATrackSimReadRawRandomHitsTool::finalize ( )
overridevirtual

Definition at line 120 of file FPGATrackSimReadRawRandomHitsTool.cxx.

120  {
121  delete m_eventHeader;
122  return StatusCode::SUCCESS;
123 }

◆ finalize() [2/2]

virtual StatusCode FPGATrackSimReadRawRandomHitsTool::finalize ( )
overridevirtual

◆ initialize() [1/2]

StatusCode FPGATrackSimReadRawRandomHitsTool::initialize ( )
overridevirtual

Definition at line 14 of file FPGATrackSimReadRawRandomHitsTool.cxx.

14  {
15 
16  // open input file
17  ATH_MSG_INFO ( "Opening input file: " << m_inpath.value() );
18  m_infile = TFile::Open(m_inpath.value().c_str(),"READ");
19  if (m_infile == nullptr){
20  ATH_MSG_FATAL ("Could not open input file: " << m_inpath.value() );
21  return StatusCode::FAILURE;
22  }
23 
24  //get the tree, try old and new versions for backwards compatability
25  m_EventTree = (TTree*) m_infile->Get("FPGATrackSimEventTree");
26  if (m_EventTree == nullptr || m_EventTree->GetEntries() == -1 ){
27  ATH_MSG_FATAL ("Input file: " << m_inpath << " has no entries");
28  return StatusCode::FAILURE;
29  }
30 
31  std::string branchName="FPGATrackSimEventInputHeader";
32  if(!m_EventTree->GetListOfBranches()->FindObject(branchName.c_str())){
33  ATH_MSG_FATAL ("Branch: " << branchName << " not found!");
34  return StatusCode::FAILURE;
35  }
36  ATH_MSG_INFO ( "Getting branch and set EventHeader" );
37  TBranch *branch = m_EventTree->GetBranch(branchName.c_str());
38  branch->Print();
39 
40  m_eventHeader = new FPGATrackSimEventInputHeader();
41  branch->SetAddress(&m_eventHeader);
42 
43  return StatusCode::SUCCESS;
44 }

◆ initialize() [2/2]

virtual StatusCode FPGATrackSimReadRawRandomHitsTool::initialize ( )
overridevirtual

◆ readData() [1/4]

StatusCode FPGATrackSimReadRawRandomHitsTool::readData ( FPGATrackSimEventInputHeader header,
bool &  last 
)
overridevirtual

Definition at line 48 of file FPGATrackSimReadRawRandomHitsTool.cxx.

49 {
50  return readData(header, last, false); // by default with this tool don't reset data
51 }

◆ readData() [2/4]

virtual StatusCode FPGATrackSimReadRawRandomHitsTool::readData ( FPGATrackSimEventInputHeader header,
bool &  last 
)
overridevirtual

◆ readData() [3/4]

StatusCode FPGATrackSimReadRawRandomHitsTool::readData ( FPGATrackSimEventInputHeader header,
bool &  last,
bool  doReset 
)

Definition at line 53 of file FPGATrackSimReadRawRandomHitsTool.cxx.

54 {
55 
56  last = false;
57  //unsigned entry = static_cast<unsigned>(CLHEP::RandFlat::shoot() * m_nEntries);
58  m_EventTree->GetEntry(m_entry++);
59 
60  // Truth Info
62  unsigned long int mbc = 0; // to scale up barcodes!
63 
64  // --- Copy old data
65  if (doReset)
66  {
67  header->reset(); //reset things!
68  }
69  else // not resetting, start by copying over truth information from old header
70  {
71  for (const auto& truthtrack : header->optional().getTruthTracks())
72  {
73  if (truthtrack.getBarcode() > mbc) mbc = truthtrack.getBarcode();
74  optional.addTruthTrack(truthtrack);
75  }
76 
77  // now we got the max bar code, copy the offline tracks
78  for (const auto& offlinetrack : header->optional().getOfflineTracks())
79  {
80  optional.addOfflineTrack(offlinetrack);
81  }
82  }
83 
84  // --- Copy new data
85  for (auto truthtrack : m_eventHeader->optional().getTruthTracks())
86  {
87  truthtrack.setBarcode(truthtrack.getBarcode() + mbc);
88  optional.addTruthTrack(truthtrack);
89  }
90  for (auto offlinetrack : m_eventHeader->optional().getOfflineTracks())
91  {
92  offlinetrack.setBarcode(offlinetrack.getBarcode() + mbc);
93  optional.addOfflineTrack(offlinetrack);
94  }
95 
96  header->setOptional(optional);
97 
98  // copy Hits
99  for (auto rawhit : m_eventHeader->hits())
100  {
101  FPGATrackSimMultiTruth origtruth = rawhit.getTruth();
103  FPGATrackSimMultiTruth::Barcode uniquecode(rawhit.getEventIndex(),rawhit.getBarcode()+mbc);
104  mt.maximize(uniquecode, rawhit.getBarcodePt());
105  rawhit.setBarcode(rawhit.getBarcode() + mbc);
106  rawhit.setTruth(mt);
107  header->addHit(rawhit);
108  }
109 
110  return StatusCode::SUCCESS;
111 }

◆ readData() [4/4]

StatusCode FPGATrackSimReadRawRandomHitsTool::readData ( FPGATrackSimEventInputHeader header,
bool &  last,
bool  doReset 
)

◆ writeData() [1/2]

StatusCode FPGATrackSimReadRawRandomHitsTool::writeData ( FPGATrackSimEventInputHeader header)
overridevirtual

Definition at line 114 of file FPGATrackSimReadRawRandomHitsTool.cxx.

114  {
115  ATH_MSG_FATAL("This tool is being forced to write things. But it is only designed to read things. Don't worry, everything is fine");
116  return StatusCode::FAILURE;// this tool is not designed to write things
117 }

◆ writeData() [2/2]

virtual StatusCode FPGATrackSimReadRawRandomHitsTool::writeData ( FPGATrackSimEventInputHeader header)
overridevirtual

Member Data Documentation

◆ m_entry

unsigned FPGATrackSimReadRawRandomHitsTool::m_entry = 0
private

◆ m_inpath

StringProperty FPGATrackSimReadRawRandomHitsTool::m_inpath {this, "InFileName", "httsim_smartwrapper.root", "input path"}
private

◆ m_nEntries

unsigned int FPGATrackSimReadRawRandomHitsTool::m_nEntries = 0U
private

Definition at line 34 of file src/FPGATrackSimReadRawRandomHitsTool.h.


The documentation for this class was generated from the following files:
getMenu.algname
algname
Definition: getMenu.py:54
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
header
Definition: hcg.cxx:526
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
FPGATrackSimReadRawRandomHitsTool::m_entry
unsigned m_entry
Definition: FPGATrackSimInput/FPGATrackSimReadRawRandomHitsTool.h:34
FPGATrackSimReadRawRandomHitsTool::readData
virtual StatusCode readData(FPGATrackSimEventInputHeader *header, bool &last) override
Definition: FPGATrackSimReadRawRandomHitsTool.cxx:48
FPGATrackSimMultiTruth::Barcode
std::pair< unsigned long, unsigned long > Barcode
Definition: FPGATrackSimMultiTruth.h:49
FPGATrackSimOptionalEventInfo::addOfflineTrack
void addOfflineTrack(const FPGATrackSimOfflineTrack &t)
Definition: FPGATrackSimOptionalEventInfo.h:34
FPGATrackSimEventInputHeader
Definition: FPGATrackSimEventInputHeader.h:22
FPGATrackSimOptionalEventInfo
Definition: FPGATrackSimOptionalEventInfo.h:17
FPGATrackSimMultiTruth::maximize
void maximize(const FPGATrackSimMultiTruth::Barcode &code, const FPGATrackSimMultiTruth::Weight &weight)
Definition: FPGATrackSimMultiTruth.cxx:36
FPGATrackSimMultiTruth
Definition: FPGATrackSimMultiTruth.h:46
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
FPGATrackSimReadRawRandomHitsTool::m_inpath
StringProperty m_inpath
Definition: FPGATrackSimInput/FPGATrackSimReadRawRandomHitsTool.h:31
FPGATrackSimOptionalEventInfo::addTruthTrack
void addTruthTrack(const FPGATrackSimTruthTrack &t)
Definition: FPGATrackSimOptionalEventInfo.h:39
RTTAlgmain.branch
branch
Definition: RTTAlgmain.py:61