]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDInput.cxx
Fix compiler warnings and coding violations
[u/mrichter/AliRoot.git] / FMD / AliFMDInput.cxx
index 3189d46c54330bb1739d6f080274d25093f4b44a..a3a97a521e49ff53d2277f07ffa1d2df197fc4fb 100644 (file)
@@ -29,7 +29,7 @@
 // Latest changes by Christian Holm Christensen
 //
 #include "AliFMDInput.h"       // ALIFMDHIT_H
-#include "AliLog.h"            // ALILOG_H
+#include "AliFMDDebug.h"               // ALIFMDDEBUG_H ALILOG_H
 #include "AliLoader.h"          // ALILOADER_H
 #include "AliRunLoader.h"       // ALIRUNLOADER_H
 #include "AliRun.h"             // ALIRUN_H
@@ -55,7 +55,8 @@
 #include <TGeoManager.h>        // ROOT_TGeoManager 
 #include <TSystemDirectory.h>   // ROOT_TSystemDirectory
 #include <Riostream.h>         // ROOT_Riostream
-
+#include <TFile.h>              // ROOT_TFile
+#include <TStreamerInfo.h>
 //____________________________________________________________________
 ClassImp(AliFMDInput)
 #if 0
@@ -79,6 +80,7 @@ AliFMDInput::AliFMDInput()
     fTreeD(0),
     fTreeS(0),
     fTreeR(0), 
+    fTreeA(0), 
     fChainE(0),
     fArrayE(0),
     fArrayH(0),
@@ -86,6 +88,7 @@ AliFMDInput::AliFMDInput()
     fArrayS(0), 
     fArrayR(0), 
     fArrayA(0), 
+    fGeoManager(0),
     fTreeMask(0), 
     fIsInit(kFALSE)
 {
@@ -113,6 +116,7 @@ AliFMDInput::AliFMDInput(const char* gAliceFile)
     fTreeD(0),
     fTreeS(0),
     fTreeR(0), 
+    fTreeA(0), 
     fChainE(0),
     fArrayE(0),
     fArrayH(0),
@@ -120,6 +124,7 @@ AliFMDInput::AliFMDInput(const char* gAliceFile)
     fArrayS(0), 
     fArrayR(0), 
     fArrayA(0), 
+    fGeoManager(0),
     fTreeMask(0), 
     fIsInit(kFALSE)
 {
@@ -232,7 +237,7 @@ AliFMDInput::Init()
          AliAlignObjAngles* a = static_cast<AliAlignObjAngles*>(array->At(i));
          if (!a->ApplyToGeometry()) {
            AliWarning(Form("Failed to apply alignment to %s", 
-                           a->GetVolPath()));
+                           a->GetSymName()));
          }
        }
       }
@@ -263,13 +268,13 @@ AliFMDInput::Begin(Int_t event)
   AliInfo(Form("Now in event %d/%d", event, NEvents()));
 
   // Possibly load global kinematics information 
