ROOT logo
void pythia6FastjetExample(Int_t nEvent = 50, Float_t e_cms = 2760, Float_t pthardmin = 10, Float_t pthardmax = 50) {

  // example macro for on-the-fly generation of PYTHIA6 events
  // and analysis with new reader interface and FastJet
  // M. van Leeuwen

  gSystem->Load("libANALYSIS");
  gSystem->Load("libANALYSISalice");
  gSystem->Load("libCGAL");
  gSystem->Load("libfastjet");
  gSystem->Load("libsiscone");
  gSystem->Load("libsiscone_spherical");
  gSystem->Load("libfastjetplugins");
  gSystem->Load("libJETAN");
  gSystem->Load("libFASTJETAN");

  gSystem->Load("libpythia6");
  gSystem->Load("libEGPythia6");
  gSystem->Load("liblhapdf");
  gSystem->Load("libAliPythia6");


  AliPDG::AddParticlesToPdgDataBase(); // to add some PDF codes to TDatabasePDG

  // Create random number generator and set seed
  AliPythiaRndm::SetPythiaRandom(new TRandom3());
  AliPythiaRndm::GetPythiaRandom()->SetSeed(clock()+gSystem->GetPid());

  AliGenPythia *pythia=new AliGenPythia(1);
  pythia->SetProcess(kPyJets);
  pythia->SetPtHard(pthardmin, pthardmax);
  pythia->SetEnergyCMS(e_cms);

  pythia->Init();

  //
  // Jet finder settings go via the FastJetHeader
  //
  AliFastJetHeaderV1 *header = new AliFastJetHeaderV1;
  header->SetBGMode(0);
  //  header->SetRadius(0.4);
  header->SetRparam(0.4); 
  //header->SetGhostEtaMax(2);
  //header->SetGhostArea(0.05);
  header->SetAlgorithm(2); // antikt_algorithm = 2, kt = 0 (see fastjet/fastjet/JetDefinition.hh

  AliFastJetFinder *FastJet = new AliFastJetFinder;
  FastJet->SetJetHeader(header);

  // Infrastructure needed for AliGenPythia
  AliStack *stack = new AliStack();
  // There is a big mess with the connection between runloader, AliRun and the gAlice pointer. 
  // This order of things seems to work...
  AliRunLoader *dummyrl = new AliRunLoader("dummyEvtFolder");
  dummyrl->MakeHeader();
  dummyrl->SetEventNumber(0);
  gAlice->SetRunLoader(dummyrl);
  pythia->SetStack(stack);

  // Set up dummy AOD event for JETAN output
  AliAODEvent *aod = new AliAODEvent();
  aod->CreateStdContent();
  FastJet->ConnectAOD(aod);

  // Set up input structures for FastJet
  AliJetCalTrkEvent JetFinderEvent(0,1);
  TClonesArray aliplist("AliMCParticle",1000);

  for (Int_t iEvent = 0; iEvent < nEvent; iEvent++) {

    TProcessID::SetObjectCount(0); // Needed for TRefs in AliCalTrkTrack and AliAODJet

    stack->Reset();
    pythia->Generate();

    aliplist.Clear();
    JetFinderEvent.Clear();

    Int_t n_part = stack->GetNtrack();
    for (Int_t i_part = 0; i_part < n_part; i_part++) {
      part=(TParticle*) stack->Particle(i_part);

      if (part->GetStatusCode() >= 10)  // Not a final state particle
	continue;

      new (aliplist[i_part]) AliMCParticle(part);

      JetFinderEvent.AddCalTrkTrackKine((AliMCParticle*)aliplist[i_part],1,1);
    }

    aod->ClearStd();
    FastJet->Reset();
    FastJet->SetCalTrkEvent(JetFinderEvent);
    FastJet->ProcessEvent();
    if (aod->GetNJets() > 0) {
      cout << "event " << iEvent << " " << aod->GetNJets() << " jets found" << endl;
      for (Int_t iJet = 0; iJet < aod->GetNJets(); iJet++) {
	jet = aod->GetJet(iJet);
	cout << "\t jet " << iJet << " pt " << jet->Pt() << " eta " << jet->Eta() << " phi " << jet->Phi() << endl; 
      }
    }
  }
}

