]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Transition to newIO
authormasera <masera@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 31 Jul 2003 17:28:17 +0000 (17:28 +0000)
committermasera <masera@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 31 Jul 2003 17:28:17 +0000 (17:28 +0000)
ITS/AliITSDigits2RecPoints.C
ITS/AliITSHits2Digits.C
ITS/AliITSHits2SDigits.C
ITS/AliITSPrintGeom.C
ITS/AliITSPrintHits.C
ITS/AliITSPrintRecPoints.C
ITS/AliITSstandard.C

index eaf6b1646053b8740dc99c9067412a44f197a078..82633d9a70fbd1530ae8596f0eff67630ca3817e 100644 (file)
@@ -1,24 +1,26 @@
 #if !defined(__CINT__) || defined(__MAKECINT__)
 
-#include "iostream.h"
-#include "TDatetime.h"
-#include "STEER/AliRun.h"
-#include "STEER/AliRunDigitizer.h"
-#include "ITS/AliITSDigitizer.h"
-#include "ITS/AliITS.h"
-#include "ITS/AliITSDetType.h"
-#include "ITS/AliITSresponseSDD.h"
+#include "Riostream.h"
+#include "TClassTable.h"
+#include "TDatime.h"
 #include "TStopwatch.h"
+#include "AliRun.h"
+#include "AliRunDigitizer.h"
+#include "AliITSDigitizer.h"
+#include "AliITS.h"
+#include "AliITSDetType.h"
+#include "AliITSresponseSDD.h"
+#include "AliITSreconstruction.h"
 
 #endif
 #define DEBUG
+
 Int_t AliITSDigits2RecPoints(TString filename="galice.root"){
     // Standard ITS Digits to RecPoints.
 
     // Dynamically link some shared libs
     if (gClassTable->GetID("AliRun") < 0) {
-     gROOT->LoadMacro("loadlibs.C");
-     loadlibs();
+      gROOT->ProcessLine(".x $(ALICE_ROOT)/macros/loadlibs.C");
     }else if (gAlice){
       delete gAlice->GetRunLoader();
       delete gAlice;
index 7e55c9f7d20d3618c116028a7db1216f8f461ae7..e44595cddcad7fb741d962fc8826c10b5a1d9a66 100644 (file)
 #if !defined(__CINT__) || defined(__MAKECINT__)
 
-#include "iostream.h"
-#include "TDatetime.h"
-#include "STEER/AliRun.h"
-#include "STEER/AliRunDigitizer.h"
-#include "ITS/AliITSDigitizer.h"
-#include "ITS/AliITS.h"
-#include "ITS/AliITSDetType.h"
-#include "ITS/AliITSresponseSDD.h"
+#include "Riostream.h"
+#include "TDatime.h"
+#include "TClassTable.h"
+#include "AliRun.h"
+#include "AliRunDigitizer.h"
+#include "AliITSDigitizer.h"
+#include "AliITS.h"
+#include "AliITSDetType.h"
+#include "AliITSLoader.h"
+#include "AliITSresponseSDD.h"
 #include "TStopwatch.h"
 
 #endif
 
-TFile* AccessFile(TString inFile="galice.root", TString acctype="R");
-void writeAR(TFile * fin, TFile *fou);
-Int_t ChangeITSDefaults(TFile *hitfile,AliITS *ITS,TString opt="");
 //#define DEBUG
-Int_t AliITSHits2Digits(TString hitFile = "galice.root", 
-                       TString digFile = "galiceD.root",TString opt=""){
-    // Standeard ITS Hits to Digits, excluding creation of SDigits.
+Int_t AliITSHits2Digits(TString inFile = "galice.root"){
+    // Standard ITS Hits to Digits, excluding creation of SDigits.
 
     // Dynamically link some shared libs
-    if (gClassTable->GetID("AliRun") < 0) {
-       gROOT->LoadMacro("loadlibs.C");
-       loadlibs();
-    } // end if
-
-    // Connect the Root Galice file containing Geometry, Kine and Hits
-
-    TFile *hitfile = 0;   // pointer to input file.
-    TFile *digfile = 0;  // possible output file for TreeD
-    if(digFile.CompareTo(hitFile) == 0){// write output to same file as input.
-       hitfile = AccessFile(hitFile,"U");  // input file open for update.
-    }else{ // different output file then input file.
-       hitfile = AccessFile(hitFile,"R"); // input file open as read only
-       // open output file and create TreeR on it
-       digfile = gAlice->InitTreeFile("D",digFile);
-    } // end if digFile == hitFile.
+   if (gClassTable->GetID("AliRun") < 0) {
+      gROOT->ProcessLine(".x $(ALICE_ROOT)/macros/loadlibs.C");
+    }else if (gAlice){
+      delete gAlice->GetRunLoader();
+      delete gAlice;
+      gAlice=0;
+     } 
 
+   AliRunLoader* rl = AliRunLoader::Open(inFile.Data());
+    if (rl == 0x0)
+     {
+      cerr<<"AliITSHits2Digits.C : Can not open session RL=NULL"
+           << endl;
+       return 3;
+     }
+     
+    Int_t retval = rl->LoadgAlice();
+    if (retval)
+     {
+      cerr<<"AliITSHits2Digits.C : LoadgAlice returned error"
+           << endl;
+       return 3;
+     }
+    gAlice=rl->GetAliRun();
+    AliITSLoader* gime = (AliITSLoader*)rl->GetLoader("ITSLoader");
+    if (gime == 0x0)
+     {
+      cerr<<"AliITSHits2Digits.C : can not get ITS loader"
+           << endl;
+     }
     AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS");      
     if (!ITS) {
-       cerr<<"AliITSHits2DigitsDefault.C : AliITS object not found on file"
+       cerr<<"AliITSHits2Digit.C : AliITS object not found on file"
            << endl;
        return 3;
     }  // end if !ITS
+
     if(!(ITS->GetITSgeom())){
-       cerr << " AliITSgeom not found. Can't digitize with out it." << endl;
+       cerr << " AliITSgeom not found. Can't digitize without it." << endl;
        return 4;
     } // end if
 
-    ChangeITSDefaults(hitfile,ITS,opt);
-    // write the AliRun object to the output file if different from input file.
-    if(digfile) writeAR(hitfile,digfile);
+    
 
     TStopwatch timer;
     Int_t evNumber1 = 0;
     Int_t evNumber2 = gAlice->GetEventsPerRun();
     timer.Start();
+    retval = gime->LoadHits();
+    if (retval)
+     {
+      cerr<<"AliITSHits2Digits.C : ITSLoader::LoadHits returned error"
+           << endl;
+       return 3;
+     }
+
+    retval = gime->LoadDigits("recreate");
+    if (retval)
+     {
+      cerr<<"AliITSHits2Digits.C : ITSLoader::LoadDigits returned error"
+           << endl;
+       return 3;
+     }
     for(Int_t nevent = evNumber1; nevent < evNumber2; nevent++){
        // cout<<"Producing Digits for event n."<<nevent<<endl;
-       gAlice->GetEvent(nevent);
-       if(!gAlice->TreeD() && digfile == 0){ 
+
+       rl->GetEvent(nevent);
+       if(!gime->TreeD()){ 
            cout << "Having to create the Digits Tree." << endl;
-           gAlice->MakeTree("D");
+           gime->MakeTree("D");
        } // end if creating digits tree
-       if(digfile) gAlice->MakeTree("D",digfile);
        ITS->MakeBranch("D");
        ITS->SetTreeAddress();   
        ITS->Hits2Digits();
     } // end for nevent
     timer.Stop();
     timer.Print();
-    if(digfile!=0){
-       cout << digFile << " size =" << digfile->GetSize() << endl;
-    }else{
-       cout << hitFile << " size =" << hitfile->GetSize() << endl;
-    } // end if sdigfile!=0
-
-    delete gAlice; // digfile is closed by deleting gAlice if != hitfile.
-    gAlice = 0;
-    hitfile->Close(); hitfile = 0;
-}
-//______________________________________________________________________
-TFile * AccessFile(TString FileName, TString acctype){
-    // Function used to open the input file and fetch the AliRun object
-
-    TFile *retfil = 0;
-    TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(FileName);
-    if(file) {
-       file->Close();
-       delete file;
-       file = 0;
-    } // end if file
-    if(acctype.Contains("U")){
-       file = new TFile(FileName,"UPDATE");
-    } // end if open for update
-    if(acctype.Contains("N") && !file){
-       file = new TFile(FileName,"RECREATE");
-    } // end if open a new file
-    if(!file) file = new TFile(FileName,"READ");   // default readonly
-    if (!file->IsOpen()) {
-       cerr << "Can't open " << FileName << " !" << endl;
-       return retfil;
-    } // end if error opeing file
-
-    // Get AliRun object from file or return if not on file
-    if (gAlice) {delete gAlice; gAlice = 0;}
-    gAlice = (AliRun*)file->Get("gAlice");
-    if (!gAlice) {
-       cerr << "AliRun object not found on file "<< FileName << "!" << endl;
-       file->Close();  // close file and return error.
-       return retfil;
-    } // end if !gAlice
-    return file;
-}
-//______________________________________________________________________
-void writeAR(TFile * fin, TFile *fou) {
-    TDirectory *current = gDirectory;
-    TTree *TeOld;
-    TTree *TeNew;
-    AliHeader *alhe = new AliHeader();
-    TeOld = (TTree*)fin->Get("TE");
-    TeOld->SetBranchAddress("Header",&alhe);
-    TeOld->SetBranchStatus("*",1);
-    fou->cd();
-    TeNew = TeOld->CloneTree();
-    TeNew->Write(0,TObject::kOverwrite);
-    gAlice->Write(0,TObject::kOverwrite);
-    current->cd();
-    delete alhe;
-#ifdef DEBUG
-    cout << "AliRun object written to file" << endl;
-#endif
-}
-//______________________________________________________________________
-Int_t ChangeITSDefaults(TFile *hitfile,AliITS *ITS,TString opt){
-
-    TDatime *ct0 = new TDatime(2002,04,26,00,00,00);
-    TDatime ct = hitfile->GetCreationDate();
-
-    if(ct0->GetDate()>ct.GetDate()){
-       // For old files, must change SDD noise.
-       AliITSresponseSDD *resp1 = (AliITSresponseSDD*)ITS->DetType(1)->
-           GetResponseModel();
-       resp1 = new AliITSresponseSDD();
-       ITS->SetResponseModel(1,resp1);
-       cout << "Changed response class for SDD:" << endl;
-       resp1->Print();
-    } // end if
 
-    if(opt.Contains("Dubna")){
-       AliITSresponseSPDdubna *resp0 = new AliITSresponseSPDdubna();
-       if(ITS->DetType(0)->GetResponseModel() !=0){
-           delete ((AliITSresponse*)ITS->DetType(0)->GetResponseModel());
-           ITS->DetType(0)->ResponseModel(0);
-       } // end if
-       ITS->DetType(0)->ResponseModel(resp0);
-       AliITSsegmentationSPD *seg0 = (AliITSsegmentationSPD*)ITS->
-           DetType(0)->GetSegmentationModel();
-       AliITSsimulationSPDdubna *sim0 = new AliITSsimulationSPDdubna(seg0,
-                                                                     resp0);
-       if(ITS->DetType(0)->GetSimulationModel() !=0){
-           delete ((AliITSsimulation*)ITS->DetType(0)->GetSimulationModel());
-           ITS->DetType(0)->SimulationModel(0);
-       } // end if
-       ITS->DetType(0)->SimulationModel(sim0);
-    } // end if Dubna
+    delete rl;
+    return 0;
 }
index 47617ed54d98dee059bf1e5d2f636208307e0c2b..5ca9fffa7749b17fe8ce3779cf747361234418e0 100644 (file)
@@ -1,37 +1,38 @@
 #if !defined(__CINT__) || defined(__MAKECINT__)
 
-#include "iostream.h"
-#include "TDatetime.h"
-#include "STEER/AliRun.h"
-#include "STEER/AliRunDigitizer.h"
-#include "ITS/AliITSDigitizer.h"
-#include "ITS/AliITS.h"
-#include "ITS/AliITSDetType.h"
-#include "ITS/AliITSresponseSDD.h"
+#include "Riostream.h"
+#include "TDatime.h"
+#include "TClassTable.h"
+#include "AliRun.h"
+#include "AliRunDigitizer.h"
+#include "AliITSDigitizer.h"
+#include "AliITS.h"
+#include "AliITSDetType.h"
+#include "AliITSLoader.h"
+#include "AliITSresponseSDD.h"
 #include "TStopwatch.h"
 
 #endif
 
 Int_t AliITSHits2SDigits(TString  filename = "galice.root")
  {
-    // Standeard ITS Hits to SDigits.
+    // Standard ITS Hits to SDigits.
 
     // 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->ProcessLine(".x $(ALICE_ROOT)/macros/loadlibs.C");
+    }else if (gAlice){
+      delete gAlice->GetRunLoader();
+      delete gAlice;
+      gAlice=0;
+     } 
 
     // Connect the Root Galice file containing Geometry, Kine and Hits
 
     AliRunLoader* rl = AliRunLoader::Open(filename);
     if (rl == 0x0)
      {
-      cerr<<"AliITSHits2DigitsDefault.C : Can not open session RL=NULL"
+      cerr<<"AliITSHits2SDigits.C : Can not open session RL=NULL"
            << endl;
        return 3;
      }
@@ -39,25 +40,25 @@ Int_t AliITSHits2SDigits(TString  filename = "galice.root")
     Int_t retval = rl->LoadgAlice();
     if (retval)
      {
-      cerr<<"AliITSHits2DigitsDefault.C : LoadgAlice returned error"
+      cerr<<"AliITSHits2SDigits.C : LoadgAlice returned error"
            << endl;
        return 3;
      }
     gAlice=rl->GetAliRun();
-    AliLoader* gime = rl->GetLoader("ITSLoader");
+    AliITSLoader* gime = (AliITSLoader*) rl->GetLoader("ITSLoader");
     if (gime == 0x0)
      {
-      cerr<<"AliITSHits2DigitsDefault.C : can not get ITS loader"
+      cerr<<"AliITSHits2SDigits.C : can not get ITS loader"
            << endl;
      }
     AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS");      
     if (!ITS) {
-       cerr<<"AliITSHits2DigitsDefault.C : AliITS object not found on file"
+       cerr<<"AliITSHits2SDigits.C : AliITS object not found on file"
            << endl;
        return 3;
     }  // end if !ITS
     if(!(ITS->GetITSgeom())){
-       cerr << " AliITSgeom not found. Can't digitize with out it." << endl;
+       cerr << " AliITSgeom not found. Can't digitize without it." << endl;
        return 4;
     } // end if
 
@@ -68,14 +69,14 @@ Int_t AliITSHits2SDigits(TString  filename = "galice.root")
     retval = gime->LoadHits();
     if (retval)
      {
-      cerr<<"AliITSHits2DigitsDefault.C : ITSLoader::LoadHits returned error"
+      cerr<<"AliITSHits2SDigits.C : ITSLoader::LoadHits returned error"
            << endl;
        return 3;
      }
     retval = gime->LoadSDigits("recreate");
     if (retval)
      {
-      cerr<<"AliITSHits2DigitsDefault.C : ITSLoader::LoadSDigits returned error"
+      cerr<<"AliITSHits2SDigits.C : ITSLoader::LoadSDigits returned error"
            << endl;
        return 3;
      }
@@ -95,4 +96,5 @@ Int_t AliITSHits2SDigits(TString  filename = "galice.root")
     timer.Print();
 
     delete rl; // sdigfile is closed by deleting gAlice if != hitfile.
+    return 0;
 }
index 69451dade852fe7997a07136852371f8743dc14e..ae22077e191328bdb147dd86267cb792c5647e42 100644 (file)
@@ -1,13 +1,3 @@
-#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/AliITSHit.h"
-*/
 void AliITSPrintGeom(TString hfn="galice.root",Int_t mod=-1){
     // Macro to print out the information kept in the AliITSgeom class, for 
     //all or a specific module
@@ -16,44 +6,52 @@ void AliITSPrintGeom(TString hfn="galice.root",Int_t mod=-1){
     if (gClassTable->GetID("AliRun") < 0) {
         gROOT->LoadMacro("loadlibs.C");
         loadlibs();
-    } // end if
+    } 
+    else {
+      if(gAlice){
+       delete gAlice->GetRunLoader();
+       delete gAlice;
+       gAlice=0;
+      }
+    }
 
-    TFile *hf = (TFile*)gROOT->GetListOfFiles()->FindObject(hfn);
-    if(hf) {
-        hf->Close();
-        delete hf;
-        hf = 0;
-    } // end if file
-    hf = new TFile(hfn,"READ");
-    // Get AliRun object from file or return if not on file
-    if (gAlice) {delete gAlice; gAlice = 0;}
-    gAlice = (AliRun*)hf->Get("gAlice");
-    if (!gAlice) {
-        cerr << "AliRun object not found on file "<< FileName << "!" << endl;
-        file->Close();  // close file and return error.
-        return;
-    } // end if !gAlice
+    AliRunLoader* rl = AliRunLoader::Open(hfn.Data());
+    if (rl == 0x0){
+      cerr<<"AliITSPrintGeom.C : Can not open session RL=NULL"<< endl;
+      return;
+    }
+
+    Int_t retval = rl->LoadgAlice();
+    if (retval)
+     {
+      cerr<<"AliITSHits2SDigits.C : LoadgAlice returned error"
+           << endl;
+       return 3;
+     }
+    //    gAlice=rl->GetAliRun();
+    if(!gAlice){
+      cerr<<"AliITSPrintGeom.C. AliRun object not found\n";
+      return;
+    }
 
-/*
-    gROOT->LoadMacro("$(ALICE_ROOT)/ITS/AliITSstandard.C");
-    TFile *hf=0;
-    hf = AccessFile(hfn,"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
+
     AliITSgeom *gm = ITS->GetITSgeom();
     Int_t mod1 = 0;
     Int_t mod2 = gm->GetIndexMax();
     if(mod>=0){
         mod1 = mod;
-        mod2 = mode+1;
+        mod2 = mod+1;
     } // end if mod>=0
     AliITSgeomMatrix *gmm = gm->GetGeomMatrix(0);
     Int_t m;
+    cout<<endl<<endl<<"====================================\n";
     gmm->PrintComment(&cout); cout << endl;
+    cout<<endl<<endl<<"====================================\n";
     for(m=mod1;m<mod2;m++){
        gmm = gm->GetGeomMatrix(m);
        gmm->Print(&cout); cout << endl;
index f065327bacdf7153b6540a9632a07ee1542aef6f..adf5c497ff2b48524fc1f9f3e2c8ede4101f3dda 100644 (file)
@@ -1,66 +1,76 @@
-#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/AliITSHit.h"
-*/
 void AliITSPrintHits(TString hfn="galice.root",Int_t mod=-1,
-                         Int_t evnt=-1){
-    // Macro to print out the recpoints for all or a specific module
+                    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");
+  // 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");
 
-    TFile *hf=0;
-    hf = AccessFile(hfn,"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
+  AliRunLoader *rl = AccessFile(hfn); // Set up to read in Data
+  Int_t retval = rl->LoadHeader();
+  if (retval){
+    cerr<<"AliITSPrintHits.C : LoadHeader returned error"<<endl;
+    return;
+  }
 
-    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 *hpa = ITS->RecPoints();
-    AliITShit *hp = 0;
+  AliITSLoader* ITSloader =  (AliITSLoader*) rl->GetLoader("ITSLoader");
 
-    Int_t nmodules,size=-1;
+  if(!ITSloader){
+    cerr<<"AliITSPrintHits.C :  ITS loader not found"<<endl;
+    return;
+  }
+
+  ITSloader->LoadHits("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
+  AliITShit *hp = 0;
+
+  Int_t nmodules,size=-1;
+  Int_t event,m,i,i2,hit,trk;
+  for(event = evNumber1; event < evNumber2; event++){
+    cout<<"Processing event "<<event<<endl;
+    rl->GetEvent(event);
     ITS->InitModules(size,nmodules);
-    Int_t event,m,i,i2,hit,trk;
-    for(event = evNumber1; event < evNumber2; event++){
-        gAlice->GetEvent(event);
-       ITS->FillModules(event,0,-1," "," ");
-       for(m=mod1;m<mod2;m++){
-           i2 = (ITS->GetModule(m))->GetNhits();
-           cout <<  "Event=" << event << " module=" << m <<
-               " Number of Hits=" << i2 <<endl;
-           for(i=0;i<i2;i++){
-               trk = (ITS->GetModule(m))->GetHitTrackIndex(i);
-               hit = (ITS->GetModule(m))->GetHitHitIndex(i);
-               hp  = (ITS->GetModule(m))->GetHit(i);
-               cout << i << " trk#="<<trk<<" hit#="<< hit << " ";
-               hp->Print((ostream*)cout);
-               cout << endl;
-           } // end for i
-       } // end for m
-       ITS->ClearModules();
-    } // end for event
+    ITS->FillModules(event,0,-1," "," ");
+    for(m=mod1;m<mod2;m++){
+      i2 = (ITS->GetModule(m))->GetNhits();
+      cout <<  "Event=" << event << " module=" << m <<
+       " Number of Hits=" << i2 <<endl;
+      for(i=0;i<i2;i++){
+       trk = (ITS->GetModule(m))->GetHitTrackIndex(i);
+       hit = (ITS->GetModule(m))->GetHitHitIndex(i);
+       hp  = (ITS->GetModule(m))->GetHit(i);
+       cout << i << " trk#="<<trk<<" hit#="<< hit << " ";
+       hp->Print((ostream*)cout);
+       cout << endl;
+      } // end for i
+    } // end for m
+    ITS->ClearModules();
+  } // end for event
 }
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
 
 }
index cbdff9330b38885c21636cca840edca7043d48d6..642590a754ba3dd63f53c0367983e9e1733c61bb 100644 (file)
@@ -1,19 +1,5 @@
-#if !defined(__CINT__) || defined(__MAKECINT__)
-
-#include "iostream.h"
-#include "TDatetime.h"
-#include "STEER/AliRun.h"
-#include "STEER/AliRunDigitizer.h"
-#include "ITS/AliITSDigitizer.h"
-#include "ITS/AliITS.h"
-#include "ITS/AliITSDetType.h"
-#include "ITS/AliITSresponseSDD.h"
-#include "TStopwatch.h"
-
-#endif
-
-//#define DEBUG
-
+// Functions used to access input files - shared by several macros
 //______________________________________________________________________
 Bool_t GaliceITSok(){
     // Checks gAlice to see that ITS and the ITS geometry are properly
@@ -39,83 +25,20 @@ Bool_t GaliceITSok(){
     return kTRUE;
 }
 //______________________________________________________________________
-TFile * AccessFile(TString FileName, TString acctype){
-    // Function used to open the input file and fetch the AliRun object
-
-    TFile *retfil = 0;
-    TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(FileName);
-    if(file) {
-       file->Close();
-       delete file;
-       file = 0;
-    } // end if file
-    if(acctype.Contains("U")){
-       file = new TFile(FileName,"UPDATE");
-    } // end if open for update
-    if(acctype.Contains("N") && !file){
-       file = new TFile(FileName,"RECREATE");
-    } // end if open a new file
-    if(!file) file = new TFile(FileName,"READ");   // default readonly
-    if (!file->IsOpen()) {
-       cerr << "Can't open " << FileName << " !" << endl;
-       return retfil;
-    } // end if error opeing file
-
-    // Get AliRun object from file or return if not on file
-    if (gAlice) {delete gAlice; gAlice = 0;}
-    gAlice = (AliRun*)file->Get("gAlice");
-    if (!gAlice) {
-       cerr << "AliRun object not found on file "<< FileName << "!" << endl;
-       file->Close();  // close file and return error.
-       return retfil;
-    } // end if !gAlice
-    return file;
+AliRunLoader* AccessFile(TString FileName){
+  // Function used to open the input file and fetch the AliRun object
+
+  AliRunLoader* rl = AliRunLoader::Open(FileName.Data());
+  if (rl == 0x0){
+    cerr<<"AccessFile : Can not open session RL=NULL"<< endl;
+    return rl;
+  }
+  Int_t retval = rl->LoadgAlice();
+  if (retval){
+    cerr<<"AccessFile : LoadgAlice returned error"<<endl;
+    return rl;
+  }
+  return rl;
 }
-//______________________________________________________________________
-void writeAR(TFile * fin, TFile *fou) {
-    TDirectory *current = gDirectory;
-    fou->cd();
-    gAlice->TreeE()->SetBranchStatus("*",1);
-    gAlice->TreeE()->Write(0,TObject::kOverwrite);
-    gAlice->Write(0,TObject::kOverwrite);
-    current->cd();
-#ifdef DEBUG
-    cout << "AliRun object from file "<<fin->GetName() 
-        << " written to file " << fou->GetName() <<"." << endl;
-#endif
-}
-//______________________________________________________________________
-Int_t ChangeITSDefaults(TFile *hitfile,AliITS *ITS,TString opt){
 
-    TDatime *ct0 = new TDatime(2002,04,26,00,00,00);
-    TDatime ct = *ct0;
-    if(hitfile) ct = hitfile->GetCreationDate();
-
-    if(ct0->GetDate()>ct.GetDate()){
-       // For old files, must change SDD noise.
-       AliITSresponseSDD *resp1 = (AliITSresponseSDD*)ITS->DetType(1)->
-           GetResponseModel();
-       resp1 = new AliITSresponseSDD();
-       ITS->SetResponseModel(1,resp1);
-       cout << "Changed response class for SDD:" << endl;
-       resp1->Print();
-    } // end if
-
-    if(opt.Contains("Dubna")){
-       AliITSresponseSPDdubna *resp0 = new AliITSresponseSPDdubna();
-       if(ITS->DetType(0)->GetResponseModel() !=0){
-           delete ((AliITSresponse*)ITS->DetType(0)->GetResponseModel());
-           ITS->DetType(0)->ResponseModel(0);
-       } // end if
-       ITS->DetType(0)->ResponseModel(resp0);
-       AliITSsegmentationSPD *seg0 = (AliITSsegmentationSPD*)ITS->
-           DetType(0)->GetSegmentationModel();
-       AliITSsimulationSPDdubna *sim0 = new AliITSsimulationSPDdubna(seg0,
-                                                                     resp0);
-       if(ITS->DetType(0)->GetSimulationModel() !=0){
-           delete ((AliITSsimulation*)ITS->DetType(0)->GetSimulationModel());
-           ITS->DetType(0)->SimulationModel(0);
-       } // end if
-       ITS->DetType(0)->SimulationModel(sim0);
-    } // end if Dubna
-}