-  if (TESTBIT(fTreeMask, kKinematics)) {
+  if (TESTBIT(fTreeMask, kKinematics) || TESTBIT(fTreeMask, kTracks)) {
     AliInfo("Getting kinematics");
     if (fLoader->LoadKinematics()) return kFALSE;
     fStack = fLoader->Stack();
   }
   // Possibly load FMD Hit information 
-  if (TESTBIT(fTreeMask, kHits)) {
+  if (TESTBIT(fTreeMask, kHits) || TESTBIT(fTreeMask, kTracks)) {
     AliInfo("Getting FMD hits");
     if (fFMDLoader->LoadHits()) return kFALSE;
     fTreeH = fFMDLoader->TreeH();
@@ -280,7 +285,13 @@ AliFMDInput::Begin(Int_t event)
     AliInfo("Getting FMD digits");
     if (fFMDLoader->LoadDigits()) return kFALSE;
     fTreeD = fFMDLoader->TreeD();
-    if (!fArrayD) fArrayD = fFMD->Digits();
+    if (fTreeD) {
+      if (!fArrayD) fArrayD = fFMD->Digits();
+    }
+    else {
+      fArrayD = 0;
+      AliWarning(Form("Failed to load FMD Digits"));
+    } 
   }
   // Possibly load FMD Sdigit information 
   if (TESTBIT(fTreeMask, kSDigits)) {
@@ -303,6 +314,16 @@ AliFMDInput::Begin(Int_t event)
     if (read <= 0) return kFALSE;
     fESD = fMainESD->GetFMDData();
     if (!fESD) return kFALSE;
+    TFile* f = fChainE->GetFile();
+    if (f) {
+      TObject* o = f->GetStreamerInfoList()->FindObject("AliFMDMap");
+      if (o) {
+       TStreamerInfo* info = static_cast<TStreamerInfo*>(o);
+       std::cout << "AliFMDMap class version read is " 
+                 <<  info->GetClassVersion() << std::endl;
+      }
+    }
+    // fESD->CheckNeedUShort(fChainE->GetFile());
   }
   // Possibly load FMD Digit information 
   if (TESTBIT(fTreeMask, kRaw)) {
@@ -331,6 +352,8 @@ AliFMDInput::Event()
   // 
   if (TESTBIT(fTreeMask, kHits)) 
     if (!ProcessHits()) return kFALSE; 
+  if (TESTBIT(fTreeMask, kTracks)) 
+    if (!ProcessTracks()) return kFALSE; 
   if (TESTBIT(fTreeMask, kDigits)) 
     if (!ProcessDigits()) return kFALSE;
   if (TESTBIT(fTreeMask, kSDigits)) 
@@ -340,7 +363,7 @@ AliFMDInput::Event()
   if (TESTBIT(fTreeMask, kRecPoints)) 
     if (!ProcessRecPoints()) return kFALSE;
   if (TESTBIT(fTreeMask, kESD))
-    if (!ProcessESD(fESD)) return kFALSE;
+    if (!ProcessESDs()) return kFALSE;
   
   return kTRUE;
 }
@@ -379,6 +402,43 @@ AliFMDInput::ProcessHits()
   return kTRUE;
 }
 
+//____________________________________________________________________
+Bool_t 
+AliFMDInput::ProcessTracks()
+{
+  // Read the hit tree, and pass each hit to the member function
+  // ProcessHit.
+  if (!fStack) {
+    AliError("No track tree defined");
+    return kFALSE;
+  }
+  if (!fTreeH) {
+    AliError("No hit tree defined");
+    return kFALSE;
+  }
+  Int_t nTracks = fTreeH->GetEntries();
+  for (Int_t i = 0; i < nTracks; i++) {
+    TParticle* track = fStack->Particle(i);
+    if (!track) continue;
+    Int_t hitRead  = fTreeH->GetEntry(i);
+    if (hitRead <= 0) continue;
+    if (!fArrayH) {
+      AliError("No hit array defined");
+      return kFALSE;
+    }
+    Int_t nHit = fArrayH->GetEntries();
+    if (nHit <= 0) continue;
+
+    for (Int_t j = 0; j < nHit; j++) {
+      AliFMDHit* hit = static_cast<AliFMDHit*>(fArrayH->At(j));
+      if (!hit) continue;
+      if (!ProcessTrack(i, track, hit)) return kFALSE;
+    }    
+    // if (!ProcessTrack(i, track, fArrayH)) return kFALSE;
+  }
+  return kTRUE;
+}
+
 //____________________________________________________________________
 Bool_t 
 AliFMDInput::ProcessDigits()
@@ -457,6 +517,31 @@ AliFMDInput::ProcessRecPoints()
   return kTRUE;
 }
 
+//____________________________________________________________________
+Bool_t 
+AliFMDInput::ProcessESDs()
+{
+  // Process event summary data
+  if (!fESD) return kFALSE;
+  for (UShort_t det = 1; det <= 3; det++) {
+    Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' };
+    for (Char_t* rng = rings; *rng != '\0'; rng++) {
+      UShort_t nsec = (*rng == 'I' ?  20 :  40);
+      UShort_t nstr = (*rng == 'I' ? 512 : 256);
+      for (UShort_t sec = 0; sec < nsec; sec++) {
+       for (UShort_t str = 0; str < nstr; str++) {
+         Float_t eta  = fESD->Eta(det,*rng,sec,str);
+         Float_t mult = fESD->Multiplicity(det,*rng,sec,str);
+         if (!fESD->IsAngleCorrected()) 
+           mult *= TMath::Abs(TMath::Cos(2.*TMath::ATan(TMath::Exp(-eta))));
+         if (!ProcessESD(det, *rng, sec, str, eta, mult)) continue;
+       }
+      }
+    }
+  }
+  return kTRUE;
+}
+
 //____________________________________________________________________
 Bool_t
 AliFMDInput::End()
@@ -472,13 +557,13 @@ AliFMDInput::End()
     return fIsInit;
   }
   // Possibly unload global kinematics information 
-  if (TESTBIT(fTreeMask, kKinematics)) {
+  if (TESTBIT(fTreeMask, kKinematics) || TESTBIT(fTreeMask, kTracks)) {
     fLoader->UnloadKinematics();
     // fTreeK = 0;
     fStack = 0;
   }
   // Possibly unload FMD Hit information 
-  if (TESTBIT(fTreeMask, kHits)) {
+  if (TESTBIT(fTreeMask, kHits) || TESTBIT(fTreeMask, kTracks)) {
     fFMDLoader->UnloadHits();
     fTreeH = 0;
   }