LCOV - code coverage report
Current view: top level - HLT/MUON - AliHLTMUONTrack.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 146 0.7 %
Date: 2016-06-14 17:26:59 Functions: 1 9 11.1 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * This file is property of and copyright by the ALICE HLT Project        *
       3             :  * All rights reserved.                                                   *
       4             :  *                                                                        *
       5             :  * Primary Authors:                                                       *
       6             :  *   Artur Szostak <artursz@iafrica.com>                                  *
       7             :  *                                                                        *
       8             :  * Permission to use, copy, modify and distribute this software and its   *
       9             :  * documentation strictly for non-commercial purposes is hereby granted   *
      10             :  * without fee, provided that the above copyright notice appears in all   *
      11             :  * copies and that both the copyright notice and this permission notice   *
      12             :  * appear in the supporting documentation. The authors make no claims     *
      13             :  * about the suitability of this software for any purpose. It is          *
      14             :  * provided "as is" without express or implied warranty.                  *
      15             :  **************************************************************************/
      16             : 
      17             : // $Id: AliHLTMUONTrack.cxx 37131 2009-11-23 11:08:09Z aszostak $
      18             : 
      19             : ///
      20             : /// @file   AliHLTMUONTrack.cxx
      21             : /// @author Indranil Das <indra.ehep@gmail.com> and Artur Szostak <artursz@iafrica.com>
      22             : /// @date   10 March 2010
      23             : /// @brief  Implementation of the AliHLTMUONTrack class.
      24             : ///
      25             : /// The track class is used to store converted track data from dHLT raw internal
      26             : /// data blocks as a ROOT object. This allows storing these in ROOT files.
      27             : ///
      28             : 
      29             : #include "AliHLTMUONTrack.h"
      30             : #include "AliHLTMUONRecHit.h"
      31             : #include "AliHLTMUONTriggerRecord.h"
      32             : #include "AliLog.h"
      33             : #include "AliMpDEManager.h"
      34             : #include <cstring>
      35             : #include <iostream>
      36             : #include <iomanip>
      37             : 
      38           6 : ClassImp(AliHLTMUONTrack);
      39             : 
      40             : 
      41             : std::ostream& operator << (
      42             :                 std::ostream& stream,
      43             :                 const AliHLTMUONTrack& track
      44             :         )
      45             : {
      46             : /// Stream operator for std::ostream classes.
      47             : /// \param stream  The output stream object being written to.
      48             : /// \param track  The track object to print to the stream.
      49             : /// \returns  the stream object that was written to, <i>stream</i>.
      50             : 
      51           0 :         stream  << "ID: " << track.fId
      52           0 :                 << "; sign: " << track.fSign
      53           0 :                 << "; p = (" << track.Px()
      54           0 :                 << ", " << track.Py()
      55           0 :                 << ", " << track.Pz()
      56           0 :                 << "); chi^2: " << track.fChi2;
      57           0 :         return stream;
      58             : }
      59             : 
      60             : 
      61             : AliHLTMUONTrack::AliHLTMUONTrack(
      62             :                 Int_t id, Int_t sign,
      63             :                 Float_t px, Float_t py, Float_t pz,
      64             :                 Float_t invmom, Float_t thetaX, Float_t thetaY,
      65             :                 Float_t x, Float_t y, Float_t z,
      66             :                 Float_t chi2,
      67             :                 const AliHLTMUONTriggerRecord* trigrec,
      68             :                 const AliHLTMUONRecHit* hits[16]
      69             :         ) :
      70           0 :         TObject(),
      71           0 :         fId(id),
      72           0 :         fSign(sign),
      73           0 :         fInverseBendingMomentum(invmom),
      74           0 :         fThetaX(thetaX),
      75           0 :         fThetaY(thetaY),
      76           0 :         fMomentum(px, py, pz),
      77           0 :         fVertexDCA(x, y, z),
      78           0 :         fChi2(chi2),
      79           0 :         fTrigRec(trigrec)
      80           0 : {
      81             : /// Default constructor.
      82             : /// @param id       The track ID number which must be unique for any event.
      83             : /// @param sign     The particle's sign: -1, 1 or 0 if unknown.
      84             : /// @param px       X component of the particle's momentum (GeV/c).
      85             : /// @param py       Y component of the particle's momentum (GeV/c).
      86             : /// @param pz       Z component of the particle's momentum (GeV/c).
      87             : /// @param invmom   Inverse bending momentum (GeV/c).
      88             : /// @param thetaX   The non-bending plane slope of the fitted track.
      89             : /// @param thetaY   The bending plane slope of the fitted track.
      90             : /// @param x        X coordinate of the particle's distance of closest
      91             : ///                 approach (DCA) position (cm).
      92             : /// @param y        Y coordinate of the particle's DCA position (cm).
      93             : /// @param z        Z coordinate of the particle's DCA position (cm).
      94             : /// @param chi2     The chi squared of the track fit.
      95             : /// @param trigrec  Corresponding trigger record used as a seed to find
      96             : ///                 this track.
      97             : /// @param hits     The array of 16 hit coordinates found for the track.
      98             : ///                 If NULL then then all hit coordinates are set to empty.
      99             : 
     100           0 :         if (sign < -1 or 1 < sign)
     101             :         {
     102           0 :                 AliError(Form("Trying to set the sign to %d. This is outside the"
     103             :                         " valid range of [-1..1]", sign
     104             :                 ));
     105           0 :                 fSign = 0;
     106           0 :         }
     107             :         
     108             :         // Copy individual hit pointers if hits were set.
     109           0 :         if (hits != NULL)
     110             :         {
     111           0 :                 for (int i = 0; i < 16; ++i)
     112             :                 {
     113           0 :                         fHit[i] = hits[i];
     114             :                 }
     115           0 :         }
     116             :         else
     117             :         {
     118           0 :                 for (int i = 0; i < 16; ++i)
     119             :                 {
     120           0 :                         fHit[i] = NULL;
     121             :                 }
     122             :         }
     123           0 : }
     124             : 
     125             : 
     126             : const AliHLTMUONRecHit* AliHLTMUONTrack::Hit(Int_t i) const
     127             : {
     128             : /// Returns the i'th hit.
     129             : /// \param i  The number of the hit to return. Must be a value in the range [0..15].
     130             : /// \returns  A pointer to the hit object else NULL if it does not exist.
     131             : 
     132           0 :         if (0 <= i and i <= 15) return fHit[i];
     133           0 :         AliError(Form("Hit index number %d is not in the valid range [0..15].", int(i)));
     134           0 :         return NULL;
     135           0 : }
     136             : 
     137             : 
     138             : const AliHLTMUONRecHit* AliHLTMUONTrack::HitByChamber(Int_t chamber) const
     139             : {
     140             : /// Returns the first hit found for the specified chamber.
     141             : /// \param chamber  The chamber to return the hit for. Must be a value in the range [1..14].
     142             : /// \returns  A pointer to the hit object else NULL if it does not exist.
     143             : 
     144           0 :         if (not (1 <= chamber and chamber <= 14))
     145             :         {
     146           0 :                 AliError(Form(
     147             :                         "Chamber number %d is not in the valid range [1..14].",
     148             :                         int(chamber)
     149             :                 ));
     150           0 :                 return NULL;
     151             :         }
     152             :         
     153             :         const AliHLTMUONRecHit* hit = NULL;
     154           0 :         for (int i = 0; i < 16; ++i)
     155             :         {
     156           0 :                 if (fHit[i] == NULL) continue;
     157           0 :                 if (fHit[i]->Chamber(false) == chamber)
     158             :                 {
     159           0 :                         hit = fHit[i];
     160           0 :                         break;
     161             :                 }
     162             :         }
     163             :         return hit;
     164           0 : }
     165             : 
     166             : 
     167             : void AliHLTMUONTrack::Print(Option_t* option) const
     168             : {
     169             : /// Prints the track information to standard output (screen).
     170             : /// \param option  Can be one of the following:
     171             : ///           - "compact" - prints in a compact format.
     172             : ///           - "detail" - prints track information in a more detailed format.
     173             : ///           - "all" - prints a full dump of the track object.
     174             : 
     175             :         using namespace std;
     176             :         
     177           0 :         if (    option == NULL or strcmp(option, "") == 0 or
     178           0 :                 strcmp(option, "compact") == 0
     179             :            )
     180             :         {
     181           0 :                 cout << *this << endl;
     182           0 :         }
     183           0 :         else if (strcmp(option, "detail") == 0)
     184             :         {
     185           0 :                 cout << "Track ID = " << fId << "; sign = ";
     186           0 :                 if (fSign != 0)
     187           0 :                         cout << fSign;
     188             :                 else
     189           0 :                         cout << "unknown";
     190           0 :                 cout << "; momentum: (px = " << Px()
     191           0 :                         << " GeV/c, py = " << Py()
     192           0 :                         << " GeV/c, pz = " << Pz()
     193           0 :                         << " GeV/c); vertex DCA: (x = " << X()
     194           0 :                         << " cm, y = " << Y()
     195           0 :                         << " cm, z = " << Z()
     196           0 :                         << " cm); chi^2 = " << fChi2 << endl;
     197             :                 
     198           0 :                 streamsize w = cout.width();
     199           0 :                 ios::fmtflags f = cout.flags();
     200           0 :                 cout << setw(9) << "Hit no."
     201           0 :                         << setw(9) << "Chamber"
     202           0 :                         << setw(0) << "  Pos:"
     203           0 :                         << setw(8) << "X (cm)"
     204           0 :                         << setw(12) << "Y (cm)"
     205           0 :                         << setw(12) << "Z (cm)" << endl;
     206           0 :                 for (int i = 0; i < 16; i++)
     207             :                 {
     208           0 :                         cout << setw(9) << i;
     209           0 :                         if (fHit[i] != NULL)
     210             :                         {
     211           0 :                                 cout << setw(9) << fHit[i]->Chamber(false)
     212           0 :                                         << setw(14) << fHit[i]->X()
     213           0 :                                         << setw(12) << fHit[i]->Y()
     214           0 :                                         << setw(12) << fHit[i]->Z();
     215           0 :                         }
     216             :                         else
     217             :                         {
     218           0 :                                 cout << setw(9) << "-"
     219           0 :                                         << setw(14) << "-"
     220           0 :                                         << setw(12) << "-"
     221           0 :                                         << setw(12) << "-";
     222             :                         }
     223           0 :                         cout << endl;
     224             :                 }
     225           0 :                 cout.width(w); // reset the field width to previous value.
     226           0 :                 cout.flags(f); // reset the flags to previous values.
     227           0 :         }
     228           0 :         else if (strcmp(option, "all") == 0)
     229             :         {
     230           0 :                 cout << "Track ID = " << fId << "; sign = ";
     231           0 :                 if (fSign != 0)
     232           0 :                         cout << fSign;
     233             :                 else
     234           0 :                         cout << "unknown";
     235           0 :                 cout << "; momentum: (px = " << Px()
     236           0 :                         << " GeV/c, py = " << Py()
     237           0 :                         << " GeV/c, pz = " << Pz()
     238           0 :                         << " GeV/c); vertex DCA: (x = " << X()
     239           0 :                         << " cm, y = " << Y()
     240           0 :                         << " cm, z = " << Z()
     241           0 :                         << " cm); chi^2 = " << fChi2 << endl;
     242           0 :                 cout << "Inverse bending momentum = " << fInverseBendingMomentum
     243           0 :                         << "; non-bending plane slope = " << fThetaX
     244           0 :                         << "; bending plane slope = " << fThetaY << endl;
     245             :                 
     246           0 :                 streamsize w = cout.width();
     247           0 :                 ios::fmtflags f = cout.flags();
     248           0 :                 cout.width(w); // reset the field width to previous value.
     249           0 :                 cout.flags(f); // reset the flags to previous values.
     250             :                 
     251           0 :                 for (int i = 0; i < 16; i++)
     252             :                 {
     253           0 :                         cout << "======== Hit " << i << " ========" << endl;
     254           0 :                         if (fHit[i] != NULL)
     255           0 :                                 fHit[i]->Print("all");
     256             :                         else
     257           0 :                                 cout << "No hit found." << endl;
     258             :                 }
     259             :                 
     260           0 :                 cout << "===== Trigger Record =====" << endl;
     261           0 :                 if (fTrigRec != NULL)
     262           0 :                         fTrigRec->Print("all");
     263             :                 else
     264           0 :                         cout << "No trigger record associated with track." << endl;
     265           0 :         }
     266             :         else
     267             :         {
     268           0 :                 AliError("Unknown option specified. Can only be one of 'compact',"
     269             :                         " 'detail' or 'all'."
     270             :                 );
     271             :         }
     272           0 : }
     273             : 
     274             : 
     275             : Int_t AliHLTMUONTrack::Compare(const TObject* obj) const
     276             : {
     277             : /// We compare this object with 'obj' first by track ID, then by sign, then
     278             : /// by momentum, then by DCA vertex and finally by chi2.
     279             : /// \param obj  This is the object to compare to. It must be of type AliHLTMUONTrack.
     280             : /// \returns  -1 if 'this' is smaller than 'obj', 1 if greater and zero if both
     281             : ///      objects are the same.
     282             : 
     283           0 :         if (obj->IsA() == AliHLTMUONTrack::Class())
     284             :         {
     285             :                 const AliHLTMUONTrack* t =
     286           0 :                         static_cast<const AliHLTMUONTrack*>(obj);
     287           0 :                 if (fId < t->fId) return -1;
     288           0 :                 if (fId > t->fId) return 1;
     289           0 :                 if (fSign < t->fSign) return -1;
     290           0 :                 if (fSign > t->fSign) return 1;
     291           0 :                 if (Px() < t->Px()) return -1;
     292           0 :                 if (Px() > t->Px()) return 1;
     293           0 :                 if (Py() < t->Py()) return -1;
     294           0 :                 if (Py() > t->Py()) return 1;
     295           0 :                 if (Pz() < t->Pz()) return -1;
     296           0 :                 if (Pz() > t->Pz()) return 1;
     297           0 :                 if (X() < t->X()) return -1;
     298           0 :                 if (X() > t->X()) return 1;
     299           0 :                 if (Y() < t->Y()) return -1;
     300           0 :                 if (Y() > t->Y()) return 1;
     301           0 :                 if (Z() < t->Z()) return -1;
     302           0 :                 if (Z() > t->Z()) return 1;
     303           0 :                 if (fChi2 < t->fChi2) return -1;
     304           0 :                 if (fChi2 > t->fChi2) return 1;
     305           0 :                 return 0;
     306             :         }
     307             :         else
     308             :         {
     309           0 :                 AliError(Form("Do not know how to compare %s to %s.",
     310             :                         this->ClassName(),
     311             :                         obj->ClassName()
     312             :                 ));
     313           0 :                 return -999;
     314             :         }
     315           0 : }
     316             : 
     317             : 
     318             : bool AliHLTMUONTrack::operator == (const AliHLTMUONTrack& track) const
     319             : {
     320             : /// Comparison operator.
     321             : /// \param track  The track object to compare to.
     322             : /// \returns  true if 'this' object is identical to 'track' else false.
     323             : 
     324           0 :         for (int i = 0; i < 16; i++)
     325             :         {
     326           0 :                 if (fHit[i] != track.fHit[i]) return false;
     327             :         }
     328             :         
     329           0 :         return  fId == track.fId and fSign == track.fSign
     330           0 :                 and fInverseBendingMomentum == track.fInverseBendingMomentum
     331           0 :                 and fThetaX == track.fThetaX and fThetaY == track.fThetaY
     332           0 :                 and fMomentum == track.fMomentum and fVertexDCA == track.fVertexDCA
     333           0 :                 and fChi2 == track.fChi2 and fTrigRec == track.fTrigRec;
     334           0 : }

Generated by: LCOV version 1.11