-#include "iostream.h"
-
-void AliITSHits2FastRecPoints (Int_t evNumber1=0,Int_t evNumber2=0,Int_t nsignal=25, Int_t size=-1)
+#if !defined(__CINT__) || defined(__MAKECINT__)
+
+#include <Riostream.h>
+#include<TClassTable.h>
+#include <TError.h>
+#include <TInterpreter.h>
+#include <TStopwatch.h>
+#include <TString.h>
+#include "AliRun.h"
+#include "AliRunLoader.h"
+#include "AliITS.h"
+#include "AliITSInitGeometry.h"
+#include "AliITSgeom.h"
+#include "AliITSLoader.h"
+#include "AliITSsimulationFastPoints.h"
+#include "AliGeomManager.h"
+#endif
+
+/*
+$Id$
+*/
+
+
+void AliITSHits2FastRecPoints (Int_t evNumber1=0,Int_t evNumber2=0, TString inFile = "galice.root", Int_t nsignal=25, Int_t size=-1)
{
-/////////////////////////////////////////////////////////////////////////
-// This macro is a small example of a ROOT macro
-// illustrating how to read the output of GALICE
-// and do some analysis.
-//
-/////////////////////////////////////////////////////////////////////////
-
-// Dynamically link some shared libs
-
- if (gClassTable->GetID("AliRun") < 0) {
- gROOT->LoadMacro("loadlibs.C");
- loadlibs();
- } else {
- delete gAlice;
- gAlice=0;
- }
+ /////////////////////////////////////////////////////////////////////////
+ //
+ // This macro creates fast recpoints
+ //
+ /////////////////////////////////////////////////////////////////////////
-// Connect the Root Galice file containing Geometry, Kine and Hits
- TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
- if (file) file->Close();
- file = new TFile("galice.root","UPDATE");
- file->ls();
+ // Dynamically link some shared libs
- printf ("I'm after Map \n");
-
-// 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");
- }
- printf ("I'm after gAlice \n");
+ if (gClassTable->GetID("AliRun") < 0) {
+ gInterpreter->ExecuteMacro("loadlibs.C");
+ }
+ else {
+ if(gAlice){
+ delete AliRunLoader::Instance();
+ delete gAlice;
+ gAlice=0;
+ }
+ }
+
+
+ // Get geometry
+ AliGeomManager::LoadGeometry("geometry.root");
+
+ // Connect the Root Galice file containing Geometry, Kine and Hits
+ AliRunLoader* rl = AliRunLoader::Open(inFile.Data());
+ if (rl == 0x0)
+ {
+ Error("AliITSHits2FastRecPoints.C","Can not open session RL=NULL");
+ return;
+ }
+
+ Int_t retval = rl->LoadgAlice();
+ if (retval)
+ {
+ Error("AliITSHits2FastRecPoints.C","LoadgAlice returned error");
+ delete rl;
+ return;
+ }
+ gAlice=rl->GetAliRun();
+ rl->LoadHeader();
+ retval = rl->LoadKinematics();
+ if (retval)
+ {
+ Error("AliITSHits2FastRecPoints.C","LoadKinematics returned error");
+ delete rl;
+ return;
+ }
+
+ AliITSInitGeometry initgeom;
+ AliITSgeom *geom = initgeom.CreateAliITSgeom();
+ printf("Geometry name: %s \n",(initgeom.GetGeometryName()).Data());
+
+ AliITSLoader* gime = (AliITSLoader*)rl->GetLoader("ITSLoader");
+ if (gime == 0x0)
+ {
+ ::Error("AliITSHits2FastRecPoints.C","can not get ITS loader");
+ delete rl;
+ return;
+ }
+ gime->SetITSgeom(geom);
+ retval = gime->LoadHits("read");
+ if (retval)
+ {
+ ::Error("AliITSHits2FastRecPoints.C","LoadHits returned error");
+ delete rl;
+ return;
+ }
+ gime->SetRecPointsFileName("ITS.FastRecPoints.root");
+ retval = gime->LoadRecPoints("update");
+ if (retval)
+ {
+ ::Error("AliITSHits2FastRecPoints.C","LoadRecPoints returned error");
+ delete rl;
+ return;
+ }
+
- AliITS *ITS = (AliITS*) gAlice->GetModule("ITS");
- if (!ITS) return;
- // Set the simulation model
+
+ AliITS *ITS = (AliITS*) gAlice->GetModule("ITS");
+ if (!ITS) return;
- /* Bug !!! (I.Belikov)
- AliITSsimulationFastPoints *sim = new AliITSsimulationFastPoints();
+ // Set the simulation model
- for (Int_t i=0;i<3;i++) {
- ITS->SetSimulationModel(i,sim);
- }
- */
-
- for (Int_t i=0;i<3;i++) {
- ITS->SetSimulationModel(i,new AliITSsimulationFastPoints());
- }
-//
-// Event Loop
-//
-
- Int_t nbgr_ev=0;
- TStopwatch timer;
-
- cout << "Creating fast reconstructed points from hits for the ITS..." << endl;
-
- for (int ev=evNumber1; ev<= evNumber2; ev++) {
- cout << "...working on event "<< ev << " ..." << endl;
- Int_t nparticles = gAlice->GetEvent(ev);
- cout << "event " <<ev<<endl;
- cout << "nparticles " <<nparticles<<endl;
- gAlice->SetEvent(ev);
- if(!gAlice->TreeR()) gAlice-> MakeTree("R");
- ITS->MakeBranch("R");
- if (ev < evNumber1) continue;
- if (nparticles <= 0) return;
-
- Int_t bgr_ev=Int_t(ev/nsignal);
- //printf("bgr_ev %d\n",bgr_ev);
- timer.Start();
- ITS->HitsToFastRecPoints(ev,bgr_ev,size," ","All"," ");
- timer.Stop(); timer.Print();
- } // event loop
-
- delete gAlice; gAlice=0;
- file->Close();
+ //
+ // Event Loop
+ //
+
+ TStopwatch timer;
+
+ cout << "Creating fast reconstructed points from hits for the ITS..." << endl;
+ AliITSDetTypeSim* dettyp = new AliITSDetTypeSim();
+ dettyp->SetLoader(gime);
+ dettyp->SetITSgeom(geom);
+ ITS->SetDetTypeSim(dettyp);
+ for (Int_t i=0;i<3;i++) {
+ ITS->SetSimulationModel(i,new AliITSsimulationFastPoints());
+ }
+
+
+ for (int ev=evNumber1; ev<= evNumber2; ev++) {
+ cout << "...working on event "<< ev << " ..." << endl;
+ Int_t nparticles = gAlice->GetEvent(ev);
+ cout << "event " <<ev<<endl;
+ cout << "nparticles " <<nparticles<<endl;
+ rl->GetEvent(ev);
+ //if(gime->TreeR() == 0x0) gime->MakeTree("R");
+
+ if (ev < evNumber1) continue;
+ if (nparticles <= 0) return;
+
+ Int_t bgr_ev=Int_t(ev/nsignal);
+ timer.Start();
+ ITS->HitsToFastRecPoints(ev,bgr_ev,size," ","All"," ");
+ timer.Stop(); timer.Print();
+ } // event loop
+
+ delete rl;
}
-
-
-
-
-
-
-
-
-
-
-
-
-