]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSPrintRecPoints.C
Adding MUON HLT code to the repository.
[u/mrichter/AliRoot.git] / ITS / AliITSPrintRecPoints.C
index 89e510f0a4c7a115d3876d983b991b666a44c725..523379e7630dc1d1f01dae7ebbd28f86b391b076 100644 (file)
@@ -1,63 +1,79 @@
-#include "iostream.h"
-#include "TFile.h"
-#include "TString.h"
-#include "TClonesArray.h"
-/*
-#include "$(ALICE_ROOT)/STEER/AliRun.h"
-#include "$(ALICE_ROOT)/ITS/AliITS.h"
-#include "$(ALICE_ROOT)/ITS/AliITSgeom.h"
-#include "$(ALICE_ROOT)/ITS/AliITSRecPoint.h"
-*/
 void AliITSPrintRecPoints(TString rfn="galice.root",Int_t mod=-1,
                          Int_t evnt=-1){
-    // Macro to print out the recpoints for all or a specific module
-
-    // Dynamically link some shared libs
-    if (gClassTable->GetID("AliRun") < 0) {
-        gROOT->LoadMacro("loadlibs.C");
-        loadlibs();
-    } // end if
-    gROOT->LoadMacro("$(ALICE_ROOT)/ITS/AliITSstandard.C");
-
-    TFile *rf=0;
-    rf = AccessFile(rfn,"R"); // Set up to read in Data
-    AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS");
-    if(!ITS){
-       cout << "Error: no ITS found. Aborting"<<endl;
-       return;
-    } // end if !ITS
-
-    Int_t evNumber1 = 0;
-    Int_t evNumber2 = gAlice->GetEventsPerRun();
-    if(evnt>=0){
-       evNumber1 = evnt;
-       evNumber2 = evnt+1;
-    } // end if evnt>=0
-    Int_t mod1 = 0;
-    Int_t mod2 = ITS->GetITSgeom()->GetIndexMax();
-    if(mod>=0){
-       mod1 = mod;
-       mod2 = mode+1;
-    } // end if mod>=0
-    TClonesArray *rpa = ITS->RecPoints();
-    AliITSRecPoint *rp = 0;
-
-    Int_t event,m,i,i2;
-    for(event = evNumber1; event < evNumber2; event++){
-        gAlice->GetEvent(event);
-       for(m=mod1;m<mod2;m++){
-           ITS->ResetRecPoints();
-           gAlice->TreeR()->GetEvent(m);
-           i2 = rpa->GetEntriesFast();
-           cout <<  "Event=" << event << " module=" << m <<
-               " Number of Recpoints=" << i2 <<endl;
-           for(i=0;i<i2;i++){
-               rp = (AliITSRecPoint*)(rpa->At(i));
-               cout << i << " ";
-               rp->Print((ostream*)cout);
-               cout << endl;
-           } // end for i
-       } // end for m
-    } // end for event
+  // Macro to print out the recpoints for all or a specific module
+
+  // Dynamically link some shared libs
+  if (gClassTable->GetID("AliRun") < 0) {
+    gROOT->LoadMacro("loadlibs.C");
+    loadlibs();
+  } 
+  else {
+    if(gAlice){
+      delete gAlice->GetRunLoader();
+      delete gAlice;
+      gAlice=0;
+    }
+  }
+
+  gROOT->LoadMacro("$(ALICE_ROOT)/ITS/AliITSstandard.C");
+
+  AliRunLoader *rl = AccessFile(rfn); // Set up to read in Data
+  Int_t retval = rl->LoadHeader();
+  if (retval){
+    cerr<<"AliITSPrintRecPoints.C : LoadHeader returned error"<<endl;
+    return;
+  }
+
+  AliITSLoader* ITSloader =  (AliITSLoader*) rl->GetLoader("ITSLoader");
+
+  if(!ITSloader){
+    cerr<<"AliITSPrintRecPoints.C :  ITS loader not found"<<endl;
+    return;
+  }
+
+  ITSloader->LoadHits("read");
+  ITSloader->LoadDigits("read");
+  ITSloader->LoadRecPoints("read");
+  AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS");
+  if(!ITS){
+    cout << "Error: no ITS found. Aborting"<<endl;
+    return;
+  } // end if !ITS
+
+  Int_t evNumber1 = 0;
+  Int_t evNumber2 = gAlice->GetEventsPerRun();
+  if(evnt>=0){
+    evNumber1 = evnt;
+    evNumber2 = evnt+1;
+  } // end if evnt>=0
+  Int_t mod1 = 0;
+  Int_t mod2 = ITS->GetITSgeom()->GetIndexMax();
+  if(mod>=0){
+    mod1 = mod;
+    mod2 = mod+1;
+  } // end if mod>=0
+  TClonesArray *rpa;
+  AliITSRecPoint *rp = 0;
+
+  Int_t event,m,i,i2;
+  for(event = evNumber1; event < evNumber2; event++){
+    rl->GetEvent(event);
+    ITS->SetTreeAddress();
+    for(m=mod1;m<mod2;m++){
+      ITS->ResetRecPoints();
+      TTree *TR = ITSloader->TreeR();
+      TR->GetEvent(m);
+      rpa = ITS->RecPoints();
+      i2 = rpa->GetEntriesFast();
+      cout <<  "Event=" << event << " module=" << m <<
+       " Number of Recpoints=" << i2 <<endl;
+      for(i=0;i<i2;i++){
+       rp = (AliITSRecPoint*)(rpa->At(i));
+       cout << i << " ";
+       rp->Print((ostream*)cout);
+       cout << endl;
+      } // end for i
+    } // end for m
+  } // end for event
 
 }