示例#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();
}
示例#2
0
Int_t IlcTARGETGeoPlot (Int_t evesel=0, char *opt="All+ClustersV2", char *filename="gilc.root", Int_t isfastpoints = 0) {
  /*******************************************************************
   *  This macro displays geometrical information related to the
   *  hits, digits and rec points (or V2 clusters) in TARGET.
   *  There are histograms that are not displayed (i.e. energy
   *  deposition) but that are saved onto a file (see below)
   *
   *  INPUT arguments:
   *
   *  Int_t evesel:  the selected event number. It's =0 by default
   *
   *  Options: Any combination of:
   *    1) subdetector name:  "SPD", "SDD", "SSD", "All" (default)
   *    2) Printouts:        "Verbose" Almost everything is printed out: 
   *                          it is wise to redirect the output onto a file
   *                    e.g.: .x IlcTARGETGeoPlot.C("All+Verbose") > out.log 
   *    3) Rec Points option: "Rec"   ---> Uses Rec. Points (default)
   * 
   *    4) ClustersV2 option: "ClustersV2" ---->Uses ClustersV2
   *                           otherwise ---->uses hits and digits only
   *    Examples:
   *       .x IlcTARGETGeoPlot();  (All subdetectors; no-verbose; no-recpoints)
   *       .x IlcTARGETGeoPlot("SPD+SSD+Verbose+Rec"); 
   *   
   *    filename:   It's "gilc.root" by default. 
   *    isfastpoints: integer. It is set to 0 by defaults. This means that
   *                slow reconstruction is assumed. If fast recpoint are in
   *                in use, isfastpoints must be set =1.
   *
   *  OUTPUT: It produces a root file with a list of histograms
   *    
   *  WARNING: spatial information for SSD/DIGTARGET is obtained by pairing
   *          digits on p and n side originating from the same track, when
   *          possible. This (mis)use of DIGTARGET is tolerated for debugging 
   *          purposes only !!!!  The pairing in real life should be done
   *          starting from info really available... 
   * 
   *  COMPILATION: this macro can be compiled. 
   *      1)       You need to set your include path with
   * gSystem->SetIncludePath("-I- -I$ILC_ROOT/include -I$ILC_ROOT/TARGET -g");
   *      3)       If you are using root instead of ilcroot you need to
   *               execute the macro loadlibs.C in advance
   *      4)       To compile this macro from root (or ilcroot):
   *                 ---  .L IlcTARGETGeoPlot.C++
   *                 ---  IlcTARGETGeoPlot();
   *     
   *  M.Masera  14/05/2001 18:30
   *  Last rev. 31/05/2004 14:00 (Clusters V2 added)  E.C.          
   ********************************************************************/

  //Options
  TString choice(opt);
  Bool_t All = choice.Contains("All");
  Bool_t verbose=choice.Contains("Verbose");
  Bool_t userec=choice.Contains("Rec");
  Bool_t useclustersv2=choice.Contains("ClustersV2");
  Int_t retcode=1; //return code
 
  if (gClassTable->GetID("IlcRun") < 0) {
    gInterpreter->ExecuteMacro("loadlibs.C");
  }
  else { 
    if(gIlc){
      delete gIlc->GetRunLoader();
      delete gIlc;
      gIlc=0;
    }
  }
 
  IlcRunLoader* rl = IlcRunLoader::Open(filename);
  if (rl == 0x0){
    cerr<<"IlcTARGETGeoPlot.C : Can not open session RL=NULL"<< endl;
    return -1;
  }
  Int_t retval = rl->LoadgIlc();
  if (retval){
    cerr<<"IlcTARGETGeoPlot.C : LoadgIlc returned error"<<endl;
    return -1;
  }
  gIlc=rl->GetIlcRun();

  retval = rl->LoadHeader();
  if (retval){
    cerr<<"IlcTARGETGeoPlot.C : LoadHeader returned error"<<endl;
    return -1;
  }

  IlcTARGETLoader* TARGETloader =  (IlcTARGETLoader*) rl->GetLoader("TARGETLoader");

  if(!TARGETloader){
    cerr<<"IlcTARGETGeoPlot.C :  TARGET loader not found"<<endl;
    return -1;
  }

  TARGETloader->LoadHits("read");
  TARGETloader->LoadDigits("read");
  if(isfastpoints==1)TARGETloader->SetRecPointsFileName("TARGET.FastRecPoints.root");
  TARGETloader->LoadRecPoints("read");
  rl->GetEvent(evesel);
  Int_t nparticles = rl->GetHeader()->GetNtrack();
  IlcTARGET *TARGET  = (IlcTARGET*)gIlc->GetModule("TARGET");
  TARGET->SetTreeAddress();
  if(verbose) {
    cout<<" "<<endl<<" "<<endl;
    cout<<"******* Event processing started   *******"<<endl;
    cout<<"In the following, hits with 'StatusEntering' flag active"<<endl;
    cout<<"will not be processed"<<endl; 
    cout << "Number of particles=  " << nparticles <<endl;
  }

  // HTARGET
  TTree *TH = TARGETloader->TreeH();
  Stat_t ntracks = TH->GetEntries();
  if(verbose)cout<<"Number of primary tracks= "<<ntracks<<endl;

  // TARGET
  Int_t nmodules;
  TARGET->InitModules(-1,nmodules);
  cout<<"Number of TARGET modules= "<<nmodules<<endl;
  cout<<"Filling modules... It takes a while, now. Please be patient"<<endl;
  TARGET->FillModules(0,0,nmodules," "," ");
  cout<<"TARGET modules .... DONE!"<<endl;
  
  IlcTARGETDetTypeRec* detTypeRec = new IlcTARGETDetTypeRec(TARGETloader);
  detTypeRec->SetDefaults();
  // DIGTARGET
  TTree *TD = TARGETloader->TreeD();

  //RECPOINTS (V2 clusters)
  TTree *TR = TARGETloader->TreeR();
  TClonesArray *TARGETrec  = detTypeRec->RecPoints();
  TBranch *branch = 0;
  if(userec && TR && TARGETrec){
    if(isfastpoints==1){
      branch = TARGETloader->TreeR()->GetBranch("TARGETRecPointsF");
      cout<<"using fast points\n";
    }
    else {
      branch = TARGETloader->TreeR()->GetBranch("TARGETRecPoints");
    }
    if(branch)branch->SetAddress(&TARGETrec);
  }

  if(userec && (!TR || !TARGETrec || !branch)){
    userec = kFALSE;
    cout<<"\n ======================================================= \n";
    cout<<"WARNING: there are no RECPOINTS on this file ! \n";
    cout<<"======================================================= \n \n";
  }
  if(useclustersv2 && TR && TARGETrec){
    branch = TARGETloader->TreeR()->GetBranch("TARGETRecPoints");
    if(branch)branch->SetAddress(&TARGETrec);
  }

  if(useclustersv2 && (!TR || !TARGETrec || !branch)){
    useclustersv2 = kFALSE;
    cout<<"\n ======================================================= \n";
    cout<<"WARNING: there are no CLUSTERSV2 on this file ! \n";
    cout<<"======================================================= \n \n";
  }


  //local variables
  Int_t mod;   //module number
  Int_t nbytes = 0; 
  Double_t pos[3];  // Global position of the current module
  Float_t ragdet; // Radius of detector (x y plane)
  Int_t first; // first module
  Int_t last; // last module
  Int_t nrecp; //number of RecPoints for a given module

  //List of histograms
  TObjArray histos(26,0);  // contains the pointers to the histograms
  // Book histograms SPD
  TH2F *rspd = new TH2F("rspd","Radii of digits - SPD",50,-10.,10.,50,-10.,10.);
  TH2F *rhspd = new TH2F("rhspd","Radii of hits - SPD",50,-10.,10.,50,-10.,10.);
  TH2F *rmspd = new TH2F("rmspd","Radii of SPD modules",50,-10.,10.,50,-10.,10.);
  TH1F *zspd = new TH1F("zspd","Z of digits - SPD",100,-30.,30.);
  TH1F *zhspd = new TH1F("zhspd","Z of hits - SPD",100,-30.,30.);
  TH1F *zmspd = new TH1F("zmspd","Z of SPD modules",100,-30,30.);

  Char_t title1[50]="";
  Char_t title2[50]="";
  if(userec){ 
    sprintf(title1,"Radii of recpoints - %s","SPD");
    sprintf(title2,"Z of recpoints - %s","SPD");
  }
  if(useclustersv2){
    sprintf(title1,"Radii of clustersV2 - %s","SPD");
    sprintf(title2,"Z of clustersV2 - %s","SPD");
  }
  TH2F *rrspd = new TH2F("rrspd",title1,50,-10.,10.,50,-10.,10.);
  TH1F *zrspd = new TH1F("zrspd",title2,100,-30.,30.);
  TH1F *enespd = new TH1F("enespd","Energy deposition SPD (KeV)",100,0.,1000.);
  histos.AddLast(rspd);  // 0
  histos.AddLast(rhspd); // 1
  histos.AddLast(rmspd); // 2
  histos.AddLast(zspd);  // 3
  histos.AddLast(zhspd); // 4
  histos.AddLast(zmspd); // 5
  histos.AddLast(rrspd); // 6
  histos.AddLast(zrspd); // 7
  histos.AddLast(enespd); // 8
  // Book histograms SDD
  TH2F *rsdd = new TH2F("rsdd","Radii of digits - SDD",50,-40.,40.,50,-40.,40.);
  TH2F *rhsdd = new TH2F("rhsdd","Radii of hits - SDD",50,-40.,40.,50,-40.,40.);
  TH2F *rmsdd = new TH2F("rmsdd","Radii of SDD modules",50,-40.,40.,50,-40.,40.);
  TH1F *zsdd = new TH1F("zsdd","Z of digits - SDD",100,-40.,40.);
  TH1F *zhsdd = new TH1F("zhsdd","Z of hits - SDD",100,-40.,40.);
  TH1F *zmsdd = new TH1F("zmsdd","Z of SDD modules",100,-40,40.);
  Char_t title3[50];
  Char_t title4[50];
  if(userec){ 
    sprintf(title3,"Radii of recpoints - %s","SDD");
    sprintf(title4,"Z of recpoints - %s","SDD");
  }
  if(useclustersv2){
    sprintf(title3,"Radii of clustersV2 - %s","SDD");
    sprintf(title4,"Z of clustersV2 - %s","SDD");
  }
  TH2F *rrsdd = new TH2F("rrsdd",title3,50,-40.,40.,50,-40.,40.);   
  TH1F *zrsdd = new TH1F("zrsdd",title4,100,-40.,40.);
  TH1F *enesdd = new TH1F("enesdd","Energy deposition SDD (KeV)",100,0.,1000.);
  histos.AddLast(rsdd);  // 9
  histos.AddLast(rhsdd); // 10
  histos.AddLast(rmsdd); // 11
  histos.AddLast(zsdd);  // 12
  histos.AddLast(zhsdd); // 13
  histos.AddLast(zmsdd); // 14
  histos.AddLast(rrsdd); // 15
  histos.AddLast(zrsdd); // 16
  histos.AddLast(enesdd); // 17
  // Book histogram SSD
  TH2F *rssd = new TH2F("rssd","Radii of digits - SSD",50,-50.,50.,50,-50.,50.);
  TH2F *rhssd = new TH2F("rhssd","Radii of hits - SSD",50,-50.,50.,50,-50.,50.);
  TH2F *rmssd = new TH2F("rmssd","Radii of SSD modules",50,-50.,50.,50,-50.,50.);
  TH1F *zssd = new TH1F("zssd","Z of digits - SSD",100,-70.,70.);
  TH1F *zhssd = new TH1F("zhssd","Z of hits - SSD",100,-70.,70.);
  TH1F *zmssd = new TH1F("zmssd","Z of SSD modules",100,-70,70.);
  Char_t title5[50];
  Char_t title6[50];
  if(userec){ 
    sprintf(title5,"Radii of recpoints - %s","SSD");
    sprintf(title6,"Z of recpoints - %s","SSD");
  }
  if(useclustersv2){
    sprintf(title5,"Radii of clustersV2 - %s","SSD");
    sprintf(title6,"Z of clustersV2 - %s","SSD");
  }

  TH2F *rrssd = new TH2F("rrssd",title5,50,-50.,50.,50,-50.,50.);
  TH1F *zrssd = new TH1F("zrssd",title6,100,-70.,70.);
  TH1F *enessd = new TH1F("enessd","Energy deposition SSD (KeV)",100,0.,1000.);
  histos.AddLast(rssd);  // 18
  histos.AddLast(rhssd); // 19
  histos.AddLast(rmssd); // 20
  histos.AddLast(zssd);  // 21
  histos.AddLast(zhssd); // 22
  histos.AddLast(zmssd); // 23
  histos.AddLast(rrssd); // 24
  histos.AddLast(zrssd); // 25
  histos.AddLast(enessd); // 26
  //
  // Loop on subdetectors
  // 
  IlcTARGETgeom *geom = TARGET->GetTARGETgeom();
  TString detna; // subdetector name
  for(Int_t subd=0;subd<3;subd++){
    if(All || (choice.Contains("SPD") && subd==0) || (choice.Contains("SDD") && subd==1) || (choice.Contains("SSD") && subd==2)){
      // Prepare array for the digits
      TClonesArray *TARGETdigits  = TARGET->DigitsAddress(subd);
      Bool_t usedigits = kTRUE;
      if(!TARGETdigits){
        usedigits = kFALSE;
        cout<<"\n ======================================================= \n";
        cout<<"WARNING: there are no DIGTARGET on this file ! \n";
        cout<<"======================================================= \n \n";
      }
      // Get segmentation model
      if(subd==0)detna="SPD";
      if(subd==1)detna="SDD";
      if(subd==2)detna="SSD";
      IlcTARGETsegmentation *seg=(IlcTARGETsegmentation*)detTypeRec->GetSegmentationModel(subd);
      // Loop on modules
      first = geom->GetStartDet(subd);
      last = geom->GetLastDet(subd);
      if(verbose){
        cout<<"     "<<endl<<"-------------------------------------"<<endl;
        cout<<"Start processing subdetector "<<detna<<endl;
        cout<<detna<<" first module "<<first<<endl;
        cout<<detna<<" last module "<<last<<endl;
        cout<<" "<<endl<<" "<<endl;
      }
      for (mod=first; mod<=last; mod++){
        geom->GetTrans(mod,pos);  // position of the module in the MRS
        ragdet=sqrt(pos[0]*pos[0]+pos[1]*pos[1]);
        // The following 2 histos are a check of the geometry
        TH2F *bidi = (TH2F*)histos.At(2+subd*9);
        TH1F *uni = (TH1F*)histos.At(5+subd*9);
        bidi->Fill(pos[0],pos[1]);
        uni->Fill(pos[2]);
        if(verbose){
          cout<<"=========================================================\n";
          cout<<detna<<" module="<<mod<<endl;
          cout<<"Mod. coordinates: "<<pos[0]<<", "<<pos[1]<<", ";
          cout<<pos[2]<<" Radius "<<ragdet<<endl;
        }

        // Hits
        GetHitsCoor(TARGET,mod,histos,subd,verbose);

        //RecPoints     
        if(userec){
          detTypeRec->ResetRecPoints();
          branch->GetEvent(mod);
          TH2F *bidi=(TH2F*)histos.At(6+subd*9);
          TH1F *uni=(TH1F*)histos.At(7+subd*9);
          nrecp=GetRecCoor(geom,TARGETrec,mod,bidi,uni,verbose);
        }
        if(useclustersv2){
          detTypeRec->ResetRecPoints();
          branch->GetEvent(mod);
          TH2F *bidi=(TH2F*)histos.At(6+subd*9);
          TH1F *uni=(TH1F*)histos.At(7+subd*9);
          nrecp=GetClusCoor(geom,TARGETrec,mod,bidi,uni,verbose);
	  
        }
     
        // Digits
        if(usedigits){
          detTypeRec->ResetDigits();
          nbytes += TD->GetEvent(mod);
          GetDigits(seg,geom,TARGETdigits,subd,mod,verbose,histos);
        }

      } // End of loop on the modules
      TH1F *h1tmp;
      TH2F *h2tmp;
      //  Plot the histograms
      TCanvas *current=0; // current Canvas (1--> SPD, 2---> SDD, 3---> SSD)
      if(subd==0){
        // Prepare canvas 1
        TCanvas *c1 = new TCanvas("c1","SPD",10,10,600,900);
        c1->Divide(2,3);
        current=c1;
      }
      if(subd==1){
        // Prepare canvas 2
        TCanvas *c2 = new TCanvas("c2","SDD",40,40,600,900);
        c2->Divide(2,3);
        current=c2;
      }
      if(subd==2){
        // Prepare canvas 3
        TCanvas *c3 = new TCanvas("c3","SSD",70,70,600,900);
        c3->Divide(2,3);
        current=c3;
      }
      current->cd(1);
      h2tmp = (TH2F*)histos.At(9*subd);
      h2tmp->Draw();
      current->cd(2);
      h1tmp=(TH1F*)histos.At(3+subd*9);
      h1tmp->Draw();
      current->cd(3);
      h2tmp=(TH2F*)histos.At(1+9*subd);
      h2tmp->Draw();
      current->cd(4);
      h1tmp=(TH1F*)histos.At(4+subd*9);
      h1tmp->Draw();
   
      if(userec || useclustersv2){
        current->cd(5);
        h2tmp=(TH2F*)histos.At(6+9*subd);
        h2tmp->Draw();
        current->cd(6);
        h1tmp=(TH1F*)histos.At(7+subd*9);
        h1tmp->Draw();
      }
  
      else {
        current->cd(5);
        h2tmp=(TH2F*)histos.At(2+9*subd);
        h2tmp->Draw();
        current->cd(6);
        h2tmp=(TH2F*)histos.At(5+9*subd);
        h2tmp->Draw();
      }
    } // if(All.....
  } // end of loop on subdetectors
  // Save the histograms
  TFile *fh = new TFile("IlcTARGETGeoPlot.root","recreate");
  // The list is written to file as a single entry
  TList *lihi = new TList();
  // copy the pointers to the histograms to a TList object.
  // The histograms concerning recpoints are not copied if
  // 'userec' is false.
  for(Int_t i=0;i<histos.GetEntriesFast();i++){
    if(choice.Contains("All") || (choice.Contains("SPD") && i<8) || (choice.Contains("SDD") && i>7 && i<16) || (choice.Contains("SSD") && i>15)){
      if(!(!userec && ((i+2)%9==0 || (i+1)%9==0)))lihi->Add(histos.At(i));
    }
  }
  lihi->Write("Histograms TARGET hits+digits+recpoints",TObject::kSingleKey);
  fh->Close();

  return retcode;
}
示例#3
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();
}
示例#4
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();
}
示例#5
0
void fastGen(Int_t nev = 1, char* filename = "gilc.root")
{
  // 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();
  
  //  Generator
  IlcGenPythia *gener = new IlcGenPythia(-1);
  gener->SetMomentumRange(0,999999);
  gener->SetProcess(kPyMb);
  gener->SetEnergyCMS(14000.);
  gener->SetThetaRange(45, 135);
  gener->SetPtRange(0., 1000.);
  gener->SetStack(stack);
  gener->Init();
  rl->CdGAFile();
  //
  //                        Event Loop
  //
  for (Int_t iev = 0; iev < nev; iev++) {
    
    //  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 minmult = 1000;

    while(nprim<minmult) {
      // Selection of events with multiplicity
      // bigger than "minmult"
      stack->Reset();
      gener->Generate();
      ntrial++;
      nprim = stack->GetNprimary();
      
    }
    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
  
  //                         Termination
  //  Generator
  gener->FinishRun();
  //  Stack
  stack->FinishRun();
  //  Write file
  rl->WriteHeader("OVERWRITE");
  gener->Write();
  rl->Write();
}