]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDInput.cxx
Including cmath to declare fmod
[u/mrichter/AliRoot.git] / FMD / AliFMDInput.cxx
index c22fb594838d0c9ef44122f1aee512ab25b4f171..f4c561a83b7fa88f2083acc7819937908a1ac53e 100644 (file)
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
-
 /* $Id$ */
-
+/** @file    AliFMDInput.cxx
+    @author  Christian Holm Christensen <cholm@nbi.dk>
+    @date    Mon Mar 27 12:42:40 2006
+    @brief   FMD utility classes for reading FMD data
+*/
 //___________________________________________________________________
 //
 // The classes defined here, are utility classes for reading in data
 #include "AliRunLoader.h"       // ALIRUNLOADER_H
 #include "AliRun.h"             // ALIRUN_H
 #include "AliStack.h"           // ALISTACK_H
+#include "AliRawReaderFile.h"   // ALIRAWREADERFILE_H
 #include "AliFMD.h"             // ALIFMD_H
 #include "AliFMDHit.h"         // ALIFMDHIT_H
 #include "AliFMDDigit.h"       // ALIFMDDigit_H
+#include "AliFMDSDigit.h"      // ALIFMDDigit_H
 #include "AliFMDRecPoint.h"    // ALIFMDRECPOINT_H
+#include "AliFMDRawReader.h"    // ALIFMDRAWREADER_H
 #include <AliESD.h>
 #include <AliESDFMD.h>
+#include <AliCDBManager.h>
+#include <AliCDBEntry.h>
+#include <AliAlignObjAngles.h>
 #include <TTree.h>              // ROOT_TTree
 #include <TChain.h>             // ROOT_TChain
 #include <TParticle.h>          // ROOT_TParticle
@@ -61,6 +70,7 @@ AliFMDInput::AliFMDInput()
     fRun(0), 
     fStack(0),
     fFMDLoader(0), 
+    fReader(0),
     fFMD(0),
     fMainESD(0),
     fESD(0),
@@ -69,12 +79,15 @@ AliFMDInput::AliFMDInput()
     fTreeD(0),
     fTreeS(0),
     fTreeR(0), 
+    fTreeA(0), 
     fChainE(0),
     fArrayE(0),
     fArrayH(0),
     fArrayD(0),
     fArrayS(0), 
     fArrayR(0), 
+    fArrayA(0), 
+    fGeoManager(0),
     fTreeMask(0), 
     fIsInit(kFALSE)
 {
@@ -93,6 +106,7 @@ AliFMDInput::AliFMDInput(const char* gAliceFile)
     fRun(0), 
     fStack(0),
     fFMDLoader(0), 
+    fReader(0),
     fFMD(0),
     fMainESD(0),
     fESD(0),
@@ -101,12 +115,15 @@ AliFMDInput::AliFMDInput(const char* gAliceFile)
     fTreeD(0),
     fTreeS(0),
     fTreeR(0), 
+    fTreeA(0), 
     fChainE(0),
     fArrayE(0),
     fArrayH(0),
     fArrayD(0),
     fArrayS(0), 
     fArrayR(0), 
+    fArrayA(0), 
+    fGeoManager(0),
     fTreeMask(0), 
     fIsInit(kFALSE)
 {
@@ -170,9 +187,13 @@ AliFMDInput::Init()
   // Optionally, get the ESD files
   if (TESTBIT(fTreeMask, kESD)) {
     fChainE = new TChain("esdTree");
-    TSystemDirectory dir;
+    TSystemDirectory dir(".",".");
     TList*           files = dir.GetListOfFiles();
-    TSystemFile*     file;
+    TSystemFile*     file = 0;
+    if (!files) {
+      AliError("No files");
+      return kFALSE;
+    }
     files->Sort();
     TIter            next(files);
     while ((file = static_cast<TSystemFile*>(next()))) {
@@ -182,6 +203,12 @@ AliFMDInput::Init()
     fChainE->SetBranchAddress("ESD", &fMainESD);
   }
     
+  if (TESTBIT(fTreeMask, kRaw)) {
+    AliInfo("Getting FMD raw data digits");
+    fArrayA = new TClonesArray("AliFMDDigit");
+    fReader = new AliRawReaderFile(-1);
+  }
+  
   // Optionally, get the geometry 
   if (TESTBIT(fTreeMask, kGeometry)) {
     TString fname(fRun->GetGeometryFileName());
@@ -195,6 +222,25 @@ AliFMDInput::Init()
       Fatal("Init", "No geometry manager found");
       return kFALSE;
     }
+    AliCDBManager* cdb   = AliCDBManager::Instance();
+    AliCDBEntry*   align = cdb->Get("FMD/Align/Data");
+    if (align) {
+      AliInfo("Got alignment data from CDB");
+      TClonesArray* array = dynamic_cast<TClonesArray*>(align->GetObject());
+      if (!array) {
+       AliWarning("Invalid align data from CDB");
+      }
+      else {
+       Int_t nAlign = array->GetEntries();
+       for (Int_t i = 0; i < nAlign; i++) {
+         AliAlignObjAngles* a = static_cast<AliAlignObjAngles*>(array->At(i));
+         if (!a->ApplyToGeometry()) {
+           AliWarning(Form("Failed to apply alignment to %s", 
+                           a->GetSymName()));
+         }
+       }
+      }
+    }
   }
 
   
@@ -254,9 +300,7 @@ AliFMDInput::Begin(Int_t event)
     fTreeR = fFMDLoader->TreeR();
     if (!fArrayR) fArrayR = new TClonesArray("AliFMDRecPoint");
     fTreeR->SetBranchAddress("FMD",  &fArrayR);
-  }
-
-  // Possibly load FMD ESD information 
+  }  // Possibly load FMD ESD information 
   if (TESTBIT(fTreeMask, kESD)) {
     AliInfo("Getting FMD event summary data");
     Int_t read = fChainE->GetEntry(event);
@@ -264,6 +308,14 @@ AliFMDInput::Begin(Int_t event)
     fESD = fMainESD->GetFMDData();
     if (!fESD) return kFALSE;
   }
