From 70c6ebcbcb87663ab9ceb4be13ca2cf45c82edc9 Mon Sep 17 00:00:00 2001
From: Scott Snyder <scott.snyder@cern.ch>
Date: Wed, 4 Jul 2012 14:31:03 +0200
Subject: [PATCH] checkreq fix (LArSimEvent-01-04-04)

---
 .../LArSimEvent/LArSimEvent/LArHit.h          | 150 ++++++++++++++++++
 .../LArSimEvent/LArSimEvent/LArHitContainer.h |  74 +++++++++
 .../LArSimEvent/LArSimEvent/LArHitFloat.h     |  99 ++++++++++++
 .../LArSimEvent/LArHitFloatContainer.h        |  34 ++++
 .../LArSimEvent/LArSimEvent/LArSimEventDict.h |  21 +++
 .../LArSimEvent/LArSimEvent/selection.xml     |   9 ++
 LArCalorimeter/LArSimEvent/cmt/requirements   |  25 +++
 LArCalorimeter/LArSimEvent/doc/mainpage.h     |  18 +++
 .../LArSimEvent/src/LArHitContainer.cxx       |  76 +++++++++
 .../LArSimEvent/src/LArHitFloatContainer.cxx  |   5 +
 10 files changed, 511 insertions(+)
 create mode 100755 LArCalorimeter/LArSimEvent/LArSimEvent/LArHit.h
 create mode 100755 LArCalorimeter/LArSimEvent/LArSimEvent/LArHitContainer.h
 create mode 100755 LArCalorimeter/LArSimEvent/LArSimEvent/LArHitFloat.h
 create mode 100644 LArCalorimeter/LArSimEvent/LArSimEvent/LArHitFloatContainer.h
 create mode 100755 LArCalorimeter/LArSimEvent/LArSimEvent/LArSimEventDict.h
 create mode 100755 LArCalorimeter/LArSimEvent/LArSimEvent/selection.xml
 create mode 100755 LArCalorimeter/LArSimEvent/cmt/requirements
 create mode 100755 LArCalorimeter/LArSimEvent/doc/mainpage.h
 create mode 100755 LArCalorimeter/LArSimEvent/src/LArHitContainer.cxx
 create mode 100644 LArCalorimeter/LArSimEvent/src/LArHitFloatContainer.cxx

diff --git a/LArCalorimeter/LArSimEvent/LArSimEvent/LArHit.h b/LArCalorimeter/LArSimEvent/LArSimEvent/LArHit.h
new file mode 100755
index 00000000000..bc34e4b5b23
--- /dev/null
+++ b/LArCalorimeter/LArSimEvent/LArSimEvent/LArHit.h
@@ -0,0 +1,150 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+/* author : Johann Collot                                                           */
+/* date of creation : 07/01/2001                                                    */
+/* date of last modification : 13/09/2002  CLID removed                             */
+
+// 03-Dec-2003 Bill Seligman: Substantially revised.  This class no
+// longer inherits from any base class.  
+
+// 09-Dec-2006 RD Schaffer: moved energy to double for accumulation
+// precision - float in persistent version
+
+#ifndef LArSimEvent_LArHit_h
+#define LArSimEvent_LArHit_h
+
+#include "Identifier/Identifier.h"
+#include "CLHEP/Units/SystemOfUnits.h"
+
+class LArHit 
+
+/** @brief  Class to store hit energy and time in LAr cell from G4 simulation */
+
+{
+public:
+
+    /** LArHit Constructor. 
+      @param[in] l_cell   Identifier of the cell in which the hit occured.
+      @param[in] l_energy Energy (in MeV) deposited in the cell.
+      @param[in] l_time   Time   (in ns) of the hit. <br>
+     energy and time should be double in transient memory to have proper rounding accuracy in accumulating sum(E) and sum(E.t) from G4 steps
+     */
+    LArHit(Identifier l_cell, double l_energy, double l_time);
+
+    /** Default constructor for persistency.
+       Should never be used
+    */
+    LArHit();
+
+    /** Destructor. */
+    ~LArHit();
+  
+    /** @return  cell identifier of this hit */
+    Identifier cellID() const;
+  
+    /** @return  energy in MeV of this hit */
+    double     energy() const;
+  
+    /** @return time in ns of this hit <br>
+      Time is defined as the g4 time minus the time of flight at speed of light from the center of Atlas
+    */
+    double     time() const;
+
+    /** Operator Less than this for hit ordering */
+    bool       Less(LArHit* const& h) const;
+
+    /** Operator Equals this */
+    bool       Equals(LArHit* const& h) const;
+
+    /** Add another hit ot this hit
+     @param[in] h  hit to add */
+    void       Add(LArHit* const& h);
+
+    /** The method to be called at the end of event by SD.
+         Finalize time computation time = Sum(E.t)/Sum(E)  */
+    void       finalize();
+    
+
+private:
+  
+    /** identifier of the cell in which this hit occured. */
+    Identifier m_ID;
+  
+    /** energy (in MeV) deposited in this hit */
+    double m_energy;
+  
+    /** time (in ns) */
+    double m_time;
+
+};
+
+
+/// inlines
+inline
+LArHit::LArHit(Identifier l_cell, double l_energy, double l_time) 
+	:
+	m_ID(l_cell), 
+	m_energy(l_energy),
+        m_time( (l_time*l_energy) )
+{}
+
+
+inline
+LArHit::LArHit() 
+	:
+	m_ID(Identifier()),
+	m_energy(0.),
+        m_time(0.)
+{}
+
+inline
+LArHit::~LArHit() 
+{ }
+
+inline
+Identifier
+LArHit::cellID() const 
+{ return m_ID; }
+
+inline
+double
+LArHit::energy() const 
+{ return (double) m_energy; }
+  
+inline
+double
+LArHit::time() const
+{ return m_time; }
+
+inline 
+bool
+LArHit::Less(LArHit* const& h) const 
+{ return m_ID < h->m_ID; } 
+
+inline
+bool
+LArHit::Equals(LArHit* const& h) const 
+{ return m_ID == h->m_ID; }
+
+inline
+void
+LArHit::Add(LArHit* const& h)
+{
+    m_energy += h->m_energy;
+    m_time   += h->m_time;
+}
+
+// The method to be called at the end of event by SD
+// For backwards compatibility
+inline
+void
+LArHit::finalize()
+{
+  m_time = m_energy==0 ? 0. : (double)(m_time/m_energy)/CLHEP::ns;
+  m_energy = m_energy/CLHEP::MeV;
+}
+
+#endif  // LArSimEvent_LArHit_h
+
diff --git a/LArCalorimeter/LArSimEvent/LArSimEvent/LArHitContainer.h b/LArCalorimeter/LArSimEvent/LArSimEvent/LArHitContainer.h
new file mode 100755
index 00000000000..2de7ebdb239
--- /dev/null
+++ b/LArCalorimeter/LArSimEvent/LArSimEvent/LArHitContainer.h
@@ -0,0 +1,74 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+// LArHitContainer
+
+// This class exists to provides two features that an
+// AthenaHitsVector<LArHit> does not provide on its own:
+
+// - a CLID for StoreGate
+
+// - a std::string method that can be used to examine the contents of
+// the container.
+
+#ifndef LArSimEvent_LArHitContainer_h
+#define LArSimEvent_LArHitContainer_h
+
+#include "HitManagement/AthenaHitsVector.h"
+#include "LArSimEvent/LArHit.h"
+
+#include "CLIDSvc/CLASS_DEF.h"
+
+class LArHitContainer:public AthenaHitsVector<LArHit>
+
+/** @brief Hit collection */
+{
+public: 
+
+  LArHitContainer (std::string collectionName="DefaultCollectionName" ); 
+
+  virtual ~LArHitContainer()  ; 
+
+    /**
+     * Returns a string containing the description of this <br>
+     * LArHitContainer with a dump of all the hits
+     * that it contains<br>
+     * <p>
+     *
+     * Can be used in printouts <br>
+     */
+    virtual operator std::string () const ;
+
+};
+
+CLASS_DEF (LArHitContainer, 2701 , 1 ) 
+
+class StoredLArHitContainers
+
+/** @brief store pointers to the different hit collections */
+{
+ public:
+  StoredLArHitContainers():
+    embHitCollection(0),
+    emecHitCollection(0),
+    fcalHitCollection(0),
+    hecHitCollection(0),
+    miniFcalHitCollection(0)
+    {}
+
+  /** pointer to EM barrel hit collection */
+  LArHitContainer* embHitCollection;
+  /** pointer to EMEC hit collection */
+  LArHitContainer* emecHitCollection;
+  /** pointer to FCAL hit collection */
+  LArHitContainer* fcalHitCollection;
+  /** pointer to HEC hit collection */
+  LArHitContainer* hecHitCollection;
+  /** pointer to Mini FCAL hit collection */
+  LArHitContainer* miniFcalHitCollection;
+};
+
+CLASS_DEF( StoredLArHitContainers , 1265102271 , 1 )
+
+#endif     // LArSimEvent_LArHitContainer_h
diff --git a/LArCalorimeter/LArSimEvent/LArSimEvent/LArHitFloat.h b/LArCalorimeter/LArSimEvent/LArSimEvent/LArHitFloat.h
new file mode 100755
index 00000000000..551e91ad06d
--- /dev/null
+++ b/LArCalorimeter/LArSimEvent/LArSimEvent/LArHitFloat.h
@@ -0,0 +1,99 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+// 12-march-2006 G.Unal:  alternative LArHit object with float energy and time
+//  to be used in digitization /pileup to optimize memory usage
+
+#ifndef LArSimEvent_LArHitFloat_h
+#define LArSimEvent_LArHitFloat_h
+
+#include "Identifier/Identifier.h"
+#include "CLHEP/Units/SystemOfUnits.h"
+
+class LArHitFloat
+
+/** @brief  Class to store hit energy and time in LAr cell from G4 simulation */
+
+{
+public:
+
+    /** LArHitFloat Constructor. 
+      @param[in] l_cell   Identifier of the cell in which the hit occured.
+      @param[in] l_energy Energy (in MeV) deposited in the cell.
+      @param[in] l_time   Time   (in ns) of the hit. <br>
+     energy and time should be double in transient memory to have proper rounding accuracy in accumulating sum(E) and sum(E.t) from G4 steps
+     */
+    LArHitFloat(Identifier l_cell, float l_energy, float l_time);
+
+    /** Default constructor for persistency.
+       Should never be used
+    */
+    LArHitFloat();
+
+    /** Destructor. */
+    ~LArHitFloat();
+  
+    /** @return  cell identifier of this hit */
+    Identifier cellID() const;
+  
+    /** @return  energy in MeV of this hit */
+    float     energy() const;
+  
+    /** @return time in ns of this hit <br>
+      Time is defined as the g4 time minus the time of flight at speed of light from the center of Atlas
+    */
+    float     time() const;
+
+private:
+  
+    /** identifier of the cell in which this hit occured. */
+    Identifier m_ID;
+  
+    /** energy (in MeV) deposited in this hit */
+    float m_energy;
+  
+    /** time (in ns) */
+    float m_time;
+
+};
+
+
+/// inlines
+inline
+LArHitFloat::LArHitFloat(Identifier l_cell, float l_energy, float l_time) 
+	:
+	m_ID(l_cell), 
+	m_energy(l_energy),
+        m_time(l_time )
+{}
+
+
+inline
+LArHitFloat::LArHitFloat() 
+	:
+	m_ID(Identifier()),
+	m_energy(0.),
+        m_time(0.)
+{}
+
+inline
+LArHitFloat::~LArHitFloat() 
+{ }
+
+inline
+Identifier
+LArHitFloat::cellID() const 
+{ return m_ID; }
+
+inline
+float
+LArHitFloat::energy() const 
+{ return m_energy; }
+  
+inline
+float
+LArHitFloat::time() const
+{ return m_time; }
+
+#endif  // LArSimEvent_LArHitFloat_h
diff --git a/LArCalorimeter/LArSimEvent/LArSimEvent/LArHitFloatContainer.h b/LArCalorimeter/LArSimEvent/LArSimEvent/LArHitFloatContainer.h
new file mode 100644
index 00000000000..0d2e03a3fa2
--- /dev/null
+++ b/LArCalorimeter/LArSimEvent/LArSimEvent/LArHitFloatContainer.h
@@ -0,0 +1,34 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+#ifndef LArSimEvent_LArHitFloatContainer_h
+#define LArSimEvent_LArHitFloatContainer_h
+
+#include "LArSimEvent/LArHitFloat.h"
+#include "CLIDSvc/CLASS_DEF.h" 
+#include <vector>
+
+/**
+@class LArHitFloatContainer
+@brief Container for LArHitFloat
+*/
+
+class LArHitFloatContainer: public std::vector<LArHitFloat>
+{
+
+ public:
+  /** constructor */
+  LArHitFloatContainer() {};
+
+   /** desctructor */
+  virtual ~LArHitFloatContainer() {};
+
+  inline void add (const LArHitFloat& hit)
+     {this->push_back(hit);}
+
+};
+
+CLASS_DEF(LArHitFloatContainer,1247689295,0)
+
+#endif
diff --git a/LArCalorimeter/LArSimEvent/LArSimEvent/LArSimEventDict.h b/LArCalorimeter/LArSimEvent/LArSimEvent/LArSimEventDict.h
new file mode 100755
index 00000000000..157d1bfa57d
--- /dev/null
+++ b/LArCalorimeter/LArSimEvent/LArSimEvent/LArSimEventDict.h
@@ -0,0 +1,21 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+#ifndef LARSIMEVENT_LARSIMEVENT_H
+#define LARSIMEVENT_LARSIMEVENT_H
+
+#include "LArSimEvent/LArHit.h"
+#include "LArSimEvent/LArHitContainer.h"
+#include "StoreGate/StoreGateSvc.h" 
+
+namespace LArSimEvent
+{
+  struct tmp
+  {
+    PyGate<LArHitContainer>     m_ip;
+    LArHitContainer::const_iterator   m_it_ip;
+  };
+}
+
+#endif
diff --git a/LArCalorimeter/LArSimEvent/LArSimEvent/selection.xml b/LArCalorimeter/LArSimEvent/LArSimEvent/selection.xml
new file mode 100755
index 00000000000..da01189848f
--- /dev/null
+++ b/LArCalorimeter/LArSimEvent/LArSimEvent/selection.xml
@@ -0,0 +1,9 @@
+<lcgdict>
+  <class name="PyGate<LArHitContainer>" />
+  <class pattern="*iterator<LArHit*>" />
+
+  <class name="LArHit" />
+  <class name="std::vector<LArHit*>" />
+  <class name="AthenaHitsVector<LArHit>" />
+  <class name="LArHitContainer" id="32703AED-CAA5-45ED-B804-8556900CA6B5"  />
+</lcgdict>
diff --git a/LArCalorimeter/LArSimEvent/cmt/requirements b/LArCalorimeter/LArSimEvent/cmt/requirements
new file mode 100755
index 00000000000..d3bce76a6bc
--- /dev/null
+++ b/LArCalorimeter/LArSimEvent/cmt/requirements
@@ -0,0 +1,25 @@
+package LArSimEvent
+
+# Liquid Argon Hit classes
+
+author Johann Collot <collot@in2p3.fr>
+
+use AtlasPolicy    AtlasPolicy-* 
+use CLIDSvc        CLIDSvc-*           Control 
+use AtlasCLHEP     AtlasCLHEP-*        External
+
+use Identifier     Identifier-*        DetectorDescription
+use HitManagement  HitManagement-*     Simulation
+
+private
+use StoreGate      StoreGate-*         Control
+end_private
+
+library LArSimEvent *.cxx
+apply_pattern installed_library
+
+# generate dictionary 
+private
+use AtlasReflex      AtlasReflex-*      External -no_auto_imports
+
+apply_pattern lcgdict dict=LArSimEvent selectionfile=selection.xml headerfiles=" ../LArSimEvent/LArSimEventDict.h"
diff --git a/LArCalorimeter/LArSimEvent/doc/mainpage.h b/LArCalorimeter/LArSimEvent/doc/mainpage.h
new file mode 100755
index 00000000000..ab95bde4a0a
--- /dev/null
+++ b/LArCalorimeter/LArSimEvent/doc/mainpage.h
@@ -0,0 +1,18 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+/**
+@mainpage LArSimEvent Package
+
+This package provides the simulation data model for LAr Calorimeter.
+
+@author Bill Seligman
+@author many many others
+
+@section LArSimEventHit Hit related classes
+
+LArHit describes the output of the G4 simulation. Each LArHit contains the energy deposit in the visible calorimeter per cell. All LArHits are saved in a LArHitsContainer.
+
+@section LArSimEventOther Other Simulation Data Model classes
+*/
diff --git a/LArCalorimeter/LArSimEvent/src/LArHitContainer.cxx b/LArCalorimeter/LArSimEvent/src/LArHitContainer.cxx
new file mode 100755
index 00000000000..b3fbc30194e
--- /dev/null
+++ b/LArCalorimeter/LArSimEvent/src/LArHitContainer.cxx
@@ -0,0 +1,76 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+#include "LArSimEvent/LArHitContainer.h"
+#include <typeinfo>
+#include <stdio.h>
+
+#include <iostream> 
+
+LArHitContainer::LArHitContainer(std::string collectionName)
+: AthenaHitsVector<LArHit>(collectionName)
+{
+
+}
+
+LArHitContainer::~LArHitContainer() 
+{
+
+}
+
+LArHitContainer::operator std::string () const {
+ 
+ char * stCounter = new char[48] ;
+ char * nameOfContainer = new char[48] ;
+ 
+ const char * stname = typeid( *this ).name() ; 
+ int lname ; 
+ sscanf( stname , "%d%s" , &lname , nameOfContainer ) ;
+ 
+ std::string newline( "\n" ) ;    
+ std::string hitContainerString = nameOfContainer ;
+             hitContainerString +=   ": content " ;
+             hitContainerString +=  newline ;
+ 
+ LArHitContainer::const_iterator it ;
+ int counter = 0 ;
+ LArHit * hit ;    
+ 
+     for(it = this->begin() ; it != this->end() ; it++ ){ // Loop over Hits
+     
+       hit = *it ;
+             
+       sprintf( stCounter , "%d" , counter ) ;     
+        
+       hitContainerString += "LArHit[" ;
+       hitContainerString += stCounter ;
+       hitContainerString += "] " ;
+
+       sprintf( stCounter , " ID = %x ;  " ,hit->cellID().get_identifier32().get_compact() ) ;
+       hitContainerString += stCounter ;
+
+       sprintf( stCounter , " E= %f MeV ;  " , hit->energy() ) ;     
+       hitContainerString += stCounter ;
+       sprintf( stCounter , " t= %f ns ; " , hit->time() ) ;     
+       hitContainerString += stCounter ;
+
+//        hitContainerString += (std::string) (*hit) ;
+       hitContainerString += newline ;
+     
+       counter ++ ; 
+       
+     }
+     
+     sprintf( stCounter , "%d" , counter ) ;
+     hitContainerString += newline ;
+     hitContainerString += "Number of Hits in this container : " ;
+     hitContainerString += stCounter ;
+ 
+ 
+ delete[] stCounter ;
+ delete[] nameOfContainer ;
+ 
+ return hitContainerString ;
+
+}
diff --git a/LArCalorimeter/LArSimEvent/src/LArHitFloatContainer.cxx b/LArCalorimeter/LArSimEvent/src/LArHitFloatContainer.cxx
new file mode 100644
index 00000000000..7c9f74b905b
--- /dev/null
+++ b/LArCalorimeter/LArSimEvent/src/LArHitFloatContainer.cxx
@@ -0,0 +1,5 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+#include "LArSimEvent/LArHitFloatContainer.h"
-- 
GitLab