]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMD.cxx
The present commit corresponds to an important change in the way the
[u/mrichter/AliRoot.git] / FMD / AliFMD.cxx
index aec1986f5ff6e58fb8624ae48c9dd8e1c5fd795c..37a28200b661d9d556bad067a0f94ee9624e4237 100644 (file)
 // These files are not in the same directory, so there's no reason to
 // ask the preprocessor to search in the current directory for these
 // files by including them with `#include "..."' 
-#include <cmath>                // __CMATH__
+#include <TBrowser.h>          // ROOT_TBrowser
 #include <TClonesArray.h>      // ROOT_TClonesArray
+#include <TGeoGlobalMagField.h> // ROOT_TGeoGlobalMagField
+#include <TGeoManager.h>        // ROOT_TGeoManager
 #include <TRotMatrix.h>                // ROOT_TRotMatrix
 #include <TTree.h>             // ROOT_TTree
-#include <TBrowser.h>          // ROOT_TBrowser
-#include <TVirtualMC.h>                // ROOT_TVirtualMC
 #include <TVector2.h>           // ROOT_TVector2 
-#include <TGeoManager.h>        // ROOT_TGeoManager
+#include <TVirtualMC.h>                // ROOT_TVirtualMC
+#include <cmath>                // __CMATH__
 
 #include <AliRunDigitizer.h>   // ALIRUNDIGITIZER_H
 #include <AliLoader.h>         // ALILOADER_H
 //#endif
 // #include "AliFMDGeometryBuilder.h"
 #include "AliFMDRawWriter.h"   // ALIFMDRAWWRITER_H
+#include "AliFMDRawReader.h"   // ALIFMDRAWREADER_H
+#include "AliTrackReference.h" 
+#include "AliFMDStripIndex.h"
+#include "AliFMDParameters.h"
+#include "AliFMDReconstructor.h"
 
 //____________________________________________________________________
 ClassImp(AliFMD)
@@ -259,8 +265,8 @@ void AliFMD::CreateMaterials()
   Double_t density          = 0;
   Double_t radiationLength  = 0;
   Double_t absorbtionLength = 999;
-  Int_t    fieldType        = gAlice->Field()->Integ();     // Field type 
-  Double_t maxField         = gAlice->Field()->Max();     // Field max.
+  Int_t    fieldType        = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ();     // Field type 
+  Double_t maxField         = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max();     // Field max.
   Double_t maxBending       = 0;     // Max Angle
   Double_t maxStepSize      = 0.001; // Max step size 
   Double_t maxEnergyLoss    = 1;     // Max Delta E
@@ -650,7 +656,19 @@ AliFMD::AddHitByFields(Int_t    track,
   hit = new (a[fNhits]) AliFMDHit(fIshunt, track, detector, ring, sector, 
                                  strip, x, y, z, px, py, pz, edep, pdg, t, 
                                  l, stop);
+  // gMC->AddTrackReference(track, 12);
   fNhits++;
+  
+  //Reference track
+
+  AliMC *mcApplication = (AliMC*)gAlice->GetMCApp();
+  
+  AliTrackReference* trackRef = AddTrackReference(mcApplication->GetCurrentTrackNumber(), AliTrackReference::kFMD); 
+  UInt_t stripId = AliFMDStripIndex::Pack(detector,ring,sector,strip);
+  trackRef->SetUserId(stripId);
+  
+  
+  
   return hit;
 }
 
@@ -682,14 +700,15 @@ AliFMD::AddDigit(Int_t* digits, Int_t*)
 
 //____________________________________________________________________
 void 
-AliFMD::AddDigitByFields(UShort_t detector, 
-                        Char_t   ring, 
-                        UShort_t sector, 
-                        UShort_t strip, 
-                        UShort_t count1, 
-                        Short_t  count2,
-                        Short_t  count3, 
-                        Short_t  count4)
+AliFMD::AddDigitByFields(UShort_t       detector, 
+                        Char_t         ring, 
+                        UShort_t       sector, 
+                        UShort_t       strip, 
+                        UShort_t       count1, 
+                        Short_t        count2,
+                        Short_t        count3, 
+                        Short_t        count4,
+                        const TArrayI& refs)
 {
   // add a real digit - as coming from data
   // 
@@ -705,11 +724,13 @@ AliFMD::AddDigitByFields(UShort_t detector,
   TClonesArray& a = *(DigitsArray());
   
   new (a[fNdigits++]) 
-    AliFMDDigit(detector, ring, sector, strip, count1, count2, count3, count4);
-  AliFMDDebug(15, ("Adding digit # %5d/%5d for FMD%d%c[%2d,%3d]=(%d,%d,%d,%d)",
+    AliFMDDigit(detector, ring, sector, strip, 
+               count1, count2, count3, count4, refs);
+  AliFMDDebug(15, ("Adding digit # %5d/%5d for FMD%d%c[%2d,%3d]"
+                  "=(%d,%d,%d,%d) with %d tracks",
                   fNdigits-1, a.GetEntriesFast(),
                   detector, ring, sector, strip, 
-                  count1, count2, count3, count4));
+                  count1, count2, count3, count4, refs.fN));
   
 }
 
@@ -741,22 +762,22 @@ AliFMD::AddSDigit(Int_t* digits)
                    Short_t(digits[8]),    // ADC Count4
                    UShort_t(digits[9]),   // N particles
                    UShort_t(digits[10])); // N primaries
-   
 }
 
 //____________________________________________________________________
 void 
-AliFMD::AddSDigitByFields(UShort_t detector, 
-                         Char_t   ring, 
-                         UShort_t sector, 
-                         UShort_t strip, 
-                         Float_t  edep,
-                         UShort_t count1, 
-                         Short_t  count2,
-                         Short_t  count3, 
-                         Short_t  count4, 
-                         UShort_t ntot, 
-                         UShort_t nprim)
+AliFMD::AddSDigitByFields(UShort_t       detector, 
+                         Char_t         ring, 
+                         UShort_t       sector, 
+                         UShort_t       strip, 
+                         Float_t        edep,
+                         UShort_t       count1, 
+                         Short_t        count2,
+                         Short_t        count3, 
+                         Short_t        count4, 
+                         UShort_t       ntot, 
+                         UShort_t       nprim,
+                         const TArrayI& refs)
 {
   // add a summable digit
   // 
@@ -776,7 +797,7 @@ AliFMD::AddSDigitByFields(UShort_t detector,
   
   new (a[fNsdigits++]) 
     AliFMDSDigit(detector, ring, sector, strip, edep, 
-                count1, count2, count3, count4, ntot, nprim);
+                count1, count2, count3, count4, ntot, nprim, refs);
 }
 
 //____________________________________________________________________
@@ -893,6 +914,45 @@ AliFMD::Digits2Raw()
   writer.Exec();
 }
 
+//====================================================================
+//
+// Raw data reading 
+//
+//__________________________________________________________________
+Bool_t
+AliFMD::Raw2SDigits(AliRawReader* reader) 
+{
+  // Turn digits into raw data. 
+  // 
+  // This uses the class AliFMDRawWriter to do the job.   Please refer
+  // to that class for more information. 
+  AliFMDParameters::Instance()->Init();
+  MakeTree("S");
+  MakeBranch("S");
+  
+  TClonesArray*       sdigits = SDigits();
+  AliFMDReconstructor rec;
+  
+  // The two boolean arguments
+  //   Make sdigits instead of digits 
+  //   Subtract the pedestal off the signal
+  rec.Digitize(reader, sdigits);
+  // 
+  // Bool_t ret = fmdReader.ReadAdcs(sdigits, kTRUE, kTRUE);
+  // sdigits->ls();
+  UShort_t ns = sdigits->GetEntriesFast();
+  for (UShort_t i = 0; i < ns; i++) 
+    sdigits->At(i)->Print("pl");
+  
+  AliFMDDebug(1, ("Got a total of %d SDigits", ns));
+
+  fLoader->TreeS()->Fill();
+  ResetSDigits();
+  fLoader->WriteSDigits("OVERWRITE");
+
+  return kTRUE;
+}
+
 
 //====================================================================
 //