From 827a26c93063a7bfc386b67e2f12b4e43b60158b Mon Sep 17 00:00:00 2001
From: "Stephen A. Wood" <saw@jlab.org>
Date: Fri, 13 Jul 2018 16:13:34 -0400
Subject: [PATCH] Update comments for drift chamber classes for Doxygen

---
 src/THcDC.cxx                | 105 +++++++++++---------------
 src/THcDCLookupTTDConv.cxx   |   4 +-
 src/THcDCTrack.cxx           |  27 ++++---
 src/THcDriftChamber.cxx      | 142 ++++++++++++++++++++---------------
 src/THcDriftChamberPlane.cxx |  14 +++-
 5 files changed, 155 insertions(+), 137 deletions(-)

diff --git a/src/THcDC.cxx b/src/THcDC.cxx
index feccef1..350453b 100644
--- a/src/THcDC.cxx
+++ b/src/THcDC.cxx
@@ -265,11 +265,12 @@ THaAnalysisObject::EStatus THcDC::Init( const TDatime& date )
 //_____________________________________________________________________________
 Int_t THcDC::ReadDatabase( const TDatime& date )
 {
-  // Read this detector's parameters from the ThcParmList
-  // This function is called by THaDetectorBase::Init() once at the
-  // beginning of the analysis.
-  // 'date' contains the date/time of the run being analyzed.
+  /**
+  Read this detector's parameters from the ThcParmList
+  This function is called by THaDetectorBase::Init() once at the
+  beginning of the analysis.
 
+  */
   //  static const char* const here = "ReadDatabase()";
 
   delete [] fXCenter;  fXCenter = new Double_t [fNChambers];
@@ -387,8 +388,9 @@ Int_t THcDC::ReadDatabase( const TDatime& date )
 //_____________________________________________________________________________
 Int_t THcDC::DefineVariables( EMode mode )
 {
-  // Initialize global variables for histograms and Root tree
-
+  /**
+    Initialize global variables for histograms and Root tree
+  */
   if( mode == kDefine && fIsSetup ) return kOK;
   fIsSetup = ( mode == kDefine );
 
@@ -515,9 +517,11 @@ void THcDC::ClearEvent()
 //_____________________________________________________________________________
 Int_t THcDC::Decode( const THaEvData& evdata )
 {
-  // Decode event into hit list.
-  // Pass hit list to the planes.
-  // Load hits from planes into chamber objects
+  /**
+    Decode event into hit list.
+    Pass hit list to the planes.
+    Load hits from planes into chamber objects
+  */
   ClearEvent();
   Int_t num_event = evdata.GetEvNum();
   if (fdebugprintrawdc ||fdebugprintdecodeddc || fdebuglinkstubs || fdebugtrackprint) cout << " event num = " << num_event << endl;
@@ -568,14 +572,12 @@ Int_t THcDC::ApplyCorrections( void )
 //_____________________________________________________________________________
 Int_t THcDC::CoarseTrack( TClonesArray& tracks )
 {
-  // Calculation of coordinates of particle track cross point with scint
-  // plane in the detector coordinate system. For this, parameters of track
-  // reconstructed in THaVDC::CoarseTrack() are used.
-  //
-  // Apply corrections and reconstruct the complete hits.
-  //
-  //  static const Double_t sqrt2 = TMath::Sqrt(2.);
-  //
+  /**
+     Find a set of tracks through the drift chambers and put them
+     into the tracks TClonesArray.
+     Tracks are in the detector coordinate system.
+  */
+
   // Subtract starttimes from each plane hit
     for(Int_t ip=0;ip<fNPlanes;ip++) {
       fPlanes[ip]->SubtractStartTime();
@@ -628,14 +630,6 @@ Int_t THcDC::CoarseTrack( TClonesArray& tracks )
 //_____________________________________________________________________________
 Int_t THcDC::FineTrack( TClonesArray& tracks )
 {
-  // Reconstruct coordinates of particle track cross point with scintillator
-  // plane, and copy the data into the following local data structure:
-  //
-  // Units of measurements are meters.
-
-  // Calculation of coordinates of particle track cross point with scint
-  // plane in the detector coordinate system. For this, parameters of track
-  // reconstructed in THaVDC::FineTrack() are used.
 
   return 0;
 }
@@ -717,18 +711,20 @@ void THcDC::PrintStubs()
 //_____________________________________________________________________________
 void THcDC::LinkStubs()
 {
-  //     The logic is
-  //                  0) Put all space points in a single list
-  //                  1) loop over all space points as seeds  isp1
-  //                  2) Check if this space point is all ready in a track
-  //                  3) loop over all succeeding space pointss   isp2
-  //                  4)  check if there is a track-criterion match
-  //                       either add to existing track
-  //                       or if there is another point in same chamber
-  //                          make a copy containing isp2 rather than
-  //                            other point in same chamber
-  //                  5) If hsingle_stub is set, make a track of all single
-  //                     stubs.
+  /**
+       The logic is
+                    0) Put all space points in a single list
+                    1) loop over all space points as seeds  isp1
+                    2) Check if this space point is all ready in a track
+                    3) loop over all succeeding space pointss   isp2
+                    4)  check if there is a track-criterion match
+                         either add to existing track
+                         or if there is another point in same chamber
+                            make a copy containing isp2 rather than
+                              other point in same chamber
+                    5) If hsingle_stub is set, make a track of all single
+                       stubs.
+  */
 
   std::vector<THcSpacePoint*> fSp;
   fNSp=0;
@@ -927,28 +923,13 @@ if (fdebuglinkstubs) {
 //_____________________________________________________________________________
 void THcDC::TrackFit()
 {
-  // Primary track fitting routine
+  /**
+     Primary track fitting routine
+  */
 
   // Number of ray parameters in focal plane.
   const Int_t raycoeffmap[]={4,5,2,3};
 
-  // EJB_Note:  Why is this here?  It does not appear to be used anywhere ... commenting out for now.
-  //
-  //// Initialize residuals
-  //// Need to make these member variables so they can be histogrammed
-  //// Probably an array of vectors.
-  //Double_t double_resolution[fNPlanes][fNDCTracks];
-  //Double_t single_resolution[fNPlanes][fNDCTracks];
-  //Double_t double_res[fNPlanes]; // For the good track
-  //
-  // for(Int_t ip=0;ip<fNPlanes;ip++) {
-  //  double_res[ip] = 1000.0;
-  //  for(Int_t itrack=0;itrack<fNDCTracks;itrack++) {
-  //    double_resolution[ip][itrack] = 1000.0;
-  //    single_resolution[ip][itrack] = 1000.0;
-  //  }
-  // }
-
   Double_t dummychi2 = 1.0E4;
   for(UInt_t itrack=0;itrack<fNDCTracks;itrack++) {
     //    Double_t chi2 = dummychi2;
@@ -1216,7 +1197,7 @@ void THcDC::TrackFit()
 //
 Double_t THcDC::DpsiFun(Double_t ray[4], Int_t plane)
 {
-  /*
+  /**
     this function calculates the psi coordinate of the intersection
     of a ray (defined by ray) with a hms wire chamber plane. the geometry
     of the plane is contained in the coeff array calculated in the
@@ -1265,9 +1246,11 @@ Int_t THcDC::End(THaRunBase* run)
 //_____________________________________________________________________________
 void THcDC::EffInit()
 {
-  // Create, and initialize counters used to calculate
-  // efficiencies.  Register the counters in gHcParms so that the
-  // variables can be used in end of run reports.
+  /**
+     Create, and initialize counters used to calculate
+     efficiencies.  Register the counters in gHcParms so that the
+     variables can be used in end of run reports.
+  */
 
   delete [] fNChamHits; fNChamHits = new Int_t [fNChambers];
   delete [] fPlaneEvents; fPlaneEvents = new Int_t [fNPlanes];
@@ -1287,7 +1270,9 @@ void THcDC::EffInit()
 //_____________________________________________________________________________
 void THcDC::Eff()
 {
-  // Accumulate statistics for efficiency calculations
+  /**
+     Accumulate statistics for efficiency calculations
+  */
 
   fTotEvents++;
   for(UInt_t i=0;i<fNChambers;i++) {
diff --git a/src/THcDCLookupTTDConv.cxx b/src/THcDCLookupTTDConv.cxx
index 2c8ec2a..4fc3909 100644
--- a/src/THcDCLookupTTDConv.cxx
+++ b/src/THcDCLookupTTDConv.cxx
@@ -34,7 +34,9 @@ THcDCLookupTTDConv::~THcDCLookupTTDConv()
 //______________________________________________________________________________
 Double_t THcDCLookupTTDConv::ConvertTimeToDist(Double_t time)
 {
-  // Lookup in table
+  /**
+     Convert drift time to a distance from the wire by looking up in a table.
+  */
   Int_t ib = (time-fT0)/fBinSize;
   Double_t frac = 0;
   if(ib >= 0 && ib+1 < fNumBins) {
diff --git a/src/THcDCTrack.cxx b/src/THcDCTrack.cxx
index b23c7af..be7e64a 100644
--- a/src/THcDCTrack.cxx
+++ b/src/THcDCTrack.cxx
@@ -19,7 +19,9 @@ THcDCTrack::THcDCTrack(Int_t nplanes) : fnSP(0), fNHits(0)
 
 void THcDCTrack::AddHit(THcDCHit * hit, Double_t dist, Int_t lr)
 {
-  // Add a hit to the track
+  /**
+     Add hit to list of hits associated with the track
+  */
   Hit newhit;
   newhit.dchit = hit;
   newhit.distCorr = dist;
@@ -29,21 +31,26 @@ void THcDCTrack::AddHit(THcDCHit * hit, Double_t dist, Int_t lr)
 }
 void THcDCTrack::AddSpacePoint( THcSpacePoint* sp )
 {
-  // Add to list of space points in this track
-  // Need a check for maximum spacepoints of 10
+  /**
+     Add a space point to the list of space points associated with the track.
+     All hits in the SP are added to the tracks hit list.
+  */
+
   if (fnSP <10) {
-  fSp[fnSP++] = sp;
-  // Copy all the hits from the space point into the track
-  // Will need to also copy the corrected distance and lr information
-  for(Int_t ihit=0;ihit<sp->GetNHits();ihit++) {
-    AddHit(sp->GetHit(ihit),sp->GetHitDist(ihit),sp->GetHitLR(ihit));
-  }
+    fSp[fnSP++] = sp;
+    // Copy all the hits from the space point into the track
+    // Will need to also copy the corrected distance and lr information
+    for(Int_t ihit=0;ihit<sp->GetNHits();ihit++) {
+      AddHit(sp->GetHit(ihit),sp->GetHitDist(ihit),sp->GetHitLR(ihit));
+    }
   }
 }
 
 void THcDCTrack::Clear( const Option_t* )
 {
-  // Clear the space point and hit lists
+  /**
+     Clear the space point and hit lists
+  */
   fnSP = 0;
   fSp1_ID=-1;
   fSp2_ID=-1;
diff --git a/src/THcDriftChamber.cxx b/src/THcDriftChamber.cxx
index 8aa6ca2..592af15 100644
--- a/src/THcDriftChamber.cxx
+++ b/src/THcDriftChamber.cxx
@@ -276,44 +276,42 @@ void THcDriftChamber::PrintDecode( void )
 
 Int_t THcDriftChamber::FindSpacePoints( void )
 {
-  /*
-1) First check if number of hits is between fMinHits=min_hit and fMaxHits=max_pr_hits
+  /**
+1. First check if number of hits is between fMinHits=min_hit and fMaxHits=max_pr_hits
    if fails then fNSpacePoints=0
-2) Determines if it is an easy spacepoint.
-  a) if HMS style chambers finds the Y and Y' planes
+2. Determines if it is an easy spacepoint.
+  1. if HMS style chambers finds the Y and Y' planes
      if not HMS style chambers finds the X and X' planes
-  b) if both planes ahve only one hit and the difference in hit position
+  2. if both planes ahve only one hit and the difference in hit position
      between the hits < fSpacePointCriterion and less than 6 hits .
      then easy spacepoint and calls either method FindEasySpacePoint_HMS or FindEasySpacePoint_SOS
-  c) FindEasySpacePoint_SOS
-     1) Loops through hits and gets y_pos from the non-X planes and determines average Yt
-     2) Loops through hits and sees if any of "Y-planes" hits has 
+  3. FindEasySpacePoint_SOS
+     1. Loops through hits and gets y_pos from the non-X planes and determines average Yt
+     2. Loops through hits and sees if any of "Y-planes" hits has 
           difference of y_pos -Yt > TMath::Sqrt(fSpacePointCriterion/2.0)
-     3) Adds a spacepoint and set ncombos to zero.
-
-
-3) if not  EasySpacePoint calls FindHardSpacePoints
-  a) loops though hits and determines pairs of hits in planes with angles grerater then 17.5 degs
+     3. Adds a spacepoint and set ncombos to zero.
+3. if not  EasySpacePoint calls FindHardSpacePoints
+  1. loops though hits and determines pairs of hits in planes with angles grerater then 17.5 degs
       between them. These are test pairs and stores the x and y position of pair
-  b) Double loops through the test pairs to determine number of pair combinations.
-     i) Calculates d2 = (xi -xj)^2 + (yi-yj)^2 from the two pairs (i,j).
-     ii) If d2 <  fSpacePointCriterion then fills combos structure with pair info
+  1. Double loops through the test pairs to determine number of pair combinations.
+     1. Calculates d2 = (xi -xj)^2 + (yi-yj)^2 from the two pairs (i,j).
+     2. If d2 <  fSpacePointCriterion then fills combos structure with pair info
          and increments ncombos.
-  c) Loop through ncombos
-     i) First combo is set as spacepoint which is loaded with hit info from combos.
-     ii) Next combo 
-        a) Loops through previous space points
-        b) calculates  d2 = (x_c -x_sp)^2 + (y_c-y_sp)^2 between combos and spacepoint
+  c. Loop through ncombos
+     1. First combo is set as spacepoint which is loaded with hit info from combos.
+     2. Next combo 
+        1. Loops through previous space points
+        2. calculates  d2 = (x_c -x_sp)^2 + (y_c-y_sp)^2 between combos and spacepoint
            if d2 < fSpacePointCriterion then adds combos hit info to that spacepoint
            which is not already in the spacepoint.
-        c) if that combo is not already added to existing spacepoint
+        3. if that combo is not already added to existing spacepoint
            then new spacepoint is made from the combo.
-4) If it found a spacepoint
-    i) For HMS-style chamber it would DestroyPoorSpacePoints if fRemove_Sppt_If_One_YPlane
-    ii) Presently if  HMS-style chamber calls SpacePointMultiWire()
-    iii) Calls ChooseSingleHit this looks to see if two hits in the same plane.
+4. If it found a spacepoint
+    1. For HMS-style chamber it would DestroyPoorSpacePoints if fRemove_Sppt_If_One_YPlane
+    2. Presently if  HMS-style chamber calls SpacePointMultiWire()
+    3. Calls ChooseSingleHit this looks to see if two hits in the same plane.
              If two hits then rejects on with longer drift time.
-    iv) calls SelectSpacePoints. Goes through the spacepoints and eliminates spacepoints
+    4. calls SelectSpacePoints. Goes through the spacepoints and eliminates spacepoints
           that do not have nhits >  min_hits and ncombos> min_combos 
           ( exception for easyspacepoint)
   */
@@ -379,9 +377,14 @@ Int_t THcDriftChamber::FindSpacePoints( void )
 // HMS Specific
 Int_t THcDriftChamber::FindEasySpacePoint_HMS(Int_t yplane_hitind,Int_t yplanep_hitind)
 {
-  // Simplified HMS find_space_point routing.  It is given all y hits and
-  // checks to see if all x-like hits are close enough together to make
-  // a space point.
+  /**
+     Simplified HMS find_space_point routing.  It is given all y hits and
+     checks to see if all x-like hits are close enough together to make
+     a space point.
+
+     This is used for the old style HMS drift chambers, so is not used for any
+     data since the new HMS chambers were installed before the Fall 2017 run.
+  */
 
   Int_t easy_space_point=0;
   Double_t yt = (fHits[yplane_hitind]->GetPos() + fHits[yplanep_hitind]->GetPos())/2.0;
@@ -425,9 +428,14 @@ Int_t THcDriftChamber::FindEasySpacePoint_HMS(Int_t yplane_hitind,Int_t yplanep_
 // SOS Specific
 Int_t THcDriftChamber::FindEasySpacePoint_SOS(Int_t xplane_hitind,Int_t xplanep_hitind)
 {
-  // Simplified SOS find_space_point routing.  It is given all x hits and
-  // checks to see if all y-like hits are close enough together to make
-  // a space point.
+  /**
+     Simplified SOS find_space_point routing.  It is given all x hits and
+     checks to see if all y-like hits are close enough together to make
+     a space point.
+
+     This is used for the SHMS and HMS (since Fall 2017) drift chambers which are
+     of the same style as the old SOS chambers (XUV).
+  */
 
   Int_t easy_space_point=0;
   Double_t xt = (fHits[xplane_hitind]->GetPos() + fHits[xplanep_hitind]->GetPos())/2.0;
@@ -691,18 +699,20 @@ Int_t THcDriftChamber::DestroyPoorSpacePoints()
 
 //_____________________________________________________________________________
 // HMS Specific?
-  /*
-   Purpose and Methods :  This routine loops over space points and
-                          looks at all hits in the space
-                          point. If more than 1 hit is in the same
-                          plane then the space point is cloned with
-                          all combinations of 1 wire per plane.  The
-                          requirements for cloning are:  1) at least
-                          4 planes fire, and 2) no more than 6 planes
-                          have multiple hits.
-  */
 Int_t THcDriftChamber::SpacePointMultiWire()
 {
+/**
+   This method is only used for the old style HMS chambers (before Fall 2017).
+
+   This routine loops over space points and
+   looks at all hits in the space
+   point. If more than 1 hit is in the same
+   plane then the space point is cloned with
+   all combinations of 1 wire per plane.  The
+   requirements for cloning are:  1) at least
+   4 planes fire, and 2) no more than 6 planes
+   have multiple hits.
+*/
   Int_t nhitsperplane[fNPlanes];
   THcDCHit* hits_plane[fNPlanes][MAX_HITS_PER_POINT];
 
@@ -841,8 +851,10 @@ Int_t THcDriftChamber::SpacePointMultiWire()
 // Generic
 void THcDriftChamber::ChooseSingleHit()
 {
-  // Look at all hits in a space point.  If two hits are in the same plane,
-  // reject the one with the longer drift time.
+  /**
+     Look at all hits in a space point.  If two hits are in the same plane,
+     reject the one with the longer drift time.
+  */
   for(Int_t isp=0;isp<fNSpacePoints;isp++) {
     THcSpacePoint* sp = (THcSpacePoint*)(*fSpacePoints)[isp];
     Int_t startnum = sp->GetNHits();
@@ -886,11 +898,13 @@ void THcDriftChamber::ChooseSingleHit()
 //_____________________________________________________________________________
 // Generic
 void THcDriftChamber::SelectSpacePoints()
-//    This routine goes through the list of space_points and space_point_hits
-//    found by find_space_points and only accepts those with
-//    number of hits > min_hits
-//    number of combinations > min_combos
 {
+  /**
+     This routine goes through the list of space_points and space_point_hits
+     found by find_space_points and only accepts those with
+     number of hits > min_hits
+     number of combinations > min_combos
+  */
   Int_t sp_count=0;
   for(Int_t isp=0;isp<fNSpacePoints;isp++) {
     // Include fEasySpacePoint because ncombos not filled in
@@ -929,16 +943,18 @@ void THcDriftChamber::SelectSpacePoints()
 
 void THcDriftChamber::CorrectHitTimes()
 {
-	//cout<<"next event"<<endl;
-  // Use the rough hit positions in the chambers to correct the drift time
-  // for hits in the space points.
-
-  // Assume all wires for a plane are read out on the same side (l/r or t/b).
-  // If the wire is closer to horizontal, read out left/right.  If nearer
-  // vertical, assume top/bottom.  (Note, this is not always true for the
-  // SOS u and v planes.  They have 1 card each on the side, but the overall
-  // time offset per card will cancel much of the error caused by this.  The
-  // alternative is to check by card, rather than by plane and this is harder.
+  /**
+   Use the rough hit positions in the chambers to correct the drift time
+   for hits in the space points.
+
+   Assume all wires for a plane are read out on the same side (l/r or t/b).
+   If the wire is closer to horizontal, read out left/right.  If nearer
+   vertical, assume top/bottom.  (Note, this is not always true for the
+   SOS u and v planes.  They have 1 card each on the side, but the overall
+   time offset per card will cancel much of the error caused by this.  The
+   alternative is to check by card, rather than by plane and this is harder.
+  */
+
   //if (fhdebugflagpr) cout << "In correcthittimes fNSpacePoints = " << fNSpacePoints << endl;
 
   for(Int_t isp=0;isp<fNSpacePoints;isp++) {
@@ -1071,9 +1087,11 @@ UInt_t THcDriftChamber::Count1Bits(UInt_t x)
 //_____________________________________________________________________________
 void THcDriftChamber::LeftRight()
 {
-  // For each space point,
-  // Fit stubs to all possible left-right combinations of drift distances
-  // and choose the set with the minimum chi**2.
+  /**
+     For each space point,
+     Fit stubs to all possible left-right combinations of drift distances
+     and choose the set with the minimum chi**2.
+  */
 
   for(Int_t isp=0; isp<fNSpacePoints; isp++) {
     // Build a bit pattern of which planes are hit
diff --git a/src/THcDriftChamberPlane.cxx b/src/THcDriftChamberPlane.cxx
index 6031e7f..1f9ef31 100644
--- a/src/THcDriftChamberPlane.cxx
+++ b/src/THcDriftChamberPlane.cxx
@@ -86,8 +86,12 @@ THaAnalysisObject::EStatus THcDriftChamberPlane::Init( const TDatime& date )
 Int_t THcDriftChamberPlane::ReadDatabase( const TDatime& date )
 {
 
-  // See what file it looks for
+  /**
+     Load the drift time to drift distance map.
 
+     Retrieve geometry parameters from main drift chamber detector object (THcDC)
+  */
+  
   char prefix[2];
   UInt_t NumDriftMapBins;
   Double_t DriftMapFirstBin;
@@ -321,9 +325,11 @@ Int_t THcDriftChamberPlane::FineProcess( TClonesArray& tracks )
 }
 Int_t THcDriftChamberPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit)
 {
-  // Extract the data for this plane from hit list
-  // Assumes that the hit list is sorted by plane, so we stop when the
-  // plane doesn't agree and return the index for the next hit.
+  /**
+     Extract the data for this plane from hit list
+     Assumes that the hit list is sorted by plane, so we stop when the
+     plane doesn't agree and return the index for the next hit.
+  */
 
   fHits->Clear();
 
-- 
GitLab