-void AliITSDigits2RecPoints(Int_t evNumber1=0,Int_t evNumber2=0, const char *filename="galice.root"){
- TStopwatch timer;
-
- if(gAlice){
- delete gAlice;
- gAlice = 0;
- } // end if gAlice
- cout << "Creating reconstructed points from digits for the ITS..." << endl;
- AliITSreconstruction *itsr = new AliITSreconstruction(filename);
- timer.Start();
- itsr->Init();
- itsr->Exec();
- timer.Stop(); timer.Print();
- delete itsr;
+TFile* AccessFile(TString inFile="galice.root", TString acctype="R");
+
+void AliITSDigits2RecPoints(TString inFile="galice.root", TString outFile="galice.root"){
+
+ TFile *file;
+ if(outFile.Data() == inFile.Data()){
+ file = AccessFile(inFile,"U");
+ }
+ else {
+ file = AccessFile(inFile);
+ }
+
+ TStopwatch timer;
+
+ cout << "Creating reconstructed points from digits for the ITS..." << endl;
+ const char *nulptr=0;
+ AliITSreconstruction *itsr = new AliITSreconstruction(nulptr);
+ if(outFile.Data() != inFile.Data())itsr->SetOutputFile(outFile);
+ timer.Start();
+ itsr->Init();
+ itsr->Exec();
+ timer.Stop();
+ timer.Print();
+ delete itsr;
+}
+
+//-------------------------------------------------------------------
+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;}
+ if(acctype.Contains("U")){
+ file = new TFile(FileName,"update");
+ }
+ if(acctype.Contains("N") && !file){
+ file = new TFile(FileName,"recreate");
+ }
+ if(!file) file = new TFile(FileName); // default readonly
+ if (!file->IsOpen()) {
+ cerr<<"Can't open "<<FileName<<" !" << endl;
+ return retfil;
+ }
+
+ // 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"<< endl;
+ return retfil;
+ }
+ return file;
}
--- /dev/null
+TFile* AccessFile(TString inFile="galice.root", TString acctype="R");
+void writeAR(TFile * fin, TFile *fou);
+
+Int_t AliITSHits2Digits(Int_t evNumber1=0,Int_t evNumber2=0, TString inFile = "galice.root", TString outFile="galice.root"){
+
+ // 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 *file;
+ if(outFile.Data() == inFile.Data()){
+ file = AccessFile(inFile,"U");
+ }
+ else {
+ file = AccessFile(inFile);
+ }
+
+ TFile *file2 = 0; // possible output file for TreeD
+
+ if(!(outFile.Data() == inFile.Data())){
+ // open output file and create TreeR on it
+ file2 = gAlice->InitTreeFile("D",outFile);
+ }
+
+ AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS");
+ if (!ITS) {
+ cerr<<"AliITSHits2DigitsDefault.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;
+ return 4;
+ } // end if
+
+ TDatime *ct0 = new TDatime(2002,04,26,00,00,00);
+ TDatime ct = file->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: \n";
+ resp1->Print();
+ } // end if
+ TStopwatch timer;
+ timer.Start();
+
+ for(Int_t nevent = evNumber1; nevent <= evNumber2; nevent++){
+ cout<<"Producing Digits for event n."<<nevent<<endl;
+ gAlice->GetEvent(nevent);
+ if(!gAlice->TreeD() && file2 == 0){
+ cout << "Having to create the Digits Tree." << endl;
+ gAlice->MakeTree("D");
+ }
+ if(file2)gAlice->MakeTree("D",file2);
+ ITS->MakeBranch("D");
+ ITS->SetTreeAddress();
+ ITS->Hits2Digits();
+ }
+ timer.Stop();
+ timer.Print();
+
+ // write the AliRun object to the output file
+ if(file2)writeAR(file,file2);
+
+ delete gAlice;
+ gAlice=0;
+ file->Close();
+}
+
+//-------------------------------------------------------------------
+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;}
+ if(acctype.Contains("U")){
+ file = new TFile(FileName,"update");
+ }
+ if(acctype.Contains("N") && !file){
+ file = new TFile(FileName,"recreate");
+ }
+ if(!file) file = new TFile(FileName); // default readonly
+ if (!file->IsOpen()) {
+ cerr<<"Can't open "<<FileName<<" !" << endl;
+ return retfil;
+ }
+
+ // 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"<< endl;
+ return retfil;
+ }
+ return file;
+}
+
+//-------------------------------------------------------------------
+void writeAR(TFile * fin, TFile *fou) {
+ TDirectory *current = gDirectory;
+ TTree *Te;
+ TTree *TeNew;
+ AliHeader *alhe = new AliHeader();
+ Te = (TTree*)fin->Get("TE");
+ Te->SetBranchAddress("Header",&alhe);
+ Te->SetBranchStatus("*",1);
+ fou->cd();
+ TeNew = Te->CloneTree();
+ TeNew->Write(0,TObject::kOverwrite);
+ gAlice->Write(0,TObject::kOverwrite);
+ current->cd();
+ delete alhe;
+ cout<<"AliRun object written to file\n";
+}
+
+
+
+
+
-#include "iostream.h"
+TFile* AccessFile(TString inFile="galice.root", TString acctype="R");
-void AliITSHits2FastRecPoints (Int_t evNumber1=0,Int_t evNumber2=0,Int_t nsignal=25, Int_t size=-1)
+void AliITSHits2FastRecPoints (Int_t evNumber1=0,Int_t evNumber2=0, TString inFile = "galice.root", TString outFile="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;
- }
-
-// 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();
-
- 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");
-
- AliITS *ITS = (AliITS*) gAlice->GetModule("ITS");
- if (!ITS) return;
+ /////////////////////////////////////////////////////////////////////////
+ //
+ // This macro creates fast recpoints, optionally on a separate file
+ //
+ /////////////////////////////////////////////////////////////////////////
+
+ // Dynamically link some shared libs
+
+ if (gClassTable->GetID("AliRun") < 0) {
+ gROOT->LoadMacro("loadlibs.C");
+ loadlibs();
+ } else {
+ delete gAlice;
+ gAlice=0;
+ }
+
+ // Connect the Root Galice file containing Geometry, Kine and Hits
+ TFile *file;
+ if(outFile.Data() == inFile.Data()){
+ file = AccessFile(inFile,"U");
+ }
+ else {
+ file = AccessFile(inFile);
+ }
+
+ TFile *file2 = 0; // possible output file for TreeR
+ if(!(outFile.Data() == inFile.Data())){
+ // open output file and create TreeR on it
+ file2 = gAlice->InitTreeFile("R",outFile);
+ }
+
+ AliITS *ITS = (AliITS*) gAlice->GetModule("ITS");
+ if (!ITS) return;
// Set the simulation model
- /* Bug !!! (I.Belikov)
- AliITSsimulationFastPoints *sim = new AliITSsimulationFastPoints();
-
- 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());
- }
+ 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
+ //
+
+ 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() && file2 == 0) gAlice-> MakeTree("R");
+ if(!gAlice->TreeR() && file2 != 0) gAlice->MakeTree("R",file2);
+ ITS->MakeBranch("RF");
+ 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();
}
-
-
-
-
-
-
-
-
-
-
-
-
+//-------------------------------------------------------------------
+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;}
+ if(acctype.Contains("U")){
+ file = new TFile(FileName,"update");
+ }
+ if(acctype.Contains("N") && !file){
+ file = new TFile(FileName,"recreate");
+ }
+ if(!file) file = new TFile(FileName); // default readonly
+ if (!file->IsOpen()) {
+ cerr<<"Can't open "<<FileName<<" !" << endl;
+ return retfil;
+ }
+
+ // 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"<< endl;
+ return retfil;
+ }
+ return file;
+}
return ;
}
- // for old files
+ // these re-instantiations are necessary if the input file was created
+ // with aliroot version V3.07 or older
AliITSresponseSDD *resp1 = (AliITSresponseSDD*)ITS->DetType(1)->GetResponseModel();
- TDatime *ct0= new TDatime(2002,04,26,00,00,00),ct=file2->GetCreationDate();
- if(ct0->GetDate()<ct.GetDate()){
- resp1 = new AliITSresponseSDD();
- ITS->SetResponseModel(1,resp1);
- cout << "Changed response class for SDD: \n";
- resp1->Print();
- } // end if
- // end mods for old files (<26/4/2002)
+ resp1 = new AliITSresponseSDD();
+ ITS->SetResponseModel(1,resp1);
+ cout << "Changed response class for SDD: \n";
+ resp1->Print();
+
for (Int_t nevent=0; nevent<gAlice->TreeE()->GetEntries(); nevent++) {
gAlice->GetEvent(nevent);
gAlice->MakeTree("S",file2);
-Int_t AliITSHits2SDigits(const char *inFile = "galice.root"){
+TFile* AccessFile(TString inFile="galice.root", TString acctype="R");
+void writeAR(TFile * fin, TFile *fou);
- // Dynamically link some shared libs
- if (gClassTable->GetID("AliRun") < 0) {
+Int_t AliITSHits2SDigits(Int_t evNumber1=0,Int_t evNumber2=0, TString inFile = "galice.root", TString outFile="galice.root"){
+
+ // Dynamically link some shared libs
+ if (gClassTable->GetID("AliRun") < 0) {
gROOT->LoadMacro("loadlibs.C");
loadlibs();
- } // end if
+ } // end if
+
+ // Connect the Root Galice file containing Geometry, Kine and Hits
- // Connect the Root Galice file containing Geometry, Kine and Hits
+ TFile *file;
+ if(outFile.Data() == inFile.Data()){
+ file = AccessFile(inFile,"U");
+ }
+ else {
+ file = AccessFile(inFile);
+ }
- TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(inFile);
- if (file) {file->Close(); delete file;}
- cout << "AliITSHits2SDigitsDefault" << endl;
- file = new TFile(inFile,"UPDATE");
- if (!file->IsOpen()) {
- cerr<<"Can't open "<<inFile<<" !" << endl;
- return 1;
- } // end if !file
- file->ls();
- if(!file) file = new TFile(fileNameSDigitsSig.Data());
- TDatime *ct0 = new TDatime(2002,04,26,00,00,00), ct = file->GetCreationDate();
-
- // Get AliRun object from file or return if not on file
- if (gAlice) delete gAlice;
- gAlice = (AliRun*)file->Get("gAlice");
- if (!gAlice) {
- cerr << "AliITSITSHits2Digits.C : AliRun object not found on file"
- << endl;
- return 2;
- } // end if !gAlice
+ TFile *file2 = 0; // possible output file for TreeS
- gAlice->GetEvent(0);
- AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS");
- if (!ITS) {
+ if(!(outFile.Data() == inFile.Data())){
+ // open output file and create TreeS on it
+ file2 = gAlice->InitTreeFile("S",outFile);
+ }
+
+ AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS");
+ if (!ITS) {
cerr<<"AliITSHits2DigitsDefault.C : AliITS object not found on file"
<< endl;
return 3;
- } // end if !ITS
- if(!(ITS->GetITSgeom())){
+ } // end if !ITS
+ if(!(ITS->GetITSgeom())){
cerr << " AliITSgeom not found. Can't digitize with out it." << endl;
return 4;
- } // end if
+ } // end if
+
+ TDatime *ct0 = new TDatime(2002,04,26,00,00,00);
+ TDatime ct = file->GetCreationDate();
- if(ct0->GetDate()>ct.GetDate()){
+ if(ct0->GetDate()>ct.GetDate()){
// For old files, must change SDD noise.
- AliITS *ITS = (AliITS*) gAlice->GetDetector("ITS");
- AliITSresponseSDD *resp1 = ITS->DetType(1)->GetResponseModel();
- resp1->SetNoiseParam();
- resp1->SetNoiseAfterElectronics();
- Float_t n,b;
- Int_t cPar[8];
- resp1->GetNoiseParam(n,b);
- n = resp1->GetNoiseAfterElectronics();
- cPar[0]=0;
- cPar[1]=0;
- cPar[2]=(Int_t)(b + 2.*n + 0.5);
- cPar[3]=(Int_t)(b + 2.*n + 0.5);
- cPar[4]=0;
- cPar[5]=0;
- cPar[6]=0;
- cPar[7]=0;
- resp1->SetCompressParam(cPar);
- } // end if
-
- if(!gAlice->TreeS()){
- cout << "Having to create the SDigits Tree." << endl;
- gAlice->MakeTree("S");
+ AliITSresponseSDD *resp1 = (AliITSresponseSDD*)ITS->DetType(1)->GetResponseModel();
+ resp1 = new AliITSresponseSDD();
+ ITS->SetResponseModel(1,resp1);
+ cout << "Changed response class for SDD: \n";
+ resp1->Print();
+ } // end if
+ TStopwatch timer;
+ timer.Start();
+ for(Int_t nevent = evNumber1; nevent <= evNumber2; nevent++){
+ gAlice->GetEvent(nevent);
+ if(!gAlice->TreeS() && file2 == 0){
+ cout << "Having to create the SDigits Tree." << endl;
+ gAlice->MakeTree("S");
} // end if !gAlice->TreeS()
- //make branch
+ if(file2)gAlice->MakeTree("S",file2);
+ // make branch
ITS->MakeBranch("S");
ITS->SetTreeAddress();
- cout << "Digitizing ITS..." << endl;
-
+ cout<<"Making ITS SDigits for event "<<nevent<<endl;
TStopwatch timer;
Long_t size0 = file->GetSize();
- timer.Start();
ITS->Hits2SDigits();
- timer.Stop(); timer.Print();
-
- delete gAlice; gAlice=0;
- file->Close();
- Long_t size1 = file->GetSize();
- cout << "File size before = " << size0 << " file size after = " << size1;
- cout << "Increase in file size is " << size1-size0 << " Bytes" << endl;
- delete file;
- return 0;
-};
+ }
+ timer.Stop();
+ timer.Print();
+
+ // write the AliRun object to the output file
+ if(file2)writeAR(file,file2);
+
+ delete gAlice; gAlice=0;
+ file->Close();
+}
+
+//-------------------------------------------------------------------
+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;}
+ if(acctype.Contains("U")){
+ file = new TFile(FileName,"update");
+ }
+ if(acctype.Contains("N") && !file){
+ file = new TFile(FileName,"recreate");
+ }
+ if(!file) file = new TFile(FileName); // default readonly
+ if (!file->IsOpen()) {
+ cerr<<"Can't open "<<FileName<<" !" << endl;
+ return retfil;
+ }
+
+ // 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"<< endl;
+ return retfil;
+ }
+ return file;
+}
+
+//-------------------------------------------------------------------
+void writeAR(TFile * fin, TFile *fou) {
+ TDirectory *current = gDirectory;
+ TTree *Te;
+ TTree *TeNew;
+ AliHeader *alhe = new AliHeader();
+ Te = (TTree*)fin->Get("TE");
+ Te->SetBranchAddress("Header",&alhe);
+ Te->SetBranchStatus("*",1);
+ fou->cd();
+ TeNew = Te->CloneTree();
+ TeNew->Write(0,TObject::kOverwrite);
+ gAlice->Write(0,TObject::kOverwrite);
+ current->cd();
+ delete alhe;
+ cout<<"AliRun object written to file\n";
+}
+
+
+
+
-void AliITSSDigits2Digits(const char *filename = "galice.root"){
+void writeAR(TFile * fin, TFile *fou);
+void AliITSSD2D(TString inFile, TString outFile);
+
+void AliITSSDigits2Digits(TString inFile= "galice.root", TString outFile = ""){
// This macro takes SDigits and produces Digits. No merging is done
// and only one galice.root file is used.
// Dynamically link some shared libs
gAlice = 0;
} // end if gAlice
cout << "Creating digits from summable digits for the ITS..." << endl;
- AliRunDigitizer * manager = new AliRunDigitizer(1,1);
- manager->SetInputStream(0,filename);
- AliITSDigitizer *dITS = new AliITSDigitizer(manager);
- timer.Start();
- manager->Exec("");
- timer.Stop(); timer.Print();
- delete dITS;
+ AliITSSD2D(inFile,outFile);
+ timer.Stop();
+ timer.Print();
+}
+
+void AliITSSD2D(TString inFile, TString outFile){
+ AliRunDigitizer * manager = new AliRunDigitizer(1,1);
+ char ftmp[50];
+ sprintf(ftmp,"%s",inFile.Data());
+ manager->SetInputStream(0,ftmp);
+ if(outFile != "")manager->SetOutputFile(outFile);
+ AliITSDigitizer *dITS = new AliITSDigitizer(manager);
+ manager->Exec("");
+ TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(inFile);
+ TFile *file2 = 0;
+ if(outFile != ""){
+ file2 = new TFile(outFile,"UPDATE");
+ writeAR(file,file2);
+ }
+ delete dITS;
+ delete manager;
+ if(file){
+ file->Close();
+ delete file;
+ }
+ if(file2){
+ file2->Close();
+ delete file2;
+ }
}
+
+void writeAR(TFile * fin, TFile *fou) {
+ TDirectory *current = gDirectory;
+ TTree *Te;
+ TTree *TeNew;
+ AliHeader *alhe = new AliHeader();
+ Te = (TTree*)fin->Get("TE");
+ Te->SetBranchAddress("Header",&alhe);
+ Te->SetBranchStatus("*",1);
+ fou->cd();
+ TeNew = Te->CloneTree();
+ TeNew->Write(0,TObject::kOverwrite);
+ gAlice->Write(0,TObject::kOverwrite);
+ current->cd();
+ delete alhe;
+ cout<<"AliRun object written to file\n";
+}
+
+
+
+
+
+