]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
- update AliTRDtrackletMCM to carry 3 labels and assign them in AliTRDmcmSim
authorcblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 5 Sep 2010 13:24:25 +0000 (13:24 +0000)
committercblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 5 Sep 2010 13:24:25 +0000 (13:24 +0000)
- bugfix in AliTRDtrackletMCM::GetLocalZ(), was wrong for stack 2
- retrieve layer-specific position LUT (as given in TRAPconfig)

TRD/AliTRDmcmSim.cxx
TRD/AliTRDmcmSim.h
TRD/AliTRDtrackletMCM.cxx
TRD/AliTRDtrackletMCM.h

index 21dcd667135f455ae5dddf19297028006a475550..1ffce2c1240ab8f26da25182db170718434e698a 100644 (file)
@@ -668,7 +668,7 @@ Bool_t AliTRDmcmSim::GetHit(Int_t index, Int_t &channel, Int_t &timebin, Int_t &
                         (channel << 8) - ypos) 
     * (0.635 + 0.03 * (fDetector % 6))
     / 256.0;
-  label   = fHits[index].fLabel;
+  label   = fHits[index].fLabel[0];
 
   return kTRUE;
 }
@@ -1147,7 +1147,7 @@ void AliTRDmcmSim::ZSMapping()
   }
 }
 
