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 
17 LArHitContainer::operator std::string () const {
18 
19  char * stCounter = new char[48] ;
20  char * nameOfContainer = new char[48] ;
21 
22  const char * stname = typeid( *this ).name() ;
23  int lname ;
24  sscanf( stname , "%80d%47s" , &lname , nameOfContainer ) ;
25 
26  std::string newline( "\n" ) ;
27  std::string hitContainerString = nameOfContainer ;
28  hitContainerString += ": content " ;
29  hitContainerString += newline ;
30 
31  int counter = 0 ;
32 
33  for (const LArHit* hit : *this) { // Loop over Hits
34  sprintf( stCounter , "%d" , counter ) ;
35 
36  hitContainerString += "LArHit[" ;
37  hitContainerString += stCounter ;
38  hitContainerString += "] " ;
39 
40  sprintf( stCounter , " ID = %x ; " ,hit->cellID().get_identifier32().get_compact() ) ;
41  hitContainerString += stCounter ;
42 
43  sprintf( stCounter , " E= %f MeV ; " , hit->energy() ) ;
44  hitContainerString += stCounter ;
45  sprintf( stCounter , " t= %f ns ; " , hit->time() ) ;
46  hitContainerString += stCounter ;
47 
48 // hitContainerString += (std::string) (*hit) ;
49  hitContainerString += newline ;
50 
51  counter ++ ;
52 
53  }
54 
55  sprintf( stCounter , "%d" , counter ) ;
56  hitContainerString += newline ;
57  hitContainerString += "Number of Hits in this container : " ;
58  hitContainerString += stCounter ;
59 
60 
61  delete[] stCounter ;
62  delete[] nameOfContainer ;
63 
64  return hitContainerString ;
65 
66 }
Identifier::get_identifier32
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
LArHit::energy
double energy() const
Definition: LArHit.h:113
Identifier32::get_compact
value_type get_compact() const
Get the compact id.
Definition: Identifier32.h:44
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:48
test_pyathena.counter
counter
Definition: test_pyathena.py:15
calibdata.newline
newline
Definition: calibdata.py:525
LArHitContainer::LArHitContainer
LArHitContainer(const std::string &collectionName="DefaultCollectionName")
Definition: LArHitContainer.cxx:11