[264] | 1 | #ifndef _CALOUTIL_H_
|
---|
| 2 | #define _CALOUTIL_H_
|
---|
| 3 |
|
---|
| 4 | /*
|
---|
| 5 | ---- Delphes ----
|
---|
| 6 | A Fast Simulator for general purpose LHC detector
|
---|
| 7 | S. Ovyn ~~~~ severine.ovyn@uclouvain.be
|
---|
| 8 |
|
---|
| 9 | Center for Particle Physics and Phenomenology (CP3)
|
---|
| 10 | Universite Catholique de Louvain (UCL)
|
---|
| 11 | Louvain-la-Neuve, Belgium
|
---|
| 12 | */
|
---|
| 13 |
|
---|
| 14 | /// \file D_CaloUtil.h
|
---|
| 15 | /// \brief D_CaloElement, D_CaloResolution and D_CaloList classes
|
---|
| 16 |
|
---|
| 17 | #include <iostream>
|
---|
| 18 | #include <vector>
|
---|
| 19 | #include <string>
|
---|
| 20 | #include <cmath>
|
---|
| 21 | #include "D_Constants.h"
|
---|
| 22 | using namespace std;
|
---|
| 23 |
|
---|
| 24 |
|
---|
| 25 | class D_CaloResolution {
|
---|
| 26 | public:
|
---|
| 27 | D_CaloResolution(const float cterm, const float nterm, const float sterm) : _c(cterm), _n(nterm), _s(sterm) {};
|
---|
| 28 | D_CaloResolution(const D_CaloResolution& resolution) : _c(resolution._c), _n(resolution._n), _s(resolution._s) {};
|
---|
| 29 | D_CaloResolution& operator=(const D_CaloResolution& resolution);
|
---|
| 30 | const float getC() const {return _c;}
|
---|
| 31 | const float getN() const {return _n;}
|
---|
| 32 | const float getS() const {return _s;}
|
---|
| 33 | const float Smear(const float energy) const;
|
---|
| 34 | void print() const;
|
---|
| 35 | private:
|
---|
| 36 | float _c, _n, _s;
|
---|
| 37 | };
|
---|
| 38 |
|
---|
| 39 |
|
---|
| 40 |
|
---|
| 41 | class D_CaloElement {
|
---|
| 42 | public:
|
---|
| 43 | D_CaloElement(const string& name, const float etamin, const float etamax, const float c_em, const float n_em, const float s_em, const float c_had, const float n_had, const float s_had) : _name(name), _etamin(min(etamin,etamax)), _etamax(max(etamin,etamax)), _resol_em(c_em,n_em,s_em), _resol_had(c_had,n_had,s_had) {};
|
---|
| 44 | D_CaloElement(const D_CaloElement& calo) : _name(calo._name), _etamin(calo._etamin), _etamax(calo._etamax), _resol_em(calo._resol_em), _resol_had(calo._resol_had) {};
|
---|
| 45 | D_CaloElement& operator=(const D_CaloElement& calo);
|
---|
| 46 | const D_CaloResolution& getElectromagneticResolution() const {return _resol_em;}
|
---|
| 47 | const D_CaloResolution& getHadronicResolution() const {return _resol_had;}
|
---|
| 48 | const string& getName() const {return _name;}
|
---|
| 49 | const float getEtamin() const {return _etamin;}
|
---|
| 50 | const float getEtamax() const {return _etamax;}
|
---|
| 51 | /// Ordering operator acting on eta
|
---|
| 52 | inline const bool operator>(const D_CaloElement& tocomp) const {if(_etamin > tocomp._etamin) { return true; } else { return false; }};
|
---|
| 53 | /// Ordering operator acting on eta
|
---|
| 54 | inline const bool operator<(const D_CaloElement& tocomp) const {if(_etamin < tocomp._etamin) { return true; } else { return false; }};
|
---|
| 55 |
|
---|
| 56 | private:
|
---|
| 57 | string _name;
|
---|
| 58 | float _etamin, _etamax;
|
---|
| 59 | D_CaloResolution _resol_em;
|
---|
| 60 | D_CaloResolution _resol_had;
|
---|
| 61 | };
|
---|
| 62 |
|
---|
| 63 |
|
---|
| 64 |
|
---|
| 65 | class D_CaloList {
|
---|
| 66 | public:
|
---|
| 67 | D_CaloList() : _calorimeters(), _etamin(UNDEFINED), _etamax(UNDEFINED), _sorted(false) {};
|
---|
| 68 | D_CaloList(const D_CaloList& list) :
|
---|
| 69 | _calorimeters(list._calorimeters), _etamin(list._etamin), _etamax(list._etamax), _sorted(list._sorted) {};
|
---|
| 70 | D_CaloList& operator=(const D_CaloList& list);
|
---|
| 71 | const D_CaloElement& getElement(const float eta) const; // returns the pointer to the calorimeter lying in eta
|
---|
| 72 | void addElement(const D_CaloElement & calo);
|
---|
| 73 | void sortElements(); // sorts the list with respect to the eta
|
---|
| 74 | const float getEtamax() {if(!_sorted) sortElements(); return _etamax;}
|
---|
| 75 | const float getEtamin() {if(!_sorted) sortElements(); return _etamin;}
|
---|
| 76 | void print() const;
|
---|
| 77 | private:
|
---|
| 78 | vector<D_CaloElement> _calorimeters;
|
---|
| 79 | float _etamin;
|
---|
| 80 | float _etamax;
|
---|
| 81 | bool _sorted;
|
---|
| 82 | struct ordering{ bool operator()(const D_CaloElement& el1, const D_CaloElement& el2) const { return (el1 < el2);}};
|
---|
| 83 | };
|
---|
| 84 |
|
---|
| 85 | const D_CaloElement dummyCalo("not found calo",UNDEFINED,UNDEFINED+1,1,0,0,1,0,0);
|
---|
| 86 |
|
---|
| 87 |
|
---|
| 88 |
|
---|
| 89 | class D_CaloTower {
|
---|
| 90 | public:
|
---|
| 91 | //D_CaloTower(); risk that _eta and _phi not initialised before using Set_Eem_Ehad_E_ET!
|
---|
| 92 | D_CaloTower(const float iEta, const float iPhi);
|
---|
| 93 | D_CaloTower(const D_CaloTower& tower);
|
---|
| 94 | D_CaloTower& operator=(const D_CaloTower& tower);
|
---|
| 95 | void Set_Eta_Phi(const float iEta, const float iPhi) {_eta=iEta; _phi=iPhi;}
|
---|
| 96 | void Set_Eem_Ehad_E_ET(const float eem, const float ehad) { _Eem = eem ; _Ehad = ehad; _E = _Eem + _Ehad; _ET = _E/cosh(_eta);}
|
---|
| 97 | const float getEta() const {return _eta;}
|
---|
| 98 | const float getPhi() const {return _phi;}
|
---|
| 99 | const float getE() const {return _E;}
|
---|
| 100 | const float getET() const {return _ET;}
|
---|
| 101 | const float getEem() const {return _Eem;}
|
---|
| 102 | const float getEhad() const {return _Ehad;}
|
---|
| 103 | /// Ordering operator acting on eta
|
---|
| 104 | const bool operator>(const D_CaloTower& tocomp) const;
|
---|
| 105 | /// Ordering operator acting on eta
|
---|
| 106 | const bool operator<(const D_CaloTower& tocomp) const;
|
---|
| 107 | /// Egality testing if eta/phi are equal
|
---|
| 108 | const bool operator==(const D_CaloTower& el) const;
|
---|
| 109 |
|
---|
| 110 | private:
|
---|
| 111 | float _eta, _phi; // segmented eta, phi
|
---|
| 112 | float _Eem, _Ehad; // electromagnetic and hadronic components of the tower energy
|
---|
| 113 | float _E, _ET; // total tower energy and transverse energy
|
---|
| 114 | };
|
---|
| 115 |
|
---|
| 116 | const D_CaloTower dummyTower(UNDEFINED,UNDEFINED);
|
---|
| 117 |
|
---|
| 118 |
|
---|
| 119 |
|
---|
| 120 | class D_CaloTowerList {
|
---|
| 121 | public:
|
---|
| 122 | D_CaloTowerList() : _calotowers(), _sorted(true), _merged(true) {}
|
---|
| 123 | D_CaloTowerList(const D_CaloTowerList& list) : _calotowers(list._calotowers), _sorted(list._sorted), _merged(list._merged) {}
|
---|
| 124 | D_CaloTowerList& operator=(const D_CaloTowerList& list);
|
---|
| 125 | D_CaloTower& operator[](const unsigned int i) {return _calotowers[i];}
|
---|
| 126 | const D_CaloTower& getElement(const float eta, const float phi) ;
|
---|
| 127 | void addTower(const D_CaloTower& tower);
|
---|
| 128 | // sorts the elements with respect to their eta
|
---|
| 129 | void sortElements();
|
---|
| 130 | // merges the CaloTowers with the same eta and the same phi
|
---|
| 131 | void mergeDuplicates();
|
---|
| 132 | void smearTowers(const D_CaloList& list_of_calorimeters);
|
---|
| 133 | void print() const;
|
---|
| 134 | const unsigned int size() const {return _calotowers.size();}
|
---|
| 135 | //void pop_back() {_calotowers.pop_back();}
|
---|
| 136 | private:
|
---|
| 137 | vector<D_CaloTower> _calotowers;
|
---|
| 138 | bool _sorted;
|
---|
| 139 | bool _merged;
|
---|
| 140 | struct ordering{ bool operator()(const D_CaloTower& el1, const D_CaloTower& el2) const { return (el1 < el2); }};
|
---|
| 141 | };
|
---|
| 142 |
|
---|
| 143 | #endif
|
---|