-void AliTRDmcmSim::AddHitToFitreg(Int_t adc, UShort_t timebin, UShort_t qtot, Short_t ypos, Int_t label
+void AliTRDmcmSim::AddHitToFitreg(Int_t adc, UShort_t timebin, UShort_t qtot, Short_t ypos, Int_t label[])
 {
   // Add the given hit to the fit register which is lateron used for 
   // the tracklet calculation. 
@@ -1178,7 +1178,9 @@ void AliTRDmcmSim::AddHitToFitreg(Int_t adc, UShort_t timebin, UShort_t qtot, Sh
   fHits[fNHits].fQtot = qtot;
   fHits[fNHits].fYpos = ypos;
   fHits[fNHits].fTimebin = timebin;
-  fHits[fNHits].fLabel = label;
+  fHits[fNHits].fLabel[0] = label[0];
+  fHits[fNHits].fLabel[1] = label[1];
+  fHits[fNHits].fLabel[2] = label[2];
   fNHits++;
 }
 
@@ -1348,16 +1350,16 @@ void AliTRDmcmSim::CalcFitreg()
         ypos = 128*(adcLeft - adcRight) / adcCentral;
         if (ypos < 0) ypos = -ypos;
         // make the correction using the position LUT
-        ypos = ypos + fTrapConfig->GetTrapReg((AliTRDtrapConfig::TrapReg_t) (AliTRDtrapConfig::kTPL00 + (ypos & 0x7F))); 
+        ypos = ypos + fTrapConfig->GetTrapReg((AliTRDtrapConfig::TrapReg_t) (AliTRDtrapConfig::kTPL00 + (ypos & 0x7F)),
+                                             fDetector, fRobPos, fMcmPos);
         if (adcLeft > adcRight) ypos = -ypos;
 
-        // label calculation
-        Int_t mcLabel = -1;
+        // label calculation (up to 3)
+        Int_t mcLabel[] = {-1, -1, -1};
         if (fDigitsManager) {
-          Int_t label[9] = { 0 }; // up to 9 different labels possible
-          Int_t count[9] = { 0 };
-          Int_t maxIdx = -1;
-          Int_t maxCount = 0;
+          const Int_t maxLabels = 9;
+          Int_t label[maxLabels] = { 0 }; // up to 9 different labels possible
+          Int_t count[maxLabels] = { 0 };
           Int_t nLabels = 0;
           Int_t padcol[3]; 
           padcol[0] = fFeeParam->GetPadColFromADC(fRobPos, fMcmPos, adcch);
@@ -1370,26 +1372,29 @@ void AliTRDmcmSim::CalcFitreg()
             for (Int_t iPad = 0; iPad < 3; iPad++) {
               if (padcol[iPad] < 0) 
                 continue;
-              Int_t currLabel = fDict[iDict]->GetData(padrow, padcol[iPad], timebin); //fDigitsManager->GetTrack(iDict, padrow, padcol, timebin, fDetector);
+              Int_t currLabel = fDict[iDict]->GetData(padrow, padcol[iPad], timebin);
              AliDebug(10, Form("Read label: %4i for det: %3i, row: %i, col: %i, tb: %i\n", currLabel, fDetector, padrow, padcol[iPad], timebin));
               for (Int_t iLabel = 0; iLabel < nLabels; iLabel++) {
                 if (currLabel == label[iLabel]) {
                   count[iLabel]++;
-                  if (count[iLabel] > maxCount) {
-                    maxCount = count[iLabel];
-                    maxIdx = iLabel;
-                  }
                   currLabel = -1;
                   break;
                 }
               } 
               if (currLabel >= 0) {
-                label[nLabels++] = currLabel;
+                label[nLabels] = currLabel;
+               count[nLabels] = 1;
+               nLabels++;
               }
             }
           }
-          if (maxIdx >= 0)
-            mcLabel = label[maxIdx];
+         Int_t index[maxLabels];
+         TMath::Sort(maxLabels, count, index);
+         for (Int_t i = 0; i < 3; i++) {
+           if (count[index[i]] <= 0)
+             break;
+           mcLabel[i] = label[index[i]];
+         }
         }
 
         // add the hit to the fitregister
@@ -1635,14 +1640,13 @@ void AliTRDmcmSim::FitTracklet()
         fMCMT[cpu] = (pid << 24) | (padrow << 20) | (slope << 13) | offset;
 
         // calculate MC label
-        Int_t mcLabel = -1;
+        Int_t mcLabel[] = { -1, -1, -1};
        Int_t nHits0 = 0;
        Int_t nHits1 = 0;
         if (fDigitsManager) {
-          Int_t label[30] = {0}; // up to 30 different labels possible
-          Int_t count[30] = {0};
-          Int_t maxIdx = -1;
-          Int_t maxCount = 0;
+         const Int_t maxLabels = 30;
+          Int_t label[maxLabels] = {0}; // up to 30 different labels possible
+          Int_t count[maxLabels] = {0};
           Int_t nLabels = 0;
           for (Int_t iHit = 0; iHit < fNHits; iHit++) {
             if ((fHits[iHit].fChannel - fFitPtr[cpu] < 0) ||
@@ -1657,24 +1661,29 @@ void AliTRDmcmSim::FitTracklet()
                fHits[iHit].fTimebin <  fTrapConfig->GetTrapReg(AliTRDtrapConfig::kTPQE1))
              nHits1++;
 
-            Int_t currLabel = fHits[iHit].fLabel;
-            for (Int_t iLabel = 0; iLabel < nLabels; iLabel++) {
-              if (currLabel == label[iLabel]) {
-                count[iLabel]++;
-                if (count[iLabel] > maxCount) {
-                  maxCount = count[iLabel];
-                  maxIdx = iLabel;
-                }
-                currLabel = -1;
-                break;
-              }
-            }
-            if (currLabel >= 0) {
-              label[nLabels++] = currLabel;
-            }
-          }
-          if (maxIdx >= 0)
-            mcLabel = label[maxIdx];
+           for (Int_t i = 0; i < 3; i++) {
+             Int_t currLabel = fHits[iHit].fLabel[i];
+             for (Int_t iLabel = 0; iLabel < nLabels; iLabel++) {
+               if (currLabel == label[iLabel]) {
+                 count[iLabel]++;
+                 currLabel = -1;
+                 break;
+               }
+             }
+             if (currLabel >= 0 && nLabels < maxLabels) {
+               label[nLabels] = currLabel;
+               count[nLabels]++;
+               nLabels++;
+             }
+           }
+         }
+         Int_t index[maxLabels];
+         TMath::Sort(maxLabels, count, index);
+         for (Int_t i = 0; i < 3; i++) {
+           if (count[index[i]] <= 0)
+             break;
+           mcLabel[i] = label[index[i]];
+         }
         }
         new ((*fTrackletArray)[fTrackletArray->GetEntriesFast()]) AliTRDtrackletMCM((UInt_t) fMCMT[cpu], fDetector*2 + fRobPos%2, fRobPos, fMcmPos);
         ((AliTRDtrackletMCM*) (*fTrackletArray)[fTrackletArray->GetEntriesFast()-1])->SetLabel(mcLabel);
