From d2e7afa17c0f0fcd206a2d214cb378b02a5a4e35 Mon Sep 17 00:00:00 2001 From: masera Date: Thu, 31 Jul 2003 17:28:17 +0000 Subject: [PATCH] Transition to newIO --- ITS/AliITSDigits2RecPoints.C | 22 ++-- ITS/AliITSHits2Digits.C | 199 ++++++++++++----------------------- ITS/AliITSHits2SDigits.C | 50 ++++----- ITS/AliITSPrintGeom.C | 62 ++++++----- ITS/AliITSPrintHits.C | 128 +++++++++++----------- ITS/AliITSPrintRecPoints.C | 134 ++++++++++++----------- ITS/AliITSstandard.C | 111 +++---------------- 7 files changed, 295 insertions(+), 411 deletions(-) diff --git a/ITS/AliITSDigits2RecPoints.C b/ITS/AliITSDigits2RecPoints.C index eaf6b164605..82633d9a70f 100644 --- a/ITS/AliITSDigits2RecPoints.C +++ b/ITS/AliITSDigits2RecPoints.C @@ -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; diff --git a/ITS/AliITSHits2Digits.C b/ITS/AliITSHits2Digits.C index 7e55c9f7d20..e44595cddca 100644 --- a/ITS/AliITSHits2Digits.C +++ b/ITS/AliITSHits2Digits.C @@ -1,169 +1,102 @@ #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."<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; } diff --git a/ITS/AliITSHits2SDigits.C b/ITS/AliITSHits2SDigits.C index 47617ed54d9..5ca9fffa774 100644 --- a/ITS/AliITSHits2SDigits.C +++ b/ITS/AliITSHits2SDigits.C @@ -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; } diff --git a/ITS/AliITSPrintGeom.C b/ITS/AliITSPrintGeom.C index 69451dade85..ae22077e191 100644 --- a/ITS/AliITSPrintGeom.C +++ b/ITS/AliITSPrintGeom.C @@ -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"<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<PrintComment(&cout); cout << endl; + cout<GetGeomMatrix(m); gmm->Print(&cout); cout << endl; diff --git a/ITS/AliITSPrintHits.C b/ITS/AliITSPrintHits.C index f065327bacd..adf5c497ff2 100644 --- a/ITS/AliITSPrintHits.C +++ b/ITS/AliITSPrintHits.C @@ -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"<LoadHeader(); + if (retval){ + cerr<<"AliITSPrintHits.C : LoadHeader returned error"<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"<LoadHits("read"); + AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS"); + if(!ITS){ + cout << "Error: no ITS found. Aborting"<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 "<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;mGetModule(m))->GetNhits(); - cout << "Event=" << event << " module=" << m << - " Number of Hits=" << i2 <GetModule(m))->GetHitTrackIndex(i); - hit = (ITS->GetModule(m))->GetHitHitIndex(i); - hp = (ITS->GetModule(m))->GetHit(i); - cout << i << " trk#="<Print((ostream*)cout); - cout << endl; - } // end for i - } // end for m - ITS->ClearModules(); - } // end for event + ITS->FillModules(event,0,-1," "," "); + for(m=mod1;mGetModule(m))->GetNhits(); + cout << "Event=" << event << " module=" << m << + " Number of Hits=" << i2 <GetModule(m))->GetHitTrackIndex(i); + hit = (ITS->GetModule(m))->GetHitHitIndex(i); + hp = (ITS->GetModule(m))->GetHit(i); + cout << i << " trk#="<Print((ostream*)cout); + cout << endl; + } // end for i + } // end for m + ITS->ClearModules(); + } // end for event } diff --git a/ITS/AliITSPrintRecPoints.C b/ITS/AliITSPrintRecPoints.C index 89e510f0a4c..523379e7630 100644 --- a/ITS/AliITSPrintRecPoints.C +++ b/ITS/AliITSPrintRecPoints.C @@ -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"<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;mResetRecPoints(); - gAlice->TreeR()->GetEvent(m); - i2 = rpa->GetEntriesFast(); - cout << "Event=" << event << " module=" << m << - " Number of Recpoints=" << i2 <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"<GetLoader("ITSLoader"); + + if(!ITSloader){ + cerr<<"AliITSPrintRecPoints.C : ITS loader not found"<LoadHits("read"); + ITSloader->LoadDigits("read"); + ITSloader->LoadRecPoints("read"); + AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS"); + if(!ITS){ + cout << "Error: no ITS found. Aborting"<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;mResetRecPoints(); + TTree *TR = ITSloader->TreeR(); + TR->GetEvent(m); + rpa = ITS->RecPoints(); + i2 = rpa->GetEntriesFast(); + cout << "Event=" << event << " module=" << m << + " Number of Recpoints=" << i2 <At(i)); + cout << i << " "; + rp->Print((ostream*)cout); + cout << endl; + } // end for i + } // end for m + } // end for event } diff --git a/ITS/AliITSstandard.C b/ITS/AliITSstandard.C index cbdff9330b3..642590a754b 100644 --- a/ITS/AliITSstandard.C +++ b/ITS/AliITSstandard.C @@ -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"<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 "<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 -} -- 2.39.3