File indexing completed on 2025-01-30 10:06:44
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 #ifndef __FASTJET_CONTRIB_TAUCOMPONENTS_HH__
0026 #define __FASTJET_CONTRIB_TAUCOMPONENTS_HH__
0027
0028 #include "fastjet/PseudoJet.hh"
0029 #include "fastjet/ClusterSequence.hh"
0030 #include "fastjet/WrappedStructure.hh"
0031
0032
0033 #include <cmath>
0034 #include <vector>
0035 #include <list>
0036 #include <limits>
0037
0038
0039 FASTJET_BEGIN_NAMESPACE
0040
0041 namespace contrib{
0042
0043
0044 class TauComponents;
0045 class TauPartition;
0046 class NjettinessExtras;
0047
0048
0049
0050
0051
0052 enum TauMode {
0053 UNDEFINED_SHAPE = -1,
0054 UNNORMALIZED_JET_SHAPE = 0,
0055 NORMALIZED_JET_SHAPE = 1,
0056 UNNORMALIZED_EVENT_SHAPE = 2,
0057 NORMALIZED_EVENT_SHAPE = 3,
0058 };
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074 class TauComponents {
0075
0076 public:
0077
0078
0079
0080 TauComponents() {}
0081
0082
0083 TauComponents(TauMode tau_mode,
0084 const std::vector<double> & jet_pieces_numerator,
0085 double beam_piece_numerator,
0086 double denominator,
0087 const std::vector<PseudoJet> & jets,
0088 const std::vector<PseudoJet> & axes
0089 );
0090
0091
0092 bool has_denominator() const;
0093
0094 bool has_beam() const;
0095
0096
0097 double tau() const { return _tau; }
0098
0099 const std::vector<double>& jet_pieces() const { return _jet_pieces; }
0100
0101 double beam_piece() const { return _beam_piece; }
0102
0103
0104 std::vector<double> jet_pieces_numerator() const { return _jet_pieces_numerator; }
0105
0106 double beam_piece_numerator() const { return _beam_piece_numerator; }
0107
0108 double numerator() const { return _numerator; }
0109
0110 double denominator() const { return _denominator; }
0111
0112
0113 PseudoJet total_jet() const { return _total_jet;}
0114
0115 const std::vector<PseudoJet>& jets() const { return _jets;}
0116
0117 const std::vector<PseudoJet>& axes() const { return _axes;}
0118
0119 class StructureType;
0120
0121 protected:
0122
0123
0124 TauMode _tau_mode;
0125
0126 std::vector<double> _jet_pieces_numerator;
0127 double _beam_piece_numerator;
0128 double _denominator;
0129
0130 std::vector<double> _jet_pieces;
0131 double _beam_piece;
0132 double _numerator;
0133 double _tau;
0134
0135 PseudoJet _total_jet;
0136 std::vector<PseudoJet> _jets;
0137 std::vector<PseudoJet> _axes;
0138
0139 };
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153 class TauPartition {
0154
0155 public:
0156
0157 TauPartition() {}
0158
0159
0160 TauPartition(int n_jet) {
0161 _jets_list.resize(n_jet);
0162 _jets_partition.resize(n_jet);
0163 }
0164
0165
0166 void push_back_jet(int jet_num, const PseudoJet& part_to_add, int part_index) {
0167 _jets_list[jet_num].push_back(part_index);
0168 _jets_partition[jet_num].push_back(part_to_add);
0169 }
0170
0171
0172 void push_back_beam(const PseudoJet& part_to_add, int part_index) {
0173 _beam_list.push_back(part_index);
0174 _beam_partition.push_back(part_to_add);
0175 }
0176
0177
0178 PseudoJet jet(int jet_num) const { return join(_jets_partition.at(jet_num)); }
0179
0180 PseudoJet beam() const { return join(_beam_partition);}
0181
0182
0183 std::vector<PseudoJet> jets() const {
0184 std::vector<PseudoJet> jets;
0185 for (unsigned int i = 0; i < _jets_partition.size(); i++) {
0186 jets.push_back(jet(i));
0187 }
0188 return jets;
0189 }
0190
0191
0192 const std::list<int> & jet_list(int jet_num) const { return _jets_list.at(jet_num);}
0193
0194 const std::list<int> & beam_list() const { return _beam_list;}
0195
0196 const std::vector<std::list<int> > & jets_list() const { return _jets_list;}
0197
0198 private:
0199
0200 std::vector<std::list<int> > _jets_list;
0201 std::list<int> _beam_list;
0202
0203 std::vector<std::vector<PseudoJet> > _jets_partition;
0204 std::vector<PseudoJet> _beam_partition;
0205
0206 };
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223 class NjettinessExtras : public ClusterSequence::Extras, public TauComponents {
0224
0225 public:
0226
0227 NjettinessExtras(TauComponents tau_components,
0228 std::vector<int> cluster_hist_indices)
0229 : TauComponents(tau_components), _cluster_hist_indices(cluster_hist_indices) {}
0230
0231
0232
0233
0234 double tau(const fastjet::PseudoJet& ) const {return _tau;}
0235
0236
0237 double tau_piece(const fastjet::PseudoJet& jet) const {
0238 if (labelOf(jet) == -1) return std::numeric_limits<double>::quiet_NaN();
0239 return _jet_pieces[labelOf(jet)];
0240 }
0241
0242
0243 fastjet::PseudoJet axis(const fastjet::PseudoJet& jet) const {
0244 return _axes[labelOf(jet)];
0245 }
0246
0247
0248 bool has_njettiness_extras(const fastjet::PseudoJet& jet) const {
0249 return (labelOf(jet) >= 0);
0250 }
0251
0252 private:
0253
0254
0255 std::vector<int> _cluster_hist_indices;
0256
0257
0258 int labelOf(const fastjet::PseudoJet& jet) const {
0259 int thisJet = -1;
0260 for (unsigned int i = 0; i < _jets.size(); i++) {
0261 if (_cluster_hist_indices[i] == jet.cluster_hist_index()) {
0262 thisJet = i;
0263 break;
0264 }
0265 }
0266 return thisJet;
0267 }
0268
0269 public:
0270
0271
0272
0273
0274
0275 double totalTau() const {return _tau;}
0276
0277 std::vector<double> subTaus() const {return _jet_pieces;}
0278
0279
0280 double totalTau(const fastjet::PseudoJet& ) const {
0281 return _tau;
0282 }
0283
0284
0285 double subTau(const fastjet::PseudoJet& jet) const {
0286 if (labelOf(jet) == -1) return std::numeric_limits<double>::quiet_NaN();
0287 return _jet_pieces[labelOf(jet)];
0288 }
0289
0290
0291 double beamTau() const {
0292 return _beam_piece;
0293 }
0294
0295 };
0296
0297
0298
0299 inline const NjettinessExtras * njettiness_extras(const fastjet::PseudoJet& jet) {
0300 const ClusterSequence * myCS = jet.associated_cluster_sequence();
0301 if (myCS == NULL) return NULL;
0302 const NjettinessExtras* extras = dynamic_cast<const NjettinessExtras*>(myCS->extras());
0303 return extras;
0304 }
0305
0306
0307 inline const NjettinessExtras * njettiness_extras(const fastjet::ClusterSequence& myCS) {
0308 const NjettinessExtras* extras = dynamic_cast<const NjettinessExtras*>(myCS.extras());
0309 return extras;
0310 }
0311
0312
0313
0314
0315
0316
0317
0318
0319
0320
0321
0322
0323
0324
0325
0326 class TauComponents::StructureType : public WrappedStructure {
0327
0328 public:
0329
0330 StructureType(const PseudoJet& j) :
0331 WrappedStructure(j.structure_shared_ptr())
0332 {}
0333
0334
0335 double tau_piece() const { return _tau_piece; }
0336
0337
0338 double tau() const { return _tau_piece; }
0339
0340 private:
0341 friend class TauComponents;
0342 double _tau_piece;
0343 };
0344
0345
0346
0347
0348 }
0349
0350 FASTJET_END_NAMESPACE
0351
0352 #endif