78{
85
87
89
90
92
93
95 msg << MSG::ERROR<<
"CaloDetDescrManager is not initialized, module unusable!"<<
endmsg;
96 return false;
97 }
99
100
101 size_t sizeCalos = theCalos.size();
102
103 unsigned int ntowers = theTowerSeg.
neta() * theTowerSeg.
nphi();
104 msg << MSG::DEBUG <<
" number of towers " << ntowers <<
endmsg;
105 std::vector< std::vector<Entry> > ttcmatrix;
106 ttcmatrix.resize (ntowers);
109
110 for ( unsigned int iCalo=0; iCalo<sizeCalos; iCalo++ ){
111
112
113 IdentifierHash firstIndex, lastIndex;
115 msg << MSG::DEBUG <<
" firstInder,lastIndex " << firstIndex <<
" " << lastIndex <<
endmsg;
116
117
118 for( size_t cellIndex = firstIndex; cellIndex < lastIndex; cellIndex++){
119
120
121 const CaloDetDescrElement* theDDE = theManager.
get_element(cellIndex);
122
123 if(theDDE==nullptr) {
124 msg << MSG::ERROR<<
" CellIndex = "<< cellIndex<<
" has a DDE pointer NULL " <<
endmsg;
125 continue;
126 }
127
128
129 double cellDeta = theDDE->
deta();
130 double cellDphi = theDDE->
dphi();
131 double etaRaw = theDDE->
eta_raw();
133
135
137
138
139
140 size_t ke = (size_t) (cellDeta/theTowerSeg.
deta()+0.5);
141 ke = (ke==0) ? 1 : ke;
142 size_t kp = (size_t) (cellDphi/theTowerSeg.
dphi()+0.5);
143 kp = (kp==0) ? 1 : kp;
144
145 double theWeight = 1. / ( (
double) ke * kp );
146
147 double cellDdeta = cellDeta / (
double) ke;
148 double cellDdphi = cellDphi / (
double) kp;
149 double etaMin = etaRaw - cellDeta / 2.;
150 double phiMin = phiRaw - cellDphi / 2.;
151
153
155
156
157 for (
size_t ie=1;
ie<=ke;
ie++ ){
159 for (
size_t ip=1;
ip<=kp;
ip++ ){
160 double cellPhi = phiMin + ((
double)
ip - 0.5) * cellDdphi;
161
164
167 {
169 size_t iw = 0;
172 }
175
176 if (towerIndex < ntowers) {
177 ttcmatrix[towerIndex].emplace_back(cellIndex,iw);
178 }
179 }
180
181 }
182 }
183
184 }
185
186
187 }
188
189
190 m_towers.reserve (ttcmatrix.size()+1);
192 for (
size_t i = 0;
i < ttcmatrix.size();
i++) {
194 const std::vector<Entry>&
v = ttcmatrix[
i];
195
196
199 unsigned int stride = 0;
200 for (
size_t j = 1; j <
v.size(); j++) {
201 if (stride == 0) {
204 ent.stride = 1;
205 }
206 else {
207 ent.stride = 0;
209 }
210 }
211 if ((int)(v[j].hash - v[j-1].hash) == (int)stride &&
212 v[j].windex == ent.windex &&
214 ++ent.ncells;
215 else {
218 stride = 0;
219 }
220 }
222 }
223
225
226 }
227
228#if 0
229 {
230 printf ("zzztowers calos: ");
231 for (
size_t z = 0;
z < theCalos.size();
z++) printf (
"%d ", theCalos[
z]);
232 printf ("ntower: %d nent: %d nentraw: %d weights: ",
235 printf ("\n");
236
237 static FILE* flog = 0;
238 if (!flog) flog = fopen ("towstore.dump", "w");
239 fprintf (flog, "========================================\n");
241 bool backref = false;
243 fprintf (flog,
"tow %d %d %d %d %d %d\n", it,
m_towers[it].ncells,
246 if (!backref) {
248 fprintf (flog,
"%6d %6d %2d %2d %3d\n", ic,
m_entries[ic].hash,
252 }
253 }
255 }
256 }
257#endif
258
259
260 return 1;
261}
void calo_cell_hash_range(const Identifier id, IdentifierHash &caloCellMin, IdentifierHash &caloCellMax) const
to loop on 'global' cell hashes of one sub-calorimeter alone
float eta_raw() const
cell eta_raw
float dphi() const
cell dphi
float phi_raw() const
cell phi_raw
float deta() const
cell deta
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
bool isInitialized() const
for backwards compatibility only
const CaloCell_ID * getCaloCell_ID() const
get calo cell ID helper
static double fix(double phi)
index_t nphi() const
Retrieve number of bins.
size_t index_t
Type for eta, phi indices.
index_t etaphi(index_t etaInd, index_t phiInd) const
Returns combined continous index from , indices.
index_t neta() const
Retrieve number of bins.
double deta() const
Retrieve bin size .
double dphi() const
Retrieve bin size .
index_t phiIndex(double phiVal) const
Returns index for a given value.
static const index_t outOfRange
Used to flag out-of-range indices.
index_t etaIndex(double etaVal) const
Returns index for a given value.
std::vector< Tower > m_towers
std::vector< double > m_weights
CxxUtils::CachedValue< std::vector< unsigned short > > m_entry_index
One of these for each entry in m_towers, giving the index of the corresponding entry in m_entries.
void pushTower(unsigned int nentries, unsigned int ncells)
std::vector< Entry > m_entries
IMessageSvc * getMessageSvc(bool quiet=false)
unsigned int phiIndex(float phi, float binsize)
calculate phi index for a given phi
static const unsigned int ncells_max