Exemplo n.º 1
0
Arquivo: test.c Projeto: S010/test
int
main(int argc, char **argv)
{
	struct lib libs[] = {
		{ "libX11.so" },
		{ "libXcursor.so" },
		{ "libXrandr.so" },
		{ NULL },
	};

	loadlibs(libs);
	unloadlibs(libs);
	loadlibs(libs); /* XXX crash! */

	return 0;
}
Exemplo n.º 2
0
void LuaState::create()
{
    if ( m_lua )
    {
        return;
    }
    
    TRACE_ENTERLEAVE();
    
    //
    //  create new lua state
    //
    m_lua = luaL_newstate( );

    // //
    // //  register api functons
    // //
    static const luaL_Reg functions[] = {
        {"serverAddTimer", serverAddTimer },
        {"serverCreate", serverCreate },
        {"serverConnectionSendData", serverConnectionSendData },
        {"serverConnectionGetAddress", serverConnectionGetAddress},
        {"serverConnectionGetId", serverConnectionGetId},
        {"serverSendTo", serverSendTo},
        {"clientCreate", clientCreate },
        {"clientConnect", clientConnect },
        {"clientAddTimer", clientAddTimer },
        {"clientConnectionSendData", clientConnectionSendData },
        {"clientConnectionClose", clientConnectionClose },
        {"getpid", getpid },
        {"processorCount", processorCount},
        {"httpRequestGetUrl", httpRequestGetUrl},
        {"httpRequestGetHeaders", httpRequestGetHeaders},
        {"httpRequestGetBody", httpRequestGetBody},
        {"httpRequestGetMethod", httpRequestGetMethod},
        {"httpRequestGetAddress", httpRequestGetAddress},
        {"httpResponseSetBody", httpResponseSetBody},
        {"httpResponseSetStatus", httpResponseSetStatus},
        {"httpResponseSetHeaders", httpResponseSetHeaders},
        {"httpResponseAddHeader", httpResponseAddHeader},
        {"getVersion", getVersion},
        {"dictionaryGet", dictionaryGet},
        {"dictionarySet", dictionarySet},
        {"dictionaryRemove", dictionaryRemove},
        {"dictionaryGetKeys", dictionaryGetKeys},
        {"processStart", processStart},
        {"processWrite", processWrite},
        
        {NULL, NULL }
    };

    luaL_register( m_lua, "__api", functions );
    
    loadlibs();
        
}
Exemplo n.º 3
0
void anachain( const Char_t *ddname = "/star/data05/scratch/jwebb/checkin/",
	       const Char_t *pref="R5", 
	       const Char_t *ffname = ".root",
	       Int_t nmax=50000
	       ) 
{

  gROOT->LoadMacro("macros/loadlibs.C");
  loadlibs();

  c = new TCanvas("c","A canvas",500,500); 

  mTree = new TChain("mTree","A pi0 tree");

  TSystemDirectory *dir = new TSystemDirectory("pwd",ddname);
  TList *files = dir->GetListOfFiles();
  TIter next( files );
  TSystemFile *file = 0;
  Int_t nf = 0;

  TList *listOfEmpties=new TList();

  while ( (file = (TSystemFile *)next() ) ) {


    //-- Get the filename --
    TString fname = file -> GetName();
    if ( !fname.Contains(ffname) ) continue;
    if ( !fname.Contains(pref) ) continue;     
    Bool_t pi0tree = 0;

    /// Open the file and determine if it contains
    /// a TTree
    TFile pfile( fname );
    TTree *mytree = (TTree *)pfile.Get("mTree");
    if ( mytree ) pi0tree = 1;
    pfile.Close();

    //-- If we have the trees, add them
    if ( pi0tree ) {
      std::cout << "Adding " << fname 
		<< " npi0tree=" << mTree->GetEntries()
		<< std::endl;

      mTree -> Add(fname+"/mTree");
      nf++;
    }

    if ( nf > nmax ) break;
  }

  std::cout << "-- anachain -----------------------------------" << std::endl;
  std::cout << std::endl;
  std::cout << "loaded " << nf << " files" << std::endl; 
}
Exemplo n.º 4
0
void display2(const char *filename="gilc.root", Int_t nevent=0,
              Int_t *tracks=0, Int_t ntracks=0)
{
   // Dynamically link some shared libs
   if (gClassTable->GetID("IlcRun") < 0) {
      gROOT->LoadMacro("loadlibs.C");
      loadlibs();
   } else {
//       delete gIlc->GetRunLoader();
      delete gIlc;
      gIlc = 0;
   }
   //gSystem->Load("libIlcL3Src");
   gSystem->Load("libDISPLAY");

   // Connect the ROOT Gilc file containing Geometry, Kine and Hits
   IlcRunLoader *rl = 0;
   TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(filename);
   if(file) {
      Info("display2.C", "gilc.root is already open");
   }
   rl = IlcRunLoader::Open(filename, "DISPLAYED EVENT");

   if (rl == 0) {
      Error("display2.C", "can not get Run Loader, exiting...");
      return;
   }

   // Get IlcRun object from file or create it if not on file
   rl->LoadgIlc();

   gIlc = rl->GetIlcRun();
   if (!gIlc) {
      Error("display2.C", "IlcRun object not found on file, exiting...");
      return;
  }

   // Create Event Display object
   IlcDisplay2 *edisplay = new IlcDisplay2(gClient->GetRoot(), 900, 700);
   // if (ntracks > 0) edisplay->SetTracksToDisplay(tracks, ntracks);

   // Display the requested event
   rl->GetEvent(nevent);
   rl->LoadKinematics();
   rl->LoadHeader();
   rl->LoadHits();

   //edisplay->FindModules();
   edisplay->ShowNextEvent(0);
}
Exemplo n.º 5
0
void LuaState::reload( unsigned int threadId )
{
    TRACE_ENTERLEAVE();
    
    if ( Leda::instance()->debug() && Leda::instance()->changes() > 0 )
    {
        if ( !m_lua )
        {
            throw std::runtime_error( "cannot reload without a loaded script first" );
        }
        
        TRACE("have %d filesystem changes, need to reload lua", Leda::instance()->changes() );
        destroy();
        create();
        loadlibs();
        load();
        setGlobal( "threadId", threadId );
        
        Leda::instance()->resetChanges();
    }
}
Exemplo n.º 6
0
void run_litqa(Int_t nEvents = 1000)
{
   TTree::SetMaxTreeSize(90000000000);

	TString script = TString(gSystem->Getenv("SCRIPT"));
	TString parDir = TString(gSystem->Getenv("VMCWORKDIR")) + TString("/parameters");

	//gRandom->SetSeed(10);

    TString dir = "/hera/cbm/users/slebedev/mc/dielectron/sep13/25gev/trd/1.0field/nomvd/rho0/";
	TString mcFile = dir + "mc.auau.25gev.centr.00001.root";
	TString parFile = dir + "/params.auau.25gev.centr.00001.root";
	TString recoFile = dir + "/test.reco.test.auau.25gev.centr.00001.root";
	TString qaFile = dir + "/test.litqa.test.auau.25gev.centr.00001.root";

	TString delta = "no"; // if "yes" Delta electrons will be embedded
	TString deltaFile = "";

   TList *parFileList = new TList();
   TObjString stsDigiFile = parDir + "/sts/sts_v13c_std.digi.par"; // STS digi file
   TObjString trdDigiFile = parDir + "/trd/trd_v13p_3e.digi.par"; // TRD digi file
   TObjString tofDigiFile = parDir + "/tof/tof_v13b.digi.par"; // TRD digi file

   TString stsMatBudgetFileName = parDir + "/sts/sts_matbudget_v13c.root"; // Material budget file for L1 STS tracking

   TString resultDir = "results_litqa/";
   Double_t trdAnnCut = 0.85;
   Int_t minNofPointsTrd = 6;

	if (script == "yes") {
		mcFile = TString(gSystem->Getenv("MC_FILE"));
		parFile = TString(gSystem->Getenv("PAR_FILE"));
		recoFile = TString(gSystem->Getenv("RECO_FILE"));
		qaFile = TString(gSystem->Getenv("LITQA_FILE"));

		delta = TString(gSystem->Getenv("DELTA"));
		deltaFile = TString(gSystem->Getenv("DELTA_FILE"));

		stsDigiFile = TString(gSystem->Getenv("STS_DIGI"));
		trdDigiFile = TString(gSystem->Getenv("TRD_DIGI"));
		tofDigiFile = TString(gSystem->Getenv("TOF_DIGI"));

		resultDir = TString(gSystem->Getenv("RESULT_DIR"));

		stsMatBudgetFileName = TString(gSystem->Getenv("STS_MATERIAL_BUDGET_FILE"));
		trdAnnCut = TString(gSystem->Getenv("TRD_ANN_CUT")).Atof();
		minNofPointsTrd = TString(gSystem->Getenv("MIN_NOF_POINTS_TRD")).Atof();
	}

   parFileList->Add(&stsDigiFile);
   parFileList->Add(&trdDigiFile);
   parFileList->Add(&tofDigiFile);

   TStopwatch timer;
   timer.Start();

	// ----  Load libraries   -------------------------------------------------
   gROOT->LoadMacro("$VMCWORKDIR/macro/littrack/loadlibs.C");
	loadlibs();
	gROOT->LoadMacro("$VMCWORKDIR/macro/littrack/determine_setup.C");

	// -----   Reconstruction run   -------------------------------------------
	FairRunAna *run= new FairRunAna();
	if (mcFile != "") run->SetInputFile(mcFile);
	if (recoFile != "") run->AddFriend(recoFile);
	if (qaFile != "") run->SetOutputFile(qaFile);

	CbmKF* kalman = new CbmKF();
	run->AddTask(kalman);
	CbmL1* l1 = new CbmL1();
	l1->SetMaterialBudgetFileName(stsMatBudgetFileName);
	run->AddTask(l1);

   // Reconstruction Qa
   CbmLitTrackingQa* trackingQa = new CbmLitTrackingQa();
   trackingQa->SetMinNofPointsSts(4);
   trackingQa->SetUseConsecutivePointsInSts(true);
   trackingQa->SetMinNofPointsTrd(minNofPointsTrd);
   trackingQa->SetMinNofPointsMuch(10);
   trackingQa->SetMinNofPointsTof(1);
   trackingQa->SetQuota(0.7);
   trackingQa->SetMinNofHitsTrd(minNofPointsTrd);
   trackingQa->SetMinNofHitsMuch(10);
   trackingQa->SetVerbose(0);
   trackingQa->SetMinNofHitsRich(7);
   trackingQa->SetQuotaRich(0.6);
   trackingQa->SetPRange(30, 0., 6.);
   trackingQa->SetOutputDir(std::string(resultDir));
   std::vector<std::string> trackCat, richCat;
   trackCat.push_back("All");
   trackCat.push_back("Electron");
   richCat.push_back("All");
   richCat.push_back("Electron");
   richCat.push_back("ElectronReference");
   trackingQa->SetTrackCategories(trackCat);
   trackingQa->SetRingCategories(richCat);
   trackingQa->SetTrdAnnCut(trdAnnCut);
   run->AddTask(trackingQa);

   CbmLitFitQa* fitQa = new CbmLitFitQa();
   fitQa->SetMvdMinNofHits(0);
   fitQa->SetStsMinNofHits(4);
   fitQa->SetMuchMinNofHits(10);
   fitQa->SetTrdMinNofHits(minNofPointsTrd);
   fitQa->SetPRange(30, 0., 3.);
   fitQa->SetOutputDir(std::string(resultDir));
   run->AddTask(fitQa);

  /* CbmLitClusteringQa* clusteringQa = new CbmLitClusteringQa();
   clusteringQa->SetMuchDigiFileName(muchDigiFile.Data());
   clusteringQa->SetOutputDir(std::string(resultDir));
   run->AddTask(clusteringQa);*/

   CbmLitTofQa* tofQa = new CbmLitTofQa();
   tofQa->SetOutputDir(std::string(resultDir));
   run->AddTask(tofQa);


    // -----  Parameter database   --------------------------------------------
   FairRuntimeDb* rtdb = run->GetRuntimeDb();
   FairParRootFileIo* parIo1 = new FairParRootFileIo();
   FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo();
   parIo1->open(parFile.Data());
   parIo2->open(parFileList, "in");
   rtdb->setFirstInput(parIo1);
   rtdb->setSecondInput(parIo2);
   rtdb->setOutput(parIo1);
   rtdb->saveOutput();

    run->Init();
    run->Run(0, nEvents);

    // -----   Finish   -------------------------------------------------------
    timer.Stop();
    std::cout << "Macro finished successfully." << std::endl;
    std::cout << "Output file is "    << recoFile << std::endl;
    std::cout << "Parameter file is " << parFile << std::endl;
    std::cout << "Real time " << timer.RealTime() << " s, CPU time " << timer.CpuTime() << " s" << std::endl;
    std::cout << " Test passed" << std::endl;
    std::cout << " All ok " << std::endl;
}
Exemplo n.º 7
0
void runEEmcPi0Maker( Int_t nevents = 5000, 
		      Char_t *name = "mcpi0_5000_06TC05_10.MuDst.root",
		      Char_t *ofile= "mcpi0_5000_06TC05_10.pi0tree.root",
		      Char_t *path = "/star/data04/sim/jwebb/MonteCarlo/single_gamma/", 
		      Int_t nfiles = 100
		      )
{



  TString pathname = path; 
  pathname += name;

  gROOT->LoadMacro("StRoot/StEEmcPool/StMaxStripPi0/macros/loadlibs.C");
  loadlibs();
  
  /// This MUST be created in order to ::Instance() to work.(?)
  EEmcGeomSimple *g=new EEmcGeomSimple();
  

  //-- Create the analysis chain --
  mChain = new StChain("eemcAnalysisChain");

  //-- Create micro-dst maker and load in MuDsts --
  mMuDstMaker = new StMuDstMaker(0,0,path,name,"MuDst",nfiles);
  mMuDstMaker->SetStatus("*",0);
  mMuDstMaker->SetStatus("MuEvent",1);
  mMuDstMaker->SetStatus("EmcAll",1);

  //-- Initialize database connection --
  mStarDatabase = new St_db_Maker("StarDb", "MySQL:StarDb");
  
  //-- DATE TIME FOR MONTE CARLO --
#ifdef MONTE_CARLO  // flags for M-C events
  TDatime *time = new TDatime();
  mStarDatabase -> SetDateTime( time -> GetDate(), time -> GetTime() );
  mStarDatabase->SetDateTime(20031120,0);
  mStarDatabase->SetFlavor("sim","eemcPMTcal");
  mStarDatabase->SetFlavor("sim","eemcPIXcal");
  mStarDatabase->SetFlavor("sim","eemcPMTped");
  mStarDatabase->SetFlavor("sim","eemcPMTstat");
  mStarDatabase->SetFlavor("sim","eemcPMTname");
  mStarDatabase->SetFlavor("sim","eemcADCconf");
#endif

  //-- Initialize EEMC database --
  new StEEmcDbMaker("eemcDb");
  gMessMgr -> SwitchOff("D");
  gMessMgr -> SwitchOn("I");

#ifdef MONTE_CARLO
  //-- Create the slow simulator for the endcap
  if ( useSlow ) {
    StEEmcSlowMaker *slowSim = new StEEmcSlowMaker("slowSim");
    slowSim->setDropBad(0);   // 0=no action, 1=drop chn marked bad in db
    slowSim->setAddPed(0);    // 0=no action, 1=ped offset from db
    slowSim->setSmearPed(0);  // 0=no action, 1=gaussian ped, width from db
    slowSim->setOverwrite(1); // 0=no action, 1=overwrite muDst values
  }
#endif


  
  mEEmcA2E=new StEEmcA2EMaker("AandE");
  mEEmcA2E->database("eemcDb");
  mEEmcA2E->source("MuDst",1);
  mEEmcA2E->threshold(0,3.0);
  mEEmcA2E->threshold(1,3.0);
  mEEmcA2E->threshold(2,3.0);
  mEEmcA2E->threshold(3,3.0);
#ifdef MONTE_CARLO
  mEEmcA2E->scale(1.2);
#endif

  
  mEEclusters=new StEEmcClusterMaker("mEEclusters");
  mEEclusters->analysis("AandE");
  mEEclusters->seedEnergy(0.8,0); // tower seed energy
  mEEclusters->seedEnergy(2.0/1000.,4); // 2 MeV smd-u strip
  mEEclusters->seedEnergy(2.0/1000.,5); // 2 MeV smd-v strip
  mEEclusters->setSeedFloor(3.0);
  //  mEEclusters->setFillStEvent();

  mEEclusters->setMaxExtent(3);
 

  
      
  mEEpoints=new StEEmcPointMaker("mEEpoints"); 
  mEEpoints->analysis("AandE");
  mEEpoints->clusters("mEEclusters"); 
  
  
  
  //mEEmixer=new StEEmcMixMaker("mEEmixer"); 
  mEEmixer=new StEEmcMixTreeMaker("mEEmixer");
  mEEmixer->setFilename( ofile  );  
  mEEmixer->mudst("MuDst");
  mEEmixer->analysis("AandE");
  mEEmixer->points("mEEpoints");
  mEEmixer->sector(4);
  mEEmixer->sector(5);
  mEEmixer->sector(6);
  mEEmixer->sector(7);
  mEEmixer->trigger(45203);


  mEEmixer2 = new StEEmcMixHistMaker("mEEmixer2");
  mEEmixer2->mudst("MuDst");
  mEEmixer2->analysis("AandE");
  mEEmixer2->points("mEEpoints");
  mEEmixer2->sector(4);
  mEEmixer2->sector(5);
  mEEmixer2->sector(6);
  mEEmixer2->sector(7);
  mEEmixer2->trigger(45203);
  
  

  //  TFile *f=new TFile("test.root","recreate");
  //  TH1F *hNpoints=new TH1F("hNpoints","Number of points",10,0.,10.);
  

  mChain->ls(3);
  mChain->Init();

  //-- Loop over all events in the muDst --
  Int_t stat  = 0;
  Int_t count = 0;
  while ( stat == 0 ) {

    //-- Terminate once we reach nevents --
    if ( count++ >= nevents )
      if ( nevents > 0 ) break;

    //-- Call clear on all makers --
    mChain -> Clear();


    //-- Process the event through all makers --
    stat = mChain -> Make();

    if ( (count%100) ) continue;

    std::cout << "------------------------------------------------";
    std::cout << "event=" << count << std::endl;
    for ( int i = 0; i < 4; i++ ) {
      std::cout << " layer=" << i << " nhits=" << mEEmcA2E->numberOfHitTowers(i) << std::endl;
    }
        
	    
  }// loop over all events

  //-- Finish up --
  mChain -> Finish();
  //  f->Write();

  TString oo=ofile;
  oo.ReplaceAll("pi0tree","pi0hist");
  TFile *f=new TFile(oo,"recreate");
  f->cd();
  mEEmixer2->GetHistList()->Write();
  f->Write();
  f->Close();
  delete f;
  


  return;
    
}
Exemplo n.º 8
0
Int_t TOFquickanal(Int_t eventNumber = 0)
{
  /////////////////////////////////////////////////////////////////////////
  //   This macro is a small example of a ROOT macro
  //   illustrating how to read the output of GALICE
  //   and fill some histograms concerning the TOF Hit Tree.
  //
  //     Root > .L TOFquickanal.C   //this loads the macro in memory
  //     Root > TOFquickanal();     //by default process first event
  //     Root > TOFquickanal(2);    //process third event
  //Begin_Html
  /*
    <img src="picts/TOFquickanal.gif">
  */
  //End_Html
  //
  // Author: F. Pierella , Bologna University 12-04-2001
  // Updated to the new I/O by: A. De Caro, C. Zampolli
  /////////////////////////////////////////////////////////////////////////
  
  // Dynamically link some shared libs
  if (gClassTable->GetID("AliRun") < 0) {
    gROOT->LoadMacro("loadlibs.C");
    loadlibs();
  }

  Int_t rc = 0;
  
  AliRunLoader *rl =AliRunLoader::Open("galice.root",AliConfig::GetDefaultEventFolderName(),"update");
  if (!rl) 
    {
      cerr << "Can't load RunLoader from file!\n";
      rc = 1;
      return rc;
    }

  rl->LoadgAlice();
  gAlice=rl->GetAliRun();

  if (!gAlice)
    {
      cerr << "<TOFquickanal> AliRun object not found on file \n";
      rc = 2;
      return rc;
    }

  // Get the pointer to the TOF detector
  AliLoader *tofl = rl->GetLoader("TOFLoader");
  AliTOF * tof = (AliTOF*) gAlice->GetDetector("TOF");
  if (tof == 0x0 || tofl == 0x0) {
    cerr << "<TOFquickanal> Can not find TOF or TOFLoader\n";
    rc = 3;
    return rc;
  }

  //=======> Create histograms
  //---> Time of Flight for Primary Particles (ns)
  TH1F *htofprim = new TH1F("htofprim","Time of Flight for Primary Particles",100,0.,100.);
  //--->Time of Flight for Secondary Particles (ns)
  TH1F *htofsec  = new TH1F("htofsec","Time of Flight for Secondary Particles",100,0.,100.);
  
  //---> r (radius) coordinate of production in the ALICE frame for secondary particles that produce at 
  //     least one TOF-hit (cm) - cylindrical coordinate system assumed, primary plus secondary-
  TH1F *hradius = new TH1F("hradius","r (radius) coordinate at the production vertex for secondary particles with at least one TOF-Hit",50,0.,500.);
  
  //---> Momentum of primary particles that produce (at least) one TOF-hit when the hit
  //     is produced (Gev/c)
  TH1F *htofmom  = new TH1F("htofmom","Momentum of primary particles when the Hit is produced",50,0.,5.);
  
  //---> Momentum of primary particles that produce (at least) one TOF-hit at the production vertex
  //     (Gev/c)
  TH1F *hprodmom  = new TH1F("hprodmom","Momentum of primary particles (with at least one TOF hit) at the production ",50,0.,5.); 
  
  //---> Theta of production for primary particles that produce (at least) one TOF-hit (deg)
  TH1F *hprodthe  = new TH1F("hprodthe","Theta of primary particles (with at least one TOF hit) at the production ",90,0.,180.);
  
  //---> Phi of production for primary particles that produce (at least) one TOF-hit (deg)
  TH1F *hprodphi  = new TH1F("hprodphi","Phi of primary particles (with at least one TOF hit) at the production ",180,-180.,180.);
  
  //---> z Coordinate of the TOF Hit (z beam axis) - primary plus secondary - (cm)
  TH1F *hzcoor = new TH1F("hzcoor","z Coordinate of the TOF Hit",800,-400.,400.);
  
  //---> Incidence Angle of the particle on the pad (or strip) (deg)  - primary plus secondary - 
  TH1F *hincangle = new TH1F("hincangle","Incidence Angle of the particle on the strip",90,0.,180.);
  
  printf ("Processing event %d \n", eventNumber);
  rl->GetEvent(eventNumber);
  
  // Get pointers to Alice detectors and Hits containers
  tofl->LoadHits();
  TTree *TH = tofl->TreeH();
  tof->SetTreeAddress();
  if (!TH) {
    cout << "<TOFquickanal> No hit tree found" << endl;
    rc = 4;
    return rc;
  }
  
  // Import the Kine Tree for the event eventNumber in the file  
  rl->LoadHeader();
  rl->LoadKinematics();
  //AliStack * stack = rl->Stack();
  
  Int_t ntracks = TH->GetEntries();
  cout<<" ntracks = "<<ntracks<<endl;
  
  AliTOFhitT0 *tofHit;
  
  // Start loop on tracks in the hits containers
  for (Int_t track=0; track<ntracks;track++) {
    
    tof->ResetHits();
    TH->GetEvent(track);
    
    for(tofHit=(AliTOFhitT0*)tof->FirstHit(track); tofHit; tofHit=(AliTOFhitT0*)tof->NextHit()) {
      
      Float_t toflight = tofHit->GetTof();
      toflight        *= 1.E+09;  // conversion from s to ns
      Double_t tofmom  = tofHit->GetMom();
      
      Int_t ipart = tofHit->Track();
      TParticle *particle = gAlice->Particle(ipart);
      if (particle->GetFirstMother() < 0) {
	htofprim->Fill(toflight);
	htofmom->Fill(tofmom); 
      } else {
	htofsec->Fill(toflight); 
      }
      
      Double_t zcoor = tofHit->Z();
      hzcoor->Fill(zcoor);
      
      Double_t incangle = tofHit->GetIncA();
      hincangle->Fill(incangle);
      
      Double_t xcoor  = particle->Vx();
      Double_t ycoor  = particle->Vy();
      Double_t radius = TMath::Sqrt(xcoor*xcoor+ycoor*ycoor);
      if (particle->GetFirstMother() >= 0) hradius->Fill(radius);
      
      Double_t prodmom = particle->P();        
      if (prodmom!=0.) {
	Double_t dummy = (particle->Pz())/prodmom;
	Double_t prodthe = TMath::ACos(dummy);
	prodthe *= 57.29578; // conversion from rad to deg
	if (particle->GetFirstMother() < 0) hprodthe->Fill(prodthe);
      } // theta at production vertex
      
      if (particle->GetFirstMother() < 0) {         
	hprodmom->Fill(prodmom);
	Double_t dummypx = particle->Px();
	Double_t dummypy = particle->Py();
	Double_t prodphi = TMath::ATan2(dummypy,dummypx);
	prodphi *= 57.29578; // conversion from rad to deg
	hprodphi->Fill(prodphi);
      } // phi at production vertex
    } // close loop on TOF-hits
  } // close loop on tracks in the hits containers
  
  //Create  canvas, set the view range, show histograms
  TCanvas *c1 = new TCanvas("c1","Alice TOF hits quick analysis",400,10,600,700);
  c1->cd();
  hprodmom->Draw();
  
  TCanvas *c2 = new TCanvas("c2","Alice TOF hits quick analysis",400,10,600,700);
  c2->cd();
  hprodthe->Draw();
  
  TCanvas *c3 = new TCanvas("c3","Alice TOF hits quick analysis",400,10,600,700);
  c3->cd();
  hprodphi->Draw();
  
  TCanvas *c4 = new TCanvas("c4","Alice TOF hits quick analysis",400,10,600,700);
  c4->cd();
  hzcoor->Draw();
  
  TCanvas *c5 = new TCanvas("c5","Alice TOF hits quick analysis",400,10,600,700);
  c5->cd();
  hradius->Draw();
  
  TCanvas *c6 = new TCanvas("c6","Alice TOF hits quick analysis",400,10,600,700);
  c6->cd();
  htofprim->Draw();
  
  TCanvas *c7 = new TCanvas("c7","Alice TOF hits quick analysis",400,10,600,700);
  c7->cd();
  htofsec->Draw();
  
  
  TCanvas *c8 = new TCanvas("c8","Alice TOF hits quick analysis",400,10,600,700);
  c8->cd();
  htofmom->Draw();
  
  TCanvas *c9 = new TCanvas("c9","Alice TOF hits quick analysis",400,10,600,700);
  c9->cd();
  hincangle->Draw();
  
  //tofl->UnloadHits();
  //rl->UnloadHeader();
  //rl->UnloadgAlice();
  //rl->UnloadKinematics();

  return rc;

}
Exemplo n.º 9
0
void DigitMaker (Int_t evNumber=1) 
{
  /////////////////////////////////////////////////////////////////////////
  //   This macro is a small example of a ROOT macro
  //   illustrating how to read the output of GALICE
  //   and fill some histograms.
  //   
  //     Root > .L anal.C   //this loads the macro in memory
  //     Root > anal();     //by default process first event   
  //     Root > anal(2);    //process third event
  //Begin_Html
  /*
    <img src="gif/anal.gif">
  */
  //End_Html
  /////////////////////////////////////////////////////////////////////////
  
  
  // Dynamically link some shared libs
  if (gClassTable->GetID("AliRun") < 0) {
    gROOT->LoadMacro("loadlibs.C");
    loadlibs();
  }
  
  // Connect the Root Galice file containing Geometry, Kine and Hits
  TFile *file =  (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
  if (!file) file = new TFile("galice.root","UPDATE");
  
  // Get AliRun object from file or create it if not on file
  if (!gAlice) {
    gAlice = (AliRun*)file->Get("gAlice");
    if (gAlice) printf("AliRun object found on file\n");
    if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
  }

  TParticle *particle;
  AliT0hit  *startHit;

  Int_t buffersize=256;
  Int_t split=1;

  digits= new AliT0digit();
  TBranch *bDig=0;
  printf("Branch\n");

  
  AliT0 *T0  = (AliT0*) gAlice->GetDetector("T0");
  
 // Event ------------------------- LOOP  
  
  for (j=0; j<evNumber; j++){

   
    T0->Hit2digit(j); 

  }// event loop

  file->Write();
  file->Close();
 

}//endmacro
Exemplo n.º 10
0
Bool_t SETUP_SetAliRootCoreMode(TString &mode, const TString &extraLibs) {

  // Sets a certain AliRoot mode, defining a set of libraries to load. Extra
  // libraries to load can be specified as well. Returns kTRUE on success, or
  // kFALSE in case library loading failed.

  mode.ToLower();
  TString libs = extraLibs;
  Long_t rv = -9999;

  // Load needed ROOT libraries
  if (!SETUP_LoadLibraries("VMC:Tree:Physics:Matrix:Minuit:XMLParser:Gui")) {
    ::Error(gMessTag.Data(), "Loading of extra ROOT libraries failed");
    return kFALSE;
  }

  if (mode == "aliroot") {
    ::Info(gMessTag.Data(), "Loading libraries for AliRoot mode...");
    rv = gROOT->LoadMacro(
      gSystem->ExpandPathName("$ALICE_ROOT/macros/loadlibs.C") );
    if (rv == 0) loadlibs();
  }
  else if (mode == "sim") {
    ::Info(gMessTag.Data(), "Loading libraries for simulation mode...");
    rv = gROOT->LoadMacro(
      gSystem->ExpandPathName("$ALICE_ROOT/macros/loadlibssim.C") );
    if (rv == 0) loadlibssim();
  }
  else if (mode == "rec") {
    ::Info(gMessTag.Data(), "Loading libraries for reconstruction mode...");
    rv = gROOT->LoadMacro(
      gSystem->ExpandPathName("$ALICE_ROOT/macros/loadlibsrec.C") );
    if (rv == 0) loadlibsrec();
  }
  else if (mode == "base") {
    // "Base" mode: load standard libraries, and also fix loading order
    ::Info(gMessTag.Data(), "No mode specified: loading standard libraries...");
    TPMERegexp reLibs("(ANALYSISalice|ANALYSIS|STEERBase|ESD|AOD)(:|$)");
    while (reLibs.Substitute(libs, "")) {}
    libs.Prepend("STEERBase:ESD:AOD:ANALYSIS:ANALYSISalice:");
  }

  // Check status code
  if (rv == 0) {
    ::Info(gMessTag.Data(), "Successfully loaded AliRoot base libraries");
  }
  else if (rv != -9999) {
    ::Error(gMessTag.Data(), "Loading of base AliRoot libraries failed");
    return kFALSE;
  }

  // Load extra AliRoot libraries
  ::Info(gMessTag.Data(), "Loading extra AliRoot libraries...");
  if (!SETUP_LoadLibraries(libs)) {
    ::Error(gMessTag.Data(), "Loading of extra AliRoot libraries failed");
    return kFALSE;
  }
  else {
    ::Info(gMessTag.Data(), "Successfully loaded extra AliRoot libraries");
  }

  return kTRUE;
}
Exemplo n.º 11
0
void AliTRDdisplayTracks(Int_t track=157) 
{

  c1 = new TCanvas( "RecPoints", "RecPoints Display", 10, 10, 710, 740);
  c1->SetFillColor(1);
  TView *v=new TView(1);
  
      v->SetRange(-350.,-350.,-400.,350.,350.,400.); // full
  //  v->SetRange(0.,0.,0.,350.,350.,400.);  // top right
  //  v->SetRange(-350.,0.,0.,0.,350.,400.); // top left
  //  v->SetRange(0.,-350.,0.,350.,0.,400.); // bottom right 
  //  v->SetRange(-350.,-350.,0.,0.,0.,400.); // bottom left
  //  v->Side();
  v->Top();
  cerr<<"psi = "<<v->GetPsi()<<endl;

  // Dynamically link some shared libs
  if (gClassTable->GetID("AliRun") < 0) {
    gROOT->LoadMacro("loadlibs.C");
    loadlibs();
    cout << "Loaded shared libraries" << endl;
  }       


// Load tracks

   TFile *tf=TFile::Open("AliTRDtracks.root");
   if (!tf->IsOpen()) {cerr<<"Can't open AliTRDtracks.root !\n"; return 3;}
   TObjArray tarray(2000);
   //  tf->ls();
   TTree *tracktree=(TTree*)tf->Get("TreeT0_TRD");
   //   tracktree->ls();
   TBranch *tbranch=tracktree->GetBranch("tracks");
   Int_t nentr=tracktree->GetEntries();
   cerr<<"Found "<<nentr<<" entries in the track tree"<<endl;
   for (Int_t i=0; i<nentr; i++) {
       AliTRDtrack *iotrack=new AliTRDtrack;
       tbranch->SetAddress(&iotrack);
       tracktree->GetEvent(i);
       tarray.AddLast(iotrack);
       cerr<<"got track "<<i<<": index ="<<iotrack->GetLabel()<<endl;
   }
   tf->Close();                 


  // Load clusters
  Char_t *alifile = "TRDclusters.root";
  Int_t   nEvent  = 0;
  TObjArray rparray(2000);
  TObjArray *RecPointsArray = &rparray;
  const TFile *geofile =TFile::Open(alifile);
  //  AliTRDtracker *Tracker = new AliTRDtracker("dummy","dummy");
  AliTRDtracker *Tracker = new AliTRDtracker(geofile);
   Tracker->ReadClusters(RecPointsArray,alifile); 
  Int_t nRecPoints = RecPointsArray->GetEntriesFast();
  cerr<<"Found "<<nRecPoints<<" rec. points"<<endl;


  // Connect the AliRoot file containing Geometry, Kine, Hits, and Digits
      alifile = "galice.root";

   TFile *gafl = (TFile*) gROOT->GetListOfFiles()->FindObject(alifile);
  if (!gafl) {
    cout << "Open the ALIROOT-file " << alifile << endl;
    gafl = new TFile(alifile);
  }
  else {
    cout << alifile << " is already open" << endl;
  }
  

  // Get AliRun object from file or create it if not on file
  gAlice = (AliRun*) gafl->Get("gAlice");
  if (gAlice)
    cout << "AliRun object found on file" << endl;
  else
    gAlice = new AliRun("gAlice","Alice test program");
	

       AliTRDparameter *par =  ( AliTRDparameter *par) gafl->Get("TRDparameter");
       AliTRDv1       *TRD           = (AliTRDv1*) gAlice->GetDetector("TRD");
       AliTRDgeometry *fGeom   = TRD->GetGeometry();   
       
  Int_t i,j,index,det,sector, ti[3];
  Double_t x,y,z, cs,sn,tmp;
  Float_t global[3], local[3];

  // Display all TRD RecPoints
  TPolyMarker3D *pm = new TPolyMarker3D(nRecPoints);

  for (Int_t i = 0; i < nRecPoints; i++) {
    printf("\r point %d out of %d",i,nRecPoints);
    AliTRDcluster *rp = (AliTRDcluster *) RecPointsArray->UncheckedAt(i);    
  
   Int_t  idet=rp->GetDetector();
   Int_t iplan = fGeom->GetPlane(idet);    
   Int_t itt=rp->GetLocalTimeBin();
   Float_t  timeSlice = itt+0.5; 
   Float_t  time0     = par->GetTime0(iplan);

  // calculate (x,y,z) position in rotated chamber
   local[0] = time0 - (timeSlice - par->GetTimeBefore()) 
         * par->GetTimeBinSize();
   local[1]=rp->GetY();
   local[2]=rp->GetZ(); 

    for (j = 0; j < 3; j++) { ti[j] = rp->GetTrackIndex(j); }

    if((track < 0) ||
       ((ti[0]==track)||(ti[1]==track)||(ti[2]==track))) {

        if(fGeom->RotateBack(idet,local,global)) {     
       	x=global[0]; y=global[1]; z=global[2];
       	pm->SetPoint(i,x,y,z);
         }

    }
  }

  pm->SetMarkerSize(1); pm->SetMarkerColor(10); pm->SetMarkerStyle(1);
  pm->Draw();
  
   AliTRDparameter *par =  ( AliTRDparameter *par) gafl->Get("TRDparameter");

  Int_t ntracks = tarray.GetEntriesFast();

  for (i = 0; i < ntracks; i++) {
    AliTRDtrack *pt = (AliTRDtrack *) tarray.UncheckedAt(i), &t=*pt;
    Int_t nclusters = t.GetNumberOfClusters();
    cerr<<"in track "<<i<<" found "<<nclusters<<" clusters"<<endl;
   
    TPolyMarker3D *pm = new TPolyMarker3D(nclusters);
    for(j = 0; j < nclusters; j++) {
      index = t.GetClusterIndex(j);
      AliTRDcluster *rp = (AliTRDcluster *) RecPointsArray->UncheckedAt(index); 

   Int_t  idet=rp->GetDetector();
   Int_t iplan = fGeom->GetPlane(idet);    
   Int_t itt=rp->GetLocalTimeBin();
   Float_t  timeSlice = itt+0.5; 
   Float_t  time0     = par->GetTime0(iplan);


  // calculate (x,y,z) position in rotated chamber
       local[0] = time0 - (timeSlice - par->GetTimeBefore()) 
         * par->GetTimeBinSize();
       local[1]=rp->GetY(); 
       local[2]=rp->GetZ();

            if(fGeom->RotateBack(idet,local,global)) {     
      	x=global[0]; y=global[1]; z=global[2];
      	pm->SetPoint(j,x,y,z);
       }
    } 
    pm->SetMarkerSize(1); pm->SetMarkerColor(i%6+3); pm->SetMarkerStyle(1);
    //    pm->Draw();
  }
  
  TGeometry *geom=(TGeometry*)gafl->Get("AliceGeom");
  geom->Draw("same");

  c1->Modified(); 
  
  c1->Update();
  
  gafl->Close();

}
Exemplo n.º 12
0
void run_sim(Int_t nEvents = 2)
{
   TTree::SetMaxTreeSize(90000000000);
	Int_t iVerbose = 0;

	TString script = TString(gSystem->Getenv("SCRIPT"));
	TString parDir = TString(gSystem->Getenv("VMCWORKDIR")) + TString("/parameters");

	//gRandom->SetSeed(10);

	TString inFile = "/Users/slebedev/Development/cbm/data/urqmd/auau/25gev/centr/urqmd.auau.25gev.centr.00001.root";
	TString parFile = "/Users/slebedev/Development/cbm/data/simulations/rich/richreco/param.0001.root";
	TString outFile = "/Users/slebedev/Development/cbm/data/simulations/rich/richreco/mc.0001.root";

	TString caveGeom = "cave.geo";
	TString pipeGeom = "pipe/pipe_standard.geo";
	TString magnetGeom = "magnet/magnet_v12a.geo";
	TString mvdGeom = "";
	TString stsGeom = "sts/sts_v13d.geo.root";
	TString richGeom= "rich/rich_v13c_pipe_1_al_1.root";
	TString trdGeom = "trd/trd_v13g.geo.root";
	TString tofGeom = "tof/tof_v13b.geo.root";
	TString ecalGeom = "";
	TString fieldMap = "field_v12a";

	TString electrons = "yes"; // If "yes" than primary electrons will be generated
	Int_t NELECTRONS = 5; // number of e- to be generated
	Int_t NPOSITRONS = 5; // number of e+ to be generated
	TString urqmd = "yes"; // If "yes" than UrQMD will be used as background
	TString pluto = "no"; // If "yes" PLUTO particles will be embedded
	TString plutoFile = "";
	TString plutoParticle = "";
	Double_t fieldZ = 50.; // field center z position
	Double_t fieldScale =  1.0; // field scaling factor

	if (script == "yes") {
		inFile = TString(gSystem->Getenv("IN_FILE"));
		outFile = TString(gSystem->Getenv("MC_FILE"));
		parFile = TString(gSystem->Getenv("PAR_FILE"));

		caveGeom = TString(gSystem->Getenv("CAVE_GEOM"));
		pipeGeom = TString(gSystem->Getenv("PIPE_GEOM"));
		mvdGeom = TString(gSystem->Getenv("MVD_GEOM"));
		stsGeom = TString(gSystem->Getenv("STS_GEOM"));
		richGeom = TString(gSystem->Getenv("RICH_GEOM"));
		trdGeom = TString(gSystem->Getenv("TRD_GEOM"));
		tofGeom = TString(gSystem->Getenv("TOF_GEOM"));
		ecalGeom = TString(gSystem->Getenv("ECAL_GEOM"));
		fieldMap = TString(gSystem->Getenv("FIELD_MAP"));
		magnetGeom = TString(gSystem->Getenv("MAGNET_GEOM"));

		NELECTRONS = TString(gSystem->Getenv("NELECTRONS")).Atoi();
		NPOSITRONS = TString(gSystem->Getenv("NPOSITRONS")).Atoi();
		electrons = TString(gSystem->Getenv("ELECTRONS"));
		urqmd = TString(gSystem->Getenv("URQMD"));
		pluto = TString(gSystem->Getenv("PLUTO"));
		plutoFile = TString(gSystem->Getenv("PLUTO_FILE"));
		plutoParticle = TString(gSystem->Getenv("PLUTO_PARTICLE"));
		fieldScale = TString(gSystem->Getenv("FIELD_MAP_SCALE")).Atof();
	}

	gDebug = 0;
	TStopwatch timer;
	timer.Start();

   gROOT->LoadMacro("$VMCWORKDIR/macro/littrack/loadlibs.C");
   loadlibs();

	FairRunSim* fRun = new FairRunSim();
	fRun->SetName("TGeant3"); // Transport engine
	fRun->SetOutputFile(outFile);
	FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
	//fRun->SetStoreTraj(kTRUE);

	fRun->SetMaterials("media.geo"); // Materials

	if ( caveGeom != "" ) {
		FairModule* cave = new CbmCave("CAVE");
		cave->SetGeometryFileName(caveGeom);
		fRun->AddModule(cave);
	}

	if ( pipeGeom != "" ) {
		FairModule* pipe = new CbmPipe("PIPE");
		pipe->SetGeometryFileName(pipeGeom);
		fRun->AddModule(pipe);
	}

	CbmTarget* target = new CbmTarget("Gold", 0.025); // 250 mum
	fRun->AddModule(target);

	if ( magnetGeom != "" ) {
		FairModule* magnet = new CbmMagnet("MAGNET");
		magnet->SetGeometryFileName(magnetGeom);
		fRun->AddModule(magnet);
	}

	if ( mvdGeom != "" ) {
		FairDetector* mvd = new CbmMvd("MVD", kTRUE);
		mvd->SetGeometryFileName(mvdGeom);
		fRun->AddModule(mvd);
	}

	if ( stsGeom != "" ) {
		FairDetector* sts = new CbmStsMC(kTRUE);
		sts->SetGeometryFileName(stsGeom);
		fRun->AddModule(sts);
	}

	if ( richGeom != "" ) {
		FairDetector* rich = new CbmRich("RICH", kTRUE);
		rich->SetGeometryFileName(richGeom);
		fRun->AddModule(rich);
	}

	if ( trdGeom != "" ) {
		FairDetector* trd = new CbmTrd("TRD",kTRUE );
		trd->SetGeometryFileName(trdGeom);
		fRun->AddModule(trd);
	}

	if ( tofGeom != "" ) {
		FairDetector* tof = new CbmTof("TOF", kTRUE);
		tof->SetGeometryFileName(tofGeom);
		fRun->AddModule(tof);
	}

	// -----   Create magnetic field   ----------------------------------------
	CbmFieldMap* magField = NULL;
	magField = new CbmFieldMapSym2(fieldMap);
	magField->SetPosition(0., 0., fieldZ);
	magField->SetScale(fieldScale);
	fRun->SetField(magField);

	// -----   Create PrimaryGenerator   --------------------------------------
	FairPrimaryGenerator* primGen = new FairPrimaryGenerator();

	if (urqmd == "yes"){
		//CbmUrqmdGenerator*  urqmdGen = new CbmUrqmdGenerator(inFile);
	    CbmUnigenGenerator*  urqmdGen = new CbmUnigenGenerator(inFile);
		urqmdGen->SetEventPlane(0. , 360.);
		primGen->AddGenerator(urqmdGen);
	}

	//add electrons
	if (electrons == "yes"){
		FairBoxGenerator* boxGen1 = new FairBoxGenerator(11, NPOSITRONS);
		boxGen1->SetPtRange(0.,3.);
		boxGen1->SetPhiRange(0.,360.);
		boxGen1->SetThetaRange(2.5,25.);
		boxGen1->SetCosTheta();
		boxGen1->Init();
		primGen->AddGenerator(boxGen1);

		FairBoxGenerator* boxGen2 = new FairBoxGenerator(-11, NELECTRONS);
		boxGen2->SetPtRange(0.,3.);
		boxGen2->SetPhiRange(0.,360.);
		boxGen2->SetThetaRange(2.5,25.);
		boxGen2->SetCosTheta();
		boxGen2->Init();
		primGen->AddGenerator(boxGen2);

//      CbmLitPolarizedGenerator *polGen;
//      polGen = new CbmLitPolarizedGenerator(443, NELECTRONS);
//      polGen->SetDistributionPt(0.176);        // 25 GeV
//      polGen->SetDistributionY(1.9875,0.228);  // 25 GeV
//      polGen->SetRangePt(0.,3.);
//      polGen->SetRangeY(1.,3.);
//      polGen->SetBox(0);
//      polGen->SetRefFrame(CbmLitPolarizedGenerator::kHelicity);
//      polGen->SetDecayMode(CbmLitPolarizedGenerator::kDiElectron);
//      polGen->SetAlpha(0);
//      polGen->Init();
//      primGen->AddGenerator(polGen);
   }

	if (pluto == "yes") {
		FairPlutoGenerator *plutoGen= new FairPlutoGenerator(plutoFile);
		primGen->AddGenerator(plutoGen);
	}

	fRun->SetGenerator(primGen);

	fRun->Init();

	// -----   Runtime database   ---------------------------------------------
	CbmFieldPar* fieldPar = (CbmFieldPar*) rtdb->getContainer("CbmFieldPar");
	fieldPar->SetParameters(magField);
	fieldPar->setChanged();
	fieldPar->setInputVersion(fRun->GetRunId(),1);
	Bool_t kParameterMerged = kTRUE;
	FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged);
	parOut->open(parFile.Data());
	rtdb->setOutput(parOut);
	rtdb->saveOutput();
	rtdb->print();

	fRun->Run(nEvents);

	timer.Stop();
	Double_t rtime = timer.RealTime();
	Double_t ctime = timer.CpuTime();
	cout << endl << endl;
	cout << "Macro finished succesfully." << endl;
	cout << "Output file is "    << outFile << endl;
	cout << "Parameter file is " << parFile << endl;
	cout << "Real time " << rtime << " s, CPU time " << ctime
       << "s" << endl << endl;

	cout << " Test passed" << endl;
	cout << " All ok " << endl;
}