index 0ebd8b6824670326fa444f094e3059106b53983a..4989d5ff583cf0201decdbd6cec5b8bb0deaefdd 100644 (file)
@@ -101,7 +101,7 @@ class AliTRDmcmSim : public TObject {
          UShort_t  FilterTailNextSample(Int_t adc, UShort_t value);
 
          // tracklet calculation
-         void      AddHitToFitreg(Int_t adc, UShort_t timebin, UShort_t qtot, Short_t ypos, Int_t label);
+         void      AddHitToFitreg(Int_t adc, UShort_t timebin, UShort_t qtot, Short_t ypos, Int_t label[]);
          void      CalcFitreg();
          void      TrackletSelection();
          void      FitTracklet();
@@ -185,7 +185,7 @@ class AliTRDmcmSim : public TObject {
            Int_t fTimebin;                             // timebin of the hit
            Int_t fQtot;                                // total charge of the hit
            Int_t fYpos;                                // calculated y-position
-           Int_t fLabel;                               // label (only in MC)
+           Int_t fLabel[3];                            // up to 3 labels (only in MC)
          } fHits[fgkNHitsMC];
          Int_t fNHits;                                 // Number of detected hits
 
index 086b6e2fa13c3bb804f2dde05d72f05343cf81c1..df3a8911470421f7a7c786c62a5289bb93fcca4d 100644 (file)
@@ -40,7 +40,6 @@ AliTRDtrackletMCM::AliTRDtrackletMCM(UInt_t trackletWord) :
   fNHits(0),
   fNHits0(0),
   fNHits1(0),
-  fLabel(-1),
   fSlope(0.),
   fOffset(0.),
   fError(0.),
@@ -49,6 +48,9 @@ AliTRDtrackletMCM::AliTRDtrackletMCM(UInt_t trackletWord) :
   fClsCharges(0x0)
 { 
     fGeo = new AliTRDgeometry();
+    fLabel[0] = -1;
+    fLabel[1] = -1;
+    fLabel[2] = -1;
 }
 
 AliTRDtrackletMCM::AliTRDtrackletMCM(UInt_t trackletWord, Int_t hcid) :
@@ -63,7 +65,6 @@ AliTRDtrackletMCM::AliTRDtrackletMCM(UInt_t trackletWord, Int_t hcid) :
   fNHits(0),
   fNHits0(0),
   fNHits1(0),
-  fLabel(-1),
   fSlope(0.),
   fOffset(0.),
   fError(0.),
@@ -72,6 +73,9 @@ AliTRDtrackletMCM::AliTRDtrackletMCM(UInt_t trackletWord, Int_t hcid) :
   fClsCharges(0x0)
 { 
     fGeo = new AliTRDgeometry();
+    fLabel[0] = -1;
+    fLabel[1] = -1;
+    fLabel[2] = -1;
 }
 
 AliTRDtrackletMCM::AliTRDtrackletMCM(UInt_t trackletWord, Int_t hcid, Int_t rob, Int_t mcm) :
@@ -86,7 +90,6 @@ AliTRDtrackletMCM::AliTRDtrackletMCM(UInt_t trackletWord, Int_t hcid, Int_t rob,
   fNHits(0),
   fNHits0(0),
   fNHits1(0),
-  fLabel(-1),
   fSlope(0.),
   fOffset(0.),
   fError(0.),
@@ -95,6 +98,9 @@ AliTRDtrackletMCM::AliTRDtrackletMCM(UInt_t trackletWord, Int_t hcid, Int_t rob,
   fClsCharges(0x0)
 { 
     fGeo = new AliTRDgeometry();
+    fLabel[0] = -1;
+    fLabel[1] = -1;
+    fLabel[2] = -1;
 }
 
 AliTRDtrackletMCM::AliTRDtrackletMCM(const AliTRDtrackletMCM &rhs) :
@@ -109,8 +115,7 @@ AliTRDtrackletMCM::AliTRDtrackletMCM(const AliTRDtrackletMCM &rhs) :
   fNHits(rhs.fNHits),
   fNHits0(rhs.fNHits0),
   fNHits1(rhs.fNHits1),
-  fLabel(rhs.fLabel),
-  fSlope(rhs.fLabel),
+  fSlope(rhs.fSlope),
   fOffset(rhs.fOffset),
   fError(rhs.fError),
   fNClusters(rhs.fNClusters),
@@ -124,6 +129,9 @@ AliTRDtrackletMCM::AliTRDtrackletMCM(const AliTRDtrackletMCM &rhs) :
       fResiduals[iCls] = rhs.fResiduals[iCls];
       fClsCharges[iCls] = rhs.fClsCharges[iCls];
     }
+    fLabel[0] = rhs.fLabel[0];
+    fLabel[1] = rhs.fLabel[1];
+    fLabel[2] = rhs.fLabel[2];
 }
 
 AliTRDtrackletMCM::~AliTRDtrackletMCM() 
@@ -154,6 +162,13 @@ Int_t AliTRDtrackletMCM::GetdY() const
   }
 }
 
