Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "DataFormats/Candidate/interface/Candidate.h"
00011 #include "RecoParticleFlow/PFRootEvent/interface/ProtoJet.h"
00012 #include "RecoParticleFlow/PFRootEvent/interface/FastJetFWLiteWrapper.h"
00013 #include "fastjet/PseudoJet.hh"
00014 #include "fastjet/ClusterSequence.hh"
00015 #include "fastjet/ClusterSequenceActiveArea.hh"
00016 #include <string.h>
00017 #include "fastjet/ClusterSequence.hh"
00018 #include "fastjet/ClusterSequenceActiveArea.hh"
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00029
00030 using namespace edm;
00031 using namespace std;
00032
00033 FastJetFWLiteWrapper::~FastJetFWLiteWrapper(){
00034 delete mJetDefinition;
00035 delete mActiveArea;
00036 }
00037
00038 FastJetFWLiteWrapper::FastJetFWLiteWrapper()
00039 : mJetDefinition (0),
00040 mActiveArea (0)
00041 {
00042
00043
00044 theRparam_=1;
00045
00046 thePtMin_=10.;
00047
00048 string JetFinder="kt_algorithm";;
00049
00050 string Strategy="Best";
00051
00052 theDcut_=-1.;
00053
00054 theNjets_=-1;
00055
00056 theDoSubtraction_=false;
00057
00058 theGhost_EtaMax_=6;
00059
00060 theActive_Area_Repeats_=5;
00061
00062 theGhostArea_=0.01;
00063 mActiveArea = new fastjet::ActiveAreaSpec ( theGhost_EtaMax_, theActive_Area_Repeats_ , theGhostArea_);
00064
00065
00066
00067
00068
00069 fastjet::JetFinder jet_finder;
00070 if (JetFinder=="cambridge_algorithm") jet_finder=fastjet::cambridge_algorithm;
00071 else jet_finder=fastjet::kt_algorithm;
00072
00073
00074
00075 fastjet::Strategy strategy;
00076 if (Strategy=="N2Plain") strategy=fastjet::N2Plain;
00077
00078 else if (Strategy=="N2Tiled") strategy=fastjet::N2Tiled;
00079
00080 else if (Strategy=="N2MinHeapTiled") strategy=fastjet::N2MinHeapTiled;
00081
00082 else if (Strategy=="NlnN") strategy=fastjet::NlnN;
00083
00084 else if (Strategy=="NlnNCam") strategy=fastjet::NlnNCam;
00085
00086 else strategy=fastjet::Best;
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096 theMode_=0;
00097 if ((theNjets_!=-1)&&(theDcut_==-1)){
00098 theMode_=3;
00099 }
00100 else if ((theNjets_==-1)&&(theDcut_!=-1)){
00101 theMode_=2;
00102 }
00103 else if ((theNjets_!=-1)&&(theDcut_!=-1)){
00104 cout <<"[FastJetWrapper] `njets` and `dcut` set!=-1! - running inclusive Mode"<<endl;
00105 theMode_=1;
00106 }
00107 else {
00108 theMode_=0;
00109 }
00110
00111
00112 cout <<"*******************************************"<<endl;
00113 cout <<"* Configuration of FastJet "<<endl;
00114 if (theDoSubtraction_) cout <<"* running with ActiveAreaSubtraction(median)"<<endl;
00115 switch (theMode_){
00116 case 0:
00117 cout <<"* Mode : inclusive"<<endl;
00118 cout <<"* PtMin : "<<thePtMin_<<endl;
00119 break;
00120 case 1:
00121 cout <<"* [WARNING] Mode : inclusive - dcut and njets set!"<<endl;
00122 cout <<"* PtMin : "<<thePtMin_<<endl;
00123 break;
00124 case 2:
00125 cout <<"* Mode : exclusive"<<endl;
00126 cout <<"* dcut : "<<theDcut_<<endl;
00127 break;
00128 case 3:
00129 cout <<"* Mode : exclusive"<<endl;
00130 cout <<"* njets : "<<theNjets_<<endl;
00131 break;
00132 }
00133 cout <<"* Rparam : "<<theRparam_<<endl;
00134 cout <<"* JetFinder: "<<JetFinder<<endl;
00135 cout <<"* Strategy : "<<Strategy<<endl;
00136 cout <<"*******************************************"<<endl;
00137
00138 }
00139
00140 void FastJetFWLiteWrapper::run(const JetReco::InputCollection& fInput, JetReco::OutputCollection* fOutput) {
00141 if (!fOutput) return;
00142 fOutput->clear();
00143
00144
00145 std::vector<fastjet::PseudoJet> fjInputs;
00146 fjInputs.reserve (fInput.size());
00147
00148 JetReco::InputCollection::const_iterator input = fInput.begin();
00149 for (unsigned i = 0; i < fInput.size(); ++i) {
00150 const JetReco::InputItem& c = fInput[i];
00151 fjInputs.push_back (fastjet::PseudoJet (c->px(),c->py(),c->pz(),c->energy()));
00152 fjInputs.back().set_user_index(i);
00153 }
00154
00155
00156
00157
00158
00159
00160 fastjet::ClusterSequenceActiveArea* clusterSequenceWithArea = 0;
00161 fastjet::ClusterSequenceWithArea* clusterSequence = 0;
00162
00163
00164
00165
00166
00167 clusterSequence = new fastjet::ClusterSequenceWithArea (fjInputs, *mJetDefinition);
00168
00169
00170 std::vector<fastjet::PseudoJet> jets = clusterSequence->inclusive_jets (thePtMin_);
00171
00172
00173 double median_Pt_Per_Area = clusterSequenceWithArea ? clusterSequenceWithArea->pt_per_unit_area() : 0.;
00174
00175
00176 for (std::vector<fastjet::PseudoJet>::const_iterator jet=jets.begin(); jet!=jets.end();++jet) {
00177
00178 double px=jet->px();
00179 double py=jet->py();
00180 double pz=jet->pz();
00181 double E=jet->E();
00182 double jetArea=clusterSequence->area(*jet);
00183 double pu=0.;
00184
00185 if (clusterSequenceWithArea) {
00186 fastjet::PseudoJet pu_p4 = median_Pt_Per_Area * clusterSequenceWithArea->area_4vector(*jet);
00187 pu = pu_p4.E();
00188 if (pu_p4.perp2() >= jet->perp2() || pu_p4.E() >= jet->E()) {
00189 px = py = pz = E = 0.;
00190 }
00191 else {
00192 px -= pu_p4.px();
00193 py -= pu_p4.py();
00194 pz -= pu_p4.pz();
00195 E -= pu_p4.E();
00196 }
00197 }
00198 math::XYZTLorentzVector p4(px,py,pz,E);
00199
00200 std::vector<fastjet::PseudoJet> fastjet_constituents = clusterSequence->constituents(*jet);
00201 JetReco::InputCollection jetConstituents;
00202 jetConstituents.reserve (fastjet_constituents.size());
00203 for (std::vector<fastjet::PseudoJet>::const_iterator itConst=fastjet_constituents.begin();
00204 itConst!=fastjet_constituents.end();itConst++){
00205 jetConstituents.push_back(fInput[(*itConst).user_index()]);
00206 }
00207
00208 fOutput->push_back(ProtoJet(p4,jetConstituents));
00209 fOutput->back().setJetArea (jetArea);
00210 fOutput->back().setPileup (pu);
00211 }
00212
00213 if (clusterSequenceWithArea) delete clusterSequenceWithArea;
00214 else delete clusterSequence;
00215 }
00216
00217