This update contains the Full ACORDE Geometry and raw Data
[u/mrichter/AliRoot.git] / ACORDE / AliACORDE.cxx
index 68b07f7..7a0ad5c 100644 (file)
 #include <TTree.h>
 #include <TVirtualMC.h>
 #include <TGeoManager.h>
+#include <TStopwatch.h>
 
 #include "AliACORDE.h"
 #include "AliMagF.h"
 #include "AliRun.h"
 #include "AliACORDERawData.h"
+#include "AliACORDERawStream.h"
 
 ClassImp(AliACORDE)
 
@@ -282,6 +284,59 @@ void AliACORDE::Digits2Raw()
   rawdata.WriteACORDERawData(Modules);
 }
 
+//_____________________________________________________________________________
+Bool_t AliACORDE::Raw2SDigits(AliRawReader* rawReader)
+{
+  //
+  // Reads the raw data stream and exracts the digits
+  //
+  // Input:
+  //         rawReader : pointer to the current AliRawReader
+  // Output:
+  //
+  // Created:      31 Jan 2008  Mario Sitta
+  //
+  TStopwatch timer;
+  timer.Start();
+
+  if(!fLoader) {
+    AliError("no ACORDE loader found");
+    return kFALSE;
+  }
+
+  TTree* treeD  = fLoader->TreeD();
+  if(!treeD) {
+      fLoader->MakeTree("D");
+      treeD = fLoader->TreeD();
+  }
+        
+  AliACORDEdigit  digit;
+  AliACORDEdigit* pdigit = &digit;
+  const Int_t kBufferSize = 4000;
+   
+  treeD->Branch("ACORDE", "AliACORDEdigit",  &pdigit, kBufferSize);
+
+  //  rawReader->Reset();
+  AliACORDERawStream* rawStream  = new AliACORDERawStream(rawReader);    
+     
+  if (!rawStream->Next()) return kFALSE; // No ACORDE data found
+  /*  
+  for(Int_t i=0; i<64; i++) {
+      new(pdigit) AliACORDEdigit(i, (Int_t)rawStream->GetADC(i), (Int_t)rawStream->GetTime(i)); 
+      treeD->Fill();
+  }
+  */ 
+  fLoader->WriteDigits("OVERWRITE");
+  fLoader->UnloadDigits();     
+       
+  delete rawStream;
+
+  timer.Stop();
+  timer.Print();
+
+  return kTRUE;
+}
+
 //_____________________________________________________________________________
 void AliACORDE::AddAlignableVolumes() const
 {