Fork me on GitHub

source: git/modules/Calorimeter.cc@ 5e4c40d

ImprovedOutputFile Timing dual_readout llp
Last change on this file since 5e4c40d was 9da65a5, checked in by Pavel Demin <pavel.demin@…>, 9 years ago

fix ecalEnergy and hcalEnergy in Calorimeter

  • Property mode set to 100644
File size: 19.5 KB
RevLine 
[01f457a]1/*
2 * Delphes: a framework for fast simulation of a generic collider experiment
3 * Copyright (C) 2012-2014 Universite catholique de Louvain (UCL), Belgium
[1fa50c2]4 *
[01f457a]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.
[1fa50c2]9 *
[01f457a]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.
[1fa50c2]14 *
[01f457a]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
[d7d2da3]19
20/** \class Calorimeter
21 *
22 * Fills calorimeter towers, performs calorimeter resolution smearing,
[d4c4d9d]23 * and creates energy flow objects (tracks, photons, and neutral hadrons).
[d7d2da3]24 *
25 * \author P. Demin - UCL, Louvain-la-Neuve
26 *
27 */
28
29#include "modules/Calorimeter.h"
30
31#include "classes/DelphesClasses.h"
32#include "classes/DelphesFactory.h"
33#include "classes/DelphesFormula.h"
34
35#include "ExRootAnalysis/ExRootResult.h"
36#include "ExRootAnalysis/ExRootFilter.h"
37#include "ExRootAnalysis/ExRootClassifier.h"
38
39#include "TMath.h"
40#include "TString.h"
41#include "TFormula.h"
42#include "TRandom3.h"
43#include "TObjArray.h"
44#include "TDatabasePDG.h"
45#include "TLorentzVector.h"
46
47#include <algorithm>
48#include <stdexcept>
49#include <iostream>
50#include <sstream>
51
52using namespace std;
53
54//------------------------------------------------------------------------------
55
56Calorimeter::Calorimeter() :
[82575a3]57 fECalResolutionFormula(0), fHCalResolutionFormula(0),
[00e8dca]58 fItParticleInputArray(0), fItTrackInputArray(0)
[d7d2da3]59{
[00e8dca]60 Int_t i;
61
[82575a3]62 fECalResolutionFormula = new DelphesFormula;
63 fHCalResolutionFormula = new DelphesFormula;
64
[00e8dca]65 for(i = 0; i < 2; ++i)
66 {
67 fECalTowerTrackArray[i] = new TObjArray;
68 fItECalTowerTrackArray[i] = fECalTowerTrackArray[i]->MakeIterator();
69
70 fHCalTowerTrackArray[i] = new TObjArray;
71 fItHCalTowerTrackArray[i] = fHCalTowerTrackArray[i]->MakeIterator();
72 }
[d7d2da3]73}
74
75//------------------------------------------------------------------------------
76
77Calorimeter::~Calorimeter()
78{
[00e8dca]79 Int_t i;
80
[82575a3]81 if(fECalResolutionFormula) delete fECalResolutionFormula;
82 if(fHCalResolutionFormula) delete fHCalResolutionFormula;
83
[00e8dca]84 for(i = 0; i < 2; ++i)
85 {
86 if(fECalTowerTrackArray[i]) delete fECalTowerTrackArray[i];
87 if(fItECalTowerTrackArray[i]) delete fItECalTowerTrackArray[i];
88
89 if(fHCalTowerTrackArray[i]) delete fHCalTowerTrackArray[i];
90 if(fItHCalTowerTrackArray[i]) delete fItHCalTowerTrackArray[i];
91 }
[2dab783]92}
[d7d2da3]93
94//------------------------------------------------------------------------------
95
96void Calorimeter::Init()
97{
98 ExRootConfParam param, paramEtaBins, paramPhiBins, paramFractions;
[a221d1f]99 Long_t i, j, k, size, sizeEtaBins, sizePhiBins;
[82575a3]100 Double_t ecalFraction, hcalFraction;
[d7d2da3]101 TBinMap::iterator itEtaBin;
102 set< Double_t >::iterator itPhiBin;
103 vector< Double_t > *phiBins;
104
105 // read eta and phi bins
106 param = GetParam("EtaPhiBins");
107 size = param.GetSize();
108 fBinMap.clear();
109 fEtaBins.clear();
110 fPhiBins.clear();
111 for(i = 0; i < size/2; ++i)
112 {
113 paramEtaBins = param[i*2];
114 sizeEtaBins = paramEtaBins.GetSize();
115 paramPhiBins = param[i*2 + 1];
116 sizePhiBins = paramPhiBins.GetSize();
117
118 for(j = 0; j < sizeEtaBins; ++j)
119 {
120 for(k = 0; k < sizePhiBins; ++k)
121 {
122 fBinMap[paramEtaBins[j].GetDouble()].insert(paramPhiBins[k].GetDouble());
123 }
124 }
125 }
126
127 // for better performance we transform map of sets to parallel vectors:
128 // vector< double > and vector< vector< double >* >
129 for(itEtaBin = fBinMap.begin(); itEtaBin != fBinMap.end(); ++itEtaBin)
130 {
131 fEtaBins.push_back(itEtaBin->first);
132 phiBins = new vector< double >(itEtaBin->second.size());
133 fPhiBins.push_back(phiBins);
134 phiBins->clear();
135 for(itPhiBin = itEtaBin->second.begin(); itPhiBin != itEtaBin->second.end(); ++itPhiBin)
136 {
137 phiBins->push_back(*itPhiBin);
138 }
139 }
140
141 // read energy fractions for different particles
142 param = GetParam("EnergyFraction");
143 size = param.GetSize();
144
145 // set default energy fractions values
146 fFractionMap.clear();
[82575a3]147 fFractionMap[0] = make_pair(0.0, 1.0);
[d7d2da3]148
149 for(i = 0; i < size/2; ++i)
150 {
151 paramFractions = param[i*2 + 1];
[82575a3]152
153 ecalFraction = paramFractions[0].GetDouble();
154 hcalFraction = paramFractions[1].GetDouble();
155
156 fFractionMap[param[i*2].GetInt()] = make_pair(ecalFraction, hcalFraction);
[d7d2da3]157 }
[8624f58]158
[3db5282]159 // read min E value for timing measurement in ECAL
[839deb7]160 fTimingEnergyMin = GetDouble("TimingEnergyMin",4.);
[3db5282]161 // For timing
162 // So far this flag needs to be false
163 // Curved extrapolation not supported
164 fElectronsFromTrack = false;
165
[4b9a2dc]166 // read min E value for towers to be saved
[38bf1ae]167 fECalEnergyMin = GetDouble("ECalEnergyMin", 0.0);
168 fHCalEnergyMin = GetDouble("HCalEnergyMin", 0.0);
[a221d1f]169
[38bf1ae]170 fECalEnergySignificanceMin = GetDouble("ECalEnergySignificanceMin", 0.0);
171 fHCalEnergySignificanceMin = GetDouble("HCalEnergySignificanceMin", 0.0);
[a221d1f]172
[8624f58]173 // switch on or off the dithering of the center of calorimeter towers
[4e09c3a]174 fSmearTowerCenter = GetBool("SmearTowerCenter", true);
[4b9a2dc]175
[d7d2da3]176 // read resolution formulas
[82575a3]177 fECalResolutionFormula->Compile(GetString("ECalResolutionFormula", "0"));
178 fHCalResolutionFormula->Compile(GetString("HCalResolutionFormula", "0"));
179
[d7d2da3]180 // import array with output from other modules
181 fParticleInputArray = ImportArray(GetString("ParticleInputArray", "ParticlePropagator/particles"));
182 fItParticleInputArray = fParticleInputArray->MakeIterator();
183
184 fTrackInputArray = ImportArray(GetString("TrackInputArray", "ParticlePropagator/tracks"));
185 fItTrackInputArray = fTrackInputArray->MakeIterator();
186
187 // create output arrays
188 fTowerOutputArray = ExportArray(GetString("TowerOutputArray", "towers"));
[82575a3]189 fPhotonOutputArray = ExportArray(GetString("PhotonOutputArray", "photons"));
[a221d1f]190
[82575a3]191 fEFlowTrackOutputArray = ExportArray(GetString("EFlowTrackOutputArray", "eflowTracks"));
192 fEFlowPhotonOutputArray = ExportArray(GetString("EFlowPhotonOutputArray", "eflowPhotons"));
193 fEFlowNeutralHadronOutputArray = ExportArray(GetString("EFlowNeutralHadronOutputArray", "eflowNeutralHadrons"));
[d7d2da3]194}
195
196//------------------------------------------------------------------------------
197
198void Calorimeter::Finish()
199{
[2dab783]200 vector< vector< Double_t >* >::iterator itPhiBin;
[d7d2da3]201 if(fItParticleInputArray) delete fItParticleInputArray;
202 if(fItTrackInputArray) delete fItTrackInputArray;
203 for(itPhiBin = fPhiBins.begin(); itPhiBin != fPhiBins.end(); ++itPhiBin)
204 {
205 delete *itPhiBin;
206 }
207}
208
209//------------------------------------------------------------------------------
210
211void Calorimeter::Process()
212{
213 Candidate *particle, *track;
214 TLorentzVector position, momentum;
215 Short_t etaBin, phiBin, flags;
216 Int_t number;
217 Long64_t towerHit, towerEtaPhi, hitEtaPhi;
[82575a3]218 Double_t ecalFraction, hcalFraction;
219 Double_t ecalEnergy, hcalEnergy;
[00e8dca]220 Double_t ecalSigma, hcalSigma;
[d7d2da3]221 Int_t pdgCode;
222
223 TFractionMap::iterator itFractionMap;
224
225 vector< Double_t >::iterator itEtaBin;
226 vector< Double_t >::iterator itPhiBin;
227 vector< Double_t > *phiBins;
228
229 vector< Long64_t >::iterator itTowerHits;
230
231 DelphesFactory *factory = GetFactory();
232 fTowerHits.clear();
[00e8dca]233 fECalTowerFractions.clear();
234 fHCalTowerFractions.clear();
235 fECalTrackFractions.clear();
236 fHCalTrackFractions.clear();
[82575a3]237
[d7d2da3]238 // loop over all particles
239 fItParticleInputArray->Reset();
240 number = -1;
241 while((particle = static_cast<Candidate*>(fItParticleInputArray->Next())))
242 {
243 const TLorentzVector &particlePosition = particle->Position;
244 ++number;
245
246 pdgCode = TMath::Abs(particle->PID);
247
248 itFractionMap = fFractionMap.find(pdgCode);
249 if(itFractionMap == fFractionMap.end())
250 {
251 itFractionMap = fFractionMap.find(0);
252 }
253
[82575a3]254 ecalFraction = itFractionMap->second.first;
255 hcalFraction = itFractionMap->second.second;
256
[00e8dca]257 fECalTowerFractions.push_back(ecalFraction);
258 fHCalTowerFractions.push_back(hcalFraction);
[82575a3]259
260 if(ecalFraction < 1.0E-9 && hcalFraction < 1.0E-9) continue;
[d7d2da3]261
262 // find eta bin [1, fEtaBins.size - 1]
263 itEtaBin = lower_bound(fEtaBins.begin(), fEtaBins.end(), particlePosition.Eta());
264 if(itEtaBin == fEtaBins.begin() || itEtaBin == fEtaBins.end()) continue;
265 etaBin = distance(fEtaBins.begin(), itEtaBin);
266
267 // phi bins for given eta bin
268 phiBins = fPhiBins[etaBin];
269
270 // find phi bin [1, phiBins.size - 1]
271 itPhiBin = lower_bound(phiBins->begin(), phiBins->end(), particlePosition.Phi());
272 if(itPhiBin == phiBins->begin() || itPhiBin == phiBins->end()) continue;
273 phiBin = distance(phiBins->begin(), itPhiBin);
274
[73e0386]275 flags = 0;
[2dab783]276 flags |= (pdgCode == 11 || pdgCode == 22) << 1;
[d7d2da3]277
278 // make tower hit {16-bits for eta bin number, 16-bits for phi bin number, 8-bits for flags, 24-bits for particle number}
279 towerHit = (Long64_t(etaBin) << 48) | (Long64_t(phiBin) << 32) | (Long64_t(flags) << 24) | Long64_t(number);
280
281 fTowerHits.push_back(towerHit);
282 }
283
284 // loop over all tracks
285 fItTrackInputArray->Reset();
286 number = -1;
287 while((track = static_cast<Candidate*>(fItTrackInputArray->Next())))
288 {
289 const TLorentzVector &trackPosition = track->Position;
290 ++number;
291
[73e0386]292 pdgCode = TMath::Abs(track->PID);
293
294 itFractionMap = fFractionMap.find(pdgCode);
295 if(itFractionMap == fFractionMap.end())
296 {
297 itFractionMap = fFractionMap.find(0);
298 }
299
[82575a3]300 ecalFraction = itFractionMap->second.first;
301 hcalFraction = itFractionMap->second.second;
302
[00e8dca]303 fECalTrackFractions.push_back(ecalFraction);
304 fHCalTrackFractions.push_back(hcalFraction);
[82575a3]305
[d7d2da3]306 // find eta bin [1, fEtaBins.size - 1]
307 itEtaBin = lower_bound(fEtaBins.begin(), fEtaBins.end(), trackPosition.Eta());
308 if(itEtaBin == fEtaBins.begin() || itEtaBin == fEtaBins.end()) continue;
309 etaBin = distance(fEtaBins.begin(), itEtaBin);
310
311 // phi bins for given eta bin
312 phiBins = fPhiBins[etaBin];
313
314 // find phi bin [1, phiBins.size - 1]
315 itPhiBin = lower_bound(phiBins->begin(), phiBins->end(), trackPosition.Phi());
316 if(itPhiBin == phiBins->begin() || itPhiBin == phiBins->end()) continue;
317 phiBin = distance(phiBins->begin(), itPhiBin);
318
[73e0386]319 flags = 1;
320
[d7d2da3]321 // make tower hit {16-bits for eta bin number, 16-bits for phi bin number, 8-bits for flags, 24-bits for track number}
[73e0386]322 towerHit = (Long64_t(etaBin) << 48) | (Long64_t(phiBin) << 32) | (Long64_t(flags) << 24) | Long64_t(number);
[d7d2da3]323
324 fTowerHits.push_back(towerHit);
325 }
326
327 // all hits are sorted first by eta bin number, then by phi bin number,
328 // then by flags and then by particle or track number
329 sort(fTowerHits.begin(), fTowerHits.end());
330
331 // loop over all hits
332 towerEtaPhi = 0;
333 fTower = 0;
334 for(itTowerHits = fTowerHits.begin(); itTowerHits != fTowerHits.end(); ++itTowerHits)
335 {
336 towerHit = (*itTowerHits);
337 flags = (towerHit >> 24) & 0x00000000000000FFLL;
338 number = (towerHit) & 0x0000000000FFFFFFLL;
339 hitEtaPhi = towerHit >> 32;
340
341 if(towerEtaPhi != hitEtaPhi)
342 {
343 // switch to next tower
344 towerEtaPhi = hitEtaPhi;
345
346 // finalize previous tower
347 FinalizeTower();
348
349 // create new tower
350 fTower = factory->NewCandidate();
351
352 phiBin = (towerHit >> 32) & 0x000000000000FFFFLL;
353 etaBin = (towerHit >> 48) & 0x000000000000FFFFLL;
354
355 // phi bins for given eta bin
356 phiBins = fPhiBins[etaBin];
357
358 // calculate eta and phi of the tower's center
359 fTowerEta = 0.5*(fEtaBins[etaBin - 1] + fEtaBins[etaBin]);
360 fTowerPhi = 0.5*((*phiBins)[phiBin - 1] + (*phiBins)[phiBin]);
361
362 fTowerEdges[0] = fEtaBins[etaBin - 1];
363 fTowerEdges[1] = fEtaBins[etaBin];
364 fTowerEdges[2] = (*phiBins)[phiBin - 1];
365 fTowerEdges[3] = (*phiBins)[phiBin];
366
[00e8dca]367 fECalTowerEnergy = 0.0;
368 fHCalTowerEnergy = 0.0;
369
370 fECalTrackEnergy[0] = 0.0;
371 fECalTrackEnergy[1] = 0.0;
[82575a3]372
[00e8dca]373 fHCalTrackEnergy[0] = 0.0;
374 fHCalTrackEnergy[1] = 0.0;
[82575a3]375
[2dab783]376 fTowerTrackHits = 0;
377 fTowerPhotonHits = 0;
[a221d1f]378
[00e8dca]379 fECalTowerTrackArray[0]->Clear();
380 fECalTowerTrackArray[1]->Clear();
381
382 fHCalTowerTrackArray[0]->Clear();
383 fHCalTowerTrackArray[1]->Clear();
[d7d2da3]384 }
385
386 // check for track hits
[73e0386]387 if(flags & 1)
[d7d2da3]388 {
[2dab783]389 ++fTowerTrackHits;
[73e0386]390
[2dab783]391 track = static_cast<Candidate*>(fTrackInputArray->At(number));
392 momentum = track->Momentum;
[22dc7fd]393 position = track->Position;
[82575a3]394
[00e8dca]395 ecalEnergy = momentum.E() * fECalTrackFractions[number];
396 hcalEnergy = momentum.E() * fHCalTrackFractions[number];
[a221d1f]397
[839deb7]398 if(ecalEnergy > fTimingEnergyMin && fTower)
399 {
400 if(fElectronsFromTrack)
401 {
402 fTower->ECalEnergyTimePairs.push_back(make_pair<Float_t, Float_t>(ecalEnergy, track->Position.T()));
403 }
[3db5282]404 }
[a221d1f]405
[9da65a5]406 if(fECalTrackFractions[number] > 1.0E-9 && fHCalTrackFractions[number] < 1.0E-9)
[00e8dca]407 {
408 ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, momentum.E());
409 if(ecalSigma/momentum.E() < track->TrackResolution)
410 {
411 fECalTrackEnergy[0] += ecalEnergy;
412 fECalTowerTrackArray[0]->Add(track);
413 }
414 else
415 {
416 fECalTrackEnergy[1] += ecalEnergy;
417 fECalTowerTrackArray[1]->Add(track);
418 }
419 }
[9da65a5]420 else if(fECalTrackFractions[number] < 1.0E-9 && fHCalTrackFractions[number] > 1.0E-9)
[00e8dca]421 {
422 hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, momentum.E());
423 if(hcalSigma/momentum.E() < track->TrackResolution)
424 {
425 fHCalTrackEnergy[0] += hcalEnergy;
426 fHCalTowerTrackArray[0]->Add(track);
427 }
428 else
429 {
430 fHCalTrackEnergy[1] += hcalEnergy;
431 fHCalTowerTrackArray[1]->Add(track);
432 }
433 }
[9da65a5]434 else if(fECalTrackFractions[number] < 1.0E-9 && fHCalTrackFractions[number] < 1.0E-9)
435 {
436 fEFlowTrackOutputArray->Add(track);
437 }
[73e0386]438
[2dab783]439 continue;
[73e0386]440 }
[839deb7]441
[73e0386]442 // check for photon and electron hits in current tower
[2dab783]443 if(flags & 2) ++fTowerPhotonHits;
[a221d1f]444
[d7d2da3]445 particle = static_cast<Candidate*>(fParticleInputArray->At(number));
446 momentum = particle->Momentum;
[22dc7fd]447 position = particle->Position;
[d7d2da3]448
449 // fill current tower
[00e8dca]450 ecalEnergy = momentum.E() * fECalTowerFractions[number];
451 hcalEnergy = momentum.E() * fHCalTowerFractions[number];
[82575a3]452
[00e8dca]453 fECalTowerEnergy += ecalEnergy;
454 fHCalTowerEnergy += hcalEnergy;
[82575a3]455
[839deb7]456 if(ecalEnergy > fTimingEnergyMin && fTower)
457 {
458 if (abs(particle->PID) != 11 || !fElectronsFromTrack)
459 {
460 fTower->ECalEnergyTimePairs.push_back(make_pair<Float_t, Float_t>(ecalEnergy, particle->Position.T()));
[3db5282]461 }
462 }
[82575a3]463
[3079350]464 fTower->AddCandidate(particle);
[d7d2da3]465 }
466
467 // finalize last tower
468 FinalizeTower();
469}
470
471//------------------------------------------------------------------------------
472
473void Calorimeter::FinalizeTower()
474{
[e2dd4c5]475 Candidate *track, *tower, *mother;
[d7d2da3]476 Double_t energy, pt, eta, phi;
[82575a3]477 Double_t ecalEnergy, hcalEnergy;
478 Double_t ecalSigma, hcalSigma;
[e2dd4c5]479
[a98c7ef]480 TLorentzVector momentum;
481 TFractionMap::iterator itFractionMap;
[e2dd4c5]482
[839deb7]483 Float_t weight, sumWeightedTime, sumWeight;
484
[d7d2da3]485 if(!fTower) return;
486
[e2dd4c5]487
[00e8dca]488 ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fECalTowerEnergy);
489 hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fHCalTowerEnergy);
[4600a41]490
[00e8dca]491 ecalEnergy = LogNormal(fECalTowerEnergy, ecalSigma);
492 hcalEnergy = LogNormal(fHCalTowerEnergy, hcalSigma);
[82575a3]493
[4b9a2dc]494 ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, ecalEnergy);
495 hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, hcalEnergy);
496
[38bf1ae]497 if(ecalEnergy < fECalEnergyMin || ecalEnergy < fECalEnergySignificanceMin*ecalSigma) ecalEnergy = 0.0;
498 if(hcalEnergy < fHCalEnergyMin || hcalEnergy < fHCalEnergySignificanceMin*hcalSigma) hcalEnergy = 0.0;
[4b9a2dc]499
[82575a3]500 energy = ecalEnergy + hcalEnergy;
[839deb7]501
[4e09c3a]502 if(fSmearTowerCenter)
[a221d1f]503 {
[38bf1ae]504 eta = gRandom->Uniform(fTowerEdges[0], fTowerEdges[1]);
505 phi = gRandom->Uniform(fTowerEdges[2], fTowerEdges[3]);
[a221d1f]506 }
507 else
508 {
[38bf1ae]509 eta = fTowerEta;
510 phi = fTowerPhi;
[a221d1f]511 }
[d7d2da3]512
513 pt = energy / TMath::CosH(eta);
514
[3db5282]515 // Time calculation for tower
[839deb7]516 fTower->NTimeHits = 0;
517 sumWeightedTime = 0.0;
518 sumWeight = 0.0;
519
520 for(size_t i = 0; i < fTower->ECalEnergyTimePairs.size(); ++i)
[3db5282]521 {
[839deb7]522 weight = TMath::Sqrt(fTower->ECalEnergyTimePairs[i].first);
523 sumWeightedTime += weight * fTower->ECalEnergyTimePairs[i].second;
524 sumWeight += weight;
525 fTower->NTimeHits++;
[3db5282]526 }
[839deb7]527
528 if(sumWeight > 0.0)
529 {
530 fTower->Position.SetPtEtaPhiE(1.0, eta, phi, sumWeightedTime/sumWeight);
531 }
532 else
533 {
534 fTower->Position.SetPtEtaPhiE(1.0, eta, phi, 999999.9);
[3db5282]535 }
536
537
[d7d2da3]538 fTower->Momentum.SetPtEtaPhiE(pt, eta, phi, energy);
[82575a3]539 fTower->Eem = ecalEnergy;
540 fTower->Ehad = hcalEnergy;
541
[d7d2da3]542 fTower->Edges[0] = fTowerEdges[0];
543 fTower->Edges[1] = fTowerEdges[1];
544 fTower->Edges[2] = fTowerEdges[2];
545 fTower->Edges[3] = fTowerEdges[3];
546
[38bf1ae]547 if(energy > 0.0)
[82575a3]548 {
549 if(fTowerPhotonHits > 0 && fTowerTrackHits == 0)
550 {
551 fPhotonOutputArray->Add(fTower);
552 }
[a221d1f]553
[82575a3]554 fTowerOutputArray->Add(fTower);
555 }
[0d5f77c]556
[f6b9fec]557 // fill energy flow candidates
[82575a3]558
[00e8dca]559 ecalEnergy -= fECalTrackEnergy[1];
560 hcalEnergy -= fHCalTrackEnergy[1];
[e2dd4c5]561
[00e8dca]562 fItECalTowerTrackArray[0]->Reset();
563 while((track = static_cast<Candidate*>(fItECalTowerTrackArray[0]->Next())))
[e2dd4c5]564 {
[00e8dca]565 mother = track;
566 track = static_cast<Candidate*>(track->Clone());
567 track->AddCandidate(mother);
[e2dd4c5]568
[00e8dca]569 track->Momentum *= ecalEnergy/fECalTrackEnergy[0];
[e2dd4c5]570
[00e8dca]571 fEFlowTrackOutputArray->Add(track);
572 }
[e2dd4c5]573
[00e8dca]574 fItECalTowerTrackArray[1]->Reset();
575 while((track = static_cast<Candidate*>(fItECalTowerTrackArray[1]->Next())))
576 {
[e2dd4c5]577 mother = track;
578 track = static_cast<Candidate*>(track->Clone());
579 track->AddCandidate(mother);
580
[00e8dca]581 fEFlowTrackOutputArray->Add(track);
582 }
583
584 fItHCalTowerTrackArray[0]->Reset();
585 while((track = static_cast<Candidate*>(fItHCalTowerTrackArray[0]->Next())))
586 {
587 mother = track;
588 track = static_cast<Candidate*>(track->Clone());
589 track->AddCandidate(mother);
590
[cdeea24]591 track->Momentum *= hcalEnergy/fHCalTrackEnergy[0];
[e2dd4c5]592
593 fEFlowTrackOutputArray->Add(track);
[82575a3]594 }
595
[00e8dca]596 fItHCalTowerTrackArray[1]->Reset();
597 while((track = static_cast<Candidate*>(fItHCalTowerTrackArray[1]->Next())))
598 {
599 mother = track;
600 track = static_cast<Candidate*>(track->Clone());
601 track->AddCandidate(mother);
602
603 fEFlowTrackOutputArray->Add(track);
604 }
[e2dd4c5]605
[9da65a5]606 if(fECalTowerTrackArray[0]->GetEntriesFast() > 0) ecalEnergy = 0.0;
607 if(fHCalTowerTrackArray[0]->GetEntriesFast() > 0) hcalEnergy = 0.0;
608
[38bf1ae]609 ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, ecalEnergy);
610 hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, hcalEnergy);
611
612 if(ecalEnergy < fECalEnergyMin || ecalEnergy < fECalEnergySignificanceMin*ecalSigma) ecalEnergy = 0.0;
613 if(hcalEnergy < fHCalEnergyMin || hcalEnergy < fHCalEnergySignificanceMin*hcalSigma) hcalEnergy = 0.0;
[82575a3]614
615 energy = ecalEnergy + hcalEnergy;
616
617 if(ecalEnergy > 0.0)
[2dab783]618 {
[d4c4d9d]619 // create new photon tower
[2dab783]620 tower = static_cast<Candidate*>(fTower->Clone());
[0d5f77c]621
[82575a3]622 pt = ecalEnergy / TMath::CosH(eta);
623
624 tower->Momentum.SetPtEtaPhiE(pt, eta, phi, ecalEnergy);
625 tower->Eem = ecalEnergy;
[38bf1ae]626 tower->Ehad = 0.0;
[82575a3]627
628 fEFlowPhotonOutputArray->Add(tower);
629 }
630 if(hcalEnergy > 0.0)
631 {
632 // create new neutral hadron tower
633 tower = static_cast<Candidate*>(fTower->Clone());
634
635 pt = hcalEnergy / TMath::CosH(eta);
636
637 tower->Momentum.SetPtEtaPhiE(pt, eta, phi, hcalEnergy);
[38bf1ae]638 tower->Eem = 0.0;
[82575a3]639 tower->Ehad = hcalEnergy;
640
641 fEFlowNeutralHadronOutputArray->Add(tower);
[d7d2da3]642 }
643}
644
645//------------------------------------------------------------------------------
[39022b6]646
[4600a41]647Double_t Calorimeter::LogNormal(Double_t mean, Double_t sigma)
648{
649 Double_t a, b;
650
651 if(mean > 0.0)
[39022b6]652 {
[4600a41]653 b = TMath::Sqrt(TMath::Log((1.0 + (sigma*sigma)/(mean*mean))));
654 a = TMath::Log(mean) - 0.5*b*b;
655
[38bf1ae]656 return TMath::Exp(a + b*gRandom->Gaus(0.0, 1.0));
[39022b6]657 }
[4600a41]658 else
659 {
660 return 0.0;
661 }
662}
Note: See TracBrowser for help on using the repository browser.