27#include "GaudiKernel/Bootstrap.h"
28#include "GaudiKernel/Service.h"
29#include "GaudiKernel/MsgStream.h"
30#include "GaudiKernel/IMessageSvc.h"
34#include "CaloDetDescr/CaloDetDescrElement.h"
77 const std::vector<CaloCell_ID::SUBCALO>& theCalos)
95 msg << MSG::ERROR<<
"CaloDetDescrManager is not initialized, module unusable!"<<
endmsg;
101 size_t sizeCalos = theCalos.size();
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);
110 for (
unsigned int iCalo=0; iCalo<sizeCalos; iCalo++ ){
115 msg << MSG::DEBUG <<
" firstInder,lastIndex " << firstIndex <<
" " << lastIndex <<
endmsg;
118 for(
size_t cellIndex = firstIndex; cellIndex < lastIndex; cellIndex++){
123 if(theDDE==
nullptr) {
124 msg << MSG::ERROR<<
" CellIndex = "<< cellIndex<<
" has a DDE pointer NULL " <<
endmsg;
129 double cellDeta = theDDE->
deta();
130 double cellDphi = theDDE->
dphi();
131 double etaRaw = theDDE->
eta_raw();
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;
145 double theWeight = 1. / ( (double) ke * kp );
147 double cellDdeta = cellDeta / (double) ke;
148 double cellDdphi = cellDphi / (double) kp;
149 double etaMin = etaRaw - cellDeta / 2.;
150 double phiMin = phiRaw - cellDphi / 2.;
157 for (
size_t ie=1; ie<=ke; ie++ ){
158 double cellEta = etaMin + ((double)ie - 0.5) * cellDdeta;
159 for (
size_t ip=1; ip<=kp; ip++ ){
160 double cellPhi = phiMin + ((double)ip - 0.5) * cellDdphi;
176 if (towerIndex < ntowers) {
177 ttcmatrix[towerIndex].emplace_back(cellIndex,iw);
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];
199 unsigned int stride = 0;
200 for (
size_t j = 1; j < v.size(); j++) {
211 if ((
int)(v[j].hash - v[j-1].hash) == (
int)stride &&
212 v[j].windex == ent.
windex &&
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: ",
237 static FILE* flog = 0;
238 if (!flog) flog = fopen (
"towstore.dump",
"w");
239 fprintf (flog,
"========================================\n");
241 bool backref =
false;
242 for (
size_t it = 0; it <
m_towers.size(); it++) {
243 fprintf (flog,
"tow %d %d %d %d %d %d\n", it,
m_towers[it].ncells,
247 for (
size_t z = 0;
z <
m_towers[it].nentries;
z++) {
248 fprintf (flog,
"%6d %6d %2d %2d %3d\n", ic,
m_entries[ic].hash,
254 backref =
m_towers[it].backref_next;
270 std::vector<unsigned short>
entries;
274 for (
size_t i = 0; i <
sz; i++) {
279 assert (ndx < std::numeric_limits<unsigned short>::max());
289 unsigned int pos1 =
m_entries.size() - 2*nentries;
290 unsigned int pos2 =
m_entries.size() - nentries;
291 unsigned int phase = 0;
293 unsigned int offs1 = 0;
294 unsigned int offs2 = 0;
295 for (
size_t i = 0; i < nentries; i++) {
305 unsigned int offs = ent2.
hash - ent1.
hash;
311 else if (phase == 1) {
319 else if (phase == 2) {
337 m_towers.back().backref_next =
true;
338 m_towers.emplace_back(nentries, ncells, n1, offs1, offs2);
343 m_towers.emplace_back(nentries, ncells);
348 unsigned int the_windex,
349 unsigned int the_ncells ,
350 unsigned int the_stride )
364 unsigned int the_ncells)
378 unsigned int the_ncells,
380 unsigned int the_offs1,
381 unsigned int the_offs2)
391 assert (the_n1 <=
n1_max);
Definition of CaloDetDescrManager.
CaloPhiRange class declaration.
void calo_cell_hash_range(const Identifier id, IdentifierHash &caloCellMin, IdentifierHash &caloCellMax) const
to loop on 'global' cell hashes of one sub-calorimeter alone
Helper class for offline cell identifiers.
This class groups all DetDescr information related to a CaloCell.
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
This class provides the client interface for accessing the detector description information common to...
const CaloCell_ID * getCaloCell_ID() const
get calo cell ID helper
static double fix(double phi)
static SubSegIterator make(tower_iterator beg, const SubSeg &subseg)
A rectangular window within the segmentation.
Data object stores CaloTower segmentation.
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.
~CaloTowerStore()
destructor
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.
bool buildLookUp(const CaloDetDescrManager &theManager, const CaloTowerSeg &theTowerSeg, const std::vector< CaloCell_ID::SUBCALO > &theCalos)
setup trigger
void pushTower(unsigned int nentries, unsigned int ncells)
CaloTowerStore()
constructor
void checkEntryIndex() const
Check m_entry_index and fill it in if we haven't done so yet.
tower_iterator towers() const
CaloTowerSeg::SubSegIterator< tower_iterator > tower_subseg_iterator
std::vector< Entry > m_entries
This is a "hash" representation of an Identifier.
singleton-like access to IMessageSvc via open function and helper
IMessageSvc * getMessageSvc(bool quiet=false)
static const unsigned int windex_max
static const unsigned int stride_max
static const unsigned int hash_max
static const unsigned int ncells_max
Entry(unsigned int the_hash=0, unsigned int the_windex=0, unsigned int the_ncells=1, unsigned int the_stride=0)
Tower(unsigned int the_nentries, unsigned int the_ncells)
static const unsigned int nentries_max
static const unsigned int ncells_max
static const unsigned int n1_max
static const unsigned int offs1_max
static const unsigned int offs2_max