+  // Possibly load FMD Digit information 
+  if (TESTBIT(fTreeMask, kRaw)) {
+    AliInfo("Getting FMD raw data digits");
+    if (!fReader->NextEvent()) return kFALSE;
+    AliFMDRawReader r(fReader, 0);
+    fArrayA->Clear();
+    r.ReadAdcs(fArrayA);
+  }
   
   return kTRUE;
 }
@@ -287,6 +339,8 @@ AliFMDInput::Event()
     if (!ProcessDigits()) return kFALSE;
   if (TESTBIT(fTreeMask, kSDigits)) 
     if (!ProcessSDigits()) return kFALSE;
+  if (TESTBIT(fTreeMask, kRaw)) 
+    if (!ProcessRawDigits()) return kFALSE;
   if (TESTBIT(fTreeMask, kRecPoints)) 
     if (!ProcessRecPoints()) return kFALSE;
   if (TESTBIT(fTreeMask, kESD))
@@ -299,6 +353,8 @@ AliFMDInput::Event()
 Bool_t 
 AliFMDInput::ProcessHits()
 {
+  // Read the hit tree, and pass each hit to the member function
+  // ProcessHit.
   if (!fTreeH) {
     AliError("No hit tree defined");
     return kFALSE;
@@ -369,6 +425,22 @@ AliFMDInput::ProcessSDigits()
   return kTRUE;
 }
 
+//____________________________________________________________________
+Bool_t 
+AliFMDInput::ProcessRawDigits()
+{
+  // Read the digit tree, and pass each digit to the member function
+  // ProcessDigit.
+  Int_t nDigit = fArrayA->GetEntries();
+  if (nDigit <= 0) return kTRUE;
+  for (Int_t j = 0; j < nDigit; j++) {
+    AliFMDDigit* digit = static_cast<AliFMDDigit*>(fArrayA->At(j));
+    if (!digit) continue;
+    if (!ProcessRawDigit(digit)) return kFALSE;
+  }    
+  return kTRUE;
+}
+
 //____________________________________________________________________
 Bool_t 
 AliFMDInput::ProcessRecPoints()
@@ -453,30 +525,6 @@ AliFMDInput::Run()
   return retval;
 }
 
-//====================================================================
-ClassImp(AliFMDInputHits)
-#if 0
-  ;
-#endif
-
-
-//====================================================================
-ClassImp(AliFMDInputDigits)
-#if 0
-  ;
-#endif
-
-//====================================================================
-ClassImp(AliFMDInputSDigits)
-#if 0
-  ;
-#endif
-
-//====================================================================
-ClassImp(AliFMDInputRecPoints)
-#if 0
-  ;
-#endif
 
 //____________________________________________________________________
 //