// kept for backward compatibility; this was the old function name
void run(Int_t nEvent = 50, Float_t e_cms = 2760) {
  pythia6FastjetExample(nEvent, e_cms);
}
 pythia6FastjetExample.C:1
 pythia6FastjetExample.C:2
 pythia6FastjetExample.C:3
 pythia6FastjetExample.C:4
 pythia6FastjetExample.C:5
 pythia6FastjetExample.C:6
 pythia6FastjetExample.C:7
 pythia6FastjetExample.C:8
 pythia6FastjetExample.C:9
 pythia6FastjetExample.C:10
 pythia6FastjetExample.C:11
 pythia6FastjetExample.C:12
 pythia6FastjetExample.C:13
 pythia6FastjetExample.C:14
 pythia6FastjetExample.C:15
 pythia6FastjetExample.C:16
 pythia6FastjetExample.C:17
 pythia6FastjetExample.C:18
 pythia6FastjetExample.C:19
 pythia6FastjetExample.C:20
 pythia6FastjetExample.C:21
 pythia6FastjetExample.C:22
 pythia6FastjetExample.C:23
 pythia6FastjetExample.C:24
 pythia6FastjetExample.C:25
 pythia6FastjetExample.C:26
 pythia6FastjetExample.C:27
 pythia6FastjetExample.C:28
 pythia6FastjetExample.C:29
 pythia6FastjetExample.C:30
 pythia6FastjetExample.C:31
 pythia6FastjetExample.C:32
 pythia6FastjetExample.C:33
 pythia6FastjetExample.C:34
 pythia6FastjetExample.C:35
 pythia6FastjetExample.C:36
 pythia6FastjetExample.C:37
 pythia6FastjetExample.C:38
 pythia6FastjetExample.C:39
 pythia6FastjetExample.C:40
 pythia6FastjetExample.C:41
 pythia6FastjetExample.C:42
 pythia6FastjetExample.C:43
 pythia6FastjetExample.C:44
 pythia6FastjetExample.C:45
 pythia6FastjetExample.C:46
 pythia6FastjetExample.C:47
 pythia6FastjetExample.C:48
 pythia6FastjetExample.C:49
 pythia6FastjetExample.C:50
 pythia6FastjetExample.C:51
 pythia6FastjetExample.C:52
 pythia6FastjetExample.C:53
 pythia6FastjetExample.C:54
 pythia6FastjetExample.C:55
 pythia6FastjetExample.C:56
 pythia6FastjetExample.C:57
 pythia6FastjetExample.C:58
 pythia6FastjetExample.C:59
 pythia6FastjetExample.C:60
 pythia6FastjetExample.C:61
 pythia6FastjetExample.C:62
 pythia6FastjetExample.C:63
 pythia6FastjetExample.C:64
 pythia6FastjetExample.C:65
 pythia6FastjetExample.C:66
 pythia6FastjetExample.C:67
 pythia6FastjetExample.C:68
 pythia6FastjetExample.C:69
 pythia6FastjetExample.C:70
 pythia6FastjetExample.C:71
 pythia6FastjetExample.C:72
 pythia6FastjetExample.C:73
 pythia6FastjetExample.C:74
 pythia6FastjetExample.C:75
 pythia6FastjetExample.C:76
 pythia6FastjetExample.C:77
 pythia6FastjetExample.C:78
 pythia6FastjetExample.C:79
 pythia6FastjetExample.C:80
 pythia6FastjetExample.C:81
 pythia6FastjetExample.C:82
 pythia6FastjetExample.C:83
 pythia6FastjetExample.C:84
 pythia6FastjetExample.C:85
 pythia6FastjetExample.C:86
 pythia6FastjetExample.C:87
 pythia6FastjetExample.C:88
 pythia6FastjetExample.C:89
 pythia6FastjetExample.C:90
 pythia6FastjetExample.C:91
 pythia6FastjetExample.C:92
 pythia6FastjetExample.C:93
 pythia6FastjetExample.C:94
 pythia6FastjetExample.C:95
 pythia6FastjetExample.C:96
 pythia6FastjetExample.C:97
 pythia6FastjetExample.C:98
 pythia6FastjetExample.C:99
 pythia6FastjetExample.C:100
 pythia6FastjetExample.C:101
 pythia6FastjetExample.C:102
 pythia6FastjetExample.C:103
 pythia6FastjetExample.C:104
 pythia6FastjetExample.C:105
 pythia6FastjetExample.C:106
 pythia6FastjetExample.C:107
 pythia6FastjetExample.C:108
 pythia6FastjetExample.C:109