Changeset cd75093 in git for examples/ExternalFastJetHepMC.cpp
- Timestamp:
- Dec 12, 2014, 2:58:04 PM (10 years ago)
- Branches:
- ImprovedOutputFile, Timing, dual_readout, llp, master
- Children:
- 0c871e5
- Parents:
- 17826f2 (diff), 3d10d1f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
examples/ExternalFastJetHepMC.cpp
r17826f2 rcd75093 17 17 */ 18 18 19 /* 20 ######################################################################## 21 22 23 This simple example shows how to use Delphes with an external fastjet installation. 24 Events in hepmc format are read via the DelphesHepMC reader. 25 26 In order to run this example you first, you need to set the paths to your Delphes, FastJet 27 and ROOT installations (DELPHES_DIR, FASTJET_DIR and ROOT_DIR): 28 29 DELPHES_DIR=<path to Delphes installation> 30 FASTJET_DIR=<path to FastJet installation> 31 ROOT_DIR=<path to ROOT installation> 32 33 Then run the following commands to build the executable: 34 35 DELPHES_LIB="-Wl,-rpath $DELPHES_DIR -L$DELPHES_DIR -lDelphesNoFastJet" 36 37 FASTJET_INC=`$FASTJET_DIR/bin/fastjet-config --cxxflags` 38 FASTJET_LIB=`$FASTJET_DIR/bin/fastjet-config --libs` 39 40 ROOT_INC=`$ROOT_DIR/bin/root-config --incdir` 41 ROOT_LIB=`$ROOT_DIR/bin/root-config --libs` 42 43 CXXFLAGS="$FASTJET_INC -I$ROOT_INC -I$DELPHES_DIR -I$DELPHES_DIR/external" 44 LDFLAGS="$FASTJET_LIB $ROOT_LIB $DELPHES_LIB" 45 46 g++ $CXXFLAGS $LDFLAGS examples/ExternalFastJetHepMC.cpp -o examples/ExternalFastJetHepMC 47 48 Then run (you need an event file in hepmc format): 49 50 ./examples/ExternalFastJetHepMC cards/delphes_card_CMS_NoFastJet.tcl file.hepmc 51 52 53 ######################################################################## 54 55 */ 56 19 57 #include <stdexcept> 20 58 #include <iostream> … … 46 84 #include "fastjet/JetDefinition.hh" 47 85 #include "fastjet/ClusterSequence.hh" 48 #include "fastjet/Selector.hh" 49 #include "fastjet/ClusterSequenceArea.hh" 50 #include "fastjet/tools/JetMedianBackgroundEstimator.hh" 51 52 #include "fastjet/plugins/SISCone/fastjet/SISConePlugin.hh" 53 #include "fastjet/plugins/CDFCones/fastjet/CDFMidPointPlugin.hh" 54 #include "fastjet/plugins/CDFCones/fastjet/CDFJetCluPlugin.hh" 55 56 #include "fastjet/contribs/Nsubjettiness/Nsubjettiness.hh" 57 #include "fastjet/contribs/Nsubjettiness/Njettiness.hh" 58 #include "fastjet/contribs/Nsubjettiness/NjettinessPlugin.hh" 59 #include "fastjet/contribs/Nsubjettiness/WinnerTakeAllRecombiner.hh" 86 87 // #include "fastjet/contrib/Nsubjettiness.hh" 88 // #include "fastjet/contrib/Njettiness.hh" 89 // #include "fastjet/contrib/NjettinessPlugin.hh" 90 // #include "fastjet/contrib/WinnerTakeAllRecombiner.hh" 60 91 61 92 using namespace std; 62 93 using namespace fastjet; 63 using namespace fastjet::contrib;94 // using namespace fastjet::contrib; 64 95 65 96 //--------------------------------------------------------------------------- … … 76 107 int main(int argc, char *argv[]) 77 108 { 78 char appName[] = " StandaloneHepMC";109 char appName[] = "ExternalFastJetHepMC"; 79 110 stringstream message; 80 111 FILE *inputFile = 0; … … 93 124 94 125 JetDefinition *definition = 0; 95 JetDefinition::Recombiner *recomb = 0;126 // JetDefinition::Recombiner *recomb = 0; 96 127 vector<PseudoJet> inputList, outputList; 97 128 PseudoJet jet; … … 145 176 146 177 ClusterSequence::print_banner(); 147 recomb = new WinnerTakeAllRecombiner(); 148 definition = new JetDefinition(antikt_algorithm, 0.5, recomb, Best); 149 150 inputArray = modularDelphes->ImportArray("Calorimeter/towers"); 178 179 // recomb = new WinnerTakeAllRecombiner(); 180 // definition = new JetDefinition(antikt_algorithm, 0.5, recomb, Best); 181 182 definition = new JetDefinition(antikt_algorithm, 0.5); 183 184 185 // Define your input candidates to fastjet (by default particle-flow objects). 186 // If you want pure calorimeter towers change "EFlowMerger/eflow" into "Calorimeter/towers": 187 188 inputArray = modularDelphes->ImportArray("EFlowMerger/eflow"); 189 151 190 inputIterator = inputArray->MakeIterator(); 191 192 193 // start reading hepmc file 152 194 153 195 i = 2; … … 185 227 } 186 228 229 187 230 reader->SetInputFile(inputFile); 188 231 … … 195 238 stableParticleOutputArray, partonOutputArray) && !interrupted) 196 239 { 197 if(reader->EventReady()) 240 241 // loop over events 242 if(reader->EventReady()) 198 243 { 199 244 ++eventCounter; … … 201 246 if(eventCounter > skipEvents) 202 247 { 203 modularDelphes->ProcessTask(); 248 249 // run delphes reconstruction 250 modularDelphes->ProcessTask(); 204 251 205 252 inputList.clear(); 206 253 inputIterator->Reset(); 207 while((candidate = static_cast<Candidate*>(inputIterator->Next()))) 254 255 256 // pass delphes candidates to fastjet clustering 257 while((candidate = static_cast<Candidate*>(inputIterator->Next()))) 208 258 { 209 259 momentum = candidate->Momentum; … … 211 261 inputList.push_back(jet); 212 262 } 213 ClusterSequence sequence(inputList, *definition); 263 264 // run fastjet clustering 265 ClusterSequence sequence(inputList, *definition); 214 266 outputList.clear(); 215 outputList = sorted_by_pt(sequence.inclusive_jets(10.0)); 267 outputList = sorted_by_pt(sequence.inclusive_jets(0.0)); 268 269 270 // Prints for the first event: 271 // - the description of the algorithm used 272 // - show the inclusive jets as 273 // {index, rapidity, phi, pt} 274 //---------------------------------------------------------- 275 276 if(eventCounter == skipEvents + 1) 277 { 278 cout << "Ran " << definition->description() << endl; 279 280 // label the columns 281 printf("%5s %15s %15s %15s\n","jet #", "rapidity", "phi", "pt"); 282 283 // print out the details for each jet 284 for (unsigned int i = 0; i < outputList.size(); i++) { 285 printf("%5u %15.8f %15.8f %15.8f\n", 286 i, outputList[i].rap(), outputList[i].phi(), 287 outputList[i].perp()); 288 } 289 } 216 290 } 217 291 … … 219 293 reader->Clear(); 220 294 } 221 } 295 } // end of event loop 222 296 223 297 if(inputFile != stdin) fclose(inputFile); … … 230 304 231 305 cout << "** Exiting..." << endl; 306 307 delete definition; 308 // delete recomb; 232 309 233 310 delete reader;
Note:
See TracChangeset
for help on using the changeset viewer.