ATLAS Offline Software
Loading...
Searching...
No Matches
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
11LArHitContainer::LArHitContainer(const std::string& collectionName)
12: AthenaHitsVector<LArHit>(collectionName)
13{
14
15}
16
17LArHitContainer::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}
AthenaHitsVector(const std::string &collectionName="DefaultCollectionName", AthHitVec::OwnershipPolicy ownPolicy=AthHitVec::OWN_ELEMENTS)
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
LArHitContainer(const std::string &collectionName="DefaultCollectionName")
Class to store hit energy and time in LAr cell from G4 simulation.
Definition LArHit.h:25
double energy() const
Definition LArHit.h:113
Identifier cellID() const
Definition LArHit.h:108
double time() const
Definition LArHit.h:118