1 | /*
|
---|
2 | * Delphes: a framework for fast simulation of a generic collider experiment
|
---|
3 | * Copyright (C) 2012-2014 Universite catholique de Louvain (UCL), Belgium
|
---|
4 | *
|
---|
5 | * This program is free software: you can redistribute it and/or modify
|
---|
6 | * it under the terms of the GNU General Public License as published by
|
---|
7 | * the Free Software Foundation, either version 3 of the License, or
|
---|
8 | * (at your option) any later version.
|
---|
9 | *
|
---|
10 | * This program is distributed in the hope that it will be useful,
|
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | * GNU General Public License for more details.
|
---|
14 | *
|
---|
15 | * You should have received a copy of the GNU General Public License
|
---|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
17 | */
|
---|
18 |
|
---|
19 |
|
---|
20 | /** \class Calorimeter
|
---|
21 | *
|
---|
22 | * Fills calorimeter towers, performs calorimeter resolution smearing,
|
---|
23 | * and creates energy flow objects (tracks, photons, and neutral hadrons).
|
---|
24 | *
|
---|
25 | * $Date$
|
---|
26 | * $Revision$
|
---|
27 | *
|
---|
28 | *
|
---|
29 | * \author P. Demin - UCL, Louvain-la-Neuve
|
---|
30 | *
|
---|
31 | */
|
---|
32 |
|
---|
33 | #include "modules/Calorimeter.h"
|
---|
34 |
|
---|
35 | #include "classes/DelphesClasses.h"
|
---|
36 | #include "classes/DelphesFactory.h"
|
---|
37 | #include "classes/DelphesFormula.h"
|
---|
38 |
|
---|
39 | #include "ExRootAnalysis/ExRootResult.h"
|
---|
40 | #include "ExRootAnalysis/ExRootFilter.h"
|
---|
41 | #include "ExRootAnalysis/ExRootClassifier.h"
|
---|
42 |
|
---|
43 | #include "TMath.h"
|
---|
44 | #include "TString.h"
|
---|
45 | #include "TFormula.h"
|
---|
46 | #include "TRandom3.h"
|
---|
47 | #include "TObjArray.h"
|
---|
48 | #include "TDatabasePDG.h"
|
---|
49 | #include "TLorentzVector.h"
|
---|
50 |
|
---|
51 | #include <algorithm>
|
---|
52 | #include <stdexcept>
|
---|
53 | #include <iostream>
|
---|
54 | #include <sstream>
|
---|
55 |
|
---|
56 | using namespace std;
|
---|
57 |
|
---|
58 | //------------------------------------------------------------------------------
|
---|
59 |
|
---|
60 | Calorimeter::Calorimeter() :
|
---|
61 | fECalResolutionFormula(0), fHCalResolutionFormula(0),
|
---|
62 | fItParticleInputArray(0), fItTrackInputArray(0),
|
---|
63 | fTowerTrackArray(0), fItTowerTrackArray(0)
|
---|
64 | {
|
---|
65 | fECalResolutionFormula = new DelphesFormula;
|
---|
66 | fHCalResolutionFormula = new DelphesFormula;
|
---|
67 |
|
---|
68 | fTowerTrackArray = new TObjArray;
|
---|
69 | fItTowerTrackArray = fTowerTrackArray->MakeIterator();
|
---|
70 | }
|
---|
71 |
|
---|
72 | //------------------------------------------------------------------------------
|
---|
73 |
|
---|
74 | Calorimeter::~Calorimeter()
|
---|
75 | {
|
---|
76 | if(fECalResolutionFormula) delete fECalResolutionFormula;
|
---|
77 | if(fHCalResolutionFormula) delete fHCalResolutionFormula;
|
---|
78 |
|
---|
79 | if(fTowerTrackArray) delete fTowerTrackArray;
|
---|
80 | if(fItTowerTrackArray) delete fItTowerTrackArray;
|
---|
81 | }
|
---|
82 |
|
---|
83 | //------------------------------------------------------------------------------
|
---|
84 |
|
---|
85 | void Calorimeter::Init()
|
---|
86 | {
|
---|
87 | ExRootConfParam param, paramEtaBins, paramPhiBins, paramFractions;
|
---|
88 | Long_t i, j, k, size, sizeEtaBins, sizePhiBins;
|
---|
89 | Double_t ecalFraction, hcalFraction;
|
---|
90 | TBinMap::iterator itEtaBin;
|
---|
91 | set< Double_t >::iterator itPhiBin;
|
---|
92 | vector< Double_t > *phiBins;
|
---|
93 |
|
---|
94 | // read eta and phi bins
|
---|
95 | param = GetParam("EtaPhiBins");
|
---|
96 | size = param.GetSize();
|
---|
97 | fBinMap.clear();
|
---|
98 | fEtaBins.clear();
|
---|
99 | fPhiBins.clear();
|
---|
100 | for(i = 0; i < size/2; ++i)
|
---|
101 | {
|
---|
102 | paramEtaBins = param[i*2];
|
---|
103 | sizeEtaBins = paramEtaBins.GetSize();
|
---|
104 | paramPhiBins = param[i*2 + 1];
|
---|
105 | sizePhiBins = paramPhiBins.GetSize();
|
---|
106 |
|
---|
107 | for(j = 0; j < sizeEtaBins; ++j)
|
---|
108 | {
|
---|
109 | for(k = 0; k < sizePhiBins; ++k)
|
---|
110 | {
|
---|
111 | fBinMap[paramEtaBins[j].GetDouble()].insert(paramPhiBins[k].GetDouble());
|
---|
112 | }
|
---|
113 | }
|
---|
114 | }
|
---|
115 |
|
---|
116 | // for better performance we transform map of sets to parallel vectors:
|
---|
117 | // vector< double > and vector< vector< double >* >
|
---|
118 | for(itEtaBin = fBinMap.begin(); itEtaBin != fBinMap.end(); ++itEtaBin)
|
---|
119 | {
|
---|
120 | fEtaBins.push_back(itEtaBin->first);
|
---|
121 | phiBins = new vector< double >(itEtaBin->second.size());
|
---|
122 | fPhiBins.push_back(phiBins);
|
---|
123 | phiBins->clear();
|
---|
124 | for(itPhiBin = itEtaBin->second.begin(); itPhiBin != itEtaBin->second.end(); ++itPhiBin)
|
---|
125 | {
|
---|
126 | phiBins->push_back(*itPhiBin);
|
---|
127 | }
|
---|
128 | }
|
---|
129 |
|
---|
130 | // read energy fractions for different particles
|
---|
131 | param = GetParam("EnergyFraction");
|
---|
132 | size = param.GetSize();
|
---|
133 |
|
---|
134 | // set default energy fractions values
|
---|
135 | fFractionMap.clear();
|
---|
136 | fFractionMap[0] = make_pair(0.0, 1.0);
|
---|
137 |
|
---|
138 | for(i = 0; i < size/2; ++i)
|
---|
139 | {
|
---|
140 | paramFractions = param[i*2 + 1];
|
---|
141 |
|
---|
142 | ecalFraction = paramFractions[0].GetDouble();
|
---|
143 | hcalFraction = paramFractions[1].GetDouble();
|
---|
144 |
|
---|
145 | fFractionMap[param[i*2].GetInt()] = make_pair(ecalFraction, hcalFraction);
|
---|
146 | }
|
---|
147 | /*
|
---|
148 | TFractionMap::iterator itFractionMap;
|
---|
149 | for(itFractionMap = fFractionMap.begin(); itFractionMap != fFractionMap.end(); ++itFractionMap)
|
---|
150 | {
|
---|
151 | cout << itFractionMap->first << " " << itFractionMap->second.first << " " << itFractionMap->second.second << endl;
|
---|
152 | }
|
---|
153 | */
|
---|
154 |
|
---|
155 | // read min E value for towers to be saved
|
---|
156 | fEcalEnergyMin = GetDouble("EcalTowerMinEnergy", 0.0);
|
---|
157 | fHcalEnergyMin = GetDouble("HcalTowerMinEnergy", 0.0);
|
---|
158 |
|
---|
159 | fEcalSigmaMin = GetDouble("EcalTowerMinSignificance", 0.0);
|
---|
160 | fHcalSigmaMin = GetDouble("HcalTowerMinSignificance", 0.0);
|
---|
161 |
|
---|
162 |
|
---|
163 | // read resolution formulas
|
---|
164 | fECalResolutionFormula->Compile(GetString("ECalResolutionFormula", "0"));
|
---|
165 | fHCalResolutionFormula->Compile(GetString("HCalResolutionFormula", "0"));
|
---|
166 |
|
---|
167 | // import array with output from other modules
|
---|
168 | fParticleInputArray = ImportArray(GetString("ParticleInputArray", "ParticlePropagator/particles"));
|
---|
169 | fItParticleInputArray = fParticleInputArray->MakeIterator();
|
---|
170 |
|
---|
171 | fTrackInputArray = ImportArray(GetString("TrackInputArray", "ParticlePropagator/tracks"));
|
---|
172 | fItTrackInputArray = fTrackInputArray->MakeIterator();
|
---|
173 |
|
---|
174 | // create output arrays
|
---|
175 | fTowerOutputArray = ExportArray(GetString("TowerOutputArray", "towers"));
|
---|
176 | fPhotonOutputArray = ExportArray(GetString("PhotonOutputArray", "photons"));
|
---|
177 |
|
---|
178 | fEFlowTrackOutputArray = ExportArray(GetString("EFlowTrackOutputArray", "eflowTracks"));
|
---|
179 | fEFlowPhotonOutputArray = ExportArray(GetString("EFlowPhotonOutputArray", "eflowPhotons"));
|
---|
180 | fEFlowNeutralHadronOutputArray = ExportArray(GetString("EFlowNeutralHadronOutputArray", "eflowNeutralHadrons"));
|
---|
181 |
|
---|
182 | fDitherTowerCenter = GetBool("DitherTowerCenters", true);
|
---|
183 | }
|
---|
184 |
|
---|
185 | //------------------------------------------------------------------------------
|
---|
186 |
|
---|
187 | void Calorimeter::Finish()
|
---|
188 | {
|
---|
189 | vector< vector< Double_t >* >::iterator itPhiBin;
|
---|
190 | if(fItParticleInputArray) delete fItParticleInputArray;
|
---|
191 | if(fItTrackInputArray) delete fItTrackInputArray;
|
---|
192 | for(itPhiBin = fPhiBins.begin(); itPhiBin != fPhiBins.end(); ++itPhiBin)
|
---|
193 | {
|
---|
194 | delete *itPhiBin;
|
---|
195 | }
|
---|
196 | }
|
---|
197 |
|
---|
198 | //------------------------------------------------------------------------------
|
---|
199 |
|
---|
200 | void Calorimeter::Process()
|
---|
201 | {
|
---|
202 | Candidate *particle, *track;
|
---|
203 | TLorentzVector position, momentum;
|
---|
204 | Short_t etaBin, phiBin, flags;
|
---|
205 | Int_t number;
|
---|
206 | Long64_t towerHit, towerEtaPhi, hitEtaPhi;
|
---|
207 | Double_t ecalFraction, hcalFraction;
|
---|
208 | Double_t ecalEnergy, hcalEnergy;
|
---|
209 | Int_t pdgCode;
|
---|
210 |
|
---|
211 | TFractionMap::iterator itFractionMap;
|
---|
212 |
|
---|
213 | vector< Double_t >::iterator itEtaBin;
|
---|
214 | vector< Double_t >::iterator itPhiBin;
|
---|
215 | vector< Double_t > *phiBins;
|
---|
216 |
|
---|
217 | vector< Long64_t >::iterator itTowerHits;
|
---|
218 |
|
---|
219 | DelphesFactory *factory = GetFactory();
|
---|
220 | fTowerHits.clear();
|
---|
221 | fTowerECalFractions.clear();
|
---|
222 | fTowerHCalFractions.clear();
|
---|
223 | fTrackECalFractions.clear();
|
---|
224 | fTrackHCalFractions.clear();
|
---|
225 |
|
---|
226 | // loop over all particles
|
---|
227 | fItParticleInputArray->Reset();
|
---|
228 | number = -1;
|
---|
229 | while((particle = static_cast<Candidate*>(fItParticleInputArray->Next())))
|
---|
230 | {
|
---|
231 | const TLorentzVector &particlePosition = particle->Position;
|
---|
232 | ++number;
|
---|
233 |
|
---|
234 | pdgCode = TMath::Abs(particle->PID);
|
---|
235 |
|
---|
236 | itFractionMap = fFractionMap.find(pdgCode);
|
---|
237 | if(itFractionMap == fFractionMap.end())
|
---|
238 | {
|
---|
239 | itFractionMap = fFractionMap.find(0);
|
---|
240 | }
|
---|
241 |
|
---|
242 | ecalFraction = itFractionMap->second.first;
|
---|
243 | hcalFraction = itFractionMap->second.second;
|
---|
244 |
|
---|
245 | fTowerECalFractions.push_back(ecalFraction);
|
---|
246 | fTowerHCalFractions.push_back(hcalFraction);
|
---|
247 |
|
---|
248 | if(ecalFraction < 1.0E-9 && hcalFraction < 1.0E-9) continue;
|
---|
249 |
|
---|
250 | // find eta bin [1, fEtaBins.size - 1]
|
---|
251 | itEtaBin = lower_bound(fEtaBins.begin(), fEtaBins.end(), particlePosition.Eta());
|
---|
252 | if(itEtaBin == fEtaBins.begin() || itEtaBin == fEtaBins.end()) continue;
|
---|
253 | etaBin = distance(fEtaBins.begin(), itEtaBin);
|
---|
254 |
|
---|
255 | // phi bins for given eta bin
|
---|
256 | phiBins = fPhiBins[etaBin];
|
---|
257 |
|
---|
258 | // find phi bin [1, phiBins.size - 1]
|
---|
259 | itPhiBin = lower_bound(phiBins->begin(), phiBins->end(), particlePosition.Phi());
|
---|
260 | if(itPhiBin == phiBins->begin() || itPhiBin == phiBins->end()) continue;
|
---|
261 | phiBin = distance(phiBins->begin(), itPhiBin);
|
---|
262 |
|
---|
263 | flags = 0;
|
---|
264 | flags |= (pdgCode == 11 || pdgCode == 22) << 1;
|
---|
265 |
|
---|
266 | // make tower hit {16-bits for eta bin number, 16-bits for phi bin number, 8-bits for flags, 24-bits for particle number}
|
---|
267 | towerHit = (Long64_t(etaBin) << 48) | (Long64_t(phiBin) << 32) | (Long64_t(flags) << 24) | Long64_t(number);
|
---|
268 |
|
---|
269 | fTowerHits.push_back(towerHit);
|
---|
270 | }
|
---|
271 |
|
---|
272 | // loop over all tracks
|
---|
273 | fItTrackInputArray->Reset();
|
---|
274 | number = -1;
|
---|
275 | while((track = static_cast<Candidate*>(fItTrackInputArray->Next())))
|
---|
276 | {
|
---|
277 | const TLorentzVector &trackPosition = track->Position;
|
---|
278 | ++number;
|
---|
279 |
|
---|
280 | pdgCode = TMath::Abs(track->PID);
|
---|
281 |
|
---|
282 | itFractionMap = fFractionMap.find(pdgCode);
|
---|
283 | if(itFractionMap == fFractionMap.end())
|
---|
284 | {
|
---|
285 | itFractionMap = fFractionMap.find(0);
|
---|
286 | }
|
---|
287 |
|
---|
288 | ecalFraction = itFractionMap->second.first;
|
---|
289 | hcalFraction = itFractionMap->second.second;
|
---|
290 |
|
---|
291 | fTrackECalFractions.push_back(ecalFraction);
|
---|
292 | fTrackHCalFractions.push_back(hcalFraction);
|
---|
293 |
|
---|
294 | // find eta bin [1, fEtaBins.size - 1]
|
---|
295 | itEtaBin = lower_bound(fEtaBins.begin(), fEtaBins.end(), trackPosition.Eta());
|
---|
296 | if(itEtaBin == fEtaBins.begin() || itEtaBin == fEtaBins.end()) continue;
|
---|
297 | etaBin = distance(fEtaBins.begin(), itEtaBin);
|
---|
298 |
|
---|
299 | // phi bins for given eta bin
|
---|
300 | phiBins = fPhiBins[etaBin];
|
---|
301 |
|
---|
302 | // find phi bin [1, phiBins.size - 1]
|
---|
303 | itPhiBin = lower_bound(phiBins->begin(), phiBins->end(), trackPosition.Phi());
|
---|
304 | if(itPhiBin == phiBins->begin() || itPhiBin == phiBins->end()) continue;
|
---|
305 | phiBin = distance(phiBins->begin(), itPhiBin);
|
---|
306 |
|
---|
307 | flags = 1;
|
---|
308 |
|
---|
309 | // make tower hit {16-bits for eta bin number, 16-bits for phi bin number, 8-bits for flags, 24-bits for track number}
|
---|
310 | towerHit = (Long64_t(etaBin) << 48) | (Long64_t(phiBin) << 32) | (Long64_t(flags) << 24) | Long64_t(number);
|
---|
311 |
|
---|
312 | fTowerHits.push_back(towerHit);
|
---|
313 | }
|
---|
314 |
|
---|
315 | // all hits are sorted first by eta bin number, then by phi bin number,
|
---|
316 | // then by flags and then by particle or track number
|
---|
317 | sort(fTowerHits.begin(), fTowerHits.end());
|
---|
318 |
|
---|
319 | // loop over all hits
|
---|
320 | towerEtaPhi = 0;
|
---|
321 | fTower = 0;
|
---|
322 | for(itTowerHits = fTowerHits.begin(); itTowerHits != fTowerHits.end(); ++itTowerHits)
|
---|
323 | {
|
---|
324 | towerHit = (*itTowerHits);
|
---|
325 | flags = (towerHit >> 24) & 0x00000000000000FFLL;
|
---|
326 | number = (towerHit) & 0x0000000000FFFFFFLL;
|
---|
327 | hitEtaPhi = towerHit >> 32;
|
---|
328 |
|
---|
329 | if(towerEtaPhi != hitEtaPhi)
|
---|
330 | {
|
---|
331 | // switch to next tower
|
---|
332 | towerEtaPhi = hitEtaPhi;
|
---|
333 |
|
---|
334 | // finalize previous tower
|
---|
335 | FinalizeTower();
|
---|
336 |
|
---|
337 | // create new tower
|
---|
338 | fTower = factory->NewCandidate();
|
---|
339 |
|
---|
340 | phiBin = (towerHit >> 32) & 0x000000000000FFFFLL;
|
---|
341 | etaBin = (towerHit >> 48) & 0x000000000000FFFFLL;
|
---|
342 |
|
---|
343 | // phi bins for given eta bin
|
---|
344 | phiBins = fPhiBins[etaBin];
|
---|
345 |
|
---|
346 | // calculate eta and phi of the tower's center
|
---|
347 | fTowerEta = 0.5*(fEtaBins[etaBin - 1] + fEtaBins[etaBin]);
|
---|
348 | fTowerPhi = 0.5*((*phiBins)[phiBin - 1] + (*phiBins)[phiBin]);
|
---|
349 |
|
---|
350 | fTowerEdges[0] = fEtaBins[etaBin - 1];
|
---|
351 | fTowerEdges[1] = fEtaBins[etaBin];
|
---|
352 | fTowerEdges[2] = (*phiBins)[phiBin - 1];
|
---|
353 | fTowerEdges[3] = (*phiBins)[phiBin];
|
---|
354 |
|
---|
355 | fTowerECalEnergy = 0.0;
|
---|
356 | fTowerHCalEnergy = 0.0;
|
---|
357 |
|
---|
358 | fTrackECalEnergy = 0.0;
|
---|
359 | fTrackHCalEnergy = 0.0;
|
---|
360 |
|
---|
361 | fTowerECalTime = 0.0;
|
---|
362 | fTowerHCalTime = 0.0;
|
---|
363 |
|
---|
364 | fTrackECalTime = 0.0;
|
---|
365 | fTrackHCalTime = 0.0;
|
---|
366 |
|
---|
367 | fTowerECalWeightTime = 0.0;
|
---|
368 | fTowerHCalWeightTime = 0.0;
|
---|
369 |
|
---|
370 | fTowerTrackHits = 0;
|
---|
371 | fTowerPhotonHits = 0;
|
---|
372 |
|
---|
373 | fTowerTrackArray->Clear();
|
---|
374 | }
|
---|
375 |
|
---|
376 | // check for track hits
|
---|
377 | if(flags & 1)
|
---|
378 | {
|
---|
379 | ++fTowerTrackHits;
|
---|
380 |
|
---|
381 | track = static_cast<Candidate*>(fTrackInputArray->At(number));
|
---|
382 | momentum = track->Momentum;
|
---|
383 | position = track->Position;
|
---|
384 |
|
---|
385 |
|
---|
386 | ecalEnergy = momentum.E() * fTrackECalFractions[number];
|
---|
387 | hcalEnergy = momentum.E() * fTrackHCalFractions[number];
|
---|
388 |
|
---|
389 | fTrackECalEnergy += ecalEnergy;
|
---|
390 | fTrackHCalEnergy += hcalEnergy;
|
---|
391 |
|
---|
392 | fTrackECalTime += TMath::Sqrt(ecalEnergy)*position.T();
|
---|
393 | fTrackHCalTime += TMath::Sqrt(hcalEnergy)*position.T();
|
---|
394 |
|
---|
395 | fTrackECalWeightTime += TMath::Sqrt(ecalEnergy);
|
---|
396 | fTrackHCalWeightTime += TMath::Sqrt(hcalEnergy);
|
---|
397 |
|
---|
398 | fTowerTrackArray->Add(track);
|
---|
399 |
|
---|
400 | continue;
|
---|
401 | }
|
---|
402 |
|
---|
403 | // check for photon and electron hits in current tower
|
---|
404 | if(flags & 2) ++fTowerPhotonHits;
|
---|
405 |
|
---|
406 | particle = static_cast<Candidate*>(fParticleInputArray->At(number));
|
---|
407 | momentum = particle->Momentum;
|
---|
408 | position = particle->Position;
|
---|
409 |
|
---|
410 | // fill current tower
|
---|
411 | ecalEnergy = momentum.E() * fTowerECalFractions[number];
|
---|
412 | hcalEnergy = momentum.E() * fTowerHCalFractions[number];
|
---|
413 |
|
---|
414 | fTowerECalEnergy += ecalEnergy;
|
---|
415 | fTowerHCalEnergy += hcalEnergy;
|
---|
416 |
|
---|
417 | fTowerECalTime += TMath::Sqrt(ecalEnergy)*position.T();
|
---|
418 | fTowerHCalTime += TMath::Sqrt(hcalEnergy)*position.T();
|
---|
419 |
|
---|
420 | fTowerECalWeightTime += TMath::Sqrt(ecalEnergy);
|
---|
421 | fTowerHCalWeightTime += TMath::Sqrt(hcalEnergy);
|
---|
422 |
|
---|
423 |
|
---|
424 | fTower->AddCandidate(particle);
|
---|
425 | }
|
---|
426 |
|
---|
427 | // finalize last tower
|
---|
428 | FinalizeTower();
|
---|
429 | }
|
---|
430 |
|
---|
431 | //------------------------------------------------------------------------------
|
---|
432 |
|
---|
433 | void Calorimeter::FinalizeTower()
|
---|
434 | {
|
---|
435 | Candidate *track, *tower;
|
---|
436 | Double_t energy, pt, eta, phi;
|
---|
437 | Double_t ecalEnergy, hcalEnergy;
|
---|
438 | Double_t ecalSigma, hcalSigma;
|
---|
439 | Double_t ecalTime, hcalTime, time;
|
---|
440 |
|
---|
441 | if(!fTower) return;
|
---|
442 | // cout<<"----------------------"<<endl;
|
---|
443 | // cout<<"Finalize Tower"<<endl;
|
---|
444 | // cout<<""<<endl;
|
---|
445 |
|
---|
446 |
|
---|
447 | ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerECalEnergy);
|
---|
448 |
|
---|
449 | // ecalEnergy = gRandom->Gaus(fTowerECalEnergy, ecalSigma);
|
---|
450 | // if(ecalEnergy < 0.0) ecalEnergy = 0.0;
|
---|
451 |
|
---|
452 | ecalEnergy = LogNormal(fTowerECalEnergy, ecalSigma);
|
---|
453 | ecalTime = (fTowerECalWeightTime < 1.0E-09 ) ? 0 : fTowerECalTime/fTowerECalWeightTime;
|
---|
454 |
|
---|
455 | hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerHCalEnergy);
|
---|
456 |
|
---|
457 | // hcalEnergy = gRandom->Gaus(fTowerHCalEnergy, hcalSigma);
|
---|
458 | // if(hcalEnergy < 0.0) hcalEnergy = 0.0;
|
---|
459 |
|
---|
460 | hcalEnergy = LogNormal(fTowerHCalEnergy, hcalSigma);
|
---|
461 | hcalTime = (fTowerHCalWeightTime < 1.0E-09 ) ? 0 : fTowerHCalTime/fTowerHCalWeightTime;
|
---|
462 |
|
---|
463 |
|
---|
464 | ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, ecalEnergy);
|
---|
465 | hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, hcalEnergy);
|
---|
466 |
|
---|
467 | ecalEnergy = (ecalEnergy < fEcalEnergyMin || ecalEnergy < fEcalSigmaMin*ecalSigma) ? 0 : ecalEnergy;
|
---|
468 | hcalEnergy = (hcalEnergy < fHcalEnergyMin || hcalEnergy < fHcalSigmaMin*hcalSigma) ? 0 : hcalEnergy;
|
---|
469 |
|
---|
470 | energy = ecalEnergy + hcalEnergy;
|
---|
471 | time = (TMath::Sqrt(ecalEnergy)*ecalTime + TMath::Sqrt(hcalEnergy)*hcalTime)/(TMath::Sqrt(ecalEnergy) + TMath::Sqrt(hcalEnergy));
|
---|
472 |
|
---|
473 | if(fDitherTowerCenter)
|
---|
474 | {
|
---|
475 | eta = gRandom->Uniform(fTowerEdges[0], fTowerEdges[1]);
|
---|
476 | phi = gRandom->Uniform(fTowerEdges[2], fTowerEdges[3]);
|
---|
477 | }
|
---|
478 | else
|
---|
479 | {
|
---|
480 | eta = fTowerEta;
|
---|
481 | phi = fTowerPhi;
|
---|
482 | }
|
---|
483 |
|
---|
484 | pt = energy / TMath::CosH(eta);
|
---|
485 |
|
---|
486 | // fTower->Position.SetXYZT(-time, 0.0, 0.0, time);
|
---|
487 | fTower->Position.SetPtEtaPhiE(1.0, eta, phi, time);
|
---|
488 | fTower->Momentum.SetPtEtaPhiE(pt, eta, phi, energy);
|
---|
489 | fTower->Eem = ecalEnergy;
|
---|
490 | fTower->Ehad = hcalEnergy;
|
---|
491 |
|
---|
492 | fTower->Edges[0] = fTowerEdges[0];
|
---|
493 | fTower->Edges[1] = fTowerEdges[1];
|
---|
494 | fTower->Edges[2] = fTowerEdges[2];
|
---|
495 | fTower->Edges[3] = fTowerEdges[3];
|
---|
496 |
|
---|
497 | if( energy > 0.0 )
|
---|
498 | {
|
---|
499 | if(fTowerPhotonHits > 0 && fTowerTrackHits == 0)
|
---|
500 | {
|
---|
501 | fPhotonOutputArray->Add(fTower);
|
---|
502 | }
|
---|
503 |
|
---|
504 | fTowerOutputArray->Add(fTower);
|
---|
505 | }
|
---|
506 |
|
---|
507 | // fill energy flow candidates
|
---|
508 |
|
---|
509 | // save all the tracks as energy flow tracks
|
---|
510 | fItTowerTrackArray->Reset();
|
---|
511 | while((track = static_cast<Candidate*>(fItTowerTrackArray->Next())))
|
---|
512 | {
|
---|
513 | fEFlowTrackOutputArray->Add(track);
|
---|
514 | }
|
---|
515 |
|
---|
516 | ecalEnergy -= fTrackECalEnergy;
|
---|
517 | if(ecalEnergy < fEcalEnergyMin || ecalEnergy < fEcalSigmaMin*fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, ecalEnergy)) ecalEnergy = 0.0;
|
---|
518 |
|
---|
519 | hcalEnergy -= fTrackHCalEnergy;
|
---|
520 | if(hcalEnergy < fHcalEnergyMin || hcalEnergy < fHcalSigmaMin*fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, hcalEnergy)) hcalEnergy = 0.0;
|
---|
521 |
|
---|
522 | energy = ecalEnergy + hcalEnergy;
|
---|
523 |
|
---|
524 | if(ecalEnergy > 0.0)
|
---|
525 | {
|
---|
526 | // create new photon tower
|
---|
527 | tower = static_cast<Candidate*>(fTower->Clone());
|
---|
528 |
|
---|
529 | pt = ecalEnergy / TMath::CosH(eta);
|
---|
530 |
|
---|
531 | tower->Momentum.SetPtEtaPhiE(pt, eta, phi, ecalEnergy);
|
---|
532 | tower->Eem = ecalEnergy;
|
---|
533 | tower->Ehad = 0;
|
---|
534 |
|
---|
535 | fEFlowPhotonOutputArray->Add(tower);
|
---|
536 | }
|
---|
537 | if(hcalEnergy > 0.0)
|
---|
538 | {
|
---|
539 | // create new neutral hadron tower
|
---|
540 | tower = static_cast<Candidate*>(fTower->Clone());
|
---|
541 |
|
---|
542 | pt = hcalEnergy / TMath::CosH(eta);
|
---|
543 |
|
---|
544 | tower->Momentum.SetPtEtaPhiE(pt, eta, phi, hcalEnergy);
|
---|
545 | tower->Eem = 0;
|
---|
546 | tower->Ehad = hcalEnergy;
|
---|
547 |
|
---|
548 | fEFlowNeutralHadronOutputArray->Add(tower);
|
---|
549 | }
|
---|
550 |
|
---|
551 |
|
---|
552 |
|
---|
553 |
|
---|
554 | }
|
---|
555 |
|
---|
556 | //------------------------------------------------------------------------------
|
---|
557 |
|
---|
558 | Double_t Calorimeter::LogNormal(Double_t mean, Double_t sigma)
|
---|
559 | {
|
---|
560 | Double_t a, b;
|
---|
561 |
|
---|
562 | if(mean > 0.0)
|
---|
563 | {
|
---|
564 | b = TMath::Sqrt(TMath::Log((1.0 + (sigma*sigma)/(mean*mean))));
|
---|
565 | a = TMath::Log(mean) - 0.5*b*b;
|
---|
566 |
|
---|
567 | return TMath::Exp(a + b*gRandom->Gaus(0, 1));
|
---|
568 | }
|
---|
569 | else
|
---|
570 | {
|
---|
571 | return 0.0;
|
---|
572 | }
|
---|
573 | }
|
---|