Fork me on GitHub

Changeset cd75093 in git for examples


Ignore:
Timestamp:
Dec 12, 2014, 2:58:04 PM (10 years ago)
Author:
Michele Selvaggi <michele.selvaggi@…>
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.
Message:

Merge pull request #8 from selvaggi/master

Added external fast jet examples.

Location:
examples
Files:
1 added
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • examples/DelphesBrowser.C

    r17826f2 rcd75093  
    1818  TObjArray *partonOutputArray = modularDelphes->ExportArray("partons");
    1919
    20   confReader->ReadFile("examples/delphes_card_CMS.tcl");
     20  confReader->ReadFile("cards/delphes_card_CMS.tcl");
    2121
    2222  modularDelphes->SetConfReader(confReader);
  • examples/ExternalFastJetHepMC.cpp

    r17826f2 rcd75093  
    1717 */
    1818
     19/*
     20########################################################################
     21
     22
     23This simple example shows how to use Delphes with an external fastjet installation.
     24Events in hepmc format are read via the DelphesHepMC reader.
     25
     26In order to run this example you first, you need to set the paths to your Delphes, FastJet
     27and ROOT installations (DELPHES_DIR, FASTJET_DIR and ROOT_DIR):
     28
     29DELPHES_DIR=<path to Delphes installation>
     30FASTJET_DIR=<path to FastJet installation>
     31ROOT_DIR=<path to ROOT installation>
     32
     33Then run the following commands to build the executable:
     34
     35DELPHES_LIB="-Wl,-rpath $DELPHES_DIR -L$DELPHES_DIR -lDelphesNoFastJet"
     36
     37FASTJET_INC=`$FASTJET_DIR/bin/fastjet-config --cxxflags`
     38FASTJET_LIB=`$FASTJET_DIR/bin/fastjet-config --libs`
     39
     40ROOT_INC=`$ROOT_DIR/bin/root-config --incdir`
     41ROOT_LIB=`$ROOT_DIR/bin/root-config --libs`
     42
     43CXXFLAGS="$FASTJET_INC -I$ROOT_INC -I$DELPHES_DIR -I$DELPHES_DIR/external"
     44LDFLAGS="$FASTJET_LIB $ROOT_LIB $DELPHES_LIB"
     45
     46g++ $CXXFLAGS $LDFLAGS examples/ExternalFastJetHepMC.cpp -o examples/ExternalFastJetHepMC
     47
     48Then 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
    1957#include <stdexcept>
    2058#include <iostream>
     
    4684#include "fastjet/JetDefinition.hh"
    4785#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"
    6091
    6192using namespace std;
    6293using namespace fastjet;
    63 using namespace fastjet::contrib;
     94// using namespace fastjet::contrib;
    6495
    6596//---------------------------------------------------------------------------
     
    76107int main(int argc, char *argv[])
    77108{
    78   char appName[] = "StandaloneHepMC";
     109  char appName[] = "ExternalFastJetHepMC";
    79110  stringstream message;
    80111  FILE *inputFile = 0;
     
    93124
    94125  JetDefinition *definition = 0;
    95   JetDefinition::Recombiner *recomb = 0;
     126//  JetDefinition::Recombiner *recomb = 0;
    96127  vector<PseudoJet> inputList, outputList;
    97128  PseudoJet jet;
     
    145176
    146177    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
    151190    inputIterator = inputArray->MakeIterator();
     191
     192
     193    // start reading hepmc file
    152194
    153195    i = 2;
     
    185227      }
    186228
     229     
    187230      reader->SetInputFile(inputFile);
    188231
     
    195238        stableParticleOutputArray, partonOutputArray) && !interrupted)
    196239      {
    197         if(reader->EventReady())
     240       
     241         // loop over events
     242        if(reader->EventReady())
    198243        {
    199244          ++eventCounter;
     
    201246          if(eventCounter > skipEvents)
    202247          {
    203             modularDelphes->ProcessTask();
     248           
     249            // run delphes reconstruction
     250            modularDelphes->ProcessTask();
    204251           
    205252            inputList.clear();
    206253            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())))
    208258            {
    209259              momentum = candidate->Momentum;
     
    211261              inputList.push_back(jet);
    212262            }
    213             ClusterSequence sequence(inputList, *definition);
     263           
     264            // run fastjet clustering
     265            ClusterSequence sequence(inputList, *definition);
    214266            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            }
    216290          }
    217291
     
    219293          reader->Clear();
    220294        }
    221       }
     295      } // end of event loop
    222296
    223297      if(inputFile != stdin) fclose(inputFile);
     
    230304
    231305    cout << "** Exiting..." << endl;
     306
     307    delete definition;
     308//    delete recomb;
    232309
    233310    delete reader;
Note: See TracChangeset for help on using the changeset viewer.