Macro to convert Hits to SDigits
authorschutz <schutz@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 16 Apr 2002 12:31:19 +0000 (12:31 +0000)
committerschutz <schutz@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 16 Apr 2002 12:31:19 +0000 (12:31 +0000)
PHOS/AliPHOSHits2SDigits.C [new file with mode: 0644]

diff --git a/PHOS/AliPHOSHits2SDigits.C b/PHOS/AliPHOSHits2SDigits.C
new file mode 100644 (file)
index 0000000..8df1d46
--- /dev/null
@@ -0,0 +1,89 @@
+////////////////////////////////////////////////////////////////////////
+//
+// name: AliPHOSHits2SDigits
+// date: 4.4.2002
+// last update: 4.4.2002
+// author: Jiri Chudoba
+// version: 1.0
+//
+// description: 
+//       creates sdigits for digits for PHOS.
+//       stores sdigits in separate file (or in the source file
+//       with hits). Stores gAlice object and copies TE to the
+//       file with sdigits.
+//
+// input:
+//        TString fileNameHits ... input file with hits
+//        TString fileNameSDigits ... output file with sdigits
+//
+// History:
+//
+// 04.04.02 - first version
+// 
+////////////////////////////////////////////////////////////////////////
+
+
+Int_t AliPHOSHits2SDigits(TString
+fileNameSDigits="PHOS.sdigits.root",TString fileNameHits="rfio:galice.root")
+
+{
+  TFile *fileSDigits;
+  fileSDigits = Init(fileNameSDigits, fileNameHits);
+  if (!fileSDigits) return 1;
+
+  AliPHOSSDigitizer *sdPHOS = new AliPHOSSDigitizer(fileNameHits.Data(),"PHOS");
+
+  TStopwatch timer;
+  timer.Start();
+
+  gAlice->MakeTree("S",fileSDigits);
+  sdPHOS->ExecuteTask("deb all");
+
+  timer.Stop(); 
+  timer.Print();
+
+  fileSDigits->Close();
+  delete fileSDigits;
+
+}
+
+////////////////////////////////////////////////////////////////////////
+TFile* Init(TString fileNameSDigits, TString fileNameHits) {
+// open input file, read in gAlice, prepare output file
+  if (gAlice) delete gAlice;
+  gAlice = 0;
+
+  Bool_t sameFiles = kFALSE;
+  if (fileNameSDigits == fileNameHits || fileNameSDigits == "") sameFiles = kTRUE;
+
+  TString fileMode = "read";
+  if (sameFiles) fileMode = "update";
+
+  TFile *fileHits =  OpenFile(fileNameHits.Data(),fileMode.Data());
+  if (!fileHits) return 0;
+  if (!ImportgAlice(fileHits)) return 0;
+  if (!sameFiles) return gAlice->InitTreeFile("S",fileNameSDigits.Data());
+  return fileHits;
+
+}
+
+////////////////////////////////////////////////////////////////////////
+TFile* OpenFile(TString fileName, TString fileMode) {
+// open file fileName
+  TFile *file = TFile::Open(fileName.Data(),fileMode.Data());
+  if (!file->IsOpen()) {
+    cerr<<"Can't open "<<fileName.Data()<<" !\n";
+    return 0;
+  }
+  return file;
+}
+
+////////////////////////////////////////////////////////////////////////
+Bool_t ImportgAlice(TFile *file) {
+// read in gAlice object from the file
+  gAlice = (AliRun*)file->Get("gAlice");
+  if (!gAlice)  return kFALSE;
+  return kTRUE;
+}
+////////////////////////////////////////////////////////////////////////