+void AliTRDtrackletMCM::SetLabel(Int_t label[])
+{ 
+  fLabel[0] = label[0];
+  fLabel[1] = label[1];
+  fLabel[2] = label[2];
+}
+
 void AliTRDtrackletMCM::SetClusters(Float_t *res, Float_t *q, Int_t n)
 {
   fNClusters = n;
index 118ce76792e339cdc36f3e9a0d2f98d02221a5eb..884471d8a25a270a1bfb75215803b1bad693cd34 100644 (file)
@@ -33,7 +33,9 @@ class AliTRDtrackletMCM : public AliTRDtrackletBase {
   // ----- Getters for MCM-tracklet information -----
   Int_t GetMCM() const { return fMCM; }
   Int_t GetROB() const { return fROB; }
-  Int_t GetLabel() const { return fLabel; }
+  Int_t GetLabel() const { return fLabel[0]; }
+  Int_t GetLabel(const Int_t i) const { return fLabel[i]; }
+  Bool_t HasLabel(const Int_t label) const { return (fLabel[0] == label || fLabel[1] == label || fLabel[2] == label); }
 
   // ----- Getters for offline corresponding values -----
   Bool_t CookPID() { return kFALSE; }
@@ -45,7 +47,8 @@ class AliTRDtrackletMCM : public AliTRDtrackletBase {
   Float_t GetY() const { return (GetYbin() * 160e-4); }
   Float_t GetZ() const { return fGeo->GetPadPlane((fHCId % 12) / 2, (fHCId / 12) % 5)->GetRowPos( 4 * (fROB / 2) + fMCM / 4) - 
       fGeo->GetPadPlane((fHCId % 12) / 2, (fHCId /12) % 5)->GetRowSize(4 * (fROB / 2) + fMCM / 4) * .5; }
-  Float_t GetLocalZ() const { return GetZ() - fGeo->GetPadPlane((fHCId % 12) / 2, (fHCId / 12) % 5)->GetRowPos(8); }
+  Float_t GetLocalZ() const { return GetZ() - 
+      (fGeo->GetPadPlane((fHCId % 12) / 2, (fHCId / 12) % 5)->GetRow0()+fGeo->GetPadPlane((fHCId % 12) / 2, (fHCId / 12) % 5)->GetRowEnd())/2.; }
 
   Int_t GetQ0() const { return fQ0; }
   Int_t GetQ1() const { return fQ1; }
@@ -60,7 +63,7 @@ class AliTRDtrackletMCM : public AliTRDtrackletBase {
   void SetHCId(Int_t id) { fHCId = id; }
   void SetMCM(Int_t mcm) { fMCM = mcm; }
   void SetROB(Int_t rob) { fROB = rob; }
-  void SetLabel(Int_t label) { fLabel = label; }
+  void SetLabel(Int_t label[]);
   void SetQ0(Int_t charge) { fQ0 = charge; }
   void SetQ1(Int_t charge) { fQ1 = charge; }
   void SetNHits(Int_t nhits) { fNHits = nhits; }
@@ -95,7 +98,7 @@ class AliTRDtrackletMCM : public AliTRDtrackletBase {
   Int_t fNHits0; // no. of contributing clusters in window 0
   Int_t fNHits1; // no. of contributing clusters in window 1
 
-  Int_t fLabel; // label for MC track
+  Int_t fLabel[3]; // up to 3 labels for MC track
   
   Float_t  fSlope;           // tracklet slope
   Float_t  fOffset;          // tracklet offset