Beispiel #1
0
void fastGen(Int_t nev = 1, char* filename = "gilc.root")
{
  IlcPDG::AddParticlesToPdgDataBase();
  TDatabasePDG::Instance();
 


  // Run loader
  IlcRunLoader* rl = IlcRunLoader::Open("gilc.root","FASTRUN","recreate");
  
  rl->SetCompressionLevel(2);
  rl->SetNumberOfEventsPerFile(nev);
  rl->LoadKinematics("RECREATE");
  rl->MakeTree("E");
  gIlc->SetRunLoader(rl);
  
  //  Create stack
  rl->MakeStack();
  IlcStack* stack = rl->Stack();
  
  //  Header
  IlcHeader* header = rl->GetHeader();
  
  //  Create and Initialize Generator
 
  // Example of charm generation taken from Config_PythiaHeavyFlavours.C
  IlcGenPythia *gener = new IlcGenPythia(-1);
  gener->SetEnergyCMS(14000.);
  gener->SetMomentumRange(0,999999);
  gener->SetPhiRange(0., 360.);
  gener->SetThetaRange(0.,180.);
  //  gener->SetProcess(kPyCharmppMNR); // Correct Pt distribution, wrong mult
  gener->SetProcess(kPyMb); // Correct multiplicity, wrong Pt
  gener->SetStrucFunc(kCTEQ4L);
  gener->SetPtHard(2.1,-1.0);
  gener->SetFeedDownHigherFamily(kFALSE);
  gener->SetStack(stack);
  gener->Init();

  // Go to gilc.root
  rl->CdGAFile();

  // Forbid some decays. Do it after gener->Init(0, because
  // the initialization of the generator includes reading of the decay table.

  IlcPythia * py= IlcPythia::Instance();
  py->SetMDME(737,1,0); //forbid D*+->D+ + pi0
  py->SetMDME(738,1,0);//forbid D*+->D+ + gamma

  // Forbid all D0 decays except D0->K- pi+
  for(Int_t d=747; d<=762; d++){ 
    py->SetMDME(d,1,0);
  }
  // decay 763 is D0->K- pi+
  for(Int_t d=764; d<=807; d++){ 
    py->SetMDME(d,1,0);
  }

  //
  //                        Event Loop
  //
  
  TStopwatch timer;
  timer.Start();
  for (Int_t iev = 0; iev < nev; iev++) {
    
    cout <<"Event number "<< iev << endl;
    
    //  Initialize event
    header->Reset(0,iev);
    rl->SetEventNumber(iev);
    stack->Reset();
    rl->MakeTree("K");
    
    //  Generate event
    Int_t nprim = 0;
    Int_t ntrial = 0;
    Int_t ndstar = 0;
   
   

    //-------------------------------------------------------------------------------------

    while(!ndstar) {
      // Selection of events with D*
      stack->Reset();
      stack->ConnectTree(rl->TreeK());
      gener->Generate();
      ntrial++;
      nprim = stack->GetNprimary();
      
      for(Int_t ipart =0; ipart < nprim; ipart++){
        TParticle * part = stack->Particle(ipart);
        if(part)    {
          
          if (TMath::Abs(part->GetPdgCode())== 413) {

	    TArrayI daughtersId;

	    GetFinalDecayProducts(ipart,*stack,daughtersId);

	    Bool_t kineOK = kTRUE;

	    Double_t thetaMin = TMath::Pi()/4;
	    Double_t thetaMax = 3*TMath::Pi()/4;

	    for (Int_t id=1; id<=daughtersId[0]; id++) {
	      TParticle * daughter = stack->Particle(daughtersId[id]);
	      if (!daughter) {
		kineOK = kFALSE;
		break;
	      }

	      Double_t theta = daughter->Theta();
	      if (theta<thetaMin || theta>thetaMax) {
		kineOK = kFALSE;
		break;
	      }
	    }

	    if (!kineOK) continue;

            part->Print();
            ndstar++;     
	    
          }
        }
      }   
    }   
      
    cout << "Number of particles " << nprim << endl;
    cout << "Number of trials " << ntrial << endl;
    
    //  Finish event
    header->SetNprimary(stack->GetNprimary());
    header->SetNtrack(stack->GetNtrack());  
    
    //      I/O
    stack->FinishEvent();
    header->SetStack(stack);
    rl->TreeE()->Fill();
    rl->WriteKinematics("OVERWRITE");
    
  } // event loop
  timer.Stop();
  timer.Print();
  
  //                         Termination
  //  Generator
  gener->FinishRun();
  //  Write file
  rl->WriteHeader("OVERWRITE");
  gener->Write();
  rl->Write();
}
Beispiel #2
0
void gen(Int_t nev = 1, char* filename = "gilc.root")
{
  // Load libraries
  // gSystem->SetIncludePath("-I$ROOTSYS/include -I$ILC_ROOT/include -I$ILC_ROOT");
  gSystem->Load("liblhapdf.so");      // Parton density functions
  gSystem->Load("libEGPythia6.so");   // TGenerator interface
  gSystem->Load("libpythia6.so");     // Pythia
  gSystem->Load("libIlcPythia6.so");  // ILC specific implementations

  IlcPDG::AddParticlesToPdgDataBase();
  TDatabasePDG::Instance();

  // Run loader
  IlcRunLoader* rl = IlcRunLoader::Open("gilc.root","FASTRUN","recreate");
  
  rl->SetCompressionLevel(2);
  rl->SetNumberOfEventsPerFile(nev);
  rl->LoadKinematics("RECREATE");
  rl->MakeTree("E");
  gIlc->SetRunLoader(rl);
  
  //  Create stack
  rl->MakeStack();
  IlcStack* stack = rl->Stack();
  
  //  Header
  IlcHeader* header = rl->GetHeader();
  
  //  Create and Initialize Generator
  gROOT->LoadMacro("$ILC_ROOT/test/vmctest/ppbench/genPPbenchConfig.C");
  IlcGenerator* gener = genPPbenchConfig();

  // Go to gilc.root
  rl->CdGAFile();

  // Forbid some decays. Do it after gener->Init(0, because
  // the initialization of the generator includes reading of the decay table.
  // ...

  //
  // Event Loop
  //
  
  TStopwatch timer;
  timer.Start();
  for (Int_t iev = 0; iev < nev; iev++) {
    
    cout <<"Event number "<< iev << endl;
    
    // Initialize event
    header->Reset(0,iev);
    rl->SetEventNumber(iev);
    stack->Reset();
    rl->MakeTree("K");
    
    // Generate event
    stack->Reset();
    stack->ConnectTree(rl->TreeK());
    gener->Generate();
    cout << "Number of particles " << stack->GetNprimary() << endl;
    
    // Finish event
    header->SetNprimary(stack->GetNprimary());
    header->SetNtrack(stack->GetNtrack());  
    
    // I/O
    stack->FinishEvent();
    header->SetStack(stack);
    rl->TreeE()->Fill();
    rl->WriteKinematics("OVERWRITE");
    
  } // event loop
  timer.Stop();
  timer.Print();
  
  //                         Termination
  //  Generator
  gener->FinishRun();
  //  Write file
  rl->WriteHeader("OVERWRITE");
  gener->Write();
  rl->Write();
}