Exemplo n.º 1
0
void genExtFileConfig()
{
  cout << "Running genExtFileConfig.C ... " << endl;

  //=======================================================================
  // Steering parameters for ILC simulation
  //=======================================================================

  gMC->SetProcess("DCAY",1);
  gMC->SetProcess("PAIR",1);
  gMC->SetProcess("COMP",1);
  gMC->SetProcess("PHOT",1);
  gMC->SetProcess("PFIS",0);
  gMC->SetProcess("DRAY",0);
  gMC->SetProcess("ANNI",1);
  gMC->SetProcess("BREM",1);
  gMC->SetProcess("MUNU",1);
  gMC->SetProcess("CKOV",1);
  gMC->SetProcess("HADR",1);
  gMC->SetProcess("LOSS",2);
  gMC->SetProcess("MULS",1);
  //gMC->SetProcess("RAYL",1);

  Float_t cut = 1.e-3;        // 1MeV cut by default
  Float_t tofmax = 1.e10;

  gMC->SetCut("CUTGAM", cut);
  gMC->SetCut("CUTELE", cut);
  gMC->SetCut("CUTNEU", cut);
  gMC->SetCut("CUTHAD", cut);
  gMC->SetCut("CUTMUO", cut);
  gMC->SetCut("BCUTE",  cut); 
  gMC->SetCut("BCUTM",  cut); 
  gMC->SetCut("DCUTE",  cut); 
  gMC->SetCut("DCUTM",  cut); 
  gMC->SetCut("PPCUTM", cut);
  gMC->SetCut("TOFMAX", tofmax); 

  //=======================================================================
  // External decayer
  //=======================================================================

  TVirtualMCDecayer *decayer = new IlcDecayerPythia();
  decayer->SetForceDecay(kAll);
  decayer->Init();
/*
  //forbid some decays
  IlcPythia * py= IlcPythia::Instance();
  py->SetMDME(737,1,0); //forbid D*+->D+ + pi0
  py->SetMDME(738,1,0);//forbid D*+->D+ + gamma

  for(Int_t d=747; d<=762; d++){ 
    py->SetMDME(d,1,0);
  }

  for(Int_t d=764; d<=807; d++){ 
    py->SetMDME(d,1,0);
  }
*/
  gMC->SetExternalDecayer(decayer);
  
  //=======================================================================
  // Event generator
  //=======================================================================

  // External generator configuration
  IlcGenerator* gener = GeneratorFactory();
  gener->SetOrigin(0, 0, 0);    // vertex position
  //gener->SetSigma(0, 0, 5.3);   // Sigma in (X,Y,Z) (cm) on IP position
  //gener->SetCutVertexZ(1.);     // Truncate at 1 sigma
  //gener->SetVertexSmear(kPerEvent); 
  gener->SetTrackingFlag(1);
  gener->Init();
    
  cout << "Running genExtFileConfig.C finished ... " << endl;
}
Exemplo n.º 2
0
void GeneratorFactory(PprRun_t srun) {
  
  IlcGenerator * gGener = 0x0;
  typedef enum { kNoSmear, kPerEvent, kPerTrack }  VertexSmear_t;
  
  comment = comment.Append("*** GENERATOR: ");
  
  switch (srun) {
    
    
      //Particle Type specified  by user  
      
      /****************************************************
       *     // Particles type
       *     //  PDG    Name
       *     //  22     // photon
       *     //  -11    // positron
       *     //  11     // electron
       *     //  12     // neutrino e
       *     //  -13    // muon +
       *     //  13     // muon -
       *     //  111    // pi0
       *     //  211    // pi+
       *     //  -211   // pi-
       *     //  130    // Kaon Long
       *     //  321    // Kaon +
       *     //  -321   // Kaon -
       *     //  2112   // Neutron
       *     //  2212   // Proton
       *     //  -2212  // Anti Proton
       *     //  310    // Kaon Short
       ****************************************************/
      
      
      case kGenFixed:
	//*******************************************************
	// Example of fixed particle gun                        *
	//*******************************************************
	
	//Fixed momentum, phi, theta and vertex position specified by the user:
	//SetMomentum(momentum)
	//SetPhi(phi)
	//SetTheta(theta)
	
	//Particle Type specified  by user:
	//SetPart(ipart)
	
	{
	  Int_t nParticles=1;
	  IlcGenFixed *gener = new IlcGenFixed(nParticles);
	  Int_t PDG=321;     //set the PDG code of particle
	  gener->SetPart(PDG);
	  Double_t pmom = 1.e-5;
	  gener->SetMomentum(pmom);
	  Double_t phi = 90.;
	  gener->SetPhi(phi);
	  Double_t theta = 2.;
	  gener->SetTheta(theta);
	  const TParticlePDG *ap = TDatabasePDG::Instance()->GetParticle(PDG);
	  char *name = ap->GetName();
	  
	  comment = comment.Append(Form ("IlcGenFixed for %d %s (%f GeV/c) with phi %f and theta %f\n", nParticles,name,pmom,phi,theta));
	  
	  gGener=gener;
	  
	  // gGener->SetOrigin(0., 0., -20.);    // vertex position
	  // gGener->SetSigma(0, 0, 2.);   // Sigma in (X,Y,Z) (cm) on IP position
	  // gGener->SetCutVertexZ(1.);     // Truncate at 1 sigma
	  // gGener->SetVertexSmear(kPerTrack); 
	  
	}
	break;  
	
	
    case kGenBox:
      //*******************************************************
      // Example moving  particle gun                        *
      //*******************************************************
      
      //Random generation of  momentum (transverse momentum), phi and theta in user specified range.
      //Gaussian smearing of vertex either per event or per track.
      {      
	Int_t nParticles=1;
	IlcGenBox *gener = new IlcGenBox(nParticles);
	Int_t PDG=321;     //set the PDG code of particle
	gener->SetPart(PDG);
	Double_t pmin = 0.;
	Double_t pmax = 1.e-7; 
	gener->SetMomentumRange(pmin,pmax);
	Double_t phimin = 0.0;
	Double_t phimax = 360.0; 
	gener->SetPhiRange(phimin,phimax);
	Float_t thmin = 0.;
	Float_t thmax = 3.;
	gener->SetThetaRange(thmin,thmax);
	const TParticlePDG *ap = TDatabasePDG::Instance()->GetParticle(PDG);
	char *name = ap->GetName();
	
	comment = comment.Append(Form ("IlcGenBox for %d %s (%f GeV/c-%f GeV/c) within phi %f-%f and theta %f-%f\n", nParticles,name,pmin,pmax,phimin,phimax,thmin,thmax));
	
	gGener=gener;

	// gGener->SetOrigin(0., 0., -10.);    // vertex position
	  // gGener->SetSigma(0, 0, 2.);   // Sigma in (X,Y,Z) (cm) on IP position
	  // gGener->SetCutVertexZ(1.);     // Truncate at 1 sigma
	  // gGener->SetVertexSmear(kPerTrack); 
	  
	}
	break;  
	
	
	
      case kCocktail:
	//*******************************************************
	// Example of Cocktail of particles                     *
	//*******************************************************      
	{
	  comment = comment.Append(": Cocktail of one muon and one pion from GenFixed generator\n");
	  
	  IlcGenCocktail *gener  = new IlcGenCocktail();
	  // gener->SetOrigin(0., 0., -10.);    // vertex position
	  // gener->SetSigma(0, 0, 1.);   // Sigma in (X,Y,Z) (cm) on IP position
	  // gener->SetCutVertexZ(1.);     // Truncate at 1 sigma
	  // gener->SetVertexSmear(kPerTrack); 
	  
	  IlcGenFixed *muon = new IlcGenFixed(1);
	  muon->SetPart(-13);
	  muon->SetMomentum(2.);
	  muon->SetPhi(90.);
	  muon->SetTheta(80.);
	  
	  IlcGenFixed *pion = new IlcGenFixed(1);
	  pion->SetPart(211);
	  pion->SetMomentum(2.);
	  pion->SetPhi(35.);
	  pion->SetTheta(85.);
	  
	  gener->AddGenerator(muon,"muon",1);
	  gener->AddGenerator(pion,"pion",1);
	  
	  
	  gGener=gener;
	  
	}
	break; 
	
      default: break;
  }
  
  gGener->Init();
  
}
Exemplo n.º 3
0
void fastGenPA(Int_t nev = 1, char* filename = "gilc.root")
{
//  Runloader
    IlcRunLoader* rl = IlcRunLoader::Open("gilc.root", "FASTRUN", "recreate");

    rl->SetCompressionLevel(2);
    rl->SetNumberOfEventsPerFile(10000);
    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
    IlcGenerator *gener = CreateGenerator();
    gener->Init();
    gener->SetStack(stack);
    
//
//                        Event Loop
//
    Int_t iev;
     
    for (iev = 0; iev < nev; iev++) {

	printf("\n \n Event number %d \n \n", iev);

	//  Initialize event

	header->Reset(0,iev);
	rl->SetEventNumber(iev);
	stack->Reset();
	rl->MakeTree("K");

//  Generate event

	gener->Generate();

//  Analysis
	Int_t npart = stack->GetNprimary();
	printf("Analyse %d Particles\n", npart);
	for (Int_t part=0; part<npart; part++) {
	    TParticle *MPart = stack->Particle(part);
	    Int_t mpart  = MPart->GetPdgCode();
	}
	
//  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
//
//                         Termination
//  Generator
    gener->FinishRun();

    //  Write file
    rl->WriteHeader("OVERWRITE");
    gener->Write();
    rl->Write();
}
Exemplo n.º 4
0
void Config()
{
    // ThetaRange is (0., 180.). It was (0.28,179.72) 7/12/00 09:00
    // Theta range given through pseudorapidity limits 22/6/2001

    // Set Random Number seed
    gRandom->SetSeed(sseed);
    cout<<"Seed for random number generation= "<<gRandom->GetSeed()<<endl; 
  


   // libraries required by geant321 and Pythia6
#if defined(__CINT__)
    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
    gSystem->Load("libgeant321");
#endif

    new     TGeant3TGeo("C++ Interface to Geant3");

    IlcRunLoader* rl=0x0;

    cout<<"Config.C: Creating Run Loader ..."<<endl;
    rl = IlcRunLoader::Open("gilc.root",
			    IlcConfig::GetDefaultEventFolderName(),
			    "recreate");
    if (rl == 0x0)
      {
	gIlc->Fatal("Config.C","Can not instatiate the Run Loader");
	return;
      }
    rl->SetCompressionLevel(2);
    rl->SetNumberOfEventsPerFile(100);
    gIlc->SetRunLoader(rl);

  // Set the trigger configuration
    IlcSimulation::Instance()->SetTriggerConfig(pprTrigConfName[strig]);
    cout<<"Trigger configuration is set to  "<<pprTrigConfName[strig]<<endl;


    //
    // Set External decayer
    IlcDecayer *decayer = new IlcDecayerPythia();
    decayer->SetForceDecay(kAll);
    decayer->Init();

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

    for(Int_t d=747; d<=762; d++){ 
      py->SetMDME(d,1,0);
    }

    for(Int_t d=764; d<=807; d++){ 
      py->SetMDME(d,1,0);
    }


   
    gMC->SetExternalDecayer(decayer);
    //
    //
    //=======================================================================
    //
    //=======================================================================
    // ************* STEERING parameters FOR ILC SIMULATION **************
    // --- Specify event type to be tracked through the ILC setup
    // --- All positions are in cm, angles in degrees, and P and E in GeV

    gMC->SetProcess("DCAY",1);
    gMC->SetProcess("PAIR",1);
    gMC->SetProcess("COMP",1);
    gMC->SetProcess("PHOT",1);
    gMC->SetProcess("PFIS",0);
    gMC->SetProcess("DRAY",0);
    gMC->SetProcess("ANNI",1);
    gMC->SetProcess("BREM",1);
    gMC->SetProcess("MUNU",1);
    gMC->SetProcess("CKOV",1);
    gMC->SetProcess("HADR",1);
    gMC->SetProcess("LOSS",2);
    gMC->SetProcess("MULS",1);
    gMC->SetProcess("RAYL",1);

    Float_t cut = 1.e-3;        // 1MeV cut by default
    Float_t tofmax = 1.e10;

    gMC->SetCut("CUTGAM", cut);
    gMC->SetCut("CUTELE", cut);
    gMC->SetCut("CUTNEU", cut);
    gMC->SetCut("CUTHAD", cut);
    gMC->SetCut("CUTMUO", cut);
    gMC->SetCut("BCUTE",  cut); 
    gMC->SetCut("BCUTM",  cut); 
    gMC->SetCut("DCUTE",  cut); 
    gMC->SetCut("DCUTM",  cut); 
    gMC->SetCut("PPCUTM", cut);
    gMC->SetCut("TOFMAX", tofmax); 

    // Debug and log level
    //    IlcLog::SetGlobalDebugLevel(0);
    //    IlcLog::SetGlobalLogLevel(IlcLog::kError);

    // Generator Configuration
    IlcGenerator* gener = GeneratorFactory();
    gener->SetOrigin(0, 0, 0);    // vertex position
    gener->SetSigma(0, 0, 5.3);   // Sigma in (X,Y,Z) (cm) on IP position
    gener->SetCutVertexZ(1.);     // Truncate at 1 sigma
    gener->SetVertexSmear(kPerEvent); 
    gener->SetTrackingFlag(1);
    gener->Init();
    
    if (smag == IlcMagF::k2kG) {
	comment = comment.Append(" | L3 field 0.2 T");
    } else if (smag == IlcMagF::k5kG) {
	comment = comment.Append(" | L3 field 0.5 T");
    }
    
    
    if (srad == kGluonRadiation)
    {
	comment = comment.Append(" | Gluon Radiation On");
	
    } else {
	comment = comment.Append(" | Gluon Radiation Off");
    }


    printf("\n \n Comment: %s \n \n", comment.Data());
    
    
// Field (L3 0.4 T)
    IlcMagF* field = new IlcMagF("Maps","Maps",-1., -1., smag);
    TGeoGlobalMagField::Instance()->SetField(field);

    rl->CdGAFile();
    //
    Int_t   iABSO   = 1;
    Int_t   iDIPO   = 1;
    Int_t   iFMD    = 1;
    Int_t   iFRAME  = 1;
    Int_t   iHALL   = 1;
    Int_t   iITS    = 1;
    Int_t   iMAG    = 1;
    Int_t   iMUON   = 1;
    Int_t   iPHOS   = 1;
    Int_t   iPIPE   = 1;
    Int_t   iPMD    = 1;
    Int_t   iHMPID   = 1;
    Int_t   iSHIL   = 1;
    Int_t   iT0  = 1;
    Int_t   iTOF    = 1;
    Int_t   iTPC    = 1;
    Int_t   iTRD    = 1;
    Int_t   iZDC    = 1;
    Int_t   iEMCAL  = 1;
    Int_t   iVZERO  = 1;
    Int_t   iACORDE    = 0;

    //=================== Ilc BODY parameters =============================
    IlcBODY *BODY = new IlcBODY("BODY", "Ilc envelop");


    if (iMAG)
    {
        //=================== MAG parameters ============================
        // --- Start with Magnet since detector layouts may be depending ---
        // --- on the selected Magnet dimensions ---
        IlcMAG *MAG = new IlcMAG("MAG", "Magnet");
    }


    if (iABSO)
    {
        //=================== ABSO parameters ============================
        IlcABSO *ABSO = new IlcABSOv3("ABSO", "Muon Absorber");
    }

    if (iDIPO)
    {
        //=================== DIPO parameters ============================

        IlcDIPO *DIPO = new IlcDIPOv3("DIPO", "Dipole version 3");
    }

    if (iHALL)
    {
        //=================== HALL parameters ============================

        IlcHALL *HALL = new IlcHALLv3("HALL", "Ilc Hall");
    }


    if (iFRAME)
    {
        //=================== FRAME parameters ============================

        IlcFRAMEv2 *FRAME = new IlcFRAMEv2("FRAME", "Space Frame");
	FRAME->SetHoles(1);
    }

    if (iSHIL)
    {
        //=================== SHIL parameters ============================

        IlcSHIL *SHIL = new IlcSHILv3("SHIL", "Shielding Version 3");
    }


    if (iPIPE)
    {
        //=================== PIPE parameters ============================

        IlcPIPE *PIPE = new IlcPIPEv3("PIPE", "Beam Pipe");
    }
 
    if (iITS)
    {
        //=================== ITS parameters ============================

	IlcITS *ITS  = new IlcITSv11("ITS","ITS v11");
    }

    if (iTPC)
    {
      //============================ TPC parameters =====================
        IlcTPC *TPC = new IlcTPCv2("TPC", "Default");
    }


    if (iTOF) {
        //=================== TOF parameters ============================
	IlcTOF *TOF = new IlcTOFv6T0("TOF", "normal TOF");
    }


    if (iHMPID)
    {
        //=================== HMPID parameters ===========================
        IlcHMPID *HMPID = new IlcHMPIDv3("HMPID", "normal HMPID");

    }


    if (iZDC)
    {
        //=================== ZDC parameters ============================

        IlcZDC *ZDC = new IlcZDCv4("ZDC", "normal ZDC");
    }

    if (iTRD)
    {
        //=================== TRD parameters ============================

        IlcTRD *TRD = new IlcTRDv1("TRD", "TRD slow simulator");
    }

    if (iFMD)
    {
        //=================== FMD parameters ============================
	IlcFMD *FMD = new IlcFMDv1("FMD", "normal FMD");
   }

    if (iMUON)
    {
        //=================== MUON parameters ===========================
        // New MUONv1 version (geometry defined via builders)
        IlcMUON *MUON = new IlcMUONv1("MUON", "default");
    }
    //=================== PHOS parameters ===========================

    if (iPHOS)
    {
        IlcPHOS *PHOS = new IlcPHOSv1("PHOS", "IHEP");
    }


    if (iPMD)
    {
        //=================== PMD parameters ============================
        IlcPMD *PMD = new IlcPMDv1("PMD", "normal PMD");
    }

    if (iT0)
    {
        //=================== T0 parameters ============================
        IlcT0 *T0 = new IlcT0v1("T0", "T0 Detector");
    }

    if (iEMCAL)
    {
        //=================== EMCAL parameters ============================
        IlcEMCAL *EMCAL = new IlcEMCALv2("EMCAL", "EMCAL_COMPLETEV1");
    }

     if (iACORDE)
    {
        //=================== ACORDE parameters ============================
        IlcACORDE *ACORDE = new IlcACORDEv1("ACORDE", "normal ACORDE");
    }

     if (iVZERO)
    {
        //=================== VZERO parameters ============================
        IlcVZERO *VZERO = new IlcVZEROv7("VZERO", "normal VZERO");
    }
 
             
}
Exemplo n.º 5
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();
}