ATLAS Offline Software
LArHitContainer.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include <typeinfo>
7 #include <stdio.h>
8 
9 #include <iostream>
10 
11 LArHitContainer::LArHitContainer(const std::string& collectionName)
12 : AthenaHitsVector<LArHit>(collectionName)
13 {
14 
15 }
16 
18 {
19 
20 }
21 
22 LArHitContainer::operator std::string () const {
23 
24  char * stCounter = new char[48] ;
25  char * nameOfContainer = new char[48] ;
26 
27  const char * stname = typeid( *this ).name() ;
28  int lname ;
29  sscanf( stname , "%80d%47s" , &lname , nameOfContainer ) ;
30 
31  std::string newline( "\n" ) ;
32  std::string hitContainerString = nameOfContainer ;
33  hitContainerString += ": content " ;
34  hitContainerString += newline ;
35 
36  int counter = 0 ;
37 
38  for (const LArHit* hit : *this) { // Loop over Hits
39  sprintf( stCounter , "%d" , counter ) ;
40 
41  hitContainerString += "LArHit[" ;
42  hitContainerString += stCounter ;
43  hitContainerString += "] " ;
44 
45  sprintf( stCounter , " ID = %x ; " ,hit->cellID().get_identifier32().get_compact() ) ;
46  hitContainerString += stCounter ;
47 
48  sprintf( stCounter , " E= %f MeV ; " , hit->energy() ) ;
49  hitContainerString += stCounter ;
50  sprintf( stCounter , " t= %f ns ; " , hit->time() ) ;
51  hitContainerString += stCounter ;
52 
53 // hitContainerString += (std::string) (*hit) ;
54  hitContainerString += newline ;
55 
56  counter ++ ;
57 
58  }
59 
60  sprintf( stCounter , "%d" , counter ) ;
61  hitContainerString += newline ;
62  hitContainerString += "Number of Hits in this container : " ;
63  hitContainerString += stCounter ;
64 
65 
66  delete[] stCounter ;
67  delete[] nameOfContainer ;
68 
69  return hitContainerString ;
70 
71 }
LArHitContainer::~LArHitContainer
virtual ~LArHitContainer()
Definition: LArHitContainer.cxx:17
LArHit::energy
double energy() const
Definition: LArHit.h:113
Identifier32::get_compact
value_type get_compact(void) const
Get the compact id.
Definition: Identifier32.h:171
LArHit::time
double time() const
Definition: LArHit.h:118
LArHit::cellID
Identifier cellID() const
Definition: LArHit.h:108
LArHit
Class to store hit energy and time in LAr cell from G4 simulation.
Definition: LArHit.h:25
LArHitContainer.h
AthenaHitsVector
Definition: AthenaHitsVector.h:39
Identifier::get_identifier32
Identifier32 get_identifier32(void) const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
test_pyathena.counter
counter
Definition: test_pyathena.py:15
calibdata.newline
newline
Definition: calibdata.py:526
LArHitContainer::LArHitContainer
LArHitContainer(const std::string &collectionName="DefaultCollectionName")
Definition: LArHitContainer.cxx:11