A set of macros that do ITS simulation and reconstruction all in one. See
authornilsen <nilsen@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 26 Aug 2002 21:12:47 +0000 (21:12 +0000)
committernilsen <nilsen@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 26 Aug 2002 21:12:47 +0000 (21:12 +0000)
AliITSh2r.C as an example.

ITS/AliITSd2r.C [new file with mode: 0644]
ITS/AliITSh2d.C [new file with mode: 0644]
ITS/AliITSh2r.C [new file with mode: 0644]
ITS/AliITSh2sd.C [new file with mode: 0644]
ITS/AliITSsd2d.C [new file with mode: 0644]

diff --git a/ITS/AliITSd2r.C b/ITS/AliITSd2r.C
new file mode 100644 (file)
index 0000000..4c5d09a
--- /dev/null
@@ -0,0 +1,81 @@
+#if !defined(__CINT__) || defined(__MAKECINT__)
+
+#include "iostream.h"
+#include "TDatime.h"
+#include "TFile.h"
+#include "TString.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"
+
+Bool_t GaliceITSok();
+TFile* AccessFile(TString inFile="galice.root", TString acctype="R");
+void writeAR(TFile * fin, TFile *fou);
+Int_t ChangeITSDefaults(TFile *hitfile,AliITS *ITS,TString opt="");
+void loadlibs();
+
+#endif
+
+//#define DEBUG
+
+Int_t AliITSd2r(TString df="galice.root",TString rf="",TString opt=""){
+    // Produce ITS RecPoints from Digits.
+
+    // 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 *dfp = 0, *rfp = 0;
+    if(!GaliceITSok()){
+       // gAlice not define. Must open a file and read it in.
+       if(rf.CompareTo(df) == 0 || rf.CompareTo("") == 0) {
+           // Input file = output file
+           dfp = AccessFile(df,"U");  // input file open for update.
+       }else{ // Input file different from output file.
+           dfp = AccessFile(df,"R"); // input file open as read only
+           // open output file and create TreeR on it
+           rfp = new TFile(rp,"NEW");
+       } // end if
+    } // end if !GALICEITSOK()
+    AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS"); 
+
+    ChangeITSDefaults(dfp,ITS,opt);
+    // write the AliRun object to the output file if different from input file.
+    if(rfp) {
+       writeAR(dfp,rfp);
+       rfp->Close(); // Manager will open in update mode.
+    } // end if
+
+    TStopwatch timer;
+
+#ifdef DEBUG
+    cout << "Creating reconstructed points from digits for the ITS..." << endl;
+#endif
+    if(dfp!=0)
+       AliITSreconstruction *itsr = new AliITSreconstruction(df.Data());
+    else
+       AliITSreconstruction *itsr = new AliITSreconstruction(0);
+    if(df.CompareTo(rf)!=0 && rf.CompareTo("")!=0) {
+       itsr->SetOutputFile(rf.Data());
+    } // end if
+    timer.Start();
+    itsr->Init();
+    itsr->Exec(); 
+    timer.Stop(); 
+    timer.Print();
+    delete itsr;
+
+    if(rfp!=0){
+       cout <<"After Reconstruction "<<rf<<" size ="<< rfp->GetSize()<< endl;
+    }else if(dfp!=0){
+       cout <<"After Reconstruction "<<df<<" size ="<< dfp->GetSize()<< endl;
+    } // end if sf1!=0
+    return 0;
+}
diff --git a/ITS/AliITSh2d.C b/ITS/AliITSh2d.C
new file mode 100644 (file)
index 0000000..a720521
--- /dev/null
@@ -0,0 +1,81 @@
+#if !defined(__CINT__) || defined(__MAKECINT__)
+
+#include "iostream.h"
+#include "TDatime.h"
+#include "TDatime.h"
+#include "TFile.h"
+#include "TString.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"
+
+Bool_t GaliceITSok();
+TFile* AccessFile(TString inFile="galice.root", TString acctype="R");
+void writeAR(TFile * fin, TFile *fou);
+Int_t ChangeITSDefaults(TFile *hitfile,AliITS *ITS,TString opt="");
+void loadlibs();
+
+#endif
+
+//#define DEBUG
+
+Int_t AliITSh2d(TString hf="galice.root",TString df="",TString opt=""){
+    // Produce ITS SDigits from Hits.
+
+    // 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 *hfp = 0, *dfp = 0;
+    if(!GaliceITSok()){
+       // gAlice not define. Must open a file and read it in.
+       if(hf.CompareTo(df) == 0 || df.CompareTo("") == 0) {
+           // Input file = output file
+           hfp = AccessFile(hf,"U");  // input file open for update.
+       }else{ // Input file different from output file.
+           hfp = AccessFile(hf,"R"); // input file open as read only
+           // open output file and create TreeR on it
+           dfp = gAlice->InitTreeFile("D",df);
+       } // end if
+    } // end if !GALICEITSOK()
+    AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS");
+
+    ChangeITSDefaults(hfp,ITS,opt);
+    // write the AliRun object to the output file if different from input file.
+    if(dfp) writeAR(hfp,dfp);
+
+    TStopwatch timer;
+    Int_t evNumber1 = 0;
+    Int_t evNumber2 = gAlice->GetEventsPerRun();
+    timer.Start();
+    for(Int_t event = evNumber1; event < evNumber2; event++){
+       gAlice->GetEvent(event);
+       if(!gAlice->TreeD() && dfp == 0){ 
+           cout << "Having to create the Digits Tree." << endl;
+           gAlice->MakeTree("S");
+       } // end if !gAlice->TreeS()
+       if(dfp) gAlice->MakeTree("D",dfp);
+       //    make branch
+       ITS->MakeBranch("D");
+       ITS->SetTreeAddress();
+#ifdef DEBUG
+       cout<<"Making ITS Digits for event "<<event<<endl;
+#endif
+       ITS->Hits2Digits();
+    } // end for event
+    timer.Stop();
+    timer.Print();
+    if(dfp!=0){
+       cout <<"After Digitization "<<df<< " size =" << dfp->GetSize() << endl;
+    }else if(hfp!=0){
+       cout <<"After digitization "<<hf<< " size =" << hfp->GetSize() << endl;
+    } // end if dfp!=0
+    return 0;
+}
diff --git a/ITS/AliITSh2r.C b/ITS/AliITSh2r.C
new file mode 100644 (file)
index 0000000..05cad3e
--- /dev/null
@@ -0,0 +1,56 @@
+#if !defined(__CINT__) || defined(__MAKECINT__)
+
+#include "iostream.h"
+#include "TDatime.h"
+#include "TFile.h"
+#include "TString.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"
+
+Int_t AliITSh2sd(TString hf="galice.root",TString sf="",TString opt="");
+Int_t AliITSh2d(TString hf="galice.root",TString df="",TString opt="");
+Int_t AliITSsd2d(TString df="galice.root",TString sf1="galice.root",
+                 TString sf2="",TString opt="")
+Int_t AliITSd2r(TString df="galice.root",TString rf="",TString opt="");
+void grun(Int_t nevent=1, const char *config="Config.C");
+
+#endif
+//#define DEBUG
+
+
+Int_t AliITSh2r(TString hf="galice.root",TString opt=""){
+    // Runs grun to create the file galice.root and then runs the 
+    // nessesary files to creat recpoints form that file.
+
+    gROOT->LoadMacro("$(ALICE_ROOT)/macros/grun.C");
+    if(!opt.Contains("Nogrun")) grun(1,"Config.C");
+    if(opt.Contains("SDigit")){
+       gROOT->LoadMacro("$(ALICE_ROOT)/ITS/AliITSh2sd.C");
+       if(AliITSh2sd(hf,hf,opt)!=0){
+           cout << "Error AliITSh2sd failed" << endl;
+           return 1;
+       } // end if
+       gROOT->LoadMacro("$(ALICE_ROOT)/ITS/AliITSsd2d.C");
+       if(AliITSsd2d(hf,hf,"",opt)!=0){
+           cout << "Error AliITSsd2d failed" << endl;
+           return 2;
+       } // end if
+    }else{
+       gROOT->LoadMacro("$(ALICE_ROOT)/ITS/AliITSh2d.C");
+       if(AliITSh2d(hf,hf,opt)!=0){
+           cout << "Error AliITSh2d failed" << endl;
+           return 3;
+       } // end if
+    } // end if
+    gROOT->LoadMacro("$(ALICE_ROOT)/ITS/AliITSd2r.C");
+    if(AliITSd2r(hf,hf,opt)!=0){
+       cout << "Error AliITSd2r failed" << endl;
+       return 4;
+    } // end if
+    return 0;
+}
diff --git a/ITS/AliITSh2sd.C b/ITS/AliITSh2sd.C
new file mode 100644 (file)
index 0000000..b72c1ac
--- /dev/null
@@ -0,0 +1,81 @@
+#if !defined(__CINT__) || defined(__MAKECINT__)
+
+#include "iostream.h"
+#include "TDatime.h"
+#include "TFile.h"
+#include "TString.h"
+#include "../STEER/AliRun.h"
+#include "../STEER/AliRunDigitizer.h"
+//#include "AliITSDigitizer.h"
+#include "AliITS.h"
+#include "AliITSDetType.h"
+#include "AliITSresponseSDD.h"
+#include "TStopwatch.h"
+
+Bool_t GaliceITSok();
+TFile* AccessFile(TString inFile="galice.root", TString acctype="R");
+void writeAR(TFile * fin, TFile *fou);
+Int_t ChangeITSDefaults(TFile *hitfile,AliITS *ITS,TString opt="");
+void loadlibs();
+
+#endif
+
+
+//#define DEBUG
+
+Int_t AliITSh2sd(TString hf="galice.root",TString sf="",TString opt=""){
+    // Produce ITS SDigits from Hits.
+
+    // 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 *hfp = 0, *sfp = 0;
+    if(!GaliceITSok()){
+       // gAlice not define. Must open a file and read it in.
+       if(hf.CompareTo(sf) == 0 || sf.CompareTo("") == 0) {
+           // Input file = output file
+           hfp = AccessFile(hf,"U");  // input file open for update.
+       }else{ // Input file different from output file.
+           hfp = AccessFile(hf,"R"); // input file open as read only
+           // open output file and create TreeR on it
+           sfp = gAlice->InitTreeFile("S",sf);
+       } // end if
+    } // end if !GALICEITSOK()
+    AliITS *ITS = (AliITS*) (gAlice->GetDetector("ITS"));
+
+    ChangeITSDefaults(hfp,ITS,opt);
+    // write the AliRun object to the output file if different from input file.
+    if(sfp) writeAR(hfp,sfp);
+
+    TStopwatch timer;
+    Int_t evNumber1 = 0;
+    Int_t evNumber2 = gAlice->GetEventsPerRun();
+    timer.Start();
+    for(Int_t event = evNumber1; event < evNumber2; event++){
+       gAlice->GetEvent(event);
+       if(!gAlice->TreeS() && sfp == 0){ 
+           cout << "Having to create the SDigits Tree." << endl;
+           gAlice->MakeTree("S");
+       } // end if !gAlice->TreeS()
+       if(sfp) gAlice->MakeTree("S",sfp);
+       //    make branch
+       ITS->MakeBranch("S");
+       ITS->SetTreeAddress();
+#ifdef DEBUG
+       cout<<"Making ITS SDigits for event "<<event<<endl;
+#endif
+       ITS->Hits2SDigits();
+    } // end for event
+    timer.Stop();
+    timer.Print();
+    if(sfp!=0){
+       cout << sf << " size =" << sfp->GetSize() << endl;
+    }else if(hfp!=0){
+       cout << hfp << " size =" << hfp->GetSize() << endl;
+    } // end if sfp!=0
+    return 0;
+}
diff --git a/ITS/AliITSsd2d.C b/ITS/AliITSsd2d.C
new file mode 100644 (file)
index 0000000..ffba047
--- /dev/null
@@ -0,0 +1,84 @@
+#if !defined(__CINT__) || defined(__MAKECINT__)
+
+#include "iostream.h"
+#include "TDatime.h"
+#include "TFile.h"
+#include "TString.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"
+
+Bool_t GaliceITSok();
+TFile* AccessFile(TString inFile="galice.root", TString acctype="R");
+void writeAR(TFile * fin, TFile *fou);
+Int_t ChangeITSDefaults(TFile *hitfile,AliITS *ITS,TString opt="");
+
+#endif
+
+//#define DEBUG
+
+Int_t AliITSsd2d(TString df="galice.root",TString sf1="galice.root",
+                TString sf2="",TString opt=""){
+    // Produce ITS Digits from SDigits, with psible merging.
+
+    // 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 *sfp1 = 0, *sfp2 = 0, *dfp = 0;
+    if(!GaliceITSok()){
+       // gAlice not define. Must open a file and read it in.
+       if(df.CompareTo(sf1) == 0 || df.CompareTo("") == 0) {
+           // Input file = output file
+           sfp1 = AccessFile(sf1,"U");  // input file open for update.
+       }else{ // Input file different from output file.
+           sfp1 = AccessFile(sf1,"R"); // input file open as read only
+           // open output file and create TreeR on it
+           dfp = gAlice->InitTreeFile("S",df);
+       } // end if
+    } // end if !GALICEITSOK()
+    AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS"); 
+
+    ChangeITSDefaults(sfp1,ITS,opt);
+    // write the AliRun object to the output file if different from input file.
+    if(dfp) {
+       writeAR(sfp1,dfp);
+       dfp->Close(); // Manager will open in update mode.
+    } // end if
+
+    AliRunDigitizer *manager;
+    if(sf2.CompareTo("")==0) { // do not merge.
+       manager = new AliRunDigitizer(1,1);
+       manager->SetInputStream(0,sf1);
+    }else{
+       manager = new AliRunDigitizer(2,1);
+       manager->SetInputStream(0,sf1.Data());
+       manager->SetInputStream(1,sf2.Data());
+    } // end if
+    if (df.CompareTo(sf1) !=0) {
+       manager->SetOutputFile(df);
+    } // end if
+    AliITSDigitizer *dITS = new AliITSDigitizer(manager);
+    if(opt.Contains("ROI")==0) dITS->SetByRegionOfInterestFlag(1);
+
+    TStopwatch timer;
+    timer.Start();
+    manager->Exec("all");
+    timer.Stop(); 
+    timer.Print();
+    delete manager;
+
+    if(dfp!=0){
+       cout << df << " size =" << df->GetSize() << endl;
+    }else if(sfp1!=0){
+       cout << sf1 << " size =" << sf1->GetSize() << endl;
+    } // end if sf1!=0
+    return 0;
+}