001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017 #include "AtlfastAlgs/CalSection.h"
018 #include "AtlfastAlgs/ICellSelector.h"
019 #include "AtlfastUtils/DeleteObject.h"
020
021 #include "AtlfastUtils/ISmearer.h"
022 #include "AtlfastUtils/CellFactory.h"
023
024 #include "AtlfastEvent/TwoCptCell.h"
025 #include "AtlfastEvent/ITransportedParticle.h"
026
027 #include "FastShowerUtils/Gridlet.h"
028
029 #include "CLHEP/Vector/LorentzVector.h"
030 #include "GaudiKernel/MsgStream.h"
031 #include <iostream>
032 #include <assert.h>
033 #include <algorithm>
034
035 namespace Atlfast {
036 using FastShower::GridletElement;
037
038
039 CalSection::CalSection(
040 MsgStream& log,
041 double minEta,
042 double maxEta,
043 double granEta,
044 double granPhi,
045 std::string detEffectsFileName,
046 double minPhi,
047 double maxPhi
048 ):
049 m_log(log),
050 m_minEta(minEta), m_maxEta(maxEta),
051 m_minPhi(minPhi), m_maxPhi(maxPhi),
052 m_calSectionReject(minEta, maxEta, minPhi, maxPhi){
053
054 log <<MSG::DEBUG<< "Initialising CellFactory with detector effects file: '"<<detEffectsFileName<<"'"<<endreq;
055 CellFactory cf(detEffectsFileName,log);
056
057 log <<MSG::DEBUG<< "CalSection: construction. Eta range: "
058 <<minEta<<" - "<<maxEta<<endreq;
059 log <<MSG::DEBUG<< " Phi range: "
060 <<minPhi<<" - "<<maxPhi<<endreq;
061 log <<MSG::DEBUG<< " starting granularity Eta: "<<granEta
062 << " phi: "<<granPhi
063 <<endreq;
064
065 log <<MSG::DEBUG<<"CalSectionReject parameters:"<<endreq;
066 log <<MSG::DEBUG<<m_calSectionReject<<endreq;
067
068 int nEta = int(((maxEta-minEta)/granEta)+0.5);
069 m_granEta = (maxEta-minEta)/int(nEta);
070 m_nPhi = 1+int(((m_maxPhi-m_minPhi)/granPhi)+0.5);
071 m_granPhi = (m_maxPhi-m_minPhi)/double(m_nPhi);
072 log <<MSG::DEBUG<< " final granularity Eta: "<<m_granEta
073 << " phi: "<<m_granPhi
074 <<endreq;
075 log <<MSG::DEBUG<< " final Bins in Eta: "<<nEta
076 << " phi: "<<m_nPhi
077 <<endreq;
078
079 for (int ieta=0; ieta<nEta; ieta++){
080 for (int iphi=0; iphi<m_nPhi; iphi++){
081
082 double eta = minEta+((double(ieta)+0.5)*double(m_granEta));
083 double phi = m_minPhi + ((double(iphi)+0.5)*double(m_granPhi));
084 CellDescriptor id = CellDescriptor(eta,phi);
085 ITwoCptCell* cell = cf.makeCell(id);
086
087 m_cells.push_back(cell);
088 }
089 }
090 }
091 CalSection::~CalSection(){
092 m_log<<MSG::DEBUG<<"CalSection destructor starts "<<endreq;
093 std::for_each(m_cells.begin(), m_cells.end(), DeleteObject());
094 m_log<<MSG::DEBUG<<"CalSection destructor ends "<<endreq;
095 }
096 CalSection::CalSection(const CalSection& c):
097 m_log(c.m_log),
098 m_minEta(c.m_minEta),
099 m_maxEta(c.m_maxEta),
100 m_minPhi(c.m_minPhi),
101 m_maxPhi(c.m_maxPhi),
102 m_granEta(c.m_granEta),
103 m_granPhi(c.m_granPhi),
104 m_nPhi(c.m_nPhi),
105 m_calSectionReject(c.m_calSectionReject){
106 std::vector<ITwoCptCell*>::const_iterator i=c.m_cells.begin();
107 for(;i<c.m_cells.end();++i) m_cells.push_back((*i)->cloneITCC());
108 }
109
110
111
112
113
114 void CalSection::deposit(ITransportedParticleCollectionIter& f,
115 ITransportedParticleCollectionIter& l){
116
117 ITransportedParticleCollectionIter divider;
118 divider = std::partition(f, l, m_calSectionReject);
119
120
121 for(ITransportedParticleCollectionCIter i=divider; i<l; ++i){newHit(*i);}
122
123
124 l=divider;
125 }
126
127
128 void
129 CalSection::depositEcal(std::vector<const GridletElement*>::iterator& f,
130 std::vector<const GridletElement*>::iterator& l
131 ){
132
133
134
135 std::vector<const GridletElement*>::iterator divider;
136 divider = std::partition(f, l, m_calSectionReject);
137
138
139 std::vector<const GridletElement*>::iterator i;
140 for( i=divider; i<l; ++i){newEHit(*i);}
141
142
143
144
145 l=divider;
146
147
148 }
149
150
151 void CalSection::depositHcal(std::vector<const GridletElement*>::iterator& f,
152 std::vector<const GridletElement*>::iterator& l
153 ){
154
155 std::vector<const GridletElement*>::iterator divider;
156 divider = std::partition(f, l, m_calSectionReject);
157
158 std::vector<const GridletElement*>::iterator i;
159 for( i=divider; i<l; ++i){newHHit(*i);}
160
161
162 l=divider;
163 }
164
165
166 void CalSection::depositEgen(std::vector<const Gridlet*>::iterator& f,
167 std::vector<const Gridlet*>::iterator& l
168 ){
169 std::vector<const Gridlet*>::iterator divider;
170 divider = std::partition(f, l, m_calSectionReject);
171
172
173 std::vector<const Gridlet*>::iterator i;
174 for( i=divider; i<l; ++i){setEgen(*i);}
175
176
177 l=divider;
178 }
179
180
181
182 void CalSection::newHit( const ITransportedParticle* tp){
183
184 const HepMC::GenParticle* particle = tp->particle();
185
186 const double eta = tp->eta();
187 const double phi = tp->phi();
188 int ind = iindex(phi, eta);
189 ITwoCptCell* cell = m_cells[ind];
190 assert(std::abs( eta-(cell->eta()) ) <m_granEta);
191 assert(std::abs( phi-(cell->phi()) ) <m_granPhi);
192 cell->newHit(particle);
193
194
195 m_hitCells[ind] = cell;
196 return;
197 }
198
199
200 void CalSection::newEHit( const GridletElement* ge){
201 int ind = index(ge);
202 ITwoCptCell* cell = m_cells[ind];
203
204
205
206
207 assert(std::abs( (ge->eta()-cell->eta()) )<m_granEta);
208 assert(std::abs( (ge->phi()-cell->phi()) )<m_granPhi);
209 cell->depositEcal(ge->et());
210
211
212 m_hitCells[ind] = cell;
213
214 return;
215 }
216
217
218 void CalSection::newHHit( const GridletElement* ge){
219 int ind = index(ge);
220 ITwoCptCell* cell = m_cells[ind];
221
222 assert(std::abs( (ge->eta())-(cell->eta()) )<m_granEta);
223 assert(std::abs( (ge->phi())-(cell->phi()) )<m_granPhi);
224
225 cell->depositHcal(ge->et());
226
227
228 m_hitCells[ind] = cell;
229
230 return;
231 }
232
233
234 void CalSection::setEgen( const Gridlet* gr){
235 int ind = index(gr);
236 ITwoCptCell* cell = m_cells[ind];
237 cell->addEgen(gr->eGen());
238 m_hitCells[ind] = cell;
239 return;
240 }
241
242
243 int CalSection::index(const Gridlet* gr) const{
244 int ind = this->iindex( gr->phi0(), gr->eta0() );
245 return ind;
246 }
247
248 int CalSection::index(const GridletElement* ge) const{
249 int ind = this->iindex( ge->phi(), ge->eta() );
250 return ind;
251 }
252
253 int CalSection::index(const ITransportedParticle* tp) const {
254 const HepMC::GenParticle* particle = tp->particle();
255 const double eta = particle->momentum().pseudoRapidity();
256 const double phi = tp->phi();
257 int ind = iindex(phi, eta);
258 return ind;
259 }
260
261 int CalSection::iindex(double phi, double eta) const{
262 int iphi = int( (phi-m_minPhi)/m_granPhi );
263 int ieta = int( (eta-m_minEta)/m_granEta );
264
265 return (m_nPhi*ieta + iphi);
266 }
267
268
269
270 void CalSection::giveHits
271 (const ICellSelector* p_cellselect, ITwoCptCellCollection* cells) const{
272
273 std::vector<ITwoCptCell*>::const_iterator i;
274 for(i=m_cells.begin(); i!=m_cells.end(); ++i){
275
276 if( (*p_cellselect) (*i) && (*i)->isActive()){
277 ITwoCptCell* cell = (*i)->cloneITCC();
278
279
280 cells->push_back(cell);
281 }
282 }
283
284 }
285
286
287
288
289 void CalSection::smearCells
290 (ISmearer* p_smearer) {
291 std::map<int, ITwoCptCell*, std::less<int> >::const_iterator i;
292 for(i=m_hitCells.begin(); i!=m_hitCells.end(); ++i){
293 if((*((*i).second)).momentum().e() > 0){
294 HepLorentzVector temp = p_smearer->smear((*((*i).second)).momentum());
295 (*((*i).second)).setPt(temp);
296 }
297 }
298 }
299
300
301
302 void CalSection::reset(){
303
304
305 std::vector<ITwoCptCell*>::const_iterator i = m_cells.begin();
306 for(;i!=m_cells.end();++i) {
307
308 if((*i)->isActive())(*i)->resetCell();
309 }
310 m_hitCells.erase(m_hitCells.begin(), m_hitCells.end());
311 }
312 }
313
314
315
316
317
318
319
320
321
322
323
324
325
| Due to the LXR bug, the updates fail sometimes to remove references to deleted files. The Saturday's full rebuilds fix these problems |
|
This page was automatically generated by the
LXR engine.
|
|