Exemplo n.º 1
0
void Tracks::checkLayerOrientation() {
   Float_t     n[nLayers-1], x[nLayers-1], y[nLayers-1];
   Float_t     dx, dy;
   Track     * thisTrack = nullptr;
   Cluster   * lastCluster = nullptr;
   Cluster   * thisCluster = nullptr;
   Int_t       first = 0;

   for (Int_t i=0; i<GetEntriesFast(); i++) {
      thisTrack = At(i);
      if (!At(first)) first = 1;
      if (!At(first)) continue;

      lastCluster = thisTrack->At(first);
      for (Int_t j=first+1; j<thisTrack->GetEntriesFast(); j++) {
         thisCluster = thisTrack->At(j);
         dx = thisCluster->getX() - lastCluster->getX();
         dy = thisCluster->getY() - lastCluster->getY();

         x[j] += dx;
         y[j] += dy;
         n[j]++;

         lastCluster = thisCluster;
      }
   }

   cout << "The average track movement between layers is: ";
   for (Int_t i=0; i<nLayers-1; i++) {
      if (n[i]) {
         cout << Form("Layer %d: (%.1f, %.1f), ", i, x[i]/n[i], y[i]/n[i]);
      }
   }
   cout << ".\n";
}
Exemplo n.º 2
0
Bool_t Tracks::isLastEventIDCloseToFirst(Int_t trackIdx) {
   Track     * track = At(trackIdx);
   Cluster   * comparisonCluster = nullptr;
   Int_t       lastEventID = track->Last()->getEventID();
   Int_t       firstEventID = track->getEventID(0);
   Int_t       comparisonEventID;
   Float_t     deltaXY, deltaPHI, phi1, phi2;
   Int_t       comparisonIdx;
   
   if (!track)                               return false;
   if (!track->At(0))                        return false;
   if (track->isFirstAndLastEventIDEqual())  return true;

   else {
      // check first against last ID
      comparisonIdx = getTrackIdxFromFirstLayerEID(lastEventID);

      if (comparisonIdx < 0) return true; 

      comparisonCluster = At(comparisonIdx)->At(0);
      
      if (!comparisonCluster) return false;

      deltaXY = diffmmXY(track->At(0), comparisonCluster);
      phi1 = track->getSlopeAngleAtLayer(1);
      phi2 = At(comparisonIdx)->getSlopeAngleAtLayer(1);
      deltaPHI = fabs(phi1 - phi2);

      if (deltaXY < 0.5 && deltaPHI < 0.5) {
         cout << "OK! deltaXY = " << deltaXY << "and angles (" << phi1 << ", " << phi2 << "(\n";
         cout << "A = " << *track << endl;
         cout << "B = " << *At(comparisonIdx) << endl;
         return true;
      }

      // check last against first ID
      comparisonIdx = getTrackIdxFromLastLayerEID(firstEventID);
      if (comparisonIdx < 0) return true;
      
      comparisonCluster = At(comparisonIdx)->Last();
      if (!comparisonCluster) return false;

      deltaXY = diffmmXY(track->Last(), comparisonCluster);
      phi1 = track->getSlopeAngleAtLayer(track->GetEntriesFast()-1);
      phi2 = At(comparisonIdx)->getSlopeAngleAtLayer(At(comparisonIdx)->GetEntriesFast()-1);
      deltaPHI = fabs(phi1 - phi2);
      
      if (deltaXY < 0.5 && deltaPHI < 0.5) {
         return true;
      }
   }

   return false;
}
Exemplo n.º 3
0
void Tracks::sortTrackByLayer(Int_t trackIdx) {
   // FIXME Check that this functions does what it should... It looks a bit strange!

   Int_t       lastLayer = 0;
   Bool_t      isSorted = true;
   Cluster   * lastCluster = nullptr;
   Track     * newTrack = new Track();
   Cluster   * nextCluster = nullptr;
   Int_t       firstLayer = 0;
   Int_t       n = GetEntriesFast(trackIdx);

   for (Int_t i=0; i<n; i++) {
      if (!At(i)) continue;
      firstLayer = i;
      break;
   }

   for (Int_t i=0; i<n; i++) {
      if (!At(trackIdx)->At(i)) continue;

      if (lastLayer > At( trackIdx )->getLayer(i))
         isSorted = false;

      lastLayer = At( trackIdx )->getLayer(i);
   }
   
   if (!isSorted) {
      vector<Int_t> sortList;
      sortList.resize(nLayers);
      for (Int_t i=0; i<nLayers; i++) sortList.at(i) = -1;
      for (Int_t i=0; i<n; i++) {
         if (!At(trackIdx)->At(i)) continue;
         sortList.at(At(trackIdx)->getLayer(i)) = i;
      }

      for (UInt_t i=0; i<sortList.size(); i++) {
         if (sortList.at(i) <0) continue;
         nextCluster = At(trackIdx)->At(sortList.at(i));
         newTrack->appendCluster(nextCluster, firstLayer);
      }

      if (newTrack->GetEntriesFast()) {
         appendTrack(newTrack);
         removeTrackAt(trackIdx);
         newTrack->clearTrack();
      }
   }
}
Exemplo n.º 4
0
void Tracks::matchWithEventIDs(Hits * eventIDs) {
   // Use the Monte Carlo truth list eventIDs (x, y, layer, actual event)
   // and find the closes match for each item in list
   // then set truth eventID to the Tracks->Track->Cluster object

   Float_t     minDist = 1e5; // px
   Float_t     thisDist = 0;
   Track     * thisTrack = nullptr;
   Cluster   * thisCluster = nullptr;
   Hit       * thisHit = nullptr;
   Int_t       layer = -1;
   Int_t       minIdx = 0;
   Bool_t      doLoop = true;
   Int_t       nHits = eventIDs->GetEntriesFast();
   Float_t     cX, cY;
   Int_t       nClusters = 0;

   for (Int_t t=0; t<GetEntriesFast(); t++) {
      thisTrack = At(t);
      if (!thisTrack) continue;

      nClusters += thisTrack->GetEntriesFast();

      for (Int_t c=0; c<thisTrack->GetEntriesFast(); c++) {
         thisCluster = thisTrack->At(c);
         layer = thisCluster->getLayer();

         cX = thisCluster->getX();
         cY = thisCluster->getY();

         // Optimization:
         // If thisCluster+1 is also eventIDs+1, don't loop to see if we can find it
         // But instead just use minIdx++ ;-)

         minDist = diffXY(thisCluster, eventIDs->At(minIdx+1));

         if (minDist < 10) {
            minIdx++;
            doLoop = false;
         }

         else {
            doLoop = true;
            minDist = 1e5;
            minIdx = -1;
         }

         if (doLoop) {
            for (Int_t h=0; h<eventIDs->GetEntriesFast(); h++) {
               thisHit = eventIDs->At(h);
               
               if (!thisHit) continue;
               if (thisHit->getLayer() != layer) continue;

               if (fabs(cX - thisHit->getX()) < 10) {
                  if (fabs(cY - thisHit->getY()) < 10) {

                     thisDist = diffXY(thisCluster, thisHit);
                     if (thisDist < minDist) {
                        minDist = thisDist;
                        minIdx = h;
                     }
                  }
               }
            }
         }
         
         if (minIdx >= 0 && minDist < 14) {
            thisCluster->setEventID(eventIDs->getEventID(minIdx));
            eventIDs->removeHitAt(minIdx);
         }
      }
   }

   Int_t cWithoutEventID = 0;
   for (Int_t t=0; t<GetEntriesFast(); t++) {
      for (Int_t c=0; c<At(t)->GetEntriesFast(); c++) {
         if (At(t)->getEventID(c) < 0) {
            cWithoutEventID++;
         }
      }
   }

   cout << "Number of clusters without eventID: " << cWithoutEventID << "( " << (float) cWithoutEventID / nClusters * 100 << "%)\n";
}