]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDBaseDigitizer.cxx
new macro to handle setting of default event species for reco params
[u/mrichter/AliRoot.git] / FMD / AliFMDBaseDigitizer.cxx
index c063bb378a877242017ce700b35bc0861659ab95..1970eb348a35e2758d13ff83f6ccc712fcfd4441 100644 (file)
@@ -230,7 +230,8 @@ AliFMDBaseDigitizer::AliFMDBaseDigitizer()
          AliFMDMap::kMaxRings, 
          AliFMDMap::kMaxSectors, 
          AliFMDMap::kMaxStrips),
-    fShapingTime(6)
+    fShapingTime(6),
+    fStoreTrackRefs(kTRUE)
 {
   AliFMDDebug(1, ("Constructed"));
   // Default ctor - don't use it
@@ -241,11 +242,9 @@ AliFMDBaseDigitizer::AliFMDBaseDigitizer(AliRunDigitizer* manager)
   : AliDigitizer(manager, "AliFMDBaseDigitizer", "FMD Digitizer base class"), 
     fFMD(0),
     fRunLoader(0),
-    fEdep(AliFMDMap::kMaxDetectors, 
-         AliFMDMap::kMaxRings, 
-         AliFMDMap::kMaxSectors, 
-         AliFMDMap::kMaxStrips), 
-    fShapingTime(6)
+    fEdep(0),        // nDet==0 means 51200 slots
+    fShapingTime(6),
+    fStoreTrackRefs(kTRUE)
 {
   // Normal CTOR
   AliFMDDebug(1, ("Constructed"));
@@ -258,11 +257,9 @@ AliFMDBaseDigitizer::AliFMDBaseDigitizer(const Char_t* name,
   : AliDigitizer(name, title),
     fFMD(0),
     fRunLoader(0),
-    fEdep(AliFMDMap::kMaxDetectors, 
-         AliFMDMap::kMaxRings, 
-         AliFMDMap::kMaxSectors, 
-         AliFMDMap::kMaxStrips),
-    fShapingTime(6)
+    fEdep(0),        // nDet==0 means 51200 slots
+    fShapingTime(6),
+    fStoreTrackRefs(kTRUE)
 {
   // Normal CTOR
   AliFMDDebug(1, (" Constructed"));
@@ -310,11 +307,21 @@ AliFMDBaseDigitizer::AddContribution(UShort_t detector,
                                     UShort_t sector, 
                                     UShort_t strip, 
                                     Float_t  edep, 
-                                    Bool_t   isPrimary)
+                                    Bool_t   isPrimary,
+                                    Int_t    nTrack,
+                                    Int_t*   tracknos)
 {
   // Add edep contribution from (detector,ring,sector,strip) to cache
   AliFMDParameters* param = AliFMDParameters::Instance();
-
+  AliFMDDebug(10, ("Adding contribution %7.5f for FMD%d%c[%2d,%3d] "
+                 " from %d tracks (%s)", 
+                 edep,
+                 detector, 
+                 ring,
+                 sector, 
+                 strip, 
+                 nTrack, 
+                 (isPrimary ? "primary" : "secondary")));
   // Check if strip is `dead' 
   if (param->IsDead(detector, ring, sector, strip)) { 
     AliFMDDebug(5, ("FMD%d%c[%2d,%3d] is marked as dead", 
@@ -328,19 +335,33 @@ AliFMDBaseDigitizer::AddContribution(UShort_t detector,
   //   continue;
   // }
   
+  AliFMDEdepHitPair& entry = fEdep(detector, ring, sector, strip);
+
   // Give warning in case of double sdigit 
-  if (fEdep(detector, ring, sector, strip).fEdep != 0)
-    AliFMDDebug(5, ("Double digit in %d%c(%d,%d)", 
+  if (entry.fEdep != 0)
+    AliFMDDebug(5, ("Double digit in FMD%d%c[%2d,%3d]", 
                    detector, ring, sector, strip));
       
   // Sum energy deposition
-  fEdep(detector, ring, sector, strip).fEdep    += edep;
-  fEdep(detector, ring, sector, strip).fN       += 1;
-  if (isPrimary)
-    fEdep(detector, ring, sector, strip).fNPrim += 1;
-  AliFMDDebug(15, ("Adding contribution %f to FMD%d%c[%2d,%3d] (%f)", 
+  Int_t oldN  =  entry.fN;
+  entry.fEdep += edep;
+  entry.fN    += nTrack;
+  if (isPrimary) entry.fNPrim += nTrack;
+  if (fStoreTrackRefs) { 
+    if (entry.fLabels.fN < entry.fN) {
+      AliFMDDebug(15, ("== New label array size %d, was %d, added %d", 
+                      entry.fN, entry.fLabels.fN, nTrack));
+      entry.fLabels.Set(entry.fN);
+    }
+    for (Int_t i = 0; i < nTrack; i++) {
+      AliFMDDebug(15, ("=> Setting track label # %d", oldN+i));
+      entry.fLabels[oldN + i] = tracknos[i];
+      AliFMDDebug(15, ("<= Setting track label # %d", oldN+i));
+    }
+  }
+  AliFMDDebug(15,("Adding contribution %f to FMD%d%c[%2d,%3d] (%f) track %d", 
                  edep, detector, ring, sector, strip,
-                 fEdep(detector, ring, sector, strip).fEdep));
+                 entry.fEdep, (nTrack > 0 ? tracknos[0] : -1)));
   
 }
 
@@ -385,9 +406,11 @@ AliFMDBaseDigitizer::DigitizeHits() const
          // VA1_ALICE channel. 
          if (strip % 128 == 0) last = 0;
          
-         Float_t  edep  = fEdep(detector, ring, sector, strip).fEdep;
-         UShort_t ntot  = fEdep(detector, ring, sector, strip).fN;
-         UShort_t nprim = fEdep(detector, ring, sector, strip).fNPrim;
+         const AliFMDEdepHitPair& entry  = fEdep(detector,ring,sector,strip);
+         Float_t                  edep   = entry.fEdep;
+         UShort_t                 ntot   = entry.fN;
+         UShort_t                 nprim  = entry.fNPrim;
+         const TArrayI&           labels = entry.fLabels;
          if (edep > 0)
            AliFMDDebug(15, ("Edep = %f for FMD%d%c[%2d,%3d]", 
                             edep, detector, ring, sector, strip));
@@ -415,9 +438,9 @@ AliFMDBaseDigitizer::DigitizeHits() const
          AddDigit(detector, ring, sector, strip, edep, 
                   UShort_t(counts[0]), Short_t(counts[1]), 
                   Short_t(counts[2]), Short_t(counts[3]), 
-                  ntot, nprim);
+                  ntot, nprim, labels);
          AliFMDDebug(15, ("   Adding digit in FMD%d%c[%2d,%3d]=%d", 
-                         detector,ring,sector,strip,counts[0]));
+                          detector,ring,sector,strip,counts[0]));
 #if 0
          // This checks if the digit created will give the `right'
          // number of particles when reconstructed, using a naiive
@@ -528,22 +551,23 @@ AliFMDBaseDigitizer::ConvertToCount(Float_t   edep,
 
 //____________________________________________________________________
 void
-AliFMDBaseDigitizer::AddDigit(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
+AliFMDBaseDigitizer::AddDigit(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) const
 {
   // Add a digit or summable digit
-  
   fFMD->AddDigitByFields(detector, ring, sector, strip, 
-                        count1, count2, count3, count4);
+                        count1, count2, count3, count4, 
+                        ntot, fStoreTrackRefs ? refs.fArray : 0);
 }
 
 //____________________________________________________________________