Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CCaloOrganization Class Reference

#include <CCaloOrganization.hh>

Public Member Functions

 CCaloOrganization ()
 
virtual ~CCaloOrganization ()
 
unsigned int packindex (int det, int z, int eta, int phi) const
 
unsigned int packindex (int det, int depth, int z, int eta, int phi) const
 
void unpackindex (const unsigned int &idx, int &det, int &z, int &eta, int &phi) const
 
void unpackindex (const unsigned int &idx, int &det, int &depth, int &z, int &eta, int &phi) const
 
int getUnitWithMaxEnergy (std::map< int, float, std::less< int > > &themap)
 
float energyInMatrix (int nCellInEta, int nCellInPhi, int crystalWithMaxEnergy, std::map< int, float, std::less< int > > &themap)
 

Detailed Description

Definition at line 38 of file CCaloOrganization.hh.

Constructor & Destructor Documentation

CCaloOrganization::CCaloOrganization ( )
inline

Definition at line 41 of file CCaloOrganization.hh.

41 {};
virtual CCaloOrganization::~CCaloOrganization ( )
inlinevirtual

Definition at line 42 of file CCaloOrganization.hh.

42 {};

Member Function Documentation

float CCaloOrganization::energyInMatrix ( int  nCellInEta,
int  nCellInPhi,
int  crystalWithMaxEnergy,
std::map< int, float, std::less< int > > &  themap 
)

Definition at line 121 of file CCaloOrganization.cc.

123  {
124 
125  int det,z,eta,phi;
126  this->unpackindex(crystalWithMaxEnergy, det, z, eta, phi);
127  int ncristals=0;
128 
129  int goBackInEta = nCellInEta/2;
130  int goBackInPhi = nCellInPhi/2;
131  int startEta = eta-goBackInEta;
132  int startPhi = phi-goBackInPhi;
133 
134  float totalEnergy = 0.;
135 
136  for(int ieta=startEta; ieta<startEta+nCellInEta; ieta++){
137  for(int iphi=startPhi; iphi<startPhi+nCellInPhi; iphi++){
138 
139  int index = this->packindex(det,z,ieta,iphi);
140  totalEnergy += themap[index];
141  ncristals+=1;
142 #ifdef debug
143  G4cout << "ieta - iphi - E = " << ieta << " " << iphi << " "
144  << themap[index] << G4endl;
145 #endif
146  }
147  }
148 
149 #ifdef debug
150  G4cout << "Energy in " << nCellInEta << " cells in eta times "
151  << nCellInPhi << " cells in phi matrix = " << totalEnergy
152  << " for " << ncristals << " crystals" << G4endl;
153 #endif
154  return totalEnergy;
155 
156 }
void unpackindex(const unsigned int &idx, int &det, int &z, int &eta, int &phi) const
unsigned int packindex(int det, int z, int eta, int phi) const
G4GLOB_DLL std::ostream G4cout
tuple z
Definition: test.py:28
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

int CCaloOrganization::getUnitWithMaxEnergy ( std::map< int, float, std::less< int > > &  themap)

Definition at line 94 of file CCaloOrganization.cc.

94  {
95 
96  //look for max
97  int UnitWithMaxEnergy = 0;
98  float maxEnergy = 0.;
99 
100  for(std::map<int,float,std::less<int> >::iterator iter = themap.begin();
101  iter != themap.end(); iter++){
102 
103  if( maxEnergy < (*iter).second) {
104  maxEnergy = (*iter).second;
105  UnitWithMaxEnergy = (*iter).first;
106  }
107  }
108 #ifdef debug
109  G4cout << " *** max energy of " << maxEnergy << " MeV was found in Unit id "
110  << UnitWithMaxEnergy;
111  int det,z,eta,phi;
112  unpackindex(UnitWithMaxEnergy, det, z, eta, phi);
113  G4cout << " corresponding to z= " << z << " eta= " << eta << " phi = " << phi
114  << G4endl;
115 #endif
116  return UnitWithMaxEnergy;
117 
118 }
void unpackindex(const unsigned int &idx, int &det, int &z, int &eta, int &phi) const
G4GLOB_DLL std::ostream G4cout
tuple z
Definition: test.py:28
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

unsigned int CCaloOrganization::packindex ( int  det,
int  z,
int  eta,
int  phi 
) const

Definition at line 35 of file CCaloOrganization.cc.

36  {
37  //So this is the actual encoding of the index:
38  //top 4 bits encode Detector type
39  //
40  // Should work for all calorimeter with no depth information
41 
42  unsigned int idx=(det&15)<<28; //bits 28-31 (21-23 are free for now)
43  idx+=(((z+1)/2)&1)<<20; //bits 20
44  idx+=(eta&1023)<<10; //bits 10-19
45  idx+=(phi&1023); //bits 0-9
46 #ifdef debug
47  G4cout << " ECAL packing " << det << " " << z << " " << eta << " " << phi
48  << " into " << idx << G4endl;
49 #endif
50  return idx;
51 }
G4GLOB_DLL std::ostream G4cout
tuple z
Definition: test.py:28
#define G4endl
Definition: G4ios.hh:61

Here is the caller graph for this function:

unsigned int CCaloOrganization::packindex ( int  det,
int  depth,
int  z,
int  eta,
int  phi 
) const

Definition at line 53 of file CCaloOrganization.cc.

54  {
55  //So this is the actual encoding of the index:
56  //top 4 bits encode Detector type
57  //next 4 bits encode depth information
58  // Should work for all calorimeter with no depth information
59 
60  unsigned int idx=(det&15)<<28; //bits 28-31 (21-23 are free for now)
61  idx+=(depth&15)<<24; //bits 24-27
62  idx+=(z&1)<<20; //bits 20
63  idx+=(eta&1023)<<10; //bits 10-19
64  idx+=(phi&1023); //bits 0-9
65 #ifdef debug
66  G4cout << " HCAL packing " << det << " " << depth << " " << z << " " << eta
67  << " " << phi << " into " << idx << G4endl;
68 #endif
69  return idx;
70 }
G4GLOB_DLL std::ostream G4cout
tuple z
Definition: test.py:28
#define G4endl
Definition: G4ios.hh:61
void CCaloOrganization::unpackindex ( const unsigned int idx,
int det,
int z,
int eta,
int phi 
) const

Definition at line 73 of file CCaloOrganization.cc.

74  {
75  det = (idx>>28)&15;
76  z = (idx>>20)&1;
77  z = 2*z-1;
78  eta = (idx>>10)&1023;
79  phi = (idx&1023);
80 }
tuple z
Definition: test.py:28

Here is the caller graph for this function:

void CCaloOrganization::unpackindex ( const unsigned int idx,
int det,
int depth,
int z,
int eta,
int phi 
) const

Definition at line 83 of file CCaloOrganization.cc.

85  {
86  det = (idx>>28)&15;
87  depth=(idx>>24)&15;
88  z = (idx>>20)&1;
89  eta = (idx>>10)&1023;
90  phi = (idx&1023);
91 }
tuple z
Definition: test.py:28

The documentation for this class was generated from the following files: