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