SimChannel.cxx
Go to the documentation of this file.
1 /// $Id: SimChannel.cxx,v 1.3 2010/03/26 20:08:36 brebel Exp $
2 ///
3 /// \file SimulationDataProducts/SimChannel.cxx
4 ///
5 ///
6 /// \author seligman@nevis.columbia.edu
7 ///
8 ////////////////////////////////////////////////////////////////////////
9 
10 #include <limits> // std::numeric_limits
11 #include <utility>
12 #include <stdexcept>
13 
15 
17 
18 //-------------------------------------------------
20 : fTrackID (std::numeric_limits<int >::max())
21 , fNumElectrons(std::numeric_limits<float >::max())
22 , fChannel (std::numeric_limits<unsigned int >::max())
23 , fTDC (std::numeric_limits<unsigned short>::max())
24 {}
25 
26 //-------------------------------------------------
28  int offset)
29 : fTrackID (ide.TrackID() + offset)
31 , fChannel (ide.Channel() )
32 , fTDC (ide.TDC() )
33 {}
34 
35 //-------------------------------------------------
37 {
38  if(fTrackID != b.TrackID() ||
39  fTDC != b.TDC() ){
40  MF_LOG_WARNING("SimChannel")
41  << "attempting to add IDEs with different trackIDs: "
42  << fTrackID
43  << "; "
44  << b.TrackID()
45  << " or TDCs "
46  << fTDC
47  << "; "
48  << b.TDC()
49  << " bail";
50  return;
51  }
52 
54 
55  return;
56 }
57 
58 //-------------------------------------------------
60 {
61  return (fChannel == b.Channel() &&
62  std::abs(fTrackID) == std::abs(b.TrackID()) &&
63  fTDC == b.TDC() );
64 }
65 
66 //-------------------------------------------------
67 // want to sort these by channel number, then TDC value, then
68 // TrackID contributing to charge at a given TDC
70 {
71  if(fChannel < b.Channel() ) return true;
72  else if(fChannel == b.Channel() ){
73  if(fTDC < b.TDC() ) return true;
74  else if(fTDC == b.TDC()){
75  int absTrkID = std::abs(fTrackID);
76  int absTrkIDB = std::abs(b.TrackID());
77 
78  if(absTrkID < absTrkIDB) return true;
79  } // end if the same TDC value
80  } // end if the same channel
81 
82  return false;
83 }
84 
unsigned short fTDC
TDC value of the readout.
Definition: SimChannel.h:56
unsigned int const & Channel() const
Definition: SimChannel.h:44
float const & NumElectrons() const
Definition: SimChannel.h:43
unsigned short const & TDC() const
Definition: SimChannel.h:45
int fTrackID
Geant4 supplied track ID.
Definition: SimChannel.h:53
STL namespace.
bool operator==(gar::sdp::IDE const &b) const
Definition: SimChannel.cxx:59
bool operator<(gar::sdp::IDE const &b) const
Definition: SimChannel.cxx:69
T abs(T value)
static int max(int a, int b)
void operator+=(gar::sdp::IDE const &b)
Definition: SimChannel.cxx:36
unsigned int fChannel
channel number for these electrons
Definition: SimChannel.h:55
static bool * b
Definition: config.cpp:1043
float fNumElectrons
total number of electrons for this track ID and time
Definition: SimChannel.h:54
#define MF_LOG_WARNING(category)
int const & TrackID() const
Definition: SimChannel.h:42