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 #include "fastjet/ClusterSequenceArea.hh"
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00030
00031 using namespace edm;
00032 using namespace std;
00033
00034 FastJetFWLiteWrapper::~FastJetFWLiteWrapper(){
00035 delete mJetDefinition;
00036 delete mActiveArea;
00037 }
00038
00039 FastJetFWLiteWrapper::FastJetFWLiteWrapper()
00040 : mJetDefinition (0),
00041 mActiveArea (0)
00042 {
00043
00044
00045 theRparam_=1;
00046
00047 thePtMin_=10.;
00048
00049 string JetFinder="kt_algorithm";;
00050
00051 string Strategy="Best";
00052
00053 theDcut_=-1.;
00054
00055 theNjets_=-1;
00056
00057 theDoSubtraction_=false;
00058
00059 theGhost_EtaMax_=6;
00060
00061 theActive_Area_Repeats_=5;
00062
00063 theGhostArea_=0.01;
00064 mActiveArea = new fastjet::GhostedAreaSpec ( theGhost_EtaMax_, theActive_Area_Repeats_ , theGhostArea_);
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097 theMode_=0;
00098 if ((theNjets_!=-1)&&(theDcut_==-1)){
00099 theMode_=3;
00100 }
00101 else if ((theNjets_==-1)&&(theDcut_!=-1)){
00102 theMode_=2;
00103 }
00104 else if ((theNjets_!=-1)&&(theDcut_!=-1)){
00105 cout <<"[FastJetWrapper] `njets` and `dcut` set!=-1! - running inclusive Mode"<<endl;
00106 theMode_=1;
00107 }
00108 else {
00109 theMode_=0;
00110 }
00111
00112
00113 cout <<"*******************************************"<<endl;
00114 cout <<"* Configuration of FastJet "<<endl;
00115 if (theDoSubtraction_) cout <<"* running with ActiveAreaSubtraction(median)"<<endl;
00116 switch (theMode_){
00117 case 0:
00118 cout <<"* Mode : inclusive"<<endl;
00119 cout <<"* PtMin : "<<thePtMin_<<endl;
00120 break;
00121 case 1:
00122 cout <<"* [WARNING] Mode : inclusive - dcut and njets set!"<<endl;
00123 cout <<"* PtMin : "<<thePtMin_<<endl;
00124 break;
00125 case 2:
00126 cout <<"* Mode : exclusive"<<endl;
00127 cout <<"* dcut : "<<theDcut_<<endl;
00128 break;
00129 case 3:
00130 cout <<"* Mode : exclusive"<<endl;
00131 cout <<"* njets : "<<theNjets_<<endl;
00132 break;
00133 }
00134 cout <<"* Rparam : "<<theRparam_<<endl;
00135 cout <<"* JetFinder: "<<JetFinder<<endl;
00136 cout <<"* Strategy : "<<Strategy<<endl;
00137 cout <<"*******************************************"<<endl;
00138
00139 }
00140
00141 void FastJetFWLiteWrapper::run(const JetReco::InputCollection& fInput, JetReco::OutputCollection* fOutput) {
00142 if (!fOutput) return;
00143 fOutput->clear();
00144
00145
00146 std::vector<fastjet::PseudoJet> fjInputs;
00147 fjInputs.reserve (fInput.size());
00148
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::ClusterSequenceArea* clusterSequence = 0;
00162
00163
00164
00165
00166
00167 clusterSequence = new fastjet::ClusterSequenceArea (fjInputs, *mJetDefinition, *mActiveArea);
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