CMS 3D CMS Logo

CSJetProducer.cc
Go to the documentation of this file.
3 
4 #include <memory>
5 
8 
9 #include "fastjet/contrib/ConstituentSubtractor.hh"
10 
11 using namespace std;
12 using namespace reco;
13 using namespace edm;
14 using namespace cms;
15 
16 CSJetProducer::CSJetProducer(edm::ParameterSet const& conf) : VirtualJetProducer(conf), csRParam_(-1.0), csAlpha_(0.) {
17  //get eta range, rho and rhom map
18  etaToken_ = consumes<std::vector<double>>(conf.getParameter<edm::InputTag>("etaMap"));
19  rhoToken_ = consumes<std::vector<double>>(conf.getParameter<edm::InputTag>("rho"));
20  rhomToken_ = consumes<std::vector<double>>(conf.getParameter<edm::InputTag>("rhom"));
21  csRParam_ = conf.getParameter<double>("csRParam");
22  csAlpha_ = conf.getParameter<double>("csAlpha");
23 }
24 
26  // use the default production from one collection
28  //use runAlgorithm of this class
29 
30  //Delete allocated memory. It is allocated every time runAlgorithm is called
31  fjClusterSeq_.reset();
32 }
33 
34 //______________________________________________________________________________
36  // run algorithm
37  if (!doAreaFastjet_ && !doRhoFastjet_) {
38  fjClusterSeq_ = std::make_shared<fastjet::ClusterSequence>(fjInputs_, *fjJetDefinition_);
39  } else if (voronoiRfact_ <= 0) {
41  ClusterSequencePtr(new fastjet::ClusterSequenceArea(fjInputs_, *fjJetDefinition_, *fjAreaDefinition_));
42  } else {
44  new fastjet::ClusterSequenceVoronoiArea(fjInputs_, *fjJetDefinition_, fastjet::VoronoiAreaSpec(voronoiRfact_)));
45  }
46 
47  fjJets_.clear();
48  std::vector<fastjet::PseudoJet> tempJets = fastjet::sorted_by_pt(fjClusterSeq_->inclusive_jets(jetPtMin_));
49 
50  //Get local rho and rhom map
54 
55  iEvent.getByToken(etaToken_, etaRanges);
56  iEvent.getByToken(rhoToken_, rhoRanges);
57  iEvent.getByToken(rhomToken_, rhomRanges);
58 
59  //Check if size of eta and background density vectors is the same
60  unsigned int bkgVecSize = etaRanges->size();
61  if (bkgVecSize < 1) {
62  throw cms::Exception("WrongBkgInput") << "Producer needs vector with background estimates\n";
63  }
64  if (bkgVecSize != (rhoRanges->size() + 1) || bkgVecSize != (rhomRanges->size() + 1)) {
65  throw cms::Exception("WrongBkgInput")
66  << "Size of etaRanges (" << bkgVecSize << ") and rhoRanges (" << rhoRanges->size() << ") and/or rhomRanges ("
67  << rhomRanges->size() << ") vectors inconsistent\n";
68  }
69 
70  //Allow the background densities to change within the jet
71 
72  for (fastjet::PseudoJet& ijet : tempJets) {
73  //----------------------------------------------------------------------
74  // sift ghosts and particles in the input jet
75  std::vector<fastjet::PseudoJet> particles, ghosts;
76  fastjet::SelectorIsPureGhost().sift(ijet.constituents(), ghosts, particles);
77  unsigned long nParticles = particles.size();
78  if (nParticles == 0)
79  continue; //don't subtract ghost jets
80 
81  //assign rho and rhom to ghosts according to local eta-dependent map
82  double rho = 1e-6;
83  double rhom = 1e-6;
84  for (fastjet::PseudoJet& ighost : ghosts) {
85  if (ighost.eta() <= etaRanges->at(0) || bkgVecSize == 1) {
86  rho = rhoRanges->at(0);
87  rhom = rhomRanges->at(0);
88  } else if (ighost.eta() >= etaRanges->at(bkgVecSize - 1)) {
89  rho = rhoRanges->at(bkgVecSize - 2);
90  rhom = rhomRanges->at(bkgVecSize - 2);
91  } else {
92  for (unsigned int ie = 0; ie < (bkgVecSize - 1); ie++) {
93  if (ighost.eta() >= etaRanges->at(ie) && ighost.eta() < etaRanges->at(ie + 1)) {
94  rho = rhoRanges->at(ie);
95  rhom = rhomRanges->at(ie);
96  break;
97  }
98  }
99  }
100  double pt = rho * ighost.area();
101  double mass_squared = std::pow(rhom * ighost.area() + pt, 2) - std::pow(pt, 2);
102  double mass = 0;
103  if (mass_squared > 0)
104  mass = sqrt(mass_squared);
105  ighost.reset_momentum_PtYPhiM(pt, ighost.rap(), ighost.phi(), mass);
106  }
107 
108  //----------------------------------------------------------------------
109  //from here use official fastjet contrib package
110 
111  fastjet::contrib::ConstituentSubtractor subtractor;
112  subtractor.set_distance_type(fastjet::contrib::ConstituentSubtractor::deltaR); // distance in eta-phi plane
113  subtractor.set_max_distance(
114  csRParam_); // free parameter for the maximal allowed distance between particle i and ghost k
115  subtractor.set_alpha(
116  csAlpha_); // free parameter for the distance measure (the exponent of particle pt). Note that in older versions of the package alpha was multiplied by two but in newer versions this is not the case anymore
117  subtractor.set_do_mass_subtraction(true);
118  subtractor.set_remove_all_zero_pt_particles(true);
119 
120  std::vector<fastjet::PseudoJet> subtracted_particles = subtractor.do_subtraction(particles, ghosts);
121 
122  //Create subtracted jets
123  fastjet::PseudoJet subtracted_jet = join(subtracted_particles);
124  if (subtracted_jet.perp() > 0.)
125  fjJets_.push_back(subtracted_jet);
126  }
127  fjJets_ = fastjet::sorted_by_pt(fjJets_);
128 }
129 
131  edm::ParameterSetDescription descCSJetProducer;
133  fillDescriptionsFromCSJetProducer(descCSJetProducer);
135  descCSJetProducer.add<string>("jetCollInstanceName", "");
137  descCSJetProducer.add<bool>("sumRecHits", false);
138 
140  descriptions.add("CSJetProducer", descCSJetProducer);
141 }
142 
144  desc.add<double>("csRParam", -1.);
145  desc.add<double>("csAlpha", 2.);
146 
147  desc.add<edm::InputTag>("etaMap", edm::InputTag("hiFJRhoProducer", "mapEtaEdges"));
148  desc.add<edm::InputTag>("rho", edm::InputTag("hiFJRhoProducer", "mapToRho"));
149  desc.add<edm::InputTag>("rhom", edm::InputTag("hiFJRhoProducer", "mapToRhoM"));
150 }
151 
153 // define as cmssw plugin
155 
bTagCommon_cff.etaRanges
etaRanges
Definition: bTagCommon_cff.py:42
cms::CSJetProducer::csAlpha_
double csAlpha_
for constituent subtraction : R parameter
Definition: CSJetProducer.h:36
VirtualJetProducer::produce
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition: VirtualJetProducer.cc:264
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
VirtualJetProducer::ClusterSequencePtr
std::shared_ptr< fastjet::ClusterSequence > ClusterSequencePtr
Definition: VirtualJetProducer.h:73
edm
HLT enums.
Definition: AlignableModifier.h:19
join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
cms::CSJetProducer::csRParam_
double csRParam_
Definition: CSJetProducer.h:35
edm::Handle
Definition: AssociativeIterator.h:50
VirtualJetProducer::voronoiRfact_
double voronoiRfact_
Definition: VirtualJetProducer.h:170
ecalTrigSettings_cff.particles
particles
Definition: ecalTrigSettings_cff.py:11
VirtualJetProducer::fjClusterSeq_
ClusterSequencePtr fjClusterSeq_
Definition: VirtualJetProducer.h:185
cms::CSJetProducer::rhoToken_
edm::EDGetTokenT< std::vector< double > > rhoToken_
Definition: CSJetProducer.h:40
MakerMacros.h
cms::CSJetProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: CSJetProducer.cc:130
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
VirtualJetProducer
Definition: VirtualJetProducer.h:35
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
VirtualJetProducer::doRhoFastjet_
bool doRhoFastjet_
Definition: VirtualJetProducer.h:167
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
cms::CSJetProducer
Definition: CSJetProducer.h:22
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
jetAnalyzer_cfi.rhom
rhom
Definition: jetAnalyzer_cfi.py:251
VirtualJetProducer::jetPtMin_
double jetPtMin_
Definition: VirtualJetProducer.h:155
iEvent
int iEvent
Definition: GenABIO.cc:224
cms::CSJetProducer::rhomToken_
edm::EDGetTokenT< std::vector< double > > rhomToken_
Definition: CSJetProducer.h:41
edm::EventSetup
Definition: EventSetup.h:57
VirtualJetProducer::fjAreaDefinition_
AreaDefinitionPtr fjAreaDefinition_
Definition: VirtualJetProducer.h:189
cms::CSJetProducer::runAlgorithm
void runAlgorithm(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition: CSJetProducer.cc:35
cms::CSJetProducer::produce
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition: CSJetProducer.cc:25
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
std
Definition: JetResolutionObject.h:76
cms::CSJetProducer::etaToken_
edm::EDGetTokenT< std::vector< double > > etaToken_
for HI constituent subtraction : alpha (power of pt in metric)
Definition: CSJetProducer.h:39
VirtualJetProducer::doAreaFastjet_
bool doAreaFastjet_
Definition: VirtualJetProducer.h:163
Exception
Definition: hltDiff.cc:246
CSJetProducer.h
VirtualJetProducer::fjJets_
std::vector< fastjet::PseudoJet > fjJets_
Definition: VirtualJetProducer.h:192
VirtualJetProducer::fjJetDefinition_
JetDefPtr fjJetDefinition_
Definition: VirtualJetProducer.h:186
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
JetSpecific.h
Exception.h
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
cms::CSJetProducer::fillDescriptionsFromCSJetProducer
static void fillDescriptionsFromCSJetProducer(edm::ParameterSetDescription &desc)
Definition: CSJetProducer.cc:143
VirtualJetProducer::fjInputs_
std::vector< fastjet::PseudoJet > fjInputs_
Definition: VirtualJetProducer.h:191
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
VirtualJetProducer::fillDescriptionsFromVirtualJetProducer
static void fillDescriptionsFromVirtualJetProducer(edm::ParameterSetDescription &desc)
Definition: VirtualJetProducer.cc:1016
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37