Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

AltAlgSliceList Class Reference

#include <AltAlgSliceList.h>

Inheritance diagram for AltAlgSliceList:

AlgBase List of all members.

Public Member Functions

 AltAlgSliceList ()
virtual ~AltAlgSliceList ()
virtual void RunAlg (AlgConfig &ac, CandHandle &ch, CandContext &cx)
virtual void Trace (const char *c) const

Private Member Functions

std::vector< TimeSlice_tgetSliceSeeds (CandStripHandleItr *cshItr, bool recursive_mode, PeakFinderConf_t conf=kDefault)
void peakFinder (std::vector< TimeSlice_t > &slice_seeds, PeakFinderConf_t conf) const
void reduceTimeWindows (CandStripHandleItr *cshItr, std::vector< TimeSlice_t > &slice_seeds)
std::vector< TimeSlice_tfindSmallerPeaks (CandStripHandleItr *cshItr)
void mergeSeeds (std::vector< TimeSlice_t > src, std::vector< TimeSlice_t > &target) const
void updateSliceSeedInfo (CandStripHandleItr *cshItr, std::vector< TimeSlice_t > &slice_seeds) const
void updateSingleSliceSeedInfo (CandStripHandleItr *cshItr, TimeSlice_t &seed) const
void removeNullSeeds (std::vector< TimeSlice_t > &slice_seeds) const
void resetSliceSeed (TimeSlice_t &seed) const
std::map< int, std::vector<
CandStripHandle * > > 
fillSliceSeeds (CandStripHandleItr cshItr, std::vector< TimeSlice_t > &slice_seeds)
void sortSlicesInTime (std::map< int, std::vector< CandStripHandle * > > &event_slices) const
void sortSlicesInPlaneNo (std::map< int, std::vector< CandStripHandle * > > &event_slices) const
TH1D * createSubsetTimeProfile (CandStripHandleItr *cshItr)
void getSnarlTimeBoundaries (CandStripHandleItr *cshItr, double &tmin, double &tmax) const
double getStripTime (CandStripHandle *csh, StripTime_t st, StripEnd::StripEnd_t se=StripEnd::kWhole) const
void initSliceFiltering (std::map< int, std::vector< CandStripHandle * > > &event_slices) const
void sliceMerger (std::map< int, std::vector< CandStripHandle * > > &event_slices) const
void eventClustering (std::map< int, std::vector< CandStripHandle * > > &event_slices)
void sliceSplitter (std::map< int, std::vector< CandStripHandle * > > &event_slices)
void Merge (const std::pair< int, int > &slices_to_merge, std::map< int, std::vector< CandStripHandle * > > &event_slices) const
void Split (int slice, std::vector< CandStripHandle * >::size_type n_separator, std::map< int, std::vector< CandStripHandle * > > &event_slices) const
void Split (int slice, std::vector< std::vector< CandStripHandle * > > groups, std::map< int, std::vector< CandStripHandle * > > &event_slices) const
int nextAvailableSliceId (const std::map< int, std::vector< CandStripHandle * > > &event_slices) const
std::vector< CandStripHandle * > dissolveMiniSlices (std::map< int, std::vector< CandStripHandle * > > &event_slices) const
void giveOrphanStripsForAdoption (std::vector< CandStripHandle * > orphan_strips, std::map< int, std::vector< CandStripHandle * > > &event_slices) const
int findBestSliceToAdoptAStrip (bool qweight, int dpln, double dt, CandStripHandle *orphan_strip, std::map< int, std::vector< CandStripHandle * > > *event_slices) const
std::vector< int > * findSlicesToBeEliminated (const std::map< int, std::vector< CandStripHandle * > > &event_slices) const
bool sliceShouldBeEliminated (std::map< int, std::vector< CandStripHandle * > >::const_iterator slice) const
bool smallNumberOfHitStrips (std::map< int, std::vector< CandStripHandle * > >::const_iterator slice) const
bool smallAmountOfCharge (std::map< int, std::vector< CandStripHandle * > >::const_iterator slice) const
bool noStripsInOneView (std::map< int, std::vector< CandStripHandle * > >::const_iterator slice) const
std::pair< int, int > findSlicesToMerge (std::map< int, std::vector< CandStripHandle * > > &event_slices) const
bool checkIfSlicesShouldBeMerged (std::vector< CandStripHandle * > &slice_0, std::vector< CandStripHandle * > &slice_1) const
bool checkSliceDistanceInTimeAndZ (std::vector< CandStripHandle * > &slice_0, std::vector< CandStripHandle * > &slice_1) const
bool checkSliceDistanceInTimeAndSpace (std::vector< CandStripHandle * > &slice_0, std::vector< CandStripHandle * > &slice_1) const
bool checkPeakTimeDifference (const std::vector< CandStripHandle * > &slice_0, const std::vector< CandStripHandle * > &slice_1) const
bool checkPeakZDifference (const std::vector< CandStripHandle * > &slice_0, const std::vector< CandStripHandle * > &slice_1) const
bool checkPeakUVDifference (const std::vector< CandStripHandle * > &slice_0, const std::vector< CandStripHandle * > &slice_1) const
bool checkLeadingTrailingEdgeDistance (std::vector< CandStripHandle * > &slice_0, std::vector< CandStripHandle * > &slice_1) const
double averageSliceZ (std::vector< CandStripHandle * > &slice, double tmin, double tmax) const
double minSliceTime (std::vector< CandStripHandle * > &slice) const
double maxSliceTime (std::vector< CandStripHandle * > &slice) const
bool singleKMeansIteration (std::map< int, std::vector< CandStripHandle * > > &event_slices)
int findBestSliceToHostStrip (const pair< int, CandStripHandle * > &slc_strip, const std::map< int, Centroid_t > &centroids, const std::map< int, std::vector< CandStripHandle * > > &event_slices) const
std::vector< int > checkForAlternativeSlices (const pair< int, CandStripHandle * > &slc_strip, const std::map< int, std::vector< CandStripHandle * > > &event_slices) const
WhichCandSlice_t characterizeCandidateSlices (int source, const std::vector< int > &alt_slices) const
bool needToFilterStrips (const std::map< int, std::vector< CandStripHandle * > > &event_slices) const
bool ZeroChargeInAView (const std::vector< CandStripHandle * > &slice) const
bool updateCentroids (std::map< int, Centroid_t > &centroids, std::map< int, std::vector< CandStripHandle * > > &event_slices)
Centroid_t computeSliceCentroid (const std::vector< CandStripHandle * > &slice) const
std::map< int, Centroid_tcomputeSlicesCentroid (const std::map< int, std::vector< CandStripHandle * > > &event_slices) const
int getClosestCentroid (CandStripHandle *strip, const std::map< int, Centroid_t > &centroids) const
int selectBestCandidateSlice (const pair< int, CandStripHandle * > &slc_strip, const std::vector< int > &cand_slices, const std::map< int, std::vector< CandStripHandle * > > &event_slices) const
std::multimap< double, int,
less< double > > 
MakeDistanceMap (CandStripHandle *strip, const std::vector< int > &cand_slices, const std::map< int, std::vector< CandStripHandle * > > &event_slices) const
int moreOccurences (std::multimap< double, int > ordered_slice_ids, int n) const
void rellocateStrip (int source, int target, CandStripHandle *strip, std::map< int, std::vector< CandStripHandle * > > &event_slices) const
void assignMuonSpectrHits2Slices (CandStripHandleItr cshItr, std::map< int, std::vector< CandStripHandle * > > &event_slices)
std::vector< int > slicesActiveUpstreamOfMuSpec (const std::map< int, std::vector< CandStripHandle * > > &event_slices) const
std::map< int, std::vector<
CandStripHandle * > > 
getMuSpecSlices (CandStripHandleItr cshItr)
void sliceMatcher (std::map< int, std::vector< CandStripHandle * > > &mu_slices, std::map< int, std::vector< CandStripHandle * > > &event_slices) const
bool findMatchForMuSpecSlice (std::vector< CandStripHandle * > mu_strips, std::vector< int > slice_ids, std::map< int, std::vector< CandStripHandle * > > &event_slices) const
bool sliceHasStripsInUpstreamMuSpectrometer (const std::vector< CandStripHandle * > &mu_strips) const
void addMuSpecStripsToExistingSlice (const std::vector< CandStripHandle * > &mu_strips, std::vector< CandStripHandle * > &slice_strips) const
void newSliceToHostMuSpecStrips (const std::vector< CandStripHandle * > &mu_strips, std::map< int, std::vector< CandStripHandle * > > &event_slices) const
double averageTimeAtBeginOfDownstreamSlice (std::vector< CandStripHandle * > &strips) const
double averageTimeAtEndOfUpstreamSlice (std::vector< CandStripHandle * > &strips) const
double averageTime (const std::vector< CandStripHandle * > &strips, std::vector< CandStripHandle * >::const_iterator end) const
void printStripList (CandStripHandleItr cshItr, const char *comment="") const
void printSliceSeeds (const std::vector< TimeSlice_t > &slice_seeds, const char *comment="") const
void printSliceSeed (const TimeSlice_t &seed) const
void printSlices (const std::map< int, std::vector< CandStripHandle * > > &event_slices, const char *comments="") const
void printSlice (std::map< int, std::vector< CandStripHandle * > >::const_iterator slice) const
void printSlice (const std::vector< CandStripHandle * > &slice) const
void printStrip (const CandStripHandle *strip) const
void printTimeBin (int bin, const TH1D *time_profile, const char *comment="") const
std::string asString (WhichCandSlice_t which_slice) const
std::string asString (PeakFinderConf_t conf) const
void display (std::map< int, std::vector< CandStripHandle * > > event_slices, const char *comment="")
void eventDisplay (TCanvas *c, std::map< int, std::vector< CandStripHandle * > > event_slices)
void eventDisplaySingleSlice (TCanvas *c, int sliceKey, std::map< int, std::vector< CandStripHandle * > > event_slices)
void plot3DClusters (TCanvas *c, std::map< int, std::vector< CandStripHandle * > > event_slices)
void buildCandidates (std::map< int, std::vector< CandStripHandle * > > &event_slices, CandHandle &ch, CandContext &cx)
void getAlgorithmConfiguration (const AlgConfig &ac)
void internalInit (void)

Private Attributes

int fGrfxDebugGraphics
int fGrfxTimeProfileLogView
int fPkfPeakThreshold
int fPkfNSuccessiveEmptyBins
int fPkfMuSpecPeakThreshold
int fPkfMuSpecNSuccessiveEmptyBins
int fPkfLowPeakThreshold
int fPkfLowNSuccessiveEmptyBins
int fPkfNofMergedTimeBins
int fPkfTimeWindowBefPeak
int fPkfTimeWindowAftPeak
int fOrphanStripsPlaneWindow
int fKMeansPlaneWindow
int fMuSpecNUpstrPlanes
int fMuSpecNHitStripsBefSpectr
int fMuSpecNPlnBefSpectr
int fMinNoHitStrips
bool fPkfWeightProfileWithCharge
bool fPkfRecursivePeakSearch
bool fRefinementDissolving
bool fRefinementMerging
bool fRefinementKMeansClustering
bool fRefinementMSTClustering
bool fMuSpecSuppressUnmatchedSlices
bool fOrphanStripsQWeight
double fOrphanStripsTimeWindow
double fKMeansTimeWindow
double fKMeansTPosWindow
double fMuSpecTimeAftUpstrActivity
double fMuSpecTimeBefUpstrActivity
double fTimeResolution
double fTimeDiffBetweenPeaks
double fZDiffBetweenPeaks
double fZDiffBetweenEnds
double fUVDiffBetweenPeaks
double fMinCharge
int fPeakFinderNestingLevel
int fkMeansIteration
int fNTimeBins
bool fUpdateCentroids
double fTimeProfileMax
TH1D * fTimeProfile
double ftmin
double ftmax
TH1D * fSubsetTimeProfile
double fSubsettmin
double fSubsettmax
MsgFormat fFmtStp
MsgFormat fFmtPln
MsgFormat fFmtSlc
MsgFormat fFmtTime
MsgFormat fFmtQ

Constructor & Destructor Documentation

AltAlgSliceList::AltAlgSliceList  ) 
 

Definition at line 206 of file AltAlgSliceList.cxx.

References fFmtPln, fFmtQ, fFmtSlc, fFmtStp, fFmtTime, and internalInit().

00207 {
00208   LEA_CTOR;
00209 
00210   internalInit(); // initialize private data members
00211 
00212   //-- Msg formatting objects
00213   fFmtStp  = MsgFormat("%3d");
00214   fFmtPln  = MsgFormat("%3d");
00215   fFmtSlc  = MsgFormat("%3d");
00216   fFmtTime = MsgFormat("%11.10f");
00217   fFmtQ    = MsgFormat("%6.3f");
00218 }

AltAlgSliceList::~AltAlgSliceList  )  [virtual]
 

Definition at line 220 of file AltAlgSliceList.cxx.

00221 {
00222   LEA_DTOR;
00223 }


Member Function Documentation

void AltAlgSliceList::addMuSpecStripsToExistingSlice const std::vector< CandStripHandle * > &  mu_strips,
std::vector< CandStripHandle * > &  slice_strips
const [private]
 

Definition at line 3289 of file AltAlgSliceList.cxx.

Referenced by findMatchForMuSpecSlice(), and sliceMatcher().

03292 {
03293   std::vector<CandStripHandle *>::const_iterator mu_strip_iter;
03294   for(mu_strip_iter = mu_strips.begin();
03295            mu_strip_iter != mu_strips.end(); ++mu_strip_iter)
03296                                      slice_strips.push_back( *mu_strip_iter );
03297 
03298   sort(slice_strips.begin(), slice_strips.end(), min_t());
03299 }

void AltAlgSliceList::assignMuonSpectrHits2Slices CandStripHandleItr  cshItr,
std::map< int, std::vector< CandStripHandle * > > &  event_slices
[private]
 

Definition at line 3022 of file AltAlgSliceList.cxx.

References getMuSpecSlices(), MSG, printSlices(), sliceMatcher(), and sortSlicesInTime().

Referenced by RunAlg().

03024 {
03025 // Method for assigning muon spectrometer strips to upstream detector slices
03026 
03027   // Get slices in the muon spectrometer
03028 
03029   MSG("AltAlg", Msg::kVerbose)
03030                      << "[-] Slicing the muon spectrometer activity" << endl;
03031 
03032   std::map<int, std::vector<CandStripHandle *> > mu_slices =
03033                                                      getMuSpecSlices(cshItr);
03034   printSlices(mu_slices, "muon spectrometer slices");
03035 
03036   // Try to append muon spectrometer slices to existing slice (if one exists
03037   // quite close in space & time). Otherwise, form new slices or append to
03038   // a rubbish slice made exclusively from unmatched mu-spectr. strips...
03039   // to slices.
03040 
03041   MSG("AltAlg", Msg::kVerbose)
03042      << "[-] examine mu-spectrometer & upstream detector slices for matches"
03043      << endl;
03044 
03045   sortSlicesInTime(event_slices);
03046 
03047   sliceMatcher(mu_slices, event_slices);
03048 }

std::string AltAlgSliceList::asString PeakFinderConf_t  conf  )  const [private]
 

Definition at line 1739 of file AltAlgSliceList.cxx.

01740 {
01741   switch( conf ) {
01742   case (kDefault):        return std::string("[default config]");      break;
01743   case (kLowActivity):    return std::string("[low activity config]"); break;
01744   case (kMuSpectrometer): return std::string("[mu-spectr. config]");   break;
01745   default:                return std::string(" --- ");
01746   }
01747 }

std::string AltAlgSliceList::asString WhichCandSlice_t  which_slice  )  const [private]
 

Definition at line 1719 of file AltAlgSliceList.cxx.

Referenced by findBestSliceToHostStrip(), and peakFinder().

01720 {
01721   switch( which_slices ) {
01722   case (eNone):
01723       return std::string("isolated strip - no really good match found");
01724       break;
01725   case (eSame):
01726       return std::string("no action - this strip is @ home");
01727       break;
01728   case (eOther):
01729       return std::string("a single other candidate was found");
01730       break;
01731   case (eMany):
01732       return std::string("many 'candidates' - need to resolve the ambiguity");
01733       break;
01734   default:
01735       return std::string(" --- ");
01736   }
01737 }

double AltAlgSliceList::averageSliceZ std::vector< CandStripHandle * > &  slice,
double  tmin,
double  tmax
const [private]
 

Definition at line 2433 of file AltAlgSliceList.cxx.

References MSG.

Referenced by checkLeadingTrailingEdgeDistance().

02435 {
02436 // Computes a (charge weighted) average longitudinal position of the input
02437 // strips for which time e [tmin, tmax]
02438 //
02439   std::vector<CandStripHandle *>::iterator strip_iter = partition(
02440                 slice.begin(), slice.end(), is_in_t_window_noref(tmin, tmax));
02441 
02442   double q  = accumulate(slice.begin(), strip_iter, 0.0, sum_q() );
02443   double qz = accumulate(slice.begin(), strip_iter, 0.0, sum_qz());
02444 
02445   // remove this eventually
02446   if(q==0) {
02447     MSG("AltAlg", Msg::kWarning) << "Zero charge in one view" << endl;
02448     return -999;
02449   }
02450 
02451   assert(q>0);
02452 
02453   return qz/q;
02454 }

double AltAlgSliceList::averageTime const std::vector< CandStripHandle * > &  strips,
std::vector< CandStripHandle * >::const_iterator  end
const [private]
 

Definition at line 3364 of file AltAlgSliceList.cxx.

References MSG.

Referenced by averageTimeAtBeginOfDownstreamSlice(), and averageTimeAtEndOfUpstreamSlice().

03367 {
03368   double qt = accumulate( strips.begin(), end, 0.0, sum_qtime() );
03369   double q  = accumulate( strips.begin(), end, 0.0, sum_q()     );
03370 
03371   //eventually assert(q!=0)
03372 
03373   if(q==0) {
03374       MSG("AltAlg", Msg::kWarning)
03375            << "Charge = " << q << " -- This should not be happenning" << endl;
03376       return 0;
03377   } else  return qt/q;
03378 }

double AltAlgSliceList::averageTimeAtBeginOfDownstreamSlice std::vector< CandStripHandle * > &  strips  )  const [private]
 

Definition at line 3342 of file AltAlgSliceList.cxx.

References averageTime(), fMuSpecNUpstrPlanes, and kMuSpec1stPlane.

Referenced by findMatchForMuSpecSlice().

03344 {
03345   std::vector<CandStripHandle *>::iterator mu_end = partition(
03346                   mu_strips.begin(), mu_strips.end(),
03347                   is_in_z_window_noref( kMuSpec1stPlane,
03348                                         kMuSpec1stPlane+fMuSpecNUpstrPlanes));
03349 
03350   return averageTime( mu_strips, mu_end );
03351 }

double AltAlgSliceList::averageTimeAtEndOfUpstreamSlice std::vector< CandStripHandle * > &  strips  )  const [private]
 

Definition at line 3353 of file AltAlgSliceList.cxx.

References averageTime(), fMuSpecNPlnBefSpectr, and kMuSpec1stPlane.

Referenced by findMatchForMuSpecSlice().

03355 {
03356   std::vector<CandStripHandle *>::iterator slc_end = partition(
03357                  slc_strips.begin(), slc_strips.end(),
03358                  is_in_z_window_noref( kMuSpec1stPlane - fMuSpecNPlnBefSpectr,
03359                                        kMuSpec1stPlane - 1));
03360 
03361   return averageTime(slc_strips, slc_end );
03362 }

void AltAlgSliceList::buildCandidates std::map< int, std::vector< CandStripHandle * > > &  event_slices,
CandHandle ch,
CandContext cx
[private]
 

Definition at line 3492 of file AltAlgSliceList.cxx.

References CandHandle::AddDaughterLink(), fFmtSlc, AlgFactory::GetAlgHandle(), AlgFactory::GetInstance(), CandContext::GetMom(), CandSlice::MakeCandidate(), MSG, and sortSlicesInTime().

Referenced by RunAlg().

03495 {
03496   sortSlicesInTime(event_slices);
03497 
03498   //-- Get an AlgFactory - ask it for a handle to AltAlgSlice algorithm
03499   //   and create a candidate context to supply the algorithm with
03500 
03501   AlgFactory & af = AlgFactory::GetInstance();
03502   AlgHandle    ah = af.GetAlgHandle("AltAlgSlice","default");
03503   
03504   CandContext ccx(this, cx.GetMom());
03505 
03506   std::map<int, std::vector<CandStripHandle *> >::const_iterator slc_iter;
03507   
03508   for( slc_iter = event_slices.begin(); 
03509                                  slc_iter != event_slices.end(); ++slc_iter) {
03510  
03511      MSG("AltAlg", Msg::kDebug) 
03512         << " Slice: " << fFmtSlc( (*slc_iter).first )
03513         << " / Running MakeCandidate on AltAlgSlice & Adding Doughter Link" 
03514         << endl;
03515 
03516      AltWrapperStlVecStripHandle vec_wrapper( (*slc_iter).second );
03517      ccx.SetDataIn( & vec_wrapper); 
03518      CandSliceHandle slchandle = CandSlice::MakeCandidate(ah,ccx);
03519      ch.AddDaughterLink(slchandle);     
03520   }
03521 }

WhichCandSlice_t AltAlgSliceList::characterizeCandidateSlices int  source,
const std::vector< int > &  alt_slices
const [private]
 

Definition at line 2806 of file AltAlgSliceList.cxx.

References WhichCandSlice_t.

Referenced by findBestSliceToHostStrip().

02808 {
02809   if( alt_slices.size() == 0 )     return eNone;
02810   else if ( alt_slices.size() == 1 ) {
02811 
02812        if(alt_slices[0] == source) return eSame;
02813        else                        return eOther;
02814 
02815   } else                           return eMany;
02816 
02817   return eSame;
02818 }

std::vector< int > AltAlgSliceList::checkForAlternativeSlices const pair< int, CandStripHandle * > &  slc_strip,
const std::map< int, std::vector< CandStripHandle * > > &  event_slices
const [private]
 

Definition at line 2756 of file AltAlgSliceList.cxx.

References fKMeansPlaneWindow, fKMeansTimeWindow, and fKMeansTPosWindow.

Referenced by findBestSliceToHostStrip().

02759 {
02760 // Make a list with all slices that could possibly host the input strip
02761 
02762   std::vector<int> alt_slices;
02763   std::map<int, std::vector<CandStripHandle *> >::const_iterator slice_iter;
02764 
02765   int source = slc_strip.first;
02766   CandStripHandle * current_strip = slc_strip.second;
02767 
02768   // find slices that have hit strips in a time, z, tpos window centered at the
02769   // current strip...
02770 
02771   for(slice_iter = event_slices.begin();
02772                             slice_iter != event_slices.end(); ++slice_iter) {
02773 
02774       int n = count_if(
02775                slice_iter->second.begin(), slice_iter->second.end(),
02776                is_in_tztpos_window(current_strip, fKMeansTimeWindow,
02777                                    fKMeansPlaneWindow, fKMeansTPosWindow) );
02778       if( slice_iter->first == source ) n--;
02779 
02780       if(n > 0) alt_slices.push_back( slice_iter->first );
02781   }
02782 
02783   // if none is found, relax the criteria and check in a t, z window centered
02784   // at the current strip...
02785 
02786   if( alt_slices.size() == 0 ) {
02787 
02788        for(slice_iter = event_slices.begin();
02789                             slice_iter != event_slices.end(); ++slice_iter) {
02790 
02791             int n = count_if(
02792                          slice_iter->second.begin(), slice_iter->second.end(),
02793                          is_in_tz_window(current_strip,
02794                                     fKMeansTimeWindow, 2*fKMeansPlaneWindow) );
02795 
02796             if( slice_iter->first == source ) n--;
02797 
02798             if(n > 0) alt_slices.push_back( slice_iter->first );
02799        }
02800   }
02801 
02802   // return whatever was found - if it is still empty it will be handled later
02803   return alt_slices;
02804 }

bool AltAlgSliceList::checkIfSlicesShouldBeMerged std::vector< CandStripHandle * > &  slice_0,
std::vector< CandStripHandle * > &  slice_1
const [private]
 

Definition at line 2189 of file AltAlgSliceList.cxx.

References checkSliceDistanceInTimeAndSpace().

Referenced by findSlicesToMerge().

02192 {
02193 // Applies all the slice merging criteria...
02194 
02195   std::vector<bool> check_list;
02196   std::vector<bool>::iterator check;
02197 
02198   check_list.push_back( checkSliceDistanceInTimeAndSpace( slice_0, slice_1 ) );
02199   // --- push_back() more checks later...
02200   //
02201 
02202   bool merge_them = true;
02203             for(check = check_list.begin();
02204                   check != check_list.end(); ++check)
02205                                          merge_them = merge_them && (*check);
02206   return merge_them;
02207 }

bool AltAlgSliceList::checkLeadingTrailingEdgeDistance std::vector< CandStripHandle * > &  slice_0,
std::vector< CandStripHandle * > &  slice_1
const [private]
 

Definition at line 2387 of file AltAlgSliceList.cxx.

References averageSliceZ(), maxSliceTime(), minSliceTime(), and MSG.

Referenced by checkSliceDistanceInTimeAndSpace(), and checkSliceDistanceInTimeAndZ().

02390 {
02391 // Checks the longitudinal (z) distance between the leading edge of the latest
02392 // slice and the trailing edge of the earliest one...
02393 // Returns true if the distance is smaller than fZDiffBetweenEnds
02394 // This is hoped to prevent slice breaking when use in conjunction with
02395 // temporal cuts.
02396 //
02397   double q0  = accumulate(slice_0.begin(), slice_0.end(), 0.0, sum_q());
02398   double qt0 = accumulate(slice_0.begin(), slice_0.end(), 0.0, sum_qtime());
02399 
02400   double q1  = accumulate(slice_1.begin(), slice_1.end(), 0.0, sum_q());
02401   double qt1 = accumulate(slice_1.begin(), slice_1.end(), 0.0, sum_qtime());
02402 
02403   // remove this eventually
02404   if(q0 == 0 || q1 == 0) {
02405     MSG("AltAlg", Msg::kWarning) << "Zero charge in one view" << endl;
02406     return false;
02407   }
02408 
02409   assert(q0 > 0); // slices that are striped out of their strips should
02410   assert(q1 > 0); // be removed from the slice map
02411 
02412   double t0 = qt0 / q0;
02413   double t1 = qt1 / q1;
02414 
02415   double z_earliest, z_latest;
02416 
02417   if(t0 < t1) {
02418       z_earliest = averageSliceZ( slice_0, t0, maxSliceTime(slice_0) );
02419       z_latest   = averageSliceZ( slice_1, minSliceTime(slice_1), t1 );
02420   } else {
02421       z_earliest = averageSliceZ( slice_1, t1, maxSliceTime(slice_1) );
02422       z_latest   = averageSliceZ( slice_0, minSliceTime(slice_0), t0 );
02423   }
02424 
02425   MSG("AltAlg", Msg::kVerbose)
02426      << "     |--> leading - trailing edge z difference = "
02427                                              << z_earliest - z_latest << endl;
02428 
02429   if(fabs(z_earliest-z_latest) < fZDiffBetweenEnds)  return true;
02430   else return false;
02431 }

bool AltAlgSliceList::checkPeakTimeDifference const std::vector< CandStripHandle * > &  slice_0,
const std::vector< CandStripHandle * > &  slice_1
const [private]
 

Definition at line 2264 of file AltAlgSliceList.cxx.

References fFmtTime, and MSG.

Referenced by checkSliceDistanceInTimeAndSpace(), and checkSliceDistanceInTimeAndZ().

02267 {
02268 // Checks the difference between the charge weighted average times of the two
02269 // input slices.
02270 // Returns true if dt < fTimeDiffBetweenPeaks
02271 
02272   double q0  = accumulate(slice_0.begin(), slice_0.end(), 0.0, sum_q());
02273   double qt0 = accumulate(slice_0.begin(), slice_0.end(), 0.0, sum_qtime());
02274 
02275   double q1  = accumulate(slice_1.begin(), slice_1.end(), 0.0, sum_q());
02276   double qt1 = accumulate(slice_1.begin(), slice_1.end(), 0.0, sum_qtime());
02277 
02278   //remove this eventually
02279   if(q0 == 0 || q1 == 0) {
02280     MSG("AltAlg", Msg::kWarning) << "Zero charge in one view" << endl;
02281     return false;
02282   }
02283 
02284   assert(q0 > 0); // slices that are striped out of their strips should
02285   assert(q1 > 0); // be removed from the slice map
02286 
02287   double t0 = qt0 / q0;
02288   double t1 = qt1 / q1;
02289 
02290   MSG("AltAlg", Msg::kVerbose)
02291             << "     |--> peak time difference = " << fFmtTime(t0-t1) << endl;
02292 
02293   return ( fabs(t0-t1) < fTimeDiffBetweenPeaks );
02294 }

bool AltAlgSliceList::checkPeakUVDifference const std::vector< CandStripHandle * > &  slice_0,
const std::vector< CandStripHandle * > &  slice_1
const [private]
 

Definition at line 2327 of file AltAlgSliceList.cxx.

References copy(), fUVDiffBetweenPeaks, and MSG.

Referenced by checkSliceDistanceInTimeAndSpace().

02330 {
02331 // Checks the difference between the charged-weighted transverse position
02332 // of the input slices.
02333 // Returns true if du < fUVDiffBetweenPeaks && dv < fUVDiffBetweenPeaks
02334 
02335   //-- u-v partition
02336   std::vector<CandStripHandle *> slice_0_cp( slice_0.size() );
02337   std::vector<CandStripHandle *> slice_1_cp( slice_1.size() );
02338 
02339   copy( slice_0.begin(), slice_0.end(), slice_0_cp.begin() );
02340   copy( slice_1.begin(), slice_1.end(), slice_1_cp.begin() );
02341 
02342   std::vector<CandStripHandle *>::iterator part_iter_0 = partition(
02343                         slice_0_cp.begin(), slice_0_cp.end(), is_v_view() );
02344   std::vector<CandStripHandle *>::iterator part_iter_1 = partition(
02345                         slice_1_cp.begin(), slice_1_cp.end(), is_v_view() );
02346 
02347   // slice 0
02348   double q_v_0 = accumulate(slice_0_cp.begin(), part_iter_0, 0.0, sum_q());
02349   double qtpos_v_0 = accumulate(
02350                         slice_0_cp.begin(), part_iter_0, 0.0, sum_qtpos());
02351 
02352   double q_u_0 = accumulate(part_iter_0, slice_0_cp.end(),   0.0, sum_q());
02353   double qtpos_u_0 = accumulate(
02354                         part_iter_0, slice_0_cp.end(),   0.0, sum_qtpos());
02355 
02356   // slice 1
02357   double q_v_1 = accumulate(slice_1_cp.begin(), part_iter_1, 0.0, sum_q());
02358   double qtpos_v_1 = accumulate(
02359                         slice_1_cp.begin(), part_iter_1, 0.0, sum_qtpos());
02360 
02361   double q_u_1 = accumulate(part_iter_1, slice_1_cp.end(),   0.0, sum_q());
02362   double qtpos_u_1 = accumulate(
02363                         part_iter_1, slice_1_cp.end(),   0.0, sum_qtpos());
02364 
02365   // remove this eventually
02366   if(q_v_0 == 0 || q_u_0 == 0 || q_v_1 == 0 || q_u_1 == 0) {
02367     MSG("AltAlg", Msg::kWarning) << "Zero charge in one view" << endl;
02368     return false;
02369   }
02370   assert(q_v_0 > 0); // slices that are striped out of their strips should
02371   assert(q_u_0 > 0); // be removed from the slice map
02372   assert(q_v_1 > 0);
02373   assert(q_u_1 > 0);
02374 
02375   double u0 = qtpos_u_0 / q_u_0;
02376   double v0 = qtpos_v_0 / q_v_0;
02377   double u1 = qtpos_u_1 / q_u_1;
02378   double v1 = qtpos_v_1 / q_v_1;
02379 
02380   MSG("AltAlg", Msg::kVerbose)
02381          << "     |--> d<u> = " << u0-u1 << " and d<v> = " << v0 - v1 << endl;
02382 
02383   return ( fabs(v0-v1) < fUVDiffBetweenPeaks &&
02384                                           fabs(u0-u1) < fUVDiffBetweenPeaks );
02385 }

bool AltAlgSliceList::checkPeakZDifference const std::vector< CandStripHandle * > &  slice_0,
const std::vector< CandStripHandle * > &  slice_1
const [private]
 

Definition at line 2296 of file AltAlgSliceList.cxx.

References MSG.

Referenced by checkSliceDistanceInTimeAndSpace(), and checkSliceDistanceInTimeAndZ().

02299 {
02300 // Checks the difference between the charged-weighted longitudinal position
02301 // of the input slices.
02302 // Returns true if dz < fZDiffBetweenPeaks
02303 
02304   double q0  = accumulate(slice_0.begin(), slice_0.end(), 0.0, sum_q());
02305   double qz0 = accumulate(slice_0.begin(), slice_0.end(), 0.0, sum_qz());
02306 
02307   double q1  = accumulate(slice_1.begin(), slice_1.end(), 0.0, sum_q());
02308   double qz1 = accumulate(slice_1.begin(), slice_1.end(), 0.0, sum_qz());
02309 
02310   //remove this eventually
02311   if(q0 == 0 || q1 == 0) {
02312     MSG("AltAlg", Msg::kWarning) << "Zero charge in one view" << endl;
02313     return false;
02314   }
02315 
02316   assert(q0 > 0); // slices that are striped out of their strips should
02317   assert(q1 > 0); // be removed from the slice map
02318 
02319   double z0 = qz0 / q0;
02320   double z1 = qz1 / q1;
02321 
02322   MSG("AltAlg", Msg::kVerbose) << "     |--> d<z> = " << z0-z1 << endl;
02323 
02324   return ( fabs(z0-z1) < fZDiffBetweenPeaks );
02325 }

bool AltAlgSliceList::checkSliceDistanceInTimeAndSpace std::vector< CandStripHandle * > &  slice_0,
std::vector< CandStripHandle * > &  slice_1
const [private]
 

Definition at line 2235 of file AltAlgSliceList.cxx.

References checkLeadingTrailingEdgeDistance(), checkPeakTimeDifference(), checkPeakUVDifference(), checkPeakZDifference(), and MSG.

Referenced by checkIfSlicesShouldBeMerged().

02238 {
02239 // A simple test to check whether two slices should be merged on the basis of
02240 // small time & z,u,v difference
02241 
02242   // check the time difference between the pulse height peaks
02243   if( checkPeakTimeDifference(slice_0, slice_1) ) {
02244 
02245     // check the z-difference between the pulse height peaks
02246     if( checkPeakZDifference(slice_0, slice_1) ) {
02247 
02248         // check the z-diff. between the latest hits of the earliest slice
02249         // and the earliest hits of the latest slice....
02250         if( checkLeadingTrailingEdgeDistance(slice_0, slice_1) ) {
02251 
02252             // check uv difference
02253             if( checkPeakUVDifference(slice_0, slice_1) ) {
02254                   MSG("AltAlg", Msg::kVerbose)
02255                               << "     |--[*] Slices will be merged" << endl;
02256                   return true;
02257             }
02258         }
02259     }
02260   }
02261   return false;
02262 }

bool AltAlgSliceList::checkSliceDistanceInTimeAndZ std::vector< CandStripHandle * > &  slice_0,
std::vector< CandStripHandle * > &  slice_1
const [private]
 

Definition at line 2209 of file AltAlgSliceList.cxx.

References checkLeadingTrailingEdgeDistance(), checkPeakTimeDifference(), checkPeakZDifference(), and MSG.

02212 {
02213 // A simple test to check whether two slices should be merged on the basis of
02214 // small time & z difference
02215 
02216   // check the time difference between the pulse height peaks
02217   if( checkPeakTimeDifference(slice_0, slice_1) ) {
02218 
02219     // check the z-difference between the pulse height peaks
02220     if( checkPeakZDifference(slice_0, slice_1) ) {
02221 
02222         // check the z-diff. between the latest hits of the earliest slice
02223         // and the earliest hits of the latest slice....
02224         if( checkLeadingTrailingEdgeDistance(slice_0, slice_1) ) {
02225 
02226             MSG("AltAlg", Msg::kVerbose)
02227                               << "     |--[*] Slices will be merged" << endl;
02228             return true;
02229         }
02230     }
02231   }
02232   return false;
02233 }

Centroid_t AltAlgSliceList::computeSliceCentroid const std::vector< CandStripHandle * > &  slice  )  const [private]
 

Definition at line 2661 of file AltAlgSliceList.cxx.

References Centroid_t, copy(), centroid::tu, centroid::tv, centroid::u, centroid::v, centroid::zu, and centroid::zv.

Referenced by computeSlicesCentroid().

02663 {
02664 // Method for computing the centroids of the input reconstructed slice.
02665 //
02666   Centroid_t centroid;
02667 
02668   //-- u-v partition
02669   std::vector<CandStripHandle *> slice_cp( slice.size() );
02670 
02671   copy( slice.begin(), slice.end(), slice_cp.begin() );
02672 
02673   std::vector<CandStripHandle *>::iterator part_iter = partition(
02674                              slice_cp.begin(), slice_cp.end(), is_v_view() );
02675 
02676   //-- accumulate
02677   double sum_q_v = accumulate(
02678                           slice_cp.begin(), part_iter, 0.0, sum_q());
02679   double sum_qtpos_v = accumulate(
02680                       slice_cp.begin(), part_iter, 0.0, sum_qtpos());
02681   double sum_qz_v = accumulate(
02682                          slice_cp.begin(), part_iter, 0.0, sum_qz());
02683   double sum_qtime_v = accumulate(
02684                       slice_cp.begin(), part_iter, 0.0, sum_qtime());
02685 
02686   double sum_q_u = accumulate(
02687                           part_iter, slice_cp.end(),   0.0, sum_q());
02688   double sum_qtpos_u = accumulate(
02689                       part_iter, slice_cp.end(),   0.0, sum_qtpos());
02690   double sum_qz_u = accumulate(
02691                          part_iter, slice_cp.end(),   0.0, sum_qz());
02692   double sum_qtime_u = accumulate(
02693                       part_iter, slice_cp.end(),   0.0, sum_qtime());
02694 
02695   assert(sum_q_u > 0);
02696   assert(sum_q_v > 0);
02697 
02698   centroid.u  = sum_qtpos_u    / sum_q_u;
02699   centroid.v  = sum_qtpos_v    / sum_q_v;
02700   centroid.zu = sum_qz_u       / sum_q_u;
02701   centroid.zv = sum_qz_v       / sum_q_v;
02702   centroid.tu = sum_qtime_u    / sum_q_u;
02703   centroid.tv = sum_qtime_v    / sum_q_v;
02704 
02705   return centroid;
02706 }

std::map< int, Centroid_t > AltAlgSliceList::computeSlicesCentroid const std::map< int, std::vector< CandStripHandle * > > &  event_slices  )  const [private]
 

Definition at line 2637 of file AltAlgSliceList.cxx.

References Centroid_t, and computeSliceCentroid().

Referenced by updateCentroids().

02639 {
02640 // Method for computing the centroids of the input reconstructed slices.
02641 //
02642   std::map<int, Centroid_t> clusters_centroid;
02643 
02644   std::map<int, std::vector<CandStripHandle *> >::const_iterator slice_iter;
02645 
02646   for(slice_iter = event_slices.begin();
02647                             slice_iter != event_slices.end(); ++slice_iter) {
02648 
02649       std::vector<CandStripHandle *> slice_strips = slice_iter->second;
02650 
02651       Centroid_t centroid = computeSliceCentroid(slice_strips);
02652 
02653       clusters_centroid.insert(
02654             std::map<int, Centroid_t>::value_type(
02655                                               slice_iter->first, centroid) );
02656   }
02657 
02658   return clusters_centroid;
02659 }

TH1D * AltAlgSliceList::createSubsetTimeProfile CandStripHandleItr *  cshItr  )  [private]
 

Definition at line 3314 of file AltAlgSliceList.cxx.

References fTimeProfile, CandStripHandle::GetCharge(), and CandStripHandle::GetCorrBegTime().

Referenced by findSmallerPeaks(), and getMuSpecSlices().

03315 {
03316 // Creates the time-profile for a subset of hit strips.
03317 // The selection of the strip subset (i.e. muon spectrimeter hits only etc)
03318 // is *encapsulated* in the CandStripHandleItr (a proper selection on its
03319 // NavSet using NavTools must have preceded the call to this function).
03320 // The time profile histogram is instantiated by cloning and reseting the
03321 // spill time-profile. This guarantees that the time-profile of all subsets
03322 // have the same bin size (corresponding to the same time resolution)
03323 // The returned object is owned by the calling function.
03324 //
03325   TH1D * subset_time_profile = (TH1D *) fTimeProfile->Clone();
03326   subset_time_profile->Reset("ICE"); // "ICE"--check that I remember correctly
03327 
03328   cshItr->ResetFirst();
03329   while( CandStripHandle * striph = cshItr->Ptr() ) {
03330 
03331      (fPkfWeightProfileWithCharge) ?
03332           subset_time_profile->Fill( striph->GetCorrBegTime(),
03333                                      striph->GetCharge()  )  :
03334           subset_time_profile->Fill( striph->GetCorrBegTime() )  ;
03335 
03336      cshItr->Next();
03337   }
03338 
03339   return subset_time_profile;
03340 }

void AltAlgSliceList::display std::map< int, std::vector< CandStripHandle * > >  event_slices,
const char *  comment = ""
[private]
 

Definition at line 495 of file AltAlgSliceList.cxx.

References eventDisplay(), and MSG.

Referenced by RunAlg().

00498 {
00499   MSG("AltAlg", Msg::kInfo)
00500                  << "--> Debug graphics requested - start drawing..." << endl;
00501 
00502   TCanvas * c = new TCanvas("c", comment, 20, 20, 800, 800);
00503 
00504   eventDisplay(c,event_slices);
00505   delete c;
00506 
00507   MSG("AltAlg", Msg::kInfo)
00508           << "<-- Graphics displayed - continuing with slice reco..." << endl;
00509 }

std::vector< CandStripHandle * > AltAlgSliceList::dissolveMiniSlices std::map< int, std::vector< CandStripHandle * > > &  event_slices  )  const [private]
 

Definition at line 1876 of file AltAlgSliceList.cxx.

References findSlicesToBeEliminated(), and MSG.

Referenced by initSliceFiltering().

01878 {
01879 // Removes bad slices from the slices-map and creates a list of orphan
01880 // strips to be appended in nearby slices.
01881 //
01882   MSG("AltAlg", Msg::kDebug)
01883                  << " |-->[-] Trying to eliminate some 'fake' slices" << endl;
01884 
01885   MSG("AltAlg", Msg::kDebug)
01886             << "      |---> Current number of slices: " << event_slices.size()
01887             << endl;
01888 
01889   std::vector<int>* slices_to_delete = findSlicesToBeEliminated(event_slices);
01890 
01891   MSG("AltAlg", Msg::kVerbose)
01892          << "      |---[-] Eliminate slices & copy strips to list of orphans"
01893          << endl;
01894 
01895   std::vector<CandStripHandle *> orphan_strips;
01896   std::vector<CandStripHandle *>::iterator strip_iter;
01897 
01898   std::vector<int>::iterator slice_id;
01899 
01900   for(slice_id = slices_to_delete->begin();
01901                            slice_id != slices_to_delete->end(); ++slice_id) {
01902 
01903       for(strip_iter = event_slices[*slice_id].begin();
01904               strip_iter != event_slices[*slice_id].end(); ++strip_iter)
01905                                       orphan_strips.push_back( *strip_iter );
01906 
01907        event_slices.erase( *slice_id );
01908 
01909        MSG("AltAlg", Msg::kVerbose)
01910                  << "           |--> Deleted slice : " << *slice_id  << endl;
01911   }
01912 
01913   MSG("AltAlg", Msg::kDebug)
01914         << "      |---> Number of slices *after* eliminating the fake ones: "
01915         << event_slices.size() << endl;
01916 
01917   delete slices_to_delete;
01918 
01919   return orphan_strips;
01920 }

void AltAlgSliceList::eventClustering std::map< int, std::vector< CandStripHandle * > > &  event_slices  )  [private]
 

Definition at line 2480 of file AltAlgSliceList.cxx.

References fkMeansIteration, initSliceFiltering(), MSG, and singleKMeansIteration().

Referenced by RunAlg().

02482 {
02483 // Main method for k-Means - based 3-D event clustering. Initiates single
02484 // k-Means clustering method steps until the algorithm has converged.
02485 //
02486   MSG("AltAlg", Msg::kDebug)
02487           << "[-] Applying 3-D (c*time, tpos, z) k-Means clustering"  << endl;
02488 
02489   bool converged   = false;
02490   fkMeansIteration = 0;
02491 
02492   while(!converged) {
02493 
02494       MSG("AltAlg", Msg::kDebug)
02495                    << " |--[-] k-Means clustering has not converged yet - "
02496                    << "next iteration:" << endl;
02497 
02498       converged = singleKMeansIteration(event_slices);
02499   }
02500 
02501   // refilter to catch/remove any slice that has become too 'thin'...
02502   initSliceFiltering(event_slices);
02503 }

void AltAlgSliceList::eventDisplay TCanvas *  c,
std::map< int, std::vector< CandStripHandle * > >  event_slices
[private]
 

Definition at line 511 of file AltAlgSliceList.cxx.

References fNTimeBins, fTimeProfileMax, fTimeResolution, ftmax, ftmin, and MSG.

Referenced by display().

00513 {
00514 // Quick debugging 'tool' for tracking down obvious mistakes almost 'online'.
00515 // For thorough testing I run my debugging macros on the std output ntuples
00516 
00517   //-- create the canvas pads & the display histograms
00518 
00519   TPad * padT   = new TPad("padT","strip times",0.01,0.55,0.99,0.99,0);
00520   TPad * padUZ  = new TPad("padUZ","uz view",0.01,0.01,0.49,0.54,0);
00521   TPad * padVZ  = new TPad("padVZ","vz view",0.51,0.01,0.99,0.54,0);
00522 
00523   std::vector<TH1D *> time_profileVec;
00524   std::vector<TH2D *> hVviewVec;
00525   std::vector<TH2D *> hUviewVec ;
00526 
00527   TH1D * time_profile = 0;
00528   TH2D * hVview = 0;
00529   TH2D * hUview = 0;
00530 
00531   const int kNColors   = 16;
00532   int colors[kNColors] = { 1,40,2,30,3,4,5,6,7,8,9,11,25,42,50,28 };
00533 
00534   int icolor = 0;
00535   int islice = 0;
00536 
00537   //-- beautify...
00538 
00539   c->SetBorderMode(0);
00540   c->SetFillColor(0);
00541   c->Draw();
00542   padT->Draw();
00543   padUZ->Draw();
00544   padVZ->Draw();
00545   padT->SetBorderMode(0);
00546   padUZ->SetBorderMode(0);
00547   padVZ->SetBorderMode(0);
00548 
00549   for(std::map<int, std::vector<CandStripHandle *> >::iterator iter =
00550              event_slices.begin(); iter != event_slices.end(); ++iter) {
00551 
00552      std::vector<CandStripHandle *> slice_strips = (*iter).second;
00553 
00554      //-- instantiate...
00555 
00556      time_profile = new TH1D("","tb - time stamps",
00557               fNTimeBins,ftmin-5*fTimeResolution,ftmax+10*fTimeResolution);
00558      hVview = new TH2D("","VZ-view",200,0,200,100,-4,4);
00559      hUview = new TH2D("","UZ-view",200,0,200,100,-4,4);
00560 
00561      time_profile->SetMaximum( fTimeProfileMax );
00562 
00563      if(fGrfxTimeProfileLogView) {
00564         time_profile->SetMinimum( 0.9 );
00565         padT->SetLogy();
00566      }
00567 
00568      //-- fill...
00569 
00570      for(std::vector<CandStripHandle *>::iterator strip_iter =
00571          slice_strips.begin(); strip_iter != slice_strips.end(); ++strip_iter) {
00572 
00573         //time_profile->Fill( (*strip_iter)->GetCorrBegTime() );
00574 
00575         (fPkfWeightProfileWithCharge) ?
00576            time_profile->Fill( (*strip_iter)->GetCorrBegTime(),
00577                                (*strip_iter)->GetCharge() )  :
00578                  time_profile->Fill( (*strip_iter)->GetCorrBegTime() )  ;
00579 
00580         if( (*strip_iter)->GetPlaneView() == PlaneView::kU)
00581              hUview->Fill((*strip_iter)->GetPlane(), (*strip_iter)->GetTPos());
00582 
00583         if( (*strip_iter)->GetPlaneView() == PlaneView::kV)
00584              hVview->Fill((*strip_iter)->GetPlane(), (*strip_iter)->GetTPos());
00585      }
00586 
00587      //-- format & draw...
00588 
00589      padT->cd();
00590      time_profile->SetStats(kFALSE);
00591      time_profile->SetFillColor(colors[icolor]);
00592      time_profile->SetLineColor(colors[icolor]);
00593      if(islice==0) time_profile->Draw();
00594      else          time_profile->Draw("SAME");
00595 
00596      padUZ->cd();
00597      hUview->SetMarkerStyle(20);
00598      hUview->SetMarkerSize(0.7);
00599      hUview->SetMarkerColor(colors[icolor]);
00600      hUview->SetStats(kFALSE);
00601      if(islice==0) hUview->Draw("P");
00602      else          hUview->Draw("PSAME");
00603 
00604      padVZ->cd();
00605      hVview->SetMarkerStyle(20);
00606      hVview->SetMarkerSize(0.7);
00607      hVview->SetMarkerColor(colors[icolor]);
00608      hVview->SetStats(kFALSE);
00609      if(islice==0) hVview->Draw("P");
00610      else          hVview->Draw("PSAME");
00611 
00612      c->Update();
00613 
00614      icolor = ((icolor == kNColors - 1) ? ( 0 ) : ( icolor+1 ) );
00615      islice++;
00616 
00617      time_profileVec.push_back(time_profile);
00618      hVviewVec.push_back(hVview);
00619      hUviewVec.push_back(hUview);
00620   }
00621 
00622   c->SaveAs("slices.gif");
00623 
00624   //-- delete all allocated memory...
00625 
00626   MSG("AltAlg",Msg::kVerbose)
00627                 << "<< Dellacolating memory for graphics objects..." << endl;
00628   delete padT;
00629   delete padUZ;
00630   delete padVZ;
00631 
00632   for(std::vector<TH2D *>::iterator iterTH2 = hVviewVec.begin();
00633                   iterTH2 != hVviewVec.end(); ++iterTH2)   delete (*iterTH2);
00634   for(std::vector<TH2D *>::iterator iterTH2 = hUviewVec.begin();
00635                   iterTH2 != hUviewVec.end(); ++iterTH2)   delete (*iterTH2);
00636   for(std::vector<TH1D *>::iterator iterTH1 = time_profileVec.begin();
00637             iterTH1 != time_profileVec.end(); ++iterTH1)   delete (*iterTH1);
00638 
00639   MSG("AltAlg",Msg::kVerbose) << "... Done!>>" << endl;
00640 }

void AltAlgSliceList::eventDisplaySingleSlice TCanvas *  c,
int  sliceKey,
std::map< int, std::vector< CandStripHandle * > >  event_slices
[private]
 

Definition at line 642 of file AltAlgSliceList.cxx.

References fNTimeBins, fTimeResolution, ftmax, and ftmin.

00644 {
00645   //-- create the canvas pads & the display histograms
00646 
00647   TPad *  padT   = new TPad("padT","strip times",0.01,0.55,0.99,0.99,0);
00648   TPad *  padUZ  = new TPad("padUZ","uz view",0.01,0.01,0.49,0.54,0);
00649   TPad *  padVZ  = new TPad("padVZ","vz view",0.51,0.01,0.99,0.54,0);
00650 
00651   TH1D *  time_profileSlc = new TH1D("time_profileSlc","tb - time stamps",
00652             fNTimeBins,ftmin-5*fTimeResolution,ftmax+10*fTimeResolution);
00653   TH1D *  time_profileAll = new TH1D("time_profileSlc","tb - time stamps",
00654             fNTimeBins,ftmin-5*fTimeResolution,ftmax+10*fTimeResolution);
00655 
00656   TH2D *  hVviewSlc = new TH2D("hVviewSlc","VZ-view",200,0,200,100,-4,4);
00657   TH2D *  hVviewAll = new TH2D("hVviewAll","VZ-view",200,0,200,100,-4,4);
00658   TH2D *  hUviewSlc = new TH2D("hUviewSlc","UZ-view",200,0,200,100,-4,4);
00659   TH2D *  hUviewAll = new TH2D("hUviewAll","UZ-view",200,0,200,100,-4,4);
00660 
00661   //-- beautify...
00662 
00663   c->SetBorderMode(0);
00664   c->SetFillColor(0);
00665   c->Draw();
00666   padT->Draw();
00667   padUZ->Draw();
00668   padVZ->Draw();
00669   padT->SetBorderMode(0);
00670   padUZ->SetBorderMode(0);
00671   padVZ->SetBorderMode(0);
00672 
00673   //-- fill...
00674 
00675   for(std::map<int, std::vector<CandStripHandle *> >::iterator iter =
00676             event_slices.begin(); iter != event_slices.end(); ++iter) {
00677 
00678      std::vector<CandStripHandle *> slice_strips = (*iter).second;
00679 
00680      for(std::vector<CandStripHandle *>::iterator strip_iter =
00681         slice_strips.begin(); strip_iter != slice_strips.end(); ++strip_iter) {
00682 
00683         //time_profileAll->Fill( (*strip_iter)->GetCorrBegTime() );
00684 
00685         (fPkfWeightProfileWithCharge) ?
00686                  time_profileAll->Fill( (*strip_iter)->GetCorrBegTime(),
00687                                         (*strip_iter)->GetCharge() )  :
00688                  time_profileAll->Fill( (*strip_iter)->GetCorrBegTime() )  ;
00689 
00690         if( (*strip_iter)->GetPlaneView() == PlaneView::kU)
00691             hUviewAll->Fill((*strip_iter)->GetPlane(), (*strip_iter)->GetTPos());
00692 
00693         if( (*strip_iter)->GetPlaneView() == PlaneView::kV)
00694             hVviewAll->Fill((*strip_iter)->GetPlane(), (*strip_iter)->GetTPos());
00695 
00696         if(sliceKey == (*iter).first) {
00697 
00698             //time_profileSlc->Fill( (*strip_iter)->GetCorrBegTime() );
00699 
00700            (fPkfWeightProfileWithCharge) ?
00701                  time_profileSlc->Fill( (*strip_iter)->GetCorrBegTime(),
00702                                         (*strip_iter)->GetCharge()  )  :
00703                  time_profileSlc->Fill( (*strip_iter)->GetCorrBegTime() )  ;
00704 
00705             if( (*strip_iter)->GetPlaneView() == PlaneView::kU)
00706                  hUviewSlc->Fill((*strip_iter)->GetPlane(), (*strip_iter)->GetTPos());
00707 
00708             if( (*strip_iter)->GetPlaneView() == PlaneView::kV)
00709                  hVviewSlc->Fill((*strip_iter)->GetPlane(), (*strip_iter)->GetTPos());
00710         }
00711      }
00712 
00713      padT->cd();
00714      time_profileAll->SetStats(kFALSE);
00715      time_profileAll->SetFillColor(8);
00716      time_profileAll->SetLineColor(8);
00717      time_profileSlc->SetStats(kFALSE);
00718      time_profileSlc->SetFillColor(2);
00719      time_profileSlc->SetLineColor(2);
00720      time_profileAll->Draw();
00721      time_profileSlc->Draw("SAME");
00722 
00723      padUZ->cd();
00724      hUviewAll->SetMarkerStyle(20);
00725      hUviewAll->SetMarkerSize(0.7);
00726      hUviewAll->SetMarkerColor(8);
00727      hUviewAll->SetStats(kFALSE);
00728      hUviewSlc->SetMarkerStyle(20);
00729      hUviewSlc->SetMarkerSize(0.7);
00730      hUviewSlc->SetMarkerColor(2);
00731      hUviewSlc->SetStats(kFALSE);
00732      hUviewAll->Draw("P");
00733      hUviewSlc->Draw("PSAME");
00734 
00735      padVZ->cd();
00736      hVviewAll->SetMarkerStyle(20);
00737      hVviewAll->SetMarkerSize(0.7);
00738      hVviewAll->SetMarkerColor(8);
00739      hVviewAll->SetStats(kFALSE);
00740      hVviewSlc->SetMarkerStyle(20);
00741      hVviewSlc->SetMarkerSize(0.7);
00742      hVviewSlc->SetMarkerColor(2);
00743      hVviewSlc->SetStats(kFALSE);
00744      hVviewAll->Draw("P");
00745      hVviewSlc->Draw("PSAME");
00746 
00747      c->Update();
00748   }
00749 
00750   delete padT;
00751   delete padUZ;
00752   delete padVZ;
00753   delete time_profileAll;
00754   delete hVviewAll;
00755   delete hUviewAll;
00756   delete time_profileSlc;
00757   delete hVviewSlc;
00758   delete hUviewSlc;
00759 }

std::map< int, std::vector< CandStripHandle * > > AltAlgSliceList::fillSliceSeeds CandStripHandleItr  cshItr,
std::vector< TimeSlice_t > &  slice_seeds
[private]
 

Definition at line 1426 of file AltAlgSliceList.cxx.

References PlaneView::AsString(), fFmtPln, fFmtQ, fFmtStp, fFmtTime, CandStripHandle::GetCharge(), CandStripHandle::GetCorrBegTime(), CandStripHandle::GetPlane(), CandStripHandle::GetPlaneView(), CandStripHandle::GetStrip(), MSG, printSliceSeeds(), and removeNullSeeds().

Referenced by getMuSpecSlices(), and RunAlg().

01428 {
01429 // This method is called when the construction of the slice seeds has finished
01430 // and fills the std::map<int,std::vector<CandStripHandle *> > structure that
01431 // will be used for holding the reconstructed slices in the subsequent steps
01432 // of the event slicing algorithm.
01433 // This change is necessary because it will no longer be adequate to describe
01434 // the slices with mutually exclusive [tmin, tmax] time-intervals.
01435 // During slice-refinement, the reconstructed slices might pick up strips from
01436 // other slices so as to minimize a combined temporal-spatial distance and
01437 // therefore *hard* time boundaries might not be respected.
01438 //
01439   MSG("AltAlg", Msg::kDebug) <<  "* Constructing rough slices map"  << endl;
01440 
01441   // 'narrowing' might completely strip a scattered seed
01442   removeNullSeeds(slice_seeds);
01443 
01444   sort( slice_seeds.begin(), slice_seeds.end(), peak_before() );
01445 
01446   printSliceSeeds(slice_seeds, "final slice seeds -- sorted in peak time");
01447 
01448   MSG("AltAlg", Msg::kDebug)
01449          << " |--> selected " << cshItr.GetSet()->SizeSelect()
01450          << " out of "        << cshItr.GetSet()->Size()
01451          << " entries" << endl;
01452 
01453   int islice = 0;
01454   MsgFormat fmtInt("%3d");
01455 
01456   std::map<int, std::vector<CandStripHandle *> >  event_slices;
01457 
01458   std::vector<TimeSlice_t>::const_iterator slice_seeds_iter;
01459 
01460   for(slice_seeds_iter = slice_seeds.begin();
01461                 slice_seeds_iter != slice_seeds.end(); ++slice_seeds_iter ) {
01462 
01463      MSG("AltAlg", Msg::kVerbose)
01464          << "Assigning strips to slice seed: " << fmtInt(islice) << endl;;
01465      MSG("AltAlg", Msg::kVerbose)
01466          << "[-] cshItr.GetSet()->Slice("
01467          <<   "t = " << fFmtTime( (*slice_seeds_iter).tmin )
01468          << ", t = " << fFmtTime( (*slice_seeds_iter).tmax ) << ")"
01469          << " - dt<slice> = "
01470          << fFmtTime( (*slice_seeds_iter).tmax - (*slice_seeds_iter).tmin )
01471          << endl;
01472 
01473      //-- reset previous selections
01474      cshItr.GetSet()->Slice();
01475 
01476      //-- select strips in this time-window
01477      cshItr.GetSet()->Slice( (*slice_seeds_iter).tmin,
01478                              (*slice_seeds_iter).tmax  );
01479 
01480      MSG("AltAlg", Msg::kVerbose)
01481         << " |--> selected " << cshItr.GetSet()->SizeSelect() << " out of "
01482         << cshItr.GetSet()->Size() << " entries" << endl;
01483 
01484      std::vector<CandStripHandle *> slice_strips;
01485 
01486      MSG("AltAlg", Msg::kVerbose)
01487          << "[-] while( CandStripHandle * striph = cshItr.Ptr() )" << endl;
01488 
01489      cshItr.ResetFirst();
01490      while( CandStripHandle * striph = cshItr.Ptr() ) {
01491         slice_strips.push_back(striph);
01492 
01493         MSG("AltAlg", Msg::kVerbose)
01494            << " |--> slice_strips.push_back( "
01495            << "pl = "     << fFmtPln(  striph->GetPlane()   )
01496            << ", str = "  << fFmtStp(  striph->GetStrip()   )
01497            << ", Q = "    << fFmtQ(    striph->GetCharge()  )
01498            << ", view = " << PlaneView::AsString( striph->GetPlaneView() )
01499            << ", t = "    << fFmtTime( striph->GetCorrBegTime() )
01500            << " )" << endl;
01501 
01502         cshItr.Next();
01503      }
01504 
01505      MSG("AltAlg", Msg::kVerbose)
01506          << "[-] add pair: event_slices.insert( "
01507          << "std::map<int, std::vector<CandStripHandle *> >::"
01508          << "value_type(" << islice << ", " << &slice_strips << ") );"
01509          << endl;
01510 
01511      event_slices.insert(
01512        std::map<int, std::vector<CandStripHandle *> >::value_type(
01513                                                       islice, slice_strips) );
01514      islice++;
01515   }
01516 
01517   MSG("AltAlg", Msg::kDebug)
01518                << "* Constructing of rough reco slices map completed" << endl;
01519 
01520   return event_slices;
01521 }

int AltAlgSliceList::findBestSliceToAdoptAStrip bool  qweight,
int  dpln,
double  dt,
CandStripHandle orphan_strip,
std::map< int, std::vector< CandStripHandle * > > *  event_slices
const [private]
 

Definition at line 2065 of file AltAlgSliceList.cxx.

References fFmtPln, fFmtTime, min(), and MSG.

Referenced by giveOrphanStripsForAdoption().

02068 {
02069 // Finds the best slice (amongst the already existing ones) to adopt the input
02070 // strip from the list of orphan ones.
02071 // The best slice is the one which has the biggest number of hit strips (or
02072 // the biggest amount of charge, if qweight is turned on) inside a temporal
02073 // and spatial window centered in the orphan strip.
02074 // If none is found, the method relaxes the criteria (by increasing the window
02075 // size) and calls itself again.
02076 //
02077   int    best_slice = -1;
02078   double nq_max = 0, nq;
02079 
02080   std::map<int, std::vector<CandStripHandle *> >::iterator slice_iter;
02081 
02082   for(slice_iter = event_slices->begin();
02083                            slice_iter != event_slices->end(); ++slice_iter) {
02084 
02085       //-- no weighting by charge - just count number of hit strips
02086       if(qweight == 0)
02087         nq = (double) count_if(
02088              (*slice_iter).second.begin(), (*slice_iter).second.end(),
02089                                     is_in_tz_window(orphan_strip, dt, dpln) );
02090       //-- weighting by charge
02091       else {
02092 
02093         std::vector<CandStripHandle *>::iterator part_iter = partition(
02094            (*slice_iter).second.begin(), (*slice_iter).second.end(),
02095                                     is_in_tz_window(orphan_strip, dt, dpln) );
02096         nq = accumulate(
02097                        (*slice_iter).second.begin(), part_iter, 0.0, sum_q());
02098       }
02099 
02100       if(nq > nq_max) { nq_max = nq; best_slice = (*slice_iter).first; }
02101 
02102       //MSG("AltAlg", Msg::kVerbose) << "SLICE " << (*slice_iter).first
02103       //   << " ---> nq = " << nq << endl;
02104   }// slice_iter
02105 
02106   // No slice was found - increase the window size and try again...
02107   // Obviously, this can go many levels deep... If, in the next call, none is
02108   // found as well, it will relax the criteria some more and call itself again
02109   // and then possibly again... until the 'best' slice is found...
02110   // In this case the 'best' might not be good enough, but for now all we
02111   // want is to assign all orphan strips to the best available reco slice and
02112   // we will check later if they have substructure and need to be further
02113   // sliced...
02114 
02115   if(best_slice == -1) {
02116      MSG("AltAlg", Msg::kVerbose)
02117        << "          |--> No slice was found to adopt strip - relaxing limits"
02118        << " (dpln < " << fFmtPln(  min(2*dpln, 80) )
02119        << " - dt << " << fFmtTime( 2*dt   ) << ") & re-trying" << endl;
02120 
02121      return findBestSliceToAdoptAStrip(
02122                   qweight, min(2*dpln, 80), 2*dt, orphan_strip, event_slices);
02123   }
02124   return best_slice;
02125 }

int AltAlgSliceList::findBestSliceToHostStrip const pair< int, CandStripHandle * > &  slc_strip,
const std::map< int, Centroid_t > &  centroids,
const std::map< int, std::vector< CandStripHandle * > > &  event_slices
const [private]
 

Definition at line 2708 of file AltAlgSliceList.cxx.

References asString(), characterizeCandidateSlices(), checkForAlternativeSlices(), fFmtPln, fFmtSlc, fFmtStp, getClosestCentroid(), MSG, selectBestCandidateSlice(), and WhichCandSlice_t.

Referenced by singleKMeansIteration().

02712 {
02713 // Find which of the existing reconstructed slices is the best one for hosting
02714 // the input strip.
02715 
02716   int target;
02717 
02718   std::vector<int> alt_slices = checkForAlternativeSlices(
02719                                                      slc_strip, event_slices);
02720 
02721   WhichCandSlice_t which_slice = characterizeCandidateSlices(
02722                                                  slc_strip.first, alt_slices);
02723   MSG("AltAlg", Msg::kVerbose)
02724                << "     |--[-] slice = " << fFmtSlc(slc_strip.first) << " -->"
02725                << " plane = "  << fFmtPln( slc_strip.second->GetPlane() )
02726                << ", strip = " << fFmtStp( slc_strip.second->GetStrip() )
02727                << " : " << asString(which_slice) << endl;
02728 
02729   switch( which_slice ) {
02730      case (eNone):
02731            // There is no really good slice candidate... This happens
02732            // with fairly isolated hit strips... Not much you can do
02733            // here & at this stage. Assign the strip to the cluster
02734            // with the closest centroid...
02735            target = getClosestCentroid(slc_strip.second, centroids);
02736            break;
02737      case (eSame):
02738            // There is a single slice candidate and it is the same
02739            // with the one that already owns the strip. No rellocation.
02740            target = slc_strip.first;
02741            break;
02742      case (eOther):
02743            // There is a single candidate that is different from the
02744            // one that already owns the strip. Mark for rellocation.
02745            target = alt_slices[0];
02746            break;
02747      case (eMany):
02748            target = selectBestCandidateSlice(
02749                                          slc_strip, alt_slices, event_slices);
02750      break;
02751   }
02752 
02753   return target;
02754 }

bool AltAlgSliceList::findMatchForMuSpecSlice std::vector< CandStripHandle * >  mu_strips,
std::vector< int >  slice_ids,
std::map< int, std::vector< CandStripHandle * > > &  event_slices
const [private]
 

Definition at line 3204 of file AltAlgSliceList.cxx.

References addMuSpecStripsToExistingSlice(), averageTimeAtBeginOfDownstreamSlice(), averageTimeAtEndOfUpstreamSlice(), fFmtSlc, fFmtTime, fMuSpecTimeAftUpstrActivity, and MSG.

Referenced by sliceMatcher().

03207 {
03208   bool match_found = false;
03209 
03210   // Since we are at this point, it is likely to have a match with an upstream
03211   // spectrometer slice. Find the closest one...
03212   // The closest is decided in terms of temporal distance between the
03213   // most downstream section of the upstream slice and the
03214   // most upstream section of the downstream slice...
03215 
03216   std::vector<int>::iterator slice_id_iter;
03217 
03218   std::map<double, int, less<double> > closest_slices;
03219 
03220   double tmu  = averageTimeAtBeginOfDownstreamSlice(mu_strips);
03221 
03222   MSG("AltAlg", Msg::kVerbose)
03223         << "     |--> t (mu. spec begin) = " << fFmtTime(tmu) << endl;
03224   MSG("AltAlg", Msg::kVerbose)
03225         << "     |--[-] checking for matches " << endl;
03226 
03227   for(slice_id_iter = slice_ids.begin();
03228                          slice_id_iter != slice_ids.end(); ++slice_id_iter) {
03229 
03230       double tslc = averageTimeAtEndOfUpstreamSlice(
03231                                                 event_slices[*slice_id_iter] );
03232 
03233       MSG("AltAlg", Msg::kVerbose)
03234          << "         |--> tend(slc = " << fFmtSlc(*slice_id_iter) << ") = "
03235          << fFmtTime(tslc) << " -- dtbeg(mu.slc - slc) = "
03236          << fFmtTime(tmu-tslc) << endl;
03237 
03238       if(tmu  - tslc < fMuSpecTimeAftUpstrActivity &&
03239          tslc - tmu  < fMuSpecTimeBefUpstrActivity)
03240                closest_slices.insert(std::map<double, int>::value_type(
03241                                              fabs(tslc-tmu), *slice_id_iter));
03242   }
03243 
03244   if(closest_slices.size() >= 1) {
03245 
03246       // if at least one good candidate was found append the strips to the
03247       // closest one - this can be modified to use tpos info...
03248 
03249      std::map<double, int, less<double> >::iterator closest;
03250 
03251      closest = closest_slices.begin();
03252 
03253      MSG("AltAlg", Msg::kVerbose)
03254            << "     |--> mu-slice is appended to slice " << (*closest).second
03255            << " -- the closest out of " << closest_slices.size() << " slices"
03256            << endl;
03257 
03258       match_found = true;
03259       addMuSpecStripsToExistingSlice(
03260                                   mu_strips, event_slices[(*closest).second]);
03261   }
03262 
03263   return match_found;
03264 }

std::vector< int > * AltAlgSliceList::findSlicesToBeEliminated const std::map< int, std::vector< CandStripHandle * > > &  event_slices  )  const [private]
 

Definition at line 1922 of file AltAlgSliceList.cxx.

References MSG, and sliceShouldBeEliminated().

Referenced by dissolveMiniSlices().

01924 {
01925   std::vector<int> * slices_to_delete = new std::vector<int>;
01926 
01927   std::map<int, std::vector<CandStripHandle *> >::const_iterator slice_iter;
01928 
01929   for(slice_iter = event_slices.begin();
01930                             slice_iter != event_slices.end(); ++slice_iter) {
01931 
01932      MSG("AltAlg", Msg::kVerbose)
01933          << "      |---[-] Checking slice: " << (*slice_iter).first  << endl;
01934 
01935      if( sliceShouldBeEliminated(slice_iter) )
01936                            slices_to_delete->push_back( (*slice_iter).first );
01937   }
01938 
01939   return slices_to_delete; // the calling function should delete this
01940 }

std::pair< int, int > AltAlgSliceList::findSlicesToMerge std::map< int, std::vector< CandStripHandle * > > &  event_slices  )  const [private]
 

Definition at line 2144 of file AltAlgSliceList.cxx.

References checkIfSlicesShouldBeMerged(), fFmtSlc, and MSG.

Referenced by sliceMerger().

02146 {
02147 // Returns the first pair of slices that should be merged...
02148 //
02149   std::map<int, std::vector<CandStripHandle *> >::iterator slice_iter_0;
02150   std::map<int, std::vector<CandStripHandle *> >::iterator slice_iter_1;
02151 
02152   pair<int, int> slices_to_merge(-1,-1);
02153 
02154   // The following 2-ble loop, loops over all *different* slice-pairs once.
02155   // Each pair will be checked against the 'merging' criteria.
02156 
02157   for(slice_iter_0 = event_slices.begin();
02158                         slice_iter_0 != event_slices.end(); ++slice_iter_0) {
02159 
02160       for( ++(slice_iter_1 = slice_iter_0);
02161                         slice_iter_1 != event_slices.end(); ++slice_iter_1) {
02162 
02163           MSG("AltAlg", Msg::kVerbose) << " |--[-] examining slices "
02164                          << fFmtSlc( (*slice_iter_0).first ) << " and "
02165                          << fFmtSlc( (*slice_iter_1).first ) << endl;
02166 
02167            bool should_be_merged = checkIfSlicesShouldBeMerged(
02168                          (*slice_iter_0).second, (*slice_iter_1).second );
02169 
02170            if(should_be_merged) {
02171                 slices_to_merge.first  = (*slice_iter_0).first;
02172                 slices_to_merge.second = (*slice_iter_1).first;
02173 
02174                 // return this pair *now*. If two slices are merged, then
02175                 // previous checks are potentially invalidated.
02176                 // So merge the slices & then start checking from scratch.
02177                 return slices_to_merge;
02178            }
02179 
02180       } // slice_iter_1
02181   } // slice_iter_0
02182 
02183   MSG("AltAlg", Msg::kVerbose)
02184                  << "* Finished trying to spot clusters to be merged" << endl;
02185 
02186   return slices_to_merge;
02187 }

std::vector< TimeSlice_t > AltAlgSliceList::findSmallerPeaks CandStripHandleItr *  cshItr  )  [private]
 

Definition at line 1341 of file AltAlgSliceList.cxx.

References createSubsetTimeProfile(), fFmtTime, fPkfRecursivePeakSearch, fSubsetTimeProfile, getSliceSeeds(), kLowActivity, and MSG.

Referenced by reduceTimeWindows().

01343 {
01344 // Runs the peak-finder (in a kLowActivity configuration state) at a time
01345 // window within spill (the time-window de-allocated when the duration of all
01346 // major peaks was limited) so as to search for smaller peaks.
01347 // The time window must have been defined prior to calling this method
01348 // (by setting the fSubsettmin, fSubsettmax private data members).
01349 //
01350   std::vector<TimeSlice_t> new_seeds;
01351 
01352   //-- select strips in this time-window
01353 
01354   double tmin = fSubsettmin; // copy here because these two data members change
01355   double tmax = fSubsettmax; // in nested calls of the peak-finder
01356 
01357   MSG("AltAlg", Msg::kDebug)
01358      << "           |--> cshItr.GetSet()->Slice("
01359      << fFmtTime(tmin) << ", " << fFmtTime(tmax) << ")" << endl;
01360 
01361   cshItr->GetSet()->Slice();       // reset previous
01362   cshItr->GetSet()->Slice(tmin, tmax);
01363 
01364   MSG("AltAlg", Msg::kDebug)
01365      << "           |--> selected "
01366      << cshItr->GetSet()->SizeSelect() << " out of " << cshItr->GetSet()->Size()
01367      << " entries" << endl;
01368 
01369   if( cshItr->GetSet()->SizeSelect() > 0) {
01370 
01371        // watch out for memory leaks when running the peak finder recursively
01372        if(fSubsetTimeProfile) delete fSubsetTimeProfile;
01373 
01374        fSubsetTimeProfile = createSubsetTimeProfile(cshItr);
01375 
01376        MSG("AltAlg", Msg::kDebug)
01377             << "---------------------------- PEAK FINDER (NESTED LEVEL)/ "
01378             << "---------------------------- " << endl;
01379 
01380        //-- search for new slice-seeds
01381        new_seeds = getSliceSeeds(cshItr, fPkfRecursivePeakSearch, kLowActivity);
01382 
01383        MSG("AltAlg", Msg::kDebug)
01384             << "------------------------------------------- /PEAK FINDER "
01385             << "------------------------------------------- " << endl;
01386 
01387        MSG("AltAlg", Msg::kDebug) << "           |--> search in the ["
01388           << fFmtTime(tmin) << ", " << fFmtTime(tmax)
01389           << "] time window gave " << new_seeds.size() << " more seeds" << endl;
01390 
01391        if(fSubsetTimeProfile) delete fSubsetTimeProfile;
01392        fSubsetTimeProfile = 0;
01393 
01394   } else
01395 
01396        MSG("AltAlg", Msg::kDebug)
01397             << "           |--> cshItr.GetSet()->SizeSelect() = 0, "
01398             << "terminating recursive calls for this window" << endl;
01399 
01400   return new_seeds;
01401 }

void AltAlgSliceList::getAlgorithmConfiguration const AlgConfig ac  )  [private]
 

Definition at line 3392 of file AltAlgSliceList.cxx.

References fGrfxDebugGraphics, fGrfxTimeProfileLogView, fKMeansPlaneWindow, fKMeansTimeWindow, fKMeansTPosWindow, fMinCharge, fMinNoHitStrips, fMuSpecNHitStripsBefSpectr, fMuSpecNPlnBefSpectr, fMuSpecNUpstrPlanes, fMuSpecSuppressUnmatchedSlices, fMuSpecTimeAftUpstrActivity, fMuSpecTimeBefUpstrActivity, fOrphanStripsPlaneWindow, fOrphanStripsQWeight, fOrphanStripsTimeWindow, fPkfLowNSuccessiveEmptyBins, fPkfLowPeakThreshold, fPkfMuSpecNSuccessiveEmptyBins, fPkfMuSpecPeakThreshold, fPkfNofMergedTimeBins, fPkfNSuccessiveEmptyBins, fPkfPeakThreshold, fPkfRecursivePeakSearch, fPkfTimeWindowAftPeak, fPkfTimeWindowBefPeak, fPkfWeightProfileWithCharge, fRefinementDissolving, fRefinementKMeansClustering, fRefinementMerging, fRefinementMSTClustering, fTimeDiffBetweenPeaks, fTimeResolution, fUVDiffBetweenPeaks, fZDiffBetweenEnds, fZDiffBetweenPeaks, Registry::GetDouble(), Registry::GetInt(), and internalInit().

Referenced by RunAlg().

03393 {
03394   internalInit(); // initialize internal data members
03395 
03396   fGrfxDebugGraphics              =  ac.GetInt("Grfx_DebugGraphics");
03397   fGrfxTimeProfileLogView         =  ac.GetInt("Grfx_TimeProfileLogView");  
03398   fPkfPeakThreshold               =  ac.GetInt("Pkf_PeakThreshold");  
03399   fPkfNSuccessiveEmptyBins        =  ac.GetInt("Pkf_NSuccessiveEmptyBins");     
03400   fPkfMuSpecPeakThreshold         =  ac.GetInt("Pkf_MuSpecPeakThreshold");    
03401   fPkfMuSpecNSuccessiveEmptyBins  =  ac.GetInt("Pkf_MuSpecNSuccessiveEmptyBins");   
03402   fPkfLowPeakThreshold            =  ac.GetInt("Pkf_LowPeakThreshold");  
03403   fPkfLowNSuccessiveEmptyBins     =  ac.GetInt("Pkf_LowNSuccessiveEmptyBins");   
03404   fPkfNofMergedTimeBins           =  ac.GetInt("Pkf_NofMergedTimeBins");  
03405   fPkfWeightProfileWithCharge     = (ac.GetInt("Pkf_WeightProfileWithCharge") == 1);    
03406   fPkfRecursivePeakSearch         = (ac.GetInt("Pkf_RecursivePeakSearch") == 1);
03407   fPkfTimeWindowBefPeak           =  ac.GetInt("Pkf_TimeWindowBefPeak");
03408   fPkfTimeWindowAftPeak           =  ac.GetInt("Pkf_TimeWindowAftPeak");
03409   fRefinementDissolving           = (ac.GetInt("Refinement_Dissolving") == 1);
03410   fRefinementMerging              = (ac.GetInt("Refinement_Merging") == 1);
03411   fRefinementKMeansClustering     = (ac.GetInt("Refinement_KMeansClustering") == 1);
03412   fRefinementMSTClustering        = (ac.GetInt("Refinement_MSTClustering") == 1);
03413   fOrphanStripsQWeight            = (ac.GetInt("OrphanStrips_QWeight") == 1);
03414   fOrphanStripsPlaneWindow        =  ac.GetInt("OrphanStrips_PlaneWindow");
03415   fOrphanStripsTimeWindow         =  ac.GetDouble("OrphanStrips_TimeWindow");    
03416   fKMeansTimeWindow               =  ac.GetDouble("KMeans_TimeWindow");
03417   fKMeansPlaneWindow              =  ac.GetInt("KMeans_PlaneWindow");
03418   fKMeansTPosWindow               =  ac.GetDouble("KMeans_TPosWindow");  
03419   fMuSpecNUpstrPlanes             =  ac.GetInt("MuSpec_NUpstrPlanes");
03420   fMuSpecTimeAftUpstrActivity     =  ac.GetDouble("MuSpec_TimeAftUpstrActivity");
03421   fMuSpecTimeBefUpstrActivity     =  ac.GetDouble("MuSpec_TimeBefUpstrActivity");
03422   fMuSpecNHitStripsBefSpectr      =  ac.GetInt("MuSpec_HitStripsBefSpectr");
03423   fMuSpecNPlnBefSpectr            =  ac.GetInt("MuSpec_NPlnBefSpectr");
03424   fMuSpecSuppressUnmatchedSlices  = (ac.GetInt("MuSpec_SuppressUnmatchedSlices") == 1);
03425   fTimeResolution                 =  ac.GetDouble("TimeResolution");
03426   fMinNoHitStrips                 =  ac.GetInt("MinHitStripsInSlice");  
03427   fTimeDiffBetweenPeaks           =  ac.GetDouble("TimeDiffBetweenPeaks");  
03428   fZDiffBetweenPeaks              =  ac.GetDouble("ZDiffBetweenPeaks");  
03429   fZDiffBetweenEnds               =  ac.GetDouble("ZDiffBetweenEnds");  
03430   fUVDiffBetweenPeaks             =  ac.GetDouble("UVDiffBetweenPeaks");
03431   fMinCharge                      =  ac.GetDouble("MinChargeInSlice");  
03432 }

int AltAlgSliceList::getClosestCentroid CandStripHandle strip,
const std::map< int, Centroid_t > &  centroids
const [private]
 

Definition at line 2820 of file AltAlgSliceList.cxx.

References CandStripHandle::GetCorrBegTime(), CandStripHandle::GetZPos(), and MSG.

Referenced by findBestSliceToHostStrip().

02822 {
02823   std::multimap<double, int, less<double> > slices_dt_sorted;
02824   std::multimap<double, int, less<double> > slices_dz_sorted;
02825 
02826   std::map<int, Centroid_t>::const_iterator cd_iter;
02827   for(cd_iter = centroids.begin(); cd_iter != centroids.end(); ++cd_iter) {
02828 
02829      double dt = ((*cd_iter).second.tu+(*cd_iter).second.tv)/2. -
02830                                                              strip->GetCorrBegTime();
02831 
02832      double dz = ((*cd_iter).second.zu+(*cd_iter).second.zv)/2. -
02833                                                              strip->GetZPos();
02834 
02835      slices_dt_sorted.insert(std::multimap<double, int>::value_type(
02836                                                  fabs(dt), (*cd_iter).first));
02837      slices_dz_sorted.insert(std::multimap<double, int>::value_type(
02838                                                  fabs(dz), (*cd_iter).first));
02839   }
02840 
02841   // Use this & similar information to decide what is the 'closest' centroid...
02842   // For now just:
02843 
02844   MSG("AltAlg", Msg::kVerbose)
02845        << "         |---> slice with 'closest' centroid: "
02846                                << (*(slices_dt_sorted.begin())).second << endl;
02847 
02848   return (*(slices_dt_sorted.begin())).second;
02849 }

std::map< int, std::vector< CandStripHandle * > > AltAlgSliceList::getMuSpecSlices CandStripHandleItr  cshItr  )  [private]
 

Definition at line 3051 of file AltAlgSliceList.cxx.

References createSubsetTimeProfile(), fillSliceSeeds(), fSubsetTimeProfile, fSubsettmax, fSubsettmin, getSliceSeeds(), kMuSpectrometer, MSG, and sortSlicesInTime().

Referenced by assignMuonSpectrHits2Slices().

03053 {
03054 // Finding slices in the muon spectrometer
03055 
03056   //-- Get the time-profile of muon spectrometer activity:
03057   //   CandStripHandleItr cshItr points only to strips in pl > MaxPlane which
03058   //   defines the max plane before the muon spectrometer
03059   //   Use the same time-resolution as in the fTimeResolution
03060 
03061   MSG("AltAlg", Msg::kVerbose)
03062           << " |--> Getting the muon spectrometer strip time profile" << endl;
03063 
03064   fSubsetTimeProfile = createSubsetTimeProfile(&cshItr);
03065 
03066   fSubsettmin = ftmin;
03067   fSubsettmax = ftmax;
03068 
03069   //-- Use the peak-finder to determine time slices in the profile of the muon
03070   //   spectrometer activity
03071 
03072   MSG("AltAlg", Msg::kVerbose)
03073                   << " |--> Finding time slices in muon spectrometer" << endl;
03074 
03075   std::vector<TimeSlice_t> mu_seeds = getSliceSeeds(
03076                                              &cshItr, false, kMuSpectrometer);
03077 
03078   std::map<int, std::vector<CandStripHandle *> >
03079                                  mu_slices = fillSliceSeeds(cshItr, mu_seeds);
03080 
03081   MSG("AltAlg", Msg::kVerbose)
03082                     << " |--> Muon spectrometer slice seed filtering" << endl;
03083 
03084   //initSliceFiltering(mu_slices);
03085 
03086   sortSlicesInTime(mu_slices);
03087 
03088   delete fSubsetTimeProfile;
03089   fSubsetTimeProfile = 0;
03090 
03091   return mu_slices;
03092 }

std::vector< TimeSlice_t > AltAlgSliceList::getSliceSeeds CandStripHandleItr *  cshItr,
bool  recursive_mode,
PeakFinderConf_t  conf = kDefault
[private]
 

Definition at line 870 of file AltAlgSliceList.cxx.

References fPeakFinderNestingLevel, MSG, peakFinder(), printSliceSeeds(), reduceTimeWindows(), and updateSliceSeedInfo().

Referenced by findSmallerPeaks(), getMuSpecSlices(), and RunAlg().

00872 {
00873 // Recosntruct "slice seeds" ro be refined later.
00874 // The a vector of time boundaries corresponding to the seed slices.
00875 // The vec element i corresponds to the ith seed slice.
00876 // The slice seeds are sorted in pulse height peak time (in ascending order).
00877 //
00878 
00879   MSG("AltAlg", Msg::kDebug)
00880     << "[-] Peak Finder ------- Nesting level: " << ++fPeakFinderNestingLevel
00881     << endl;
00882 
00883   assert(fPeakFinderNestingLevel < 50); // crash if things go very wrong...
00884 
00885   std::vector<TimeSlice_t> slice_seeds;
00886 
00887   MSG("AltAlg", Msg::kDebug)  << " |-->[-] Getting gross slice seeds" << endl;
00888 
00889   peakFinder(slice_seeds, conf);
00890   updateSliceSeedInfo(cshItr, slice_seeds);
00891 
00892   MSG("AltAlg", Msg::kDebug)
00893                   << "      |--> Seeds found= " << slice_seeds.size() << endl;
00894 
00895   printSliceSeeds(slice_seeds, "initial, very gross slice seeds");
00896 
00897   //-- Check the time-window of these slice-seeds.
00898   //   In some cases the time-window might be just too large, much bigger than
00899   //   the typical 'duration' of an event and therefore it collects hit strips
00900   //   from nearby slices where the overall activity was below the initial
00901   //   peak-search threshold
00902   //   In this case just confine the slice seed to an acceptable time-window
00903   //   around the found pulse height peak, set PeakFinderConf_t to kLowActivity
00904   //   and look for smaller peaks below the initial threshold.
00905 
00906   //   This step could be by-passed in conjunction with making the peak-finder
00907   //   very sensitive in the first place (low threshold - small max number of
00908   //   successive empty bins). However, the two approaches might not be equivalent.
00909   //   So, I keep both and I need to fine-tune the algorithm externally.
00910 
00911   if(recursive_mode) {
00912 
00913      // by calling the next function, essentially getSliceSeeds() will start
00914      // calling itself, until the duration  of all currently existing slice seeds
00915      // has been reduced to the maximum allowed duration and all the 'de-allocated'
00916      // time has been searched for smaller peaks...
00917 
00918      reduceTimeWindows(cshItr, slice_seeds);
00919   }
00920 
00921   fPeakFinderNestingLevel--;
00922 
00923   return slice_seeds;
00924 }

void AltAlgSliceList::getSnarlTimeBoundaries CandStripHandleItr *  cshItr,
double &  tmin,
double &  tmax
const [private]
 

Definition at line 850 of file AltAlgSliceList.cxx.

References CandStripHandle::GetCorrBegTime().

Referenced by RunAlg().

00852 {
00853 // Get the minimum & the maximum time in the NavSet that the cshItr
00854 // CandStripHandleItr iterates on. The NavSet must be sorted in time (in
00855 // ascending order)
00856 //
00857   CandStripHandle * striph = 0;
00858 
00859   cshItr->ResetFirst();
00860   striph = cshItr->Ptr();
00861   tmin = striph->GetCorrBegTime();
00862 
00863   cshItr->ResetLast();
00864   striph = cshItr->Ptr();
00865   tmax = striph->GetCorrBegTime();
00866 
00867   cshItr->ResetFirst();
00868 }

double AltAlgSliceList::getStripTime CandStripHandle csh,
StripTime_t  st,
StripEnd::StripEnd_t  se = StripEnd::kWhole
const [private]
 

Definition at line 3380 of file AltAlgSliceList.cxx.

References CandStripHandle::GetBegTime(), CandStripHandle::GetCorrBegTime(), CandStripHandle::GetEndTime(), and CandStripHandle::GetTime().

03382 {
03383   switch ( st ) {
03384   case ( eTime )        : return csh->GetTime(se);       break;
03385   case ( eBegTime )     : return csh->GetBegTime(se);    break;
03386   case ( eEndTime )     : return csh->GetEndTime(se);    break;
03387   case ( eCorrBegTime ) : return csh->GetCorrBegTime();  break;
03388   default               : return 0;
03389   }
03390 }

void AltAlgSliceList::giveOrphanStripsForAdoption std::vector< CandStripHandle * >  orphan_strips,
std::map< int, std::vector< CandStripHandle * > > &  event_slices
const [private]
 

Definition at line 2028 of file AltAlgSliceList.cxx.

References fFmtPln, fFmtStp, fFmtTime, findBestSliceToAdoptAStrip(), fOrphanStripsPlaneWindow, fOrphanStripsQWeight, fOrphanStripsTimeWindow, and MSG.

Referenced by initSliceFiltering().

02031 {
02032 // Appends the CandStripHandles found in the orphan_strips STL vector
02033 // to the reco. slice with the minimum distance in the z-time-tpos
02034 // 3-D space...
02035 //
02036   //-- assume that centroids do not change too much by the addition
02037   //   of few orhan strips, so compute them just once...
02038 
02039   MSG("AltAlg", Msg::kVerbose)
02040           << " |-->[-] Appending orphan strips to closest reco slice" << endl;
02041 
02042   std::vector<CandStripHandle *>::iterator strip_iter;
02043   for(strip_iter = orphan_strips.begin();
02044                            strip_iter != orphan_strips.end(); ++strip_iter) {
02045 
02046      MSG("AltAlg", Msg::kVerbose)
02047        << "      |--[-] Looking a home for orphan strip "
02048        << (*strip_iter)->GetUidInt()
02049        << " (pl = "  << fFmtPln(  (*strip_iter)->GetPlane() )
02050        << ", str = " << fFmtStp(  (*strip_iter)->GetStrip() )
02051        << ", t = "   << fFmtTime( (*strip_iter)->GetCorrBegTime() )
02052        << ")" << endl;
02053 
02054      int islice = findBestSliceToAdoptAStrip(
02055                        fOrphanStripsQWeight, fOrphanStripsPlaneWindow,
02056                        fOrphanStripsTimeWindow, *strip_iter, &event_slices );
02057 
02058      event_slices[islice].push_back( *strip_iter );
02059 
02060      MSG("AltAlg", Msg::kVerbose)
02061                      << "          |--> Adopted by slice "  << islice << endl;
02062   } // loop over orphan strips
02063 }

void AltAlgSliceList::initSliceFiltering std::map< int, std::vector< CandStripHandle * > > &  event_slices  )  const [private]
 

Definition at line 1859 of file AltAlgSliceList.cxx.

References dissolveMiniSlices(), giveOrphanStripsForAdoption(), MSG, and sortSlicesInTime().

Referenced by eventClustering(), RunAlg(), and updateCentroids().

01861 {
01862 
01863   MSG("AltAlg", Msg::kDebug)
01864      << "[-] Dissolving 'mini'-slices & creating an orphan strip list" << endl;
01865 
01866   std::vector<CandStripHandle *> orphan_strips_list
01867                                             = dissolveMiniSlices(event_slices);
01868 
01869   if(orphan_strips_list.size() > 0) {
01870 
01871      giveOrphanStripsForAdoption(orphan_strips_list, event_slices);
01872      sortSlicesInTime(event_slices);
01873   }
01874 }

void AltAlgSliceList::internalInit void   )  [private]
 

Definition at line 3434 of file AltAlgSliceList.cxx.

References fGrfxDebugGraphics, fGrfxTimeProfileLogView, fkMeansIteration, fKMeansPlaneWindow, fKMeansTimeWindow, fKMeansTPosWindow, fMinCharge, fMinNoHitStrips, fMuSpecNHitStripsBefSpectr, fMuSpecNPlnBefSpectr, fMuSpecNUpstrPlanes, fMuSpecSuppressUnmatchedSlices, fMuSpecTimeAftUpstrActivity, fMuSpecTimeBefUpstrActivity, fNTimeBins, fOrphanStripsPlaneWindow, fOrphanStripsQWeight, fOrphanStripsTimeWindow, fPeakFinderNestingLevel, fPkfLowNSuccessiveEmptyBins, fPkfLowPeakThreshold, fPkfMuSpecNSuccessiveEmptyBins, fPkfMuSpecPeakThreshold, fPkfNofMergedTimeBins, fPkfNSuccessiveEmptyBins, fPkfPeakThreshold, fPkfRecursivePeakSearch, fPkfTimeWindowAftPeak, fPkfTimeWindowBefPeak, fPkfWeightProfileWithCharge, fRefinementDissolving, fRefinementKMeansClustering, fRefinementMerging, fRefinementMSTClustering, fSubsetTimeProfile, fSubsettmax, fSubsettmin, fTimeDiffBetweenPeaks, fTimeProfile, fTimeProfileMax, fTimeResolution, ftmax, ftmin, fUpdateCentroids, fUVDiffBetweenPeaks, fZDiffBetweenEnds, and fZDiffBetweenPeaks.

Referenced by AltAlgSliceList(), and getAlgorithmConfiguration().

03435 {
03436 // Initialize private data members
03437 
03438   //--  ordinary private data members
03439   
03440   fNTimeBins                           = 0;
03441   fUpdateCentroids                     = false;         
03442   fTimeProfileMax                      = 0;
03443   fTimeProfile                         = 0;
03444   ftmin                                = 0;
03445   ftmax                                = 0;
03446   fSubsetTimeProfile                   = 0;
03447   fSubsettmin                          = 0;
03448   fSubsettmax                          = 0;
03449   fPeakFinderNestingLevel              = 0;
03450   fkMeansIteration                     = 0;
03451 
03452   //-- private data members that are set by external AlgConf object
03453 
03454   fGrfxDebugGraphics                   = 0;
03455   fGrfxTimeProfileLogView              = 0;
03456   fPkfPeakThreshold                    = 0;
03457   fPkfNSuccessiveEmptyBins             = 0;
03458   fPkfMuSpecPeakThreshold              = 0;
03459   fPkfMuSpecNSuccessiveEmptyBins       = 0;
03460   fPkfLowPeakThreshold                 = 0;
03461   fPkfLowNSuccessiveEmptyBins          = 0;
03462   fPkfNofMergedTimeBins                = 0;   
03463   fPkfTimeWindowBefPeak                = 0;  
03464   fPkfTimeWindowAftPeak                = 0;  
03465   fOrphanStripsPlaneWindow             = 0;
03466   fKMeansPlaneWindow                   = 0;
03467   fMuSpecNUpstrPlanes                  = 0;
03468   fMuSpecNHitStripsBefSpectr           = 0;
03469   fMuSpecNPlnBefSpectr                 = 0;
03470   fMinNoHitStrips                      = 0;            
03471   fPkfWeightProfileWithCharge          = false;
03472   fPkfRecursivePeakSearch              = false;
03473   fRefinementDissolving                = false;
03474   fRefinementMerging                   = false;      
03475   fRefinementKMeansClustering          = false;
03476   fRefinementMSTClustering             = false;
03477   fMuSpecSuppressUnmatchedSlices       = false;
03478   fOrphanStripsQWeight                 = false;   
03479   fOrphanStripsTimeWindow              = 0.0; 
03480   fKMeansTimeWindow                    = 0.0;
03481   fKMeansTPosWindow                    = 0.0;      
03482   fMuSpecTimeAftUpstrActivity          = 0.0;
03483   fMuSpecTimeBefUpstrActivity          = 0.0;
03484   fTimeResolution                      = 0.0;
03485   fTimeDiffBetweenPeaks                = 0.0;
03486   fZDiffBetweenPeaks                   = 0.0;
03487   fZDiffBetweenEnds                    = 0.0;
03488   fUVDiffBetweenPeaks                  = 0.0;  
03489   fMinCharge                           = 0.0;         
03490 }

std::multimap< double, int, less< double > > AltAlgSliceList::MakeDistanceMap CandStripHandle strip,
const std::vector< int > &  cand_slices,
const std::map< int, std::vector< CandStripHandle * > > &  event_slices
const [private]
 

Definition at line 2910 of file AltAlgSliceList.cxx.

References CandStripHandle::GetCorrBegTime(), and CandStripHandle::GetZPos().

Referenced by selectBestCandidateSlice().

02913 {
02914 // Create a map of 'distance' -> 'slice_id', sorted in distance.
02915 // The 'distance' is computed with respect to the input CandStripHandle.
02916 
02917   std::multimap<double, int, less<double> > slices_dist_sorted;
02918 
02919   std::vector<int>::const_iterator slice_id_iter;
02920   std::vector<CandStripHandle *>::const_iterator strip_iter;
02921   std::map<int, std::vector<CandStripHandle *> >::const_iterator slice_iter;
02922 
02923   for(slice_id_iter = cand_slices.begin();
02924                        slice_id_iter != cand_slices.end(); ++slice_id_iter) {
02925 
02926      slice_iter = event_slices.find(*slice_id_iter);
02927 
02928      for(strip_iter = slice_iter->second.begin();
02929                       strip_iter != slice_iter->second.end(); ++strip_iter) {
02930 
02931         double cdt = 3.0e8 * ( (*strip_iter)->GetCorrBegTime() -
02932                                                           strip->GetCorrBegTime() );
02933         double dz  = (*strip_iter)->GetZPos() - strip->GetZPos();
02934 
02935         double d2 = cdt*cdt+dz*dz; // neglect tpos for now - keep 2 views
02936 
02937         slices_dist_sorted.insert(
02938                  std::multimap<double, int>::value_type(d2, *slice_id_iter));
02939      } // slice strips
02940   }// slices
02941 
02942   return slices_dist_sorted;
02943 }

double AltAlgSliceList::maxSliceTime std::vector< CandStripHandle * > &  slice  )  const [private]
 

Definition at line 2468 of file AltAlgSliceList.cxx.

Referenced by checkLeadingTrailingEdgeDistance().

02470 {
02471 // Returns the latest strip time in the input vector of strips
02472 
02473   sort(slice.begin(), slice.end(), min_t());
02474 
02475   std::vector<CandStripHandle *>::iterator strip_iter = --(slice.end());
02476 
02477   return (*strip_iter)->GetCorrBegTime();
02478 }

void AltAlgSliceList::Merge const std::pair< int, int > &  slices_to_merge,
std::map< int, std::vector< CandStripHandle * > > &  event_slices
const [private]
 

Definition at line 1749 of file AltAlgSliceList.cxx.

References fFmtPln, fFmtSlc, fFmtStp, and MSG.

Referenced by sliceMerger().

01751 {
01752 // Method for handling the map<int, vector<CandStripHandle *> > slice map.
01753 // Gets a pair of slice ids that have to be merged and applies this operation
01754 // the map. All CandStripHandles are appended to the first slice of the pair
01755 // and the other is deleted. At the end, the map is sorted in time.
01756 //
01757   MSG("AltAlg", Msg::kVerbose) << "* Begin Slice Merging" << endl;
01758 
01759   //printSlices(event_slices,"");
01760 
01761   int target_slice = slices_to_merge.first;
01762   int source_slice = slices_to_merge.second;
01763 
01764   std::map<int, std::vector<CandStripHandle *> >::iterator slice_iter;
01765 
01766   slice_iter = event_slices.find(source_slice);
01767 
01768   std::vector<CandStripHandle *> source_strips = slice_iter->second;
01769 
01770   std::vector<CandStripHandle *>::iterator strip_iter;
01771 
01772   for(strip_iter = source_strips.begin();
01773                            strip_iter != source_strips.end(); ++strip_iter) {
01774 
01775      MSG("AltAlg", Msg::kVerbose)
01776              << "   --- Strip: " << fFmtStp( (*strip_iter)->GetStrip() )
01777              << " from plane: "  << fFmtPln( (*strip_iter)->GetPlane() )
01778              << " to be removed from slice: " << fFmtSlc( source_slice )
01779              << " and appended in slice: " << fFmtSlc( target_slice ) << endl;
01780 
01781      //-- Add cand strip handle to target slice
01782      event_slices[target_slice].push_back(*strip_iter);
01783 
01784   } // loop over source slice strips
01785 
01786   MSG("AltAlg", Msg::kVerbose)
01787                        << "   ---- Removing slice: " << source_slice << endl;
01788   event_slices.erase(slice_iter); // remove source slice
01789 
01790   MSG("AltAlg", Msg::kVerbose) << "* Slice Merging Completed" << endl;
01791 }

void AltAlgSliceList::mergeSeeds std::vector< TimeSlice_t src,
std::vector< TimeSlice_t > &  target
const [private]
 

Definition at line 1403 of file AltAlgSliceList.cxx.

References MSG.

Referenced by reduceTimeWindows().

01405 {
01406   std::vector<TimeSlice_t>::iterator time_slice_iter;
01407 
01408    //-- add new slices
01409    MSG("AltAlg", Msg::kVerbose)
01410             << "           |--> adding new seeds - initial number: "
01411             << full_seed_list.size() << endl;
01412 
01413    for(time_slice_iter = new_seeds.begin();
01414               time_slice_iter != new_seeds.end(); ++time_slice_iter) {
01415 
01416               full_seed_list.push_back( *time_slice_iter );
01417    }
01418    MSG("AltAlg", Msg::kVerbose)
01419             << "           |--> seeds added - new number: "
01420             << full_seed_list.size() << endl;
01421 
01422   //printSliceSeeds(new_seeds, "new seeds that were added in this step");
01423   //printSliceSeeds(full_seed_list, "full list of current slice seeds");
01424 }

double AltAlgSliceList::minSliceTime std::vector< CandStripHandle * > &  slice  )  const [private]
 

Definition at line 2456 of file AltAlgSliceList.cxx.

Referenced by checkLeadingTrailingEdgeDistance().

02458 {
02459 // Returns the earliest strip time in the input vector of strips
02460 
02461   sort(slice.begin(), slice.end(), min_t());
02462 
02463   std::vector<CandStripHandle *>::iterator strip_iter = slice.begin();
02464 
02465   return (*strip_iter)->GetCorrBegTime();
02466 }

int AltAlgSliceList::moreOccurences std::multimap< double, int >  ordered_slice_ids,
int  n
const [private]
 

Definition at line 2945 of file AltAlgSliceList.cxx.

References min().

Referenced by selectBestCandidateSlice().

02947 {
02948 // Finds the slice with the more occurences in the n first slots of the multimap
02949 // The 'double' argument of the multimap is a measure of 'distance' in some
02950 // variable. It therefore represents a "distance" -> "slice id" mapping.
02951 // The multimap<Key, Data, Compare, Alloc> must have Compare = less<double>
02952 // It is a multimap, rather than a map, because, in principle, >1 slices might
02953 // have the same key (generalized distance from something).
02954 // If n exceeds the multimap size it is set equal to it.
02955 // If more than one slice is found then it returns the one of them which has
02956 // the entry with the smallest distance.
02957 
02958   std::vector<int> slc_ids;
02959   std::vector<int> unique_slc_ids;
02960 
02961   std::map<double, int>::iterator id_iter;
02962   std::map<double, int>::iterator id_iter_last = slice_ids.begin();
02963   advance(id_iter_last, min(n, (int) slice_ids.size()) );
02964 
02965   for(id_iter = slice_ids.begin(); id_iter != id_iter_last; ++id_iter) {
02966 
02967        slc_ids.push_back( (*id_iter).second );
02968 
02969        if(! count_if( unique_slc_ids.begin(),  unique_slc_ids.end(),
02970                  bind2nd(equal_to<int>(), (*id_iter).second) ) )
02971                                 unique_slc_ids.push_back( (*id_iter).second );
02972   }
02973 
02974   std::map<int, int, greater<int> > occurences;
02975   std::vector<int>::iterator id;
02976 
02977   for(id = unique_slc_ids.begin(); id != unique_slc_ids.end(); ++id)
02978             occurences.insert( std::map<int, int>::value_type(
02979                         count_if( slc_ids.begin(),  slc_ids.end(),
02980                                        bind2nd(equal_to<int>(), *id) ), *id));
02981 
02982   std::multimap<int, int>::iterator max_occurences =
02983                           max_element( occurences.begin(), occurences.end() );
02984 
02985   return max_occurences->second;
02986 }

bool AltAlgSliceList::needToFilterStrips const std::map< int, std::vector< CandStripHandle * > > &  event_slices  )  const [private]
 

Definition at line 2566 of file AltAlgSliceList.cxx.

References MSG, and ZeroChargeInAView().

Referenced by updateCentroids().

02568 {
02569 // Somethimes it is possible that strip exchanges during the 3-D clustering
02570 // will (almost or completely) strip out a slice from strips.
02571 // In this case, computing slice centroids will fail because Sum{Q}=0 in
02572 // at least one of the views.
02573 // If this is happening then these small slices have to be filtered out.
02574 // In this method I check if this is necessary at *this* point...
02575 
02576   std::map<int, std::vector<CandStripHandle *> >::const_iterator slice_iter;
02577 
02578   for(slice_iter = event_slices.begin();
02579                             slice_iter != event_slices.end(); ++slice_iter) {
02580 
02581       std::vector<CandStripHandle *> slice_strips = slice_iter->second;
02582 
02583       if( ZeroChargeInAView(slice_strips) ) {
02584 
02585         MSG("AltAlg", Msg::kVerbose)
02586            << " |--[-] Oops! At least one of slices was striped out during"
02587            << " strip exchanges -- run the filter to clear them out" << endl;
02588 
02589         return true;
02590       }
02591   }//slices
02592 
02593   return false;
02594 }

void AltAlgSliceList::newSliceToHostMuSpecStrips const std::vector< CandStripHandle * > &  mu_strips,
std::map< int, std::vector< CandStripHandle * > > &  event_slices
const [private]
 

Definition at line 3301 of file AltAlgSliceList.cxx.

References nextAvailableSliceId().

Referenced by sliceMatcher().

03304 {
03305   int slice_id = nextAvailableSliceId(event_slices);
03306 
03307   event_slices.insert(
03308        std::map<int, std::vector<CandStripHandle *> >::value_type(
03309                                                        slice_id, mu_strips) );
03310 
03311   sort(event_slices[slice_id].begin(), event_slices[slice_id].end(), min_t());
03312 }

int AltAlgSliceList::nextAvailableSliceId const std::map< int, std::vector< CandStripHandle * > > &  event_slices  )  const [private]
 

Definition at line 1849 of file AltAlgSliceList.cxx.

Referenced by newSliceToHostMuSpecStrips(), and Split().

01851 {
01852   std::map<int, std::vector<CandStripHandle *> >::const_iterator slice_iter;
01853 
01854   slice_iter = --( event_slices.end() );
01855 
01856   return ( 1 + (int) (*slice_iter).first );
01857 }

bool AltAlgSliceList::noStripsInOneView std::map< int, std::vector< CandStripHandle * > >::const_iterator  slice  )  const [private]
 

Definition at line 2006 of file AltAlgSliceList.cxx.

References MSG.

Referenced by sliceShouldBeEliminated().

02008 {
02009 // check for strips in both views in the slice
02010 //
02011   int nv = count_if(
02012                  (*slice).second.begin(), (*slice).second.end(), is_v_view());
02013   int nu = count_if(
02014                  (*slice).second.begin(), (*slice).second.end(), is_u_view());
02015 
02016   if(nv == 0 || nu == 0) {
02017 
02018       MSG("AltAlg", Msg::kVerbose)
02019            << "           |--> Slice: " << (*slice).first
02020            << " will be eliminated --> 0 strips in one view: "
02021            << "  > N(U) = " << nu << " -- N(V) = " << nv << endl;
02022 
02023   } else return false;
02024 
02025   return true;
02026 }

void AltAlgSliceList::peakFinder std::vector< TimeSlice_t > &  slice_seeds,
PeakFinderConf_t  conf
const [private]
 

Definition at line 926 of file AltAlgSliceList.cxx.

References timeslice::all_sync, asString(), fFmtTime, fTimeResolution, kDefault, kLowActivity, kMuSpectrometer, MSG, printTimeBin(), timeslice::q, timeslice::qt, TimeSlice_t, timeslice::tmax, timeslice::tmin, and timeslice::tpeak.

Referenced by getSliceSeeds().

00928 {
00929 // This method is a gross peak finder that goes through a specified time-profile
00930 // in the time window [tmin, tmax] and identifies 'peaks' (i.e. time intervals
00931 // [t_slice_min, t_slice_max]) where 'maxSuccessiveEmptyBins' were encountered
00932 // (bins with content < 'peakFinderThreshold') after at least one bin with
00933 // non-empty contents was found.
00934 //
00935 
00936   MSG("AltAlg",Msg::kDebug)
00937      << "      |--> Time-profile peak search with PeakFinderConf_t conf = "
00938      << asString(conf) << endl;
00939 
00940   int cur_bin, start_bin;
00941 
00942   int    n_successive_zeros  = 0;     // zero = ( bin content < threshold )
00943   int    n_non_zero_values   = 0;     // non-zero = (bin content >= threshold)
00944   bool   non_zero_bin_found  = false; // <-- in current slice
00945   bool   slice_is_not_over   = true;
00946   bool   new_slice_starts    = true;
00947   Axis_t content_sum         = 0;
00948 
00949   //-- These values depend on PeakFinderConf_t or the algorithm stage
00950   //   when the peak finder was called
00951 
00952   int     peak_finder_threshold     = 0; // current PeakFinderConf_t value
00953   int     max_successive_empty_bins = 0; // current PeakFinderConf_t value
00954   double  tmin                      = 0; // time window: minimum
00955   double  tmax                      = 0; // time window: maximum
00956   TH1D *  time_profile              = 0; // t-prof. the peak-finder will run on
00957 
00958   switch(conf) {
00959 
00960   case kMuSpectrometer:
00961       peak_finder_threshold     = fPkfMuSpecPeakThreshold;
00962       max_successive_empty_bins = fPkfMuSpecNSuccessiveEmptyBins;
00963       time_profile              = fSubsetTimeProfile;
00964       tmin                      = fSubsettmin;
00965       tmax                      = fSubsettmax;
00966       break;
00967   case kLowActivity:
00968       peak_finder_threshold     = fPkfLowPeakThreshold;
00969       max_successive_empty_bins = fPkfLowNSuccessiveEmptyBins;
00970       time_profile              = fSubsetTimeProfile;
00971       tmin                      = fSubsettmin;
00972       tmax                      = fSubsettmax;
00973       break;
00974   case kDefault:
00975   default:
00976       peak_finder_threshold     = fPkfPeakThreshold;
00977       max_successive_empty_bins = fPkfNSuccessiveEmptyBins;
00978       time_profile              = fTimeProfile;
00979       tmin                      = ftmin;
00980       tmax                      = ftmax;
00981       break;
00982   }
00983 
00984   MsgFormat fmtInt("%4d");
00985 
00986   // Compute threshold:
00987   //     (# of strips / time bin) * (number of merged bins in time profile)
00988   int threshold = peak_finder_threshold * fPkfNofMergedTimeBins;
00989 
00990   // Find the minimum and maximum bin for this search...
00991   // Add/subtract a small dt from tmin/tmax so that we do not widen
00992   // the search range by a bin because of round-off errors if the t value
00993   // is exactly on the bin-boundary - this would lead to non-exclusive
00994   // slice-seeds.
00995   int min_bin  = time_profile->FindBin( (Axis_t) (tmin + fTimeResolution/100.) );
00996   int max_bin  = time_profile->FindBin( (Axis_t) (tmax - fTimeResolution/100.) );
00997 
00998   MSG("AltAlg",Msg::kDebug)
00999     << "      |--> For this peak search: "
01000     << "tmin = " << fFmtTime(tmin) << " bin[" << fmtInt(min_bin) << "] "
01001     << "tmax = " << fFmtTime(tmax) << " bin[" << fmtInt(max_bin) << "] "
01002     << endl;
01003 
01004   MSG("AltAlg",Msg::kVerbose)
01005        << "      |-->[-] Printing time-profile contents & peak finder actions"
01006        << endl;
01007 
01008   // Loop over the time frames for the time window under examination
01009   for(cur_bin=min_bin; cur_bin <= max_bin; cur_bin++) {
01010 
01011      // init a new slice seed & mark its starting time bin
01012      if(new_slice_starts) {
01013 
01014          new_slice_starts = false;
01015          content_sum      = 0;
01016 
01017          // skip leading zeros...
01018          for(start_bin = cur_bin; start_bin <= max_bin; start_bin++) {
01019                   bool skip = time_profile->GetBinContent(start_bin) == 0;
01020 
01021             if(!skip) break;
01022             else  printTimeBin(start_bin, time_profile, "skipped!");
01023          }
01024          cur_bin = start_bin;
01025      }
01026 
01027      // Keep on adding non-empty (>threshold) time frames to this slice seed
01028 
01029      content_sum += time_profile->GetBinContent(cur_bin);
01030 
01031      if( time_profile->GetBinContent(cur_bin) <= threshold )
01032          n_successive_zeros++;
01033      else {
01034          non_zero_bin_found   = true;
01035          n_successive_zeros   = 0;
01036          n_non_zero_values++;
01037      }
01038 
01039      std::ostringstream sstream;
01040      sstream  << " thr: "  << fmtInt( threshold )
01041               << " - N(0's) = " << fmtInt( n_successive_zeros )
01042               << " - N(1's) = " << fmtInt( n_non_zero_values );
01043 
01044      printTimeBin(cur_bin, time_profile, sstream.str().c_str());
01045 
01046      // If
01047      // a) we have not reached the maximum allowed number of successive
01048      //    time frames with pulse height < threshold, or
01049      // b) we have not included any time frame with pulse height > threshold
01050 
01051      if(n_successive_zeros < max_successive_empty_bins || !non_zero_bin_found)
01052 
01053          slice_is_not_over = true;  // then keep on expanding the slice seed
01054      else
01055          slice_is_not_over = false; // else stop expanding the slice seed now!
01056 
01057      // There is no life after tmax:
01058      //  --the current slice seed is forced to stop growing if we reach
01059      //    the 'end of the time window'
01060      //  --this only happens if there was at least one entry in the bins
01061      //    associated with this slice-seed
01062      if(cur_bin == max_bin && content_sum > 0) slice_is_not_over = false;
01063 
01064      if(!slice_is_not_over) {
01065 
01066        MSG("AltAlg",Msg::kVerbose)
01067              << "          **** Peak included - could stop at any time"
01068              << " - adding any trailing bins below threshold"<< endl;
01069 
01070         int end_bin;
01071         for(end_bin = cur_bin+1; end_bin <= max_bin; end_bin++) {
01072           bool expand = time_profile->GetBinContent(end_bin) > 0 &&
01073                          time_profile->GetBinContent(end_bin) <= threshold;
01074 
01075           if(!expand) break;
01076           else printTimeBin(end_bin, time_profile,
01077                                         "trailing bin appended to slice!");
01078         }
01079 
01080         MSG("AltAlg",Msg::kVerbose)
01081             << "          **** Stop! One more slice seed is added" << endl;
01082 
01083         cur_bin = end_bin-1;
01084 
01085         //--- reset for next slice seed within this spill
01086         n_successive_zeros  =  0;
01087         n_non_zero_values   =  0;
01088         non_zero_bin_found  =  false;
01089         slice_is_not_over   =  true;
01090         new_slice_starts    =  true;
01091 
01092         //--- add time info for the added seed
01093 
01094         TimeSlice_t current_slice_seed;
01095 
01096         current_slice_seed.tmin =
01097                         (double)   time_profile->GetBinLowEdge(start_bin);
01098         current_slice_seed.tmax =
01099                         (double)   time_profile->GetBinLowEdge(end_bin);
01100 
01101         // with the new approach that was causing overlaps...
01102         //(double) ( time_profile->GetBinLowEdge(end_bin) +
01103         //           time_profile->GetBinWidth(end_bin)  );
01104 
01105         // this will be update later (and then all_sync = true)
01106         current_slice_seed.tpeak    = -1;
01107         current_slice_seed.qt       = -1;
01108         current_slice_seed.q        = -1;
01109         current_slice_seed.all_sync = false;
01110         slice_seeds.push_back(current_slice_seed);
01111      }
01112 
01113   } // loop over time frames
01114 }

void AltAlgSliceList::plot3DClusters TCanvas *  c,
std::map< int, std::vector< CandStripHandle * > >  event_slices
[private]
 

Definition at line 761 of file AltAlgSliceList.cxx.

References fNTimeBins, ftmax, and ftmin.

00763 {
00764   TPad *  padU  = new TPad("padU","z-tpos-t @ u view",0.01,0.01,0.49,0.99,0);
00765   TPad *  padV  = new TPad("padV","z-tpos-t @ v view",0.51,0.01,0.99,0.99,0);
00766 
00767   std::vector<TH3D *> uview;
00768   std::vector<TH3D *> vview;
00769 
00770   TH3D *  hZTposT_u = 0;
00771   TH3D *  hZTposT_v = 0;
00772 
00773   int colors[26] = {
00774          1,40,2,30,3,4,5,6,7,8,9,11,25,42,50,28,1,40,2,30,3,4,5,6,7,8};
00775   int icolor = 0;
00776 
00777   double clight = 300000000;
00778 
00779   //-- beautify canvas
00780 
00781   c->SetBorderMode(0);
00782   c->SetFillColor(0);
00783   c->Draw();
00784   padU->Draw();
00785   padV->Draw();
00786   padU->SetBorderMode(0);
00787   padV->SetBorderMode(0);
00788 
00789   for(std::map<int, std::vector<CandStripHandle *> >::iterator iter =
00790             event_slices.begin(); iter != event_slices.end(); ++iter) {
00791 
00792 
00793      hZTposT_u = new TH3D("hZTposT_u","",200,0,20,100,-4,4,
00794                                        fNTimeBins,ftmin*clight,ftmax*clight);
00795 
00796      hZTposT_v = new TH3D("hZTposT_v","",200,0,20,100,-4,4,
00797                                        fNTimeBins,ftmin*clight,ftmax*clight);
00798 
00799      std::vector<CandStripHandle *> slice_strips = (*iter).second;
00800 
00801      for(std::vector<CandStripHandle *>::iterator strip_iter =
00802           slice_strips.begin(); strip_iter != slice_strips.end(); ++strip_iter) {
00803 
00804         if( (*strip_iter)->GetPlaneView() == PlaneView::kU)
00805             hZTposT_u->Fill( (*strip_iter)->GetZPos(), (*strip_iter)->GetTPos(),
00806                               clight*(*strip_iter)->GetCorrBegTime());
00807 
00808         if( (*strip_iter)->GetPlaneView() == PlaneView::kV)
00809             hZTposT_v->Fill( (*strip_iter)->GetZPos(), (*strip_iter)->GetTPos(),
00810                              clight*(*strip_iter)->GetCorrBegTime());
00811      }
00812 
00813      uview.push_back(hZTposT_u);
00814      vview.push_back(hZTposT_v);
00815 
00816      hZTposT_u->SetMarkerStyle(20);
00817      hZTposT_u->SetMarkerSize(0.7);
00818      hZTposT_u->SetMarkerColor(colors[icolor]);
00819      hZTposT_u->SetStats(kFALSE);
00820 
00821      hZTposT_v->SetMarkerStyle(20);
00822      hZTposT_v->SetMarkerSize(0.7);
00823      hZTposT_v->SetMarkerColor(colors[icolor]);
00824      hZTposT_v->SetStats(kFALSE);
00825 
00826      if(uview.size() == 1) {
00827          padU->cd();
00828          hZTposT_u->Draw("P");
00829          padV->cd();
00830          hZTposT_v->Draw("P");
00831      } else {
00832          padU->cd();
00833          hZTposT_u->Draw("PSAME");
00834          padV->cd();
00835          hZTposT_v->Draw("PSAME");
00836      }
00837      c->Update();
00838      icolor++;
00839   }
00840 
00841 
00842   c->Update();
00843 
00844   for(std::vector<TH3D *>::iterator iterTH3 = uview.begin();
00845                         iterTH3 != uview.end(); ++iterTH3) delete (*iterTH3);
00846   for(std::vector<TH3D *>::iterator iterTH3 = vview.begin();
00847                         iterTH3 != vview.end(); ++iterTH3) delete (*iterTH3);
00848 }

void AltAlgSliceList::printSlice const std::vector< CandStripHandle * > &  slice  )  const [private]
 

Definition at line 1645 of file AltAlgSliceList.cxx.

References PlaneView::AsString(), fFmtPln, fFmtQ, fFmtStp, fFmtTime, and MSG.

01647 {
01648   int nv = count_if(slice.begin(), slice.end(), is_v_view());
01649   int nu = count_if(slice.begin(), slice.end(), is_u_view());
01650 
01651   MSG("AltAlg", Msg::kDebug)
01652      << "[-] printing slice whose id was not specified or a strip collection"
01653      << " - (N(U) = " << nu << " -- N(V) = " << nv << ")" << endl;
01654 
01655   std::vector<CandStripHandle *>::const_iterator strip_iter;
01656 
01657   for(strip_iter = slice.begin(); strip_iter != slice.end(); ++strip_iter) {
01658 
01659      MSG("AltAlg", Msg::kDebug)
01660         << " |--> Pl = " << fFmtPln(  (*strip_iter)->GetPlane()   )
01661         << " Str = "     << fFmtStp(  (*strip_iter)->GetStrip()   )
01662         << " Q = "       << fFmtQ(    (*strip_iter)->GetCharge()  )
01663         << " tb = "      << fFmtTime( (*strip_iter)->GetCorrBegTime() )
01664         << " view = " << PlaneView::AsString( (*strip_iter)->GetPlaneView() )
01665         << endl;
01666   } // strip_iter
01667 }

void AltAlgSliceList::printSlice std::map< int, std::vector< CandStripHandle * > >::const_iterator  slice  )  const [private]
 

Definition at line 1615 of file AltAlgSliceList.cxx.

References PlaneView::AsString(), fFmtPln, fFmtQ, fFmtStp, fFmtTime, and MSG.

Referenced by printSlices().

01617 {
01618 // Method for printing the reconstructed event slices
01619 //
01620   int nv = count_if(
01621                  slice->second.begin(), slice->second.end(), is_v_view());
01622   int nu = count_if(
01623                  slice->second.begin(), slice->second.end(), is_u_view());
01624 
01625   MSG("AltAlg", Msg::kDebug)
01626      << "[-] Slice: " << slice->first
01627      << " - (N(U) = " << nu << " -- N(V) = " << nv << ")" << endl;
01628 
01629   const std::vector<CandStripHandle *> & slice_strips = slice->second;
01630   std::vector<CandStripHandle *>::const_iterator strip_iter;
01631 
01632   for(strip_iter = slice_strips.begin();
01633                           strip_iter != slice_strips.end(); ++strip_iter) {
01634 
01635      MSG("AltAlg", Msg::kDebug)
01636         << " |--> Pl = " << fFmtPln(  (*strip_iter)->GetPlane()   )
01637         << " Str = "     << fFmtStp(  (*strip_iter)->GetStrip()   )
01638         << " Q = "       << fFmtQ(    (*strip_iter)->GetCharge()  )
01639         << " tb = "      << fFmtTime( (*strip_iter)->GetCorrBegTime() )
01640         << " view = " << PlaneView::AsString( (*strip_iter)->GetPlaneView() )
01641         << endl;
01642   } // strip_iter
01643 }

void AltAlgSliceList::printSlices const std::map< int, std::vector< CandStripHandle * > > &  event_slices,
const char *  comments = ""
const [private]
 

Definition at line 1598 of file AltAlgSliceList.cxx.

References MSG, and printSlice().

Referenced by assignMuonSpectrHits2Slices(), and RunAlg().

01601 {
01602 // Method for printing the reconstructed event slices
01603 //
01604   MSG("AltAlg", Msg::kDebug) << "* Printing Reco Slices: " << comment << endl;
01605 
01606   std::map<int, std::vector<CandStripHandle *> >::const_iterator slice_iter;
01607 
01608   for(slice_iter = event_slices.begin();
01609                slice_iter != event_slices.end(); ++slice_iter)
01610                                                        printSlice(slice_iter);
01611 
01612   MSG("AltAlg", Msg::kDebug) << "* Printing Reco Slices completed" << endl;
01613 }

void AltAlgSliceList::printSliceSeed const TimeSlice_t seed  )  const [private]
 

Definition at line 1583 of file AltAlgSliceList.cxx.

References fFmtQ, fFmtTime, MSG, timeslice::q, TimeSlice_t, timeslice::tmax, timeslice::tmin, and timeslice::tpeak.

Referenced by updateSingleSliceSeedInfo().

01584 {
01585    MSG("AltAlg", Msg::kDebug)
01586           << "              |--> Seed info: t = ["
01587           << fFmtTime(seed.tmin) << ", "    << fFmtTime(seed.tmax)
01588           << "] with peak at t = " << fFmtTime(seed.tpeak)
01589           << " and Qtot = " << fFmtQ(seed.q) << endl;
01590 }

void AltAlgSliceList::printSliceSeeds const std::vector< TimeSlice_t > &  slice_seeds,
const char *  comment = ""
const [private]
 

Definition at line 1552 of file AltAlgSliceList.cxx.

References fFmtTime, and MSG.

Referenced by fillSliceSeeds(), and getSliceSeeds().

01554 {
01555 // Method for printing the slice seeds found by the time-profile peak-finder
01556 //
01557   MSG("AltAlg", Msg::kDebug) << "[-] Printing: " << comment << endl;
01558 
01559   int islice=0;
01560   MsgFormat fmtInt("%3d");
01561 
01562   std::vector<TimeSlice_t>::const_iterator time_slice_iter;
01563 
01564   for(time_slice_iter = slice_seeds.begin();
01565                time_slice_iter != slice_seeds.end(); ++time_slice_iter) {
01566 
01567       if( (*time_slice_iter).tpeak == -1 )
01568         MSG("AltAlg", Msg::kDebug)
01569              << " |--> t(slc-seed ="    << fmtInt( islice++ ) << ")"
01570              << " = ["  << fFmtTime( (*time_slice_iter).tmin )
01571              << ", "    << fFmtTime( (*time_slice_iter).tmax )
01572              << "] with pulse height peak not defined yet" << endl;
01573       else
01574          MSG("AltAlg", Msg::kDebug)
01575              << " |--> t(slc-seed ="    << fmtInt( islice++ ) << ")"
01576              << " = ["  << fFmtTime( (*time_slice_iter).tmin )
01577              << ", "    << fFmtTime( (*time_slice_iter).tmax )
01578              << "] with pulse height peak at t = "
01579              << fFmtTime( (*time_slice_iter).tpeak ) << endl;
01580   }
01581 }

void AltAlgSliceList::printStrip const CandStripHandle strip  )  const [private]
 

Definition at line 1694 of file AltAlgSliceList.cxx.

References PlaneView::AsString(), fFmtPln, fFmtQ, fFmtStp, fFmtTime, CandStripHandle::GetCharge(), CandStripHandle::GetCorrBegTime(), CandStripHandle::GetPlane(), CandStripHandle::GetPlaneView(), CandStripHandle::GetStrip(), and MSG.

Referenced by updateSingleSliceSeedInfo().

01695 {
01696    MSG("AltAlg", Msg::kVerbose)
01697        << "              |--> Pl = " << fFmtPln(  strip->GetPlane()   )
01698        << " Str = "     << fFmtStp(  strip->GetStrip()   )
01699        << " Q = "       << fFmtQ(    strip->GetCharge()  )
01700        << " tb = "      << fFmtTime( strip->GetCorrBegTime() )
01701        << " view = " << PlaneView::AsString( strip->GetPlaneView() )
01702        << endl;
01703 }

void AltAlgSliceList::printStripList CandStripHandleItr  cshItr,
const char *  comment = ""
const [private]
 

Definition at line 1669 of file AltAlgSliceList.cxx.

References PlaneView::AsString(), fFmtPln, fFmtQ, fFmtStp, fFmtTime, CandStripHandle::GetCharge(), CandStripHandle::GetCorrBegTime(), CandStripHandle::GetPlane(), CandStripHandle::GetPlaneView(), CandStripHandle::GetStrip(), and MSG.

Referenced by RunAlg().

01671 {
01672   MSG("AltAlg", Msg::kVerbose) << comment << endl;
01673 
01674   MSG("AltAlg", Msg::kVerbose)
01675       << " |--> selected " << cshItr.GetSet()->SizeSelect()
01676       << " out of "        << cshItr.GetSet()->Size()
01677       << " entries" << endl;
01678 
01679   cshItr.ResetFirst();
01680   while( CandStripHandle * striph = cshItr.Ptr() ) {
01681 
01682      MSG("AltAlg", Msg::kVerbose)
01683         << " |--> Pl = " << fFmtPln(  striph->GetPlane()   )
01684         << " Str = "     << fFmtStp(  striph->GetStrip()   )
01685         << " Q = "       << fFmtQ(    striph->GetCharge()  )
01686         << " tb = "      << fFmtTime( striph->GetCorrBegTime() )
01687         << " view = " << PlaneView::AsString( striph->GetPlaneView() )
01688         << endl;
01689 
01690      cshItr.Next();
01691   }
01692 }

void AltAlgSliceList::printTimeBin int  bin,
const TH1D *  time_profile,
const char *  comment = ""
const [private]
 

Definition at line 1705 of file AltAlgSliceList.cxx.

References fFmtTime, and MSG.

Referenced by peakFinder().

01707 {
01708    MsgFormat fmtInt("%4d");
01709 
01710    MSG("AltAlg",Msg::kVerbose)
01711        << "          |--> bin: "  << fmtInt( bin )
01712        << ":[" << fFmtTime( (double)    time_profile->GetBinLowEdge(bin) )
01713        << ", " << fFmtTime( (double)  ( time_profile->GetBinLowEdge(bin) +
01714                                         time_profile->GetBinWidth(bin)) )
01715        << "], cnt: "  << fmtInt( int( time_profile->GetBinContent(bin) ))
01716        << " / " << comment << endl;
01717 }

void AltAlgSliceList::reduceTimeWindows CandStripHandleItr *  cshItr,
std::vector< TimeSlice_t > &  slice_seeds
[private]
 

Definition at line 1204 of file AltAlgSliceList.cxx.

References fFmtTime, findSmallerPeaks(), fPkfTimeWindowAftPeak, fPkfTimeWindowBefPeak, fSubsettmax, fSubsettmin, fTimeProfile, fTimeResolution, mergeSeeds(), MSG, and updateSingleSliceSeedInfo().

Referenced by getSliceSeeds().

01206 {
01207 // The 'recursive' peak finding approach is actually implemented here.
01208 // After the first pass, definite peaks were found and now we are looking
01209 // for smaller peaks in the 'time' between these peaks... by calling the
01210 // method ...that has called this method (and so on, until the full space
01211 // is serached for peaks).
01212 //
01213   MsgFormat fmtInt("%3d");
01214 
01215   // Maximum time interval that can be assigned to any single slice-seed.
01216   // bin width = time resolution
01217   // maximum duration in time resolution units =
01218   //  # bins before peak + # bins after peak + the bin that contains the peak
01219 
01220   double max_duration = fTimeResolution *
01221                           (fPkfTimeWindowBefPeak + fPkfTimeWindowAftPeak + 1);
01222 
01223   MSG("AltAlg", Msg::kDebug)
01224       << "Narrowing seeds: duration limited to "
01225       << fFmtTime(max_duration)
01226       << " (-" << fPkfTimeWindowBefPeak << ", "
01227       << "+"   << fPkfTimeWindowAftPeak << ") bins around peak's bin"
01228       << endl;
01229 
01230   // caution: in this loop I perform insert() / erase() operations on the
01231   //          "std::vector<TimeSlice_t> slice_seeds"...
01232   //          Do not use STL iterators in this case because the condition
01233   //          "iter != slice_seeds.end()" gets invalidated by these operations.
01234 
01235   for(unsigned int islice = 0; islice < slice_seeds.size(); islice++) {
01236 
01237       double dt = slice_seeds[islice].tmax - slice_seeds[islice].tmin;
01238 
01239       if(dt > max_duration) {
01240 
01241           bool search_before_peak = false;
01242           bool search_after_peak  = false;
01243 
01244           MSG("AltAlg", Msg::kDebug)
01245              << "[-] Got a wide slice seed: Dt = " << fFmtTime( dt )
01246              << " > (maxDuration = ) " << fFmtTime(max_duration)
01247              << endl;
01248 
01249           //-- reduce the slice-seed width
01250 
01251           MSG("AltAlg", Msg::kDebug)
01252               << " |-->[-] initial:  t(slc-seed="    << fmtInt( islice ) << ")"
01253               << " = ["  << fFmtTime( slice_seeds[islice].tmin )
01254               << ", "    << fFmtTime( slice_seeds[islice].tmax )
01255               << "] with pulse height peak at t = "
01256               << fFmtTime( slice_seeds[islice].tpeak )
01257               << endl;
01258 
01259           int peak_bin = fTimeProfile->FindBin(
01260                                  (Axis_t) slice_seeds[islice].tpeak );
01261 
01262           int min_bin  = peak_bin - fPkfTimeWindowBefPeak;
01263           int max_bin  = peak_bin + fPkfTimeWindowAftPeak;
01264 
01265           double tmin_new = (double)   fTimeProfile->GetBinLowEdge(min_bin);
01266           double tmax_new = (double) ( fTimeProfile->GetBinLowEdge(max_bin) +
01267                                        fTimeProfile->GetBinWidth(max_bin)  );
01268 
01269           double tmin_old = slice_seeds[islice].tmin;
01270           double tmax_old = slice_seeds[islice].tmax;
01271 
01272           //-- check whether the 'after peak' time boundary should be shifted
01273 
01274           if( tmax_old > tmax_new ) {
01275              search_after_peak            = true;
01276              slice_seeds[islice].tmax     = tmax_new;
01277              slice_seeds[islice].all_sync = false;
01278           }
01279 
01280           //-- check whether the 'before peak' time boundary should be shifted
01281 
01282           if( tmin_old < tmin_new ) {
01283              search_before_peak           = true;
01284              slice_seeds[islice].tmin     = tmin_new;
01285              slice_seeds[islice].all_sync = false;
01286           }
01287 
01288           MSG("AltAlg", Msg::kDebug)
01289               << " |-->[-] updated:  t(slc-seed="    << fmtInt( islice ) << ")"
01290               << " = ["  << fFmtTime( slice_seeds[islice].tmin )
01291               << ", "    << fFmtTime( slice_seeds[islice].tmax )
01292               << "] with pulse height peak at t = "
01293               << fFmtTime( slice_seeds[islice].tpeak ) << endl;
01294 
01295 
01296           //-- tmin/tmax changed --keep all TimeSlice_t info in sync
01297           MSG("AltAlg", Msg::kDebug)
01298               << "      |-[-] sync TimeSlice info" << endl;
01299 
01300           if(!slice_seeds[islice].all_sync)
01301                       updateSingleSliceSeedInfo(cshItr, slice_seeds[islice]);
01302 
01303           //-- change PeakFinderConf_t to kLowActivity and look for new
01304           //   slice seeds in 'de-allocated' time-space
01305 
01306           if( search_after_peak ) {
01307 
01308             MSG("AltAlg", Msg::kDebug)
01309                << "      |-->[-] Looking for small peaks (after the main peak) "
01310                << "in [" << fFmtTime(tmax_new)
01311                << ", "   << fFmtTime(tmax_old) << "] time window" << endl;
01312 
01313             fSubsettmin = tmax_new;
01314             fSubsettmax = tmax_old;
01315 
01316             std::vector<TimeSlice_t> new_seeds = findSmallerPeaks(cshItr);
01317             if(new_seeds.size() > 0) mergeSeeds(new_seeds, slice_seeds);
01318           }
01319 
01320           if( search_before_peak ) {
01321 
01322             MSG("AltAlg", Msg::kDebug)
01323               << "      |-->[-] Looking for small peaks (before the main peak) "
01324               << "in [" << fFmtTime(tmin_old)
01325               << ", "   << fFmtTime(tmin_new) << "] time window" << endl;
01326 
01327             fSubsettmin = tmin_old;
01328             fSubsettmax = tmin_new;
01329 
01330             std::vector<TimeSlice_t> new_seeds = findSmallerPeaks(cshItr);
01331             if(new_seeds.size() > 0) mergeSeeds(new_seeds, slice_seeds);
01332           }
01333 
01334       } //  if dt > max_duration
01335 
01336       //islice++;
01337   } // slice seed iter
01338 
01339 }

void AltAlgSliceList::rellocateStrip int  source,
int  target,
CandStripHandle strip,
std::map< int, std::vector< CandStripHandle * > > &  event_slices
const [private]
 

Definition at line 2988 of file AltAlgSliceList.cxx.

References fFmtSlc, and MSG.

Referenced by singleKMeansIteration().

02991 {
02992 // Rellocates strip from slice: source to slice: target
02993 //
02994   MSG("AltAlg", Msg::kVerbose)
02995            << "         |--[-] strip rellocation is attempted now..." << endl;
02996 
02997   MSG("AltAlg", Msg::kVerbose)
02998              << "             |--> source: " << fFmtSlc( source )
02999              << " [elements = " << event_slices[source].size() << "]"
03000              << " --> target: " << fFmtSlc( target )
03001              << " [elements = " << event_slices[target].size() << "]" << endl;
03002 
03003   event_slices[target].push_back( strip );
03004 
03005   event_slices[source].erase( find_if( event_slices[source].begin(),
03006                                        event_slices[source].end(),
03007                                        same_strip(strip) ));
03008 
03009   MSG("AltAlg", Msg::kVerbose)
03010          << "             |--> strip rellocation done..."
03011          << " [src slice elements] = " << event_slices[source].size()
03012          << " [tgt slice elements] = " << event_slices[target].size() << endl;
03013 }

void AltAlgSliceList::removeNullSeeds std::vector< TimeSlice_t > &  slice_seeds  )  const [private]
 

Definition at line 1188 of file AltAlgSliceList.cxx.

References MSG.

Referenced by fillSliceSeeds(), and updateSliceSeedInfo().

01190 {
01191   MSG("AltAlg", Msg::kDebug)
01192           << "    |-->[-] removing any 'null' slice-seed" << endl;
01193   MSG("AltAlg", Msg::kDebug)
01194           << "         |--> init. size = " << slice_seeds.size() << endl;
01195 
01196   std::vector<TimeSlice_t>::iterator slice_iter_new_end =
01197            remove_if( slice_seeds.begin(), slice_seeds.end(), zero_charge() );
01198   slice_seeds.erase( slice_iter_new_end, slice_seeds.end() );
01199 
01200   MSG("AltAlg", Msg::kDebug)
01201           << "         |--> fin. size = " << slice_seeds.size() << endl;
01202 }

void AltAlgSliceList::resetSliceSeed TimeSlice_t seed  )  const [private]
 

Definition at line 1592 of file AltAlgSliceList.cxx.

References timeslice::all_sync, timeslice::q, timeslice::qt, TimeSlice_t, timeslice::tmax, timeslice::tmin, and timeslice::tpeak.

Referenced by updateSingleSliceSeedInfo().

01593 {
01594   seed.tmin  = 0;  seed.tpeak = 0;  seed.tmax  = 0;
01595   seed.q     = 0;  seed.qt    = 0;  seed.all_sync = true;
01596 }

void AltAlgSliceList::RunAlg AlgConfig ac,
CandHandle ch,
CandContext cx
[virtual]
 

Implements AlgBase.

Definition at line 230 of file AltAlgSliceList.cxx.

References assignMuonSpectrHits2Slices(), buildCandidates(), display(), eventClustering(), fFmtTime, fGrfxDebugGraphics, fillSliceSeeds(), fNTimeBins, fPkfNofMergedTimeBins, fPkfRecursivePeakSearch, fTimeDiffBetweenPeaks, fTimeProfile, fTimeProfileMax, fTimeResolution, ftmax, ftmin, fZDiffBetweenPeaks, getAlgorithmConfiguration(), CandStripHandle::GetCharge(), CandStripHandle::GetCorrBegTime(), CandContext::GetDataIn(), CandHandle::GetDaughterIterator(), VldContext::GetDetector(), getSliceSeeds(), getSnarlTimeBoundaries(), CandHandle::GetVldContext(), initSliceFiltering(), kMuSpec1stPlane, MSG, Registry::Print(), printSlices(), printStripList(), SelectNonZeroQ(), sliceMerger(), and StripKeyFromTime().

00231 {
00232   MSG("AltAlg",Msg::kInfo)
00233          << "**** Begin of AltAlgSliceList::RunAlg() with parameters" << endl;
00234 
00235   //cout.setf(ios_base::fmtflags(0));
00236   ac.Print();
00237 
00238   assert(cx.GetDataIn());
00239   assert(cx.GetDataIn()->InheritsFrom("CandStripListHandle"));
00240 
00241   //-- get a handle to input CandStripList & and create an iterator
00242 
00243   const CandStripListHandle * cslh =
00244                    dynamic_cast<const CandStripListHandle *> (cx.GetDataIn());
00245 
00246   CandStripHandleItr cshItr   ( cslh->GetDaughterIterator() );
00247   CandStripHandleItr cshItr_u ( cslh->GetDaughterIterator() );
00248   CandStripHandleItr cshItr_d ( cslh->GetDaughterIterator() );
00249   assert( cshItr.GetSet()->Size() > 0 );
00250 
00251   //-- this check will be removed - the algorithm is in principle applicable
00252   //   to far detector as well
00253 
00254   if(cslh->GetVldContext()->GetDetector() != DetectorType::kNear) {
00255     MSG("AltAlg", Msg::kFatal)
00256              << "DATA COMING FROM A WRONG DETECTOR!! QUITING AT ONCE" << endl;
00257     return;
00258   }
00259 
00260   //====================== get algorithm configuration =======================
00261 
00262   getAlgorithmConfiguration(ac);
00263 
00264   assert(fTimeResolution       > 0);
00265   assert(fPkfNofMergedTimeBins > 0);
00266   assert(fZDiffBetweenPeaks    > 0);
00267   assert(fTimeDiffBetweenPeaks > 0);
00268 
00269   //====== Use Navigation tools to suitably sort/select the NavSets ==========
00270   //======      accessible by my CandStripHandleItr iterators       ==========
00271 
00272   // cshItr            can be used to loop over a time-sorted collection of
00273   //                   all hit strips with Q>0
00274 
00275   CandStripHandleKeyFunc * key_func_1 =  cshItr.CreateKeyFunc();
00276   key_func_1->SetFun(SelectNonZeroQ);
00277   cshItr.GetSet()->AdoptSelectKeyFunc(key_func_1);
00278   key_func_1=0;
00279   CandStripHandleKeyFunc * key_func_2 =  cshItr.CreateKeyFunc();
00280   key_func_2->SetFun(StripKeyFromTime);
00281   cshItr.GetSet()->AdoptSortKeyFunc(key_func_2);
00282   key_func_2=0;
00283 
00284   printStripList(cshItr, "Input CandStripList: Q > 0, time-sorted");
00285 
00286   // cshItr_u          Can be used to loop over a time-sorted collection of
00287   //                   all hit strips with Q>0 in the upstream detector
00288   //                   This is used to exclude the mu-spectrometer hits in ND
00289   // cshItr_d          Like cshItr_u but for the downstream detector
00290   //                   This is used to select only mu-spectrometer hits in ND
00291 
00292   PlaneCandStripHandleKeyFunctor  plane_functor_u(kMuSpec1stPlane-1, 0, "le");
00293   PlaneCandStripHandleKeyFunctor  plane_functor_d(kMuSpec1stPlane-1, 0, "g");
00294 
00295   CandStripHandleKeyFunc * key_func_u1 =  cshItr_u.CreateKeyFunc();
00296   key_func_u1->SetFun(plane_functor_u);
00297   cshItr_u.GetSet()->AdoptSelectKeyFunc(key_func_u1);
00298   key_func_u1=0;
00299   CandStripHandleKeyFunc * key_func_u2 =  cshItr_u.CreateKeyFunc();
00300   key_func_u2->SetFun(StripKeyFromTime);
00301   cshItr_u.GetSet()->AdoptSortKeyFunc(key_func_u2);
00302   key_func_u2=0;
00303 
00304   std::ostringstream sstream_u;
00305   sstream_u  << "Input CandStripList: Pln <= "<< kMuSpec1stPlane-1
00306              << " && Q > 0, time-sorted";
00307   printStripList(cshItr_u, sstream_u.str().c_str());
00308 
00309   CandStripHandleKeyFunc * key_func_d1 =  cshItr_d.CreateKeyFunc();
00310   key_func_d1->SetFun(plane_functor_d);
00311   cshItr_d.GetSet()->AdoptSelectKeyFunc(key_func_d1);
00312   key_func_d1=0;
00313   CandStripHandleKeyFunc * key_func_d2 =  cshItr_d.CreateKeyFunc();
00314   key_func_d2->SetFun(StripKeyFromTime);
00315   cshItr_d.GetSet()->AdoptSortKeyFunc(key_func_d2);
00316   key_func_d2=0;
00317 
00318   std::ostringstream sstream_d;
00319   sstream_d  << "Input CandStripList: Pln > " << kMuSpec1stPlane-1
00320              << " && Q > 0, time-sorted";
00321   printStripList(cshItr_d, sstream_d.str().c_str());
00322 
00323 
00324   //=========================  Get spill time-profile  =======================
00325 
00326   //-- get earliest & latest time in the snarl
00327 
00328   getSnarlTimeBoundaries(&cshItr, ftmin, ftmax);
00329 
00330   MSG("AltAlg", Msg::kDebug)
00331        << "Spill time boundaries: tmin = "
00332        << fFmtTime( ftmin ) << " - tmax = " << fFmtTime( ftmax ) << endl;
00333 
00334   //-- group raw times in bins given by the near det time resolution
00335 
00336   fNTimeBins   = (int) ( (ftmax-ftmin+15*fTimeResolution) / (fTimeResolution) );
00337 
00338   fTimeProfile = new TH1D("fTimeProfile", "time profile", fNTimeBins,
00339                              ftmin-5*fTimeResolution, ftmax+10*fTimeResolution);
00340 
00341   MSG("AltAlg", Msg::kDebug)
00342       << "tprof[min] = " <<  fFmtTime( ftmin -  5*fTimeResolution ) << " "
00343       << "tprof[max] = " <<  fFmtTime( ftmax + 15*fTimeResolution ) << " "
00344       << "nbins = " << fNTimeBins << endl;
00345 
00346   // For the time profile use only strips in the upstream detector
00347   // (the cshItr_u CandStripHandleItr points only to those CandStripHandles -
00348   //  see above how the Sort/Select KeyFucs are applied using NavigationTools)
00349   //
00350   // This is used to exclude hits in the muon spectrometer.
00351   // These strips can not be included in the subsequent 3-D clustering
00352   // (in time, tpos, z) space *as they are* since they are not demuxed.
00353   //
00354   // Muon spectrometer hits are treated separately and are assigned to
00355   // event slices *after* they have been formed (see later)
00356 
00357   cshItr_u.ResetFirst();
00358   while( CandStripHandle * striph = cshItr_u.Ptr() ) {
00359 
00360      (fPkfWeightProfileWithCharge) ?
00361                  fTimeProfile->Fill( striph->GetCorrBegTime(), striph->GetCharge() )  :
00362            fTimeProfile->Fill( striph->GetCorrBegTime() )  ;
00363 
00364      cshItr_u.Next();
00365   }
00366   fTimeProfile->Rebin(fPkfNofMergedTimeBins);
00367   fTimeProfileMax = fTimeProfile->GetMaximum();
00368 
00369   //========================= Compute Slice 'Seeds'  =========================
00370 
00371   MSG("AltAlg", Msg::kInfo) << "--> Finding slice seeds " << endl;
00372 
00373   std::vector<TimeSlice_t> slice_seeds = getSliceSeeds(
00374                                           &cshItr_u, fPkfRecursivePeakSearch);
00375 
00376   MSG("AltAlg", Msg::kInfo)
00377         << "--> " << slice_seeds.size() << " slice seeds were found " << endl;
00378 
00379   //========================= Fill Slice 'Seed' maps =========================
00380 
00381   MSG("AltAlg", Msg::kInfo)
00382             << "--> Filling map<int, vector<CandStripHandle *> > event_slices"
00383             << endl;
00384 
00385   std::map<int, std::vector<CandStripHandle *> >
00386                           event_slices = fillSliceSeeds(cshItr_u, slice_seeds);
00387 
00388   //-- print / draw the event slices (time structure & UZ, VZ views)
00389   printSlices(event_slices, "rough slice seeds");
00390   if(fGrfxDebugGraphics & 1) display(event_slices,
00391                         "before space/time clustering - rough time splitting");
00392 
00393   //======================= Dissolve very small slices =======================
00394 
00395   //-- handle the most obvious cases where a 'fake' slice-seed was created by
00396   //   the recursive peak finder -- usually it must be very small or very
00397   //   scattered slices -- dissolve them and append the orphan strips to the
00398   //   best available slice...
00399 
00400   if( fRefinementDissolving ) {
00401 
00402      MSG("AltAlg", Msg::kInfo) << "--> Slice filtering" << endl;
00403 
00404      initSliceFiltering(event_slices);
00405 
00406      printSlices(event_slices, "after slice filtering");
00407      if(fGrfxDebugGraphics & 2) display(event_slices, "after slice filtering");
00408 
00409   } //if !skipping refinement
00410 
00411   //============================= Merge slices ===============================
00412 
00413   //-- handle the most obvious cases where an event is split between two or
00414   //   more slices...
00415 
00416   if( fRefinementMerging ) {
00417 
00418      MSG("AltAlg", Msg::kInfo)
00419        << "--> Merging slices where it seems that an event was split" << endl;
00420 
00421      sliceMerger(event_slices);
00422 
00423      printSlices(event_slices, "after slice merging");
00424      if(fGrfxDebugGraphics & 4) display(event_slices, "after slice merging");
00425   }
00426 
00427   //============== Re-order "misplaced" strips : 3-D clustering ==============
00428 
00429   //-- compute 3-D clusters in UZT & VZT space with a k-Means
00430   //   clustering algorithm
00431 
00432   if( fRefinementKMeansClustering ) {
00433 
00434      MSG("AltAlg", Msg::kInfo)
00435           << "--> strip 2 slice reassignments based on k-Means 3-D clustering"
00436           << endl;
00437 
00438      eventClustering(event_slices);
00439 
00440      printSlices(event_slices, "after 3-D k-Means clustering");
00441      if(fGrfxDebugGraphics & 8)
00442                  display(event_slices, "after k_Means space/time clustering");
00443   }
00444 
00445   //============== Look for substructure within existing slices ==============
00446 
00447   if( fRefinementMSTClustering ) {
00448 
00449      MSG("AltAlg", Msg::kInfo)
00450       << "--> Look for big slices that could be (better) splitted in N others"
00451       << endl;
00452 
00453      //-- need to code this part
00454 
00455      printSlices(event_slices, "after attempt to split slices");
00456      if(fGrfxDebugGraphics & 16)
00457                                display(event_slices, "after MST clustering");
00458   }
00459 
00460   //=========== Assign muon spectrometer hit strips to the slices ==========
00461 
00462   // this is relevant to the near detector only
00463 
00464   if(cslh->GetVldContext()->GetDetector() == DetectorType::kNear) {
00465 
00466     MSG("AltAlg", Msg::kInfo)
00467                  << "--> Assign ND Muon Spectrometer hits in slices" << endl;
00468 
00469     //-- hits in the muon spectrometer will be assigned to the closest
00470     //   (t-wise) slice in which hit strips just before the spectrometer
00471     //   have been assigned to...
00472 
00473     assignMuonSpectrHits2Slices(cshItr_d, event_slices);
00474   }
00475 
00476   MSG("AltAlg", Msg::kInfo)
00477       << "--> " << event_slices.size()
00478       << ((event_slices.size() == 1) ? " slice was" : " slices were")
00479       << " found in this spill" << endl;
00480 
00481   printSlices(event_slices, "final reconstructed slices");
00482   if(fGrfxDebugGraphics & 32) display(event_slices, "final slices");
00483 
00484   //========================= Build CandSlice's ============================
00485 
00486   MSG("AltAlg", Msg::kInfo) << "--> Building CandSlices" << endl;
00487 
00488   buildCandidates(event_slices, ch, cx);
00489 
00490   delete fTimeProfile;
00491 
00492   MSG("AltAlg", Msg::kInfo) << "<-- all CandSlices created!" << endl;
00493 }

int AltAlgSliceList::selectBestCandidateSlice const pair< int, CandStripHandle * > &  slc_strip,
const std::vector< int > &  cand_slices,
const std::map< int, std::vector< CandStripHandle * > > &  event_slices
const [private]
 

Definition at line 2851 of file AltAlgSliceList.cxx.

References fKMeansTimeWindow, fKMeansTPosWindow, MakeDistanceMap(), moreOccurences(), and MSG.

Referenced by findBestSliceToHostStrip().

02855 {
02856 // Selects the "best" slice to host a strip, out of a list of good candidates.
02857 // What follows is a first approach
02858 
02859   int source = slc_strip.first;
02860   CandStripHandle * strip = slc_strip.second;
02861 
02862   //-- check how many of these candidate slices have other strips in a t,tpos
02863   //   window (centered at the strip) at the two succesive planes of the same,
02864   //   orientation (1 upstream & 1 downstream)
02865 
02866   std::vector<int> slice_list;
02867   std::vector<int>::const_iterator slice_id_iter;
02868   std::map<int, std::vector<CandStripHandle *> >::const_iterator slice_iter;
02869 
02870   for(slice_id_iter = cand_slices.begin();
02871                        slice_id_iter != cand_slices.end(); ++slice_id_iter) {
02872 
02873       slice_iter = event_slices.find(*slice_id_iter);
02874 
02875       int n = count_if( slice_iter->second.begin(), slice_iter->second.end(),
02876                         is_in_tztpos_window(strip, fKMeansTimeWindow,
02877                                                      2, fKMeansTPosWindow) );
02878 
02879       if( *slice_id_iter == source ) n--; // do not count yourself...
02880 
02881       if(n > 0) slice_list.push_back( *slice_id_iter );
02882   }
02883 
02884   //-- if there was only one then return this as the best candidate
02885   if(slice_list.size() == 1) return slice_list[0];
02886 
02887   else {
02888     //-- select the slice which has more strips in the list of the N closest
02889     //   neighbors...
02890 
02891     std::multimap<double, int, less<double> > slices_dist_sorted =
02892                            MakeDistanceMap(strip, cand_slices, event_slices);
02893 
02894     //-- find the slice with the more occurences in the N closest positions
02895 
02896     int best_cand_slice = moreOccurences(slices_dist_sorted, 10);
02897 
02898     MSG("AltAlg", Msg::kVerbose)
02899        << "         |---> best candidate slice: " << best_cand_slice << endl;
02900 
02901     return best_cand_slice;
02902   }
02903 
02904   MSG("AltAlg", Msg::kVerbose)
02905        << "         |---> keep strip in slice: " << source << endl;
02906 
02907   return source; // if  something go wrong - just leave the strip in its place
02908 }

bool AltAlgSliceList::singleKMeansIteration std::map< int, std::vector< CandStripHandle * > > &  event_slices  )  [private]
 

Definition at line 2505 of file AltAlgSliceList.cxx.

References findBestSliceToHostStrip(), fkMeansIteration, fUpdateCentroids, rellocateStrip(), and updateCentroids().

Referenced by eventClustering().

02507 {
02508 // Performs a single iteration of a K-Means clustering algorithm on the
02509 // std::map<int, std::vector<CandStripHandle *> > of reco. slices
02510 // Clustering is performed in time-z-tpos 3D space and strips are
02511 // re-arranged between existing slices as appropriate.
02512 // Returns "true" if the algorithm has converged.
02513 //
02514   bool is_convergent = true;
02515 
02516   // The outer loop can go on for ever if for some reason something goes wrong.
02517   // Plan your escape route, if such an ill case appears... Force convergence:
02518   if( ++fkMeansIteration > 30 ) return true;
02519 
02520   fUpdateCentroids = true; // make known that centroids are not updated
02521 
02522   std::map<int, Centroid_t>  centroids;
02523 
02524   std::map<int, std::vector<CandStripHandle *> >::iterator slice_iter;
02525   for(slice_iter = event_slices.begin();
02526                             slice_iter != event_slices.end(); ++slice_iter) {
02527 
02528      int source = slice_iter->first; // source slice for following strips
02529 
02530      // check if all strips feel like home in this slice...
02531      for(std::vector<CandStripHandle *>::size_type istrip = 0;
02532                               istrip < slice_iter->second.size(); istrip++) {
02533 
02534          CandStripHandle * current_strip = slice_iter->second[istrip];
02535 
02536          pair<int, CandStripHandle *> slc_strip(source, current_strip);
02537 
02538          // try to update centroids - if it fails because it has to re-filter
02539          // the slices, filter them and 'admit' you have not converged yet...
02540 
02541          if ( !updateCentroids(centroids, event_slices) ) return false;
02542 
02543          // find out which is the best slice, amongst the existing ones
02544          // to host this strip...
02545 
02546          int target = findBestSliceToHostStrip(
02547                                          slc_strip, centroids, event_slices);
02548 
02549          if( source != target ) {
02550             //-- k-Means clustering is not convergent yet...
02551             is_convergent = false;
02552 
02553             //-- we rellocate a strip - recompute centroids if needed again
02554             fUpdateCentroids = true;
02555 
02556             //-- rellocate strip
02557             rellocateStrip(source, target, current_strip, event_slices);
02558          }
02559 
02560      } // strips
02561   } // slice_iter
02562 
02563   return is_convergent;
02564 }

bool AltAlgSliceList::sliceHasStripsInUpstreamMuSpectrometer const std::vector< CandStripHandle * > &  mu_strips  )  const [private]
 

Definition at line 3266 of file AltAlgSliceList.cxx.

References fMuSpecNUpstrPlanes, kMuSpec1stPlane, and MSG.

Referenced by sliceMatcher().

03268 {
03269 // Check if the muon spectrometer slice has strips in the first few muon
03270 // spectrometer planes
03271 
03272   int nhits = count_if( mu_strips.begin(), mu_strips.end(),
03273                   is_in_z_window_noref( kMuSpec1stPlane,
03274                                         kMuSpec1stPlane+fMuSpecNUpstrPlanes));
03275   MSG("AltAlg", Msg::kVerbose)
03276            << "     |--> slice has " << nhits << " strips (out of "
03277            << mu_strips.size() << " in total) in the forward "
03278            << " mu-spectr. region: planes = [" << kMuSpec1stPlane << ", "
03279            << kMuSpec1stPlane+fMuSpecNUpstrPlanes << "]" << endl;
03280 
03281   if(nhits == 0) {
03282       MSG("AltAlg", Msg::kVerbose) << "     |--> *** skipping" << endl;
03283       return false;
03284   }
03285 
03286   return true;
03287 }

void AltAlgSliceList::sliceMatcher std::map< int, std::vector< CandStripHandle * > > &  mu_slices,
std::map< int, std::vector< CandStripHandle * > > &  event_slices
const [private]
 

Definition at line 3094 of file AltAlgSliceList.cxx.

References addMuSpecStripsToExistingSlice(), findMatchForMuSpecSlice(), MSG, newSliceToHostMuSpecStrips(), sliceHasStripsInUpstreamMuSpectrometer(), and slicesActiveUpstreamOfMuSpec().

Referenced by assignMuonSpectrHits2Slices().

03098 {
03099 // Match muon spectrometer slices with upstream detector slices
03100 
03101   // Find existing slices with 'activity' just before the muon spectrometer
03102 
03103   MSG("AltAlg", Msg::kVerbose)
03104       << " |--[-] Finding existing slices with activity just upstream of the "
03105       << "muon spectrometer" << endl;
03106 
03107   std::vector<int> slice_ids = slicesActiveUpstreamOfMuSpec(event_slices);
03108 
03109   // Examine all muon spectrometer slices for matches with the above slices.
03110 
03111   std::map<int, std::vector<CandStripHandle *> >::iterator mu_slice_iter;
03112 
03113   std::vector<CandStripHandle *> rubbish;
03114 
03115   for(mu_slice_iter = mu_slices.begin();
03116                          mu_slice_iter != mu_slices.end(); ++mu_slice_iter) {
03117 
03118      std::vector<CandStripHandle *> & mu_slice = (*mu_slice_iter).second;
03119 
03120      MSG("AltAlg", Msg::kVerbose)
03121          << " |--[-] muon-spectr. slice: " << (*mu_slice_iter).first << endl;
03122 
03123      // Meaningfull to proceed only if muon spectrometer slice has hit strips
03124      // in the upstream part of the muon spectrometer
03125 
03126      if( sliceHasStripsInUpstreamMuSpectrometer(mu_slice) ) {
03127 
03128         // Check for match... If a match is found the strips will have already
03129         // be appended to the right slice... if no match is found take care of
03130         // the unmatched strips...
03131 
03132         if( ! findMatchForMuSpecSlice(mu_slice, slice_ids, event_slices) ) {
03133 
03134           if(fMuSpecSuppressUnmatchedSlices) {
03135 
03136              // do not create a separate slice for every unmatched mu-spec slc.
03137              MSG("AltAlg", Msg::kVerbose)
03138                 << "     |--> NO match - adding strips to rubbish slc" << endl;
03139              addMuSpecStripsToExistingSlice(mu_slice, rubbish);
03140 
03141           } else {
03142              // do create a separate slice for every unmatched mu-spec slc.
03143              MSG("AltAlg", Msg::kVerbose)
03144                           << "     |--> NO match - creating new slice" << endl;
03145              newSliceToHostMuSpecStrips(mu_slice, event_slices);
03146 
03147           } // if suppress creation of unmatched slices
03148        } // if no match was found
03149      } // if mu spectrometer slice has activity in its upstream section
03150   }// loop over muon spectrometer slices
03151 
03152   // If it chosen to suppress the creation of separate slices for every single
03153   // unmatched mu-spectrometer slice, the rubbish strips are added as a single
03154   // (rubbish) slice...
03155 
03156   if(fMuSpecSuppressUnmatchedSlices)
03157                             newSliceToHostMuSpecStrips(rubbish, event_slices);
03158 }

void AltAlgSliceList::sliceMerger std::map< int, std::vector< CandStripHandle * > > &  event_slices  )  const [private]
 

Definition at line 2127 of file AltAlgSliceList.cxx.

References findSlicesToMerge(), Merge(), and MSG.

Referenced by RunAlg().

02129 {
02130 // Sometimes it might be possible that a real event is split between 2 or more
02131 // reconstructed slices...
02132 // So, if slices are very close in time and span successive (or overlapping)
02133 // areas of the detector, just merge them.
02134 //
02135   MSG("AltAlg", Msg::kVerbose)
02136                           << "[-] Trying to spot slices to be merged" << endl;
02137 
02138   pair<int, int> slices_to_merge;
02139 
02140   while( (slices_to_merge = findSlicesToMerge(event_slices)).first != -1 )
02141                                          Merge(slices_to_merge, event_slices);
02142 }

std::vector< int > AltAlgSliceList::slicesActiveUpstreamOfMuSpec const std::map< int, std::vector< CandStripHandle * > > &  event_slices  )  const [private]
 

Definition at line 3160 of file AltAlgSliceList.cxx.

References fMuSpecNHitStripsBefSpectr, fMuSpecNPlnBefSpectr, kMuSpec1stPlane, and MSG.

Referenced by sliceMatcher().

03162 {
03163 // Find out which upstream slices have activity in the part just upstream of
03164 // the muon spectrometer (in the most downstream part of the forward detector)
03165 
03166   std::ostringstream sstream;
03167   sstream   << "     |--[-] Using AlgConf params: 'activity' is > "
03168             << fMuSpecNHitStripsBefSpectr  << " hit strips in the "
03169             << fMuSpecNPlnBefSpectr        << " planes before the mu-spectr.";
03170 
03171   MSG("AltAlg", Msg::kDebug) << sstream.str().c_str() << endl;
03172 
03173   std::vector<int> slice_ids;
03174 
03175   int min_plane_inclusive = kMuSpec1stPlane - fMuSpecNPlnBefSpectr;
03176   int max_plane_inclusive = kMuSpec1stPlane - 1;
03177 
03178   std::map<int, std::vector<CandStripHandle *> >::const_iterator slice_iter;
03179   for(slice_iter = event_slices.begin();
03180                            slice_iter != event_slices.end(); ++slice_iter) {
03181 
03182      int nhits = count_if(
03183                     (*slice_iter).second.begin(), (*slice_iter).second.end(),
03184              is_in_z_window_noref(min_plane_inclusive, max_plane_inclusive));
03185 
03186      MSG("AltAlg", Msg::kVerbose)
03187            << "         |--> slice " << (*slice_iter).first<< " has "<< nhits
03188            << " hit strips in planes [" << min_plane_inclusive << ", "
03189            << max_plane_inclusive << "]" << endl;
03190 
03191      if(nhits > fMuSpecNHitStripsBefSpectr) {
03192 
03193          slice_ids.push_back( (*slice_iter).first );
03194 
03195          MSG("AltAlg", Msg::kVerbose)
03196             << "         |--> *** use this one to when checking for matches "
03197             << " with mu-spectrometer activity " << endl;
03198      }
03199   }  // slice_iter
03200 
03201   return slice_ids;
03202 }

bool AltAlgSliceList::sliceShouldBeEliminated std::map< int, std::vector< CandStripHandle * > >::const_iterator  slice  )  const [private]
 

Definition at line 1942 of file AltAlgSliceList.cxx.

References noStripsInOneView(), smallAmountOfCharge(), and smallNumberOfHitStrips().

Referenced by findSlicesToBeEliminated().

01944 {
01945   bool should_be_eliminated = false;
01946 
01947   //**** apply the list of criteria for slice-elimination
01948 
01949   std::vector<bool> check_list;
01950   std::vector<bool>::iterator check;
01951 
01952   check_list.push_back( smallNumberOfHitStrips (slice)  );
01953   check_list.push_back( smallAmountOfCharge    (slice)  );
01954   check_list.push_back( noStripsInOneView      (slice)  );
01955 
01956   for(check = check_list.begin(); check != check_list.end(); ++check)
01957                       should_be_eliminated = should_be_eliminated || (*check);
01958 
01959   return should_be_eliminated;
01960 }

void AltAlgSliceList::sliceSplitter std::map< int, std::vector< CandStripHandle * > > &  event_slices  )  [private]
 

Definition at line 3015 of file AltAlgSliceList.cxx.

03017 {
03018 // Minimal Spanning Tree  code goes here...
03019 // Utility methods go below...
03020 }

bool AltAlgSliceList::smallAmountOfCharge std::map< int, std::vector< CandStripHandle * > >::const_iterator  slice  )  const [private]
 

Definition at line 1980 of file AltAlgSliceList.cxx.

References fMinCharge, and MSG.

Referenced by sliceShouldBeEliminated().

01982 {
01983 // check for small amount of charge in the slice
01984 //
01985 
01986 // double totalCharge = 0;
01987 // for(std::vector<CandStripHandle *>::iterator strip_iter =
01988 //   (*iter).second.begin();strip_iter != (*iter).second.end(); ++strip_iter)
01989 //                       totalCharge += ( (*strip_iter)->GetCharge() );
01990 
01991   double totalCharge = accumulate( (*slice).second.begin(),
01992                                    (*slice).second.end(),  0.0, sum_q());
01993 
01994   if( totalCharge < fMinCharge )  {
01995 
01996       MSG("AltAlg", Msg::kVerbose)
01997             << "           |--> Slice: " << (*slice).first
01998             << " will be eliminated --> too small charge: "
01999             << totalCharge << " < (MinCharge=) " << fMinCharge << endl;
02000 
02001   } else return false;
02002 
02003   return true;
02004 }

bool AltAlgSliceList::smallNumberOfHitStrips std::map< int, std::vector< CandStripHandle * > >::const_iterator  slice  )  const [private]
 

Definition at line 1962 of file AltAlgSliceList.cxx.

References fMinNoHitStrips, and MSG.

Referenced by sliceShouldBeEliminated().

01964 {
01965 // check for small number of hit strips in the slice
01966 //
01967   if( (int) (*slice).second.size() < fMinNoHitStrips  )  {
01968 
01969      MSG("AltAlg", Msg::kVerbose)
01970            << "           |--> Slice: " << (*slice).first
01971            << " will be eliminated --> too few hit strips: "
01972            << (*slice).second.size() << " < (MinStrips=) " << fMinNoHitStrips
01973            << endl;
01974 
01975   } else return false;
01976 
01977   return true;
01978 }

void AltAlgSliceList::sortSlicesInPlaneNo std::map< int, std::vector< CandStripHandle * > > &  event_slices  )  const [private]
 

Definition at line 1537 of file AltAlgSliceList.cxx.

References MSG.

01539 {
01540 // Sorts CandStripHandles associated with each slice is ascending plane number
01541 //
01542   MSG("AltAlg", Msg::kDebug) << "* Sorting Slices in plane number " << endl;
01543 
01544   std::map<int, std::vector<CandStripHandle *> >::iterator slice_iter;
01545 
01546   for(slice_iter = event_slices.begin();
01547                                slice_iter != event_slices.end(); ++slice_iter)
01548           sort( (*slice_iter).second.begin(),
01549                                      (*slice_iter).second.end(), min_plane());
01550 }

void AltAlgSliceList::sortSlicesInTime std::map< int, std::vector< CandStripHandle * > > &  event_slices  )  const [private]
 

Definition at line 1523 of file AltAlgSliceList.cxx.

References MSG.

Referenced by assignMuonSpectrHits2Slices(), buildCandidates(), getMuSpecSlices(), and initSliceFiltering().

01525 {
01526 // Sorts CandStripHandles associated with each slice is ascending time order
01527 //
01528   MSG("AltAlg", Msg::kDebug) << "* Sorting Slices in time " << endl;
01529 
01530   std::map<int, std::vector<CandStripHandle *> >::iterator slice_iter;
01531 
01532   for(slice_iter = event_slices.begin();
01533                               slice_iter != event_slices.end(); ++slice_iter)
01534      sort( (*slice_iter).second.begin(), (*slice_iter).second.end(), min_t());
01535 }

void AltAlgSliceList::Split int  slice,
std::vector< std::vector< CandStripHandle * > >  groups,
std::map< int, std::vector< CandStripHandle * > > &  event_slices
const [private]
 

Definition at line 1825 of file AltAlgSliceList.cxx.

References MSG, and nextAvailableSliceId().

01828 {
01829 // Method for updating the slices map to reflect the splitting of an existing
01830 // slice. New slices are created to accomodate the strips of each elemement of
01831 // the std::vector< std::vector<CandStripHandle *> > "groups" STL-vector...
01832 // These elements define a partition of the strips corresponding to the input
01833 // slice identifies.
01834 // After creating the new slices, the original slice is deleted.
01835 //
01836   MSG("AltAlg", Msg::kVerbose) << "[-] splitting slice: " << slice << endl;
01837 
01838   std::vector< std::vector<CandStripHandle *> >::iterator group_iter;
01839 
01840   for(group_iter = groups.begin(); group_iter != groups.end(); ++group_iter)
01841 
01842      event_slices.insert(
01843           std::map<int, std::vector<CandStripHandle *> >::value_type(
01844                            nextAvailableSliceId(event_slices), *group_iter) );
01845 
01846   event_slices.erase(slice);
01847 }

void AltAlgSliceList::Split int  slice,
std::vector< CandStripHandle * >::size_type  n_separator,
std::map< int, std::vector< CandStripHandle * > > &  event_slices
const [private]
 

Definition at line 1793 of file AltAlgSliceList.cxx.

References copy(), MSG, and nextAvailableSliceId().

01796 {
01797 // A specific case of Split(). ** The generic case is coded next **
01798 // In this specific case, the original slice is split in just two parts and
01799 // its vector of strips is somehow sorted to reflect this splitting.
01800 // The first n_separator elements are assigned to the first sub-slice and the
01801 // remaining size()-n_separator elements are assigned to the second one.
01802 //
01803   MSG("AltAlg", Msg::kVerbose) << "[-] splitting slice: " << slice << endl;
01804 
01805   vector<CandStripHandle *>::iterator strip_iter = event_slices[slice].begin();
01806 
01807   advance(strip_iter, n_separator);
01808 
01809   std::vector<CandStripHandle *> new_slice_strips_1(n_separator);
01810   copy(event_slices[slice].begin(),  strip_iter,  new_slice_strips_1.begin());
01811   event_slices.insert(
01812       std::map<int, std::vector<CandStripHandle *> >::value_type(
01813                      nextAvailableSliceId(event_slices), new_slice_strips_1 ));
01814 
01815   std::vector<CandStripHandle *> new_slice_strips_2(
01816                                     event_slices[slice].size() - n_separator);
01817   copy( strip_iter, event_slices[slice].end(), new_slice_strips_2.begin());
01818   event_slices.insert(
01819       std::map<int, std::vector<CandStripHandle *> >::value_type(
01820                     nextAvailableSliceId(event_slices), new_slice_strips_2 ));
01821 
01822   event_slices.erase(slice);
01823 }

void AltAlgSliceList::Trace const char *  c  )  const [virtual]
 

Reimplemented from AlgBase.

Definition at line 225 of file AltAlgSliceList.cxx.

00226 {
00227 
00228 }

bool AltAlgSliceList::updateCentroids std::map< int, Centroid_t > &  centroids,
std::map< int, std::vector< CandStripHandle * > > &  event_slices
[private]
 

Definition at line 2617 of file AltAlgSliceList.cxx.

References computeSlicesCentroid(), fUpdateCentroids, initSliceFiltering(), and needToFilterStrips().

Referenced by singleKMeansIteration().

02620 {
02621 // Try to update centroids... if its needed... and if you can...
02622 // Returns false if it had to re-filter the slices.
02623 
02624   if(fUpdateCentroids) {
02625 
02626      if(needToFilterStrips(event_slices)) {
02627         initSliceFiltering(event_slices);
02628         return false;
02629      } else {
02630         centroids = computeSlicesCentroid(event_slices);
02631         fUpdateCentroids = false;
02632      }
02633   }
02634   return true;
02635 }

void AltAlgSliceList::updateSingleSliceSeedInfo CandStripHandleItr *  cshItr,
TimeSlice_t seed
const [private]
 

Definition at line 1143 of file AltAlgSliceList.cxx.

References timeslice::all_sync, fFmtTime, CandStripHandle::GetCharge(), CandStripHandle::GetCorrBegTime(), MSG, printSliceSeed(), printStrip(), timeslice::q, timeslice::qt, resetSliceSeed(), TimeSlice_t, timeslice::tmax, timeslice::tmin, and timeslice::tpeak.

Referenced by reduceTimeWindows(), and updateSliceSeedInfo().

01145 {
01146 // Compute <tpeak> = Sum_{i} (charge(i)*time(i)) / Sum_{i} (charge(i)) for all
01147 // strips within slice seed's [tmin, tmax]
01148 //
01149   //cshItr->ResetFirst();
01150 
01151   //-- reset previous selections
01152   cshItr->GetSet()->Slice();
01153 
01154   //-- select strips in this time-window
01155   cshItr->GetSet()->Slice( seed.tmin, seed.tmax  );
01156 
01157   MSG("AltAlg", Msg::kDebug)
01158          << "         |-->[-] t = ["
01159          << fFmtTime(seed.tmin) << ", " << fFmtTime(seed.tmax ) << "]" << endl;
01160 
01161   MSG("AltAlg", Msg::kDebug)
01162          << "              |--> selected "
01163          << cshItr->GetSet()->SizeSelect() << " out of "
01164          << cshItr->GetSet()->Size()       << " entries" << endl;
01165 
01166   seed.q  = 0.;
01167   seed.qt = 0.;
01168 
01169   cshItr->ResetFirst();
01170   while( CandStripHandle * striph = cshItr->Ptr() ) {
01171 
01172       seed.q  += ( striph->GetCharge() );
01173       seed.qt += ( striph->GetCharge() * striph->GetCorrBegTime()   );
01174 
01175       printStrip(striph);
01176 
01177       cshItr->Next();
01178   }
01179 
01180   if( seed.q == 0) resetSliceSeed(seed);
01181   else             seed.tpeak = seed.qt / seed.q;
01182 
01183   seed.all_sync = true;
01184 
01185   printSliceSeed(seed);
01186 }

void AltAlgSliceList::updateSliceSeedInfo CandStripHandleItr *  cshItr,
std::vector< TimeSlice_t > &  slice_seeds
const [private]
 

Definition at line 1116 of file AltAlgSliceList.cxx.

References MSG, removeNullSeeds(), and updateSingleSliceSeedInfo().

Referenced by getSliceSeeds().

01118 {
01119 // Compute <tpeak> = Sum_{i} (charge(i)*time(i)) / Sum_{i} (charge(i)) for all
01120 // strips within slice seed's [tmin, tmax]
01121 //
01122   unsigned int islice = 0;
01123   MsgFormat fmtInt("%3d");
01124 
01125   std::vector<TimeSlice_t>::iterator slice_iter;
01126 
01127   for(slice_iter = slice_seeds.begin();
01128                             slice_iter != slice_seeds.end(); ++slice_iter) {
01129 
01130       MSG("AltAlg", Msg::kDebug)
01131              << "    |-->[-] Updating information for slice-seed: "
01132              << fmtInt(islice++) << endl;
01133 
01134       if(! (*slice_iter).all_sync)
01135                             updateSingleSliceSeedInfo( cshItr, *slice_iter );
01136   }
01137   // Eliminate slice-seeds with 0 charge that might have made it to
01138   // this point doe to relaxed criteria or rearrangements in previous steps
01139 
01140   removeNullSeeds(slice_seeds);
01141 }

bool AltAlgSliceList::ZeroChargeInAView const std::vector< CandStripHandle * > &  slice  )  const [private]
 

Definition at line 2596 of file AltAlgSliceList.cxx.

References copy().

Referenced by needToFilterStrips().

02598 {
02599   //-- u-v partition
02600   std::vector<CandStripHandle *> slice_cp( slice.size() );
02601 
02602   copy( slice.begin(), slice.end(), slice_cp.begin() );
02603 
02604   std::vector<CandStripHandle *>::iterator part_iter = partition(
02605                              slice_cp.begin(), slice_cp.end(), is_v_view() );
02606 
02607   //-- accumulate
02608   double sum_q_v = accumulate(slice_cp.begin(), part_iter, 0.0, sum_q());
02609   double sum_q_u = accumulate(part_iter, slice_cp.end(),   0.0, sum_q());
02610 
02611   //--check
02612   if(sum_q_v <= 0 || sum_q_u <= 0) return true;
02613 
02614   return false;
02615 }


Member Data Documentation

MsgFormat AltAlgSliceList::fFmtPln [private]
 

Definition at line 413 of file AltAlgSliceList.h.

Referenced by AltAlgSliceList(), fillSliceSeeds(), findBestSliceToAdoptAStrip(), findBestSliceToHostStrip(), giveOrphanStripsForAdoption(), Merge(), printSlice(), printStrip(), and printStripList().

MsgFormat AltAlgSliceList::fFmtQ [private]
 

Definition at line 416 of file AltAlgSliceList.h.

Referenced by AltAlgSliceList(), fillSliceSeeds(), printSlice(), printSliceSeed(), printStrip(), and printStripList().

MsgFormat AltAlgSliceList::fFmtSlc [private]
 

Definition at line 414 of file AltAlgSliceList.h.

Referenced by AltAlgSliceList(), buildCandidates(), findBestSliceToHostStrip(), findMatchForMuSpecSlice(), findSlicesToMerge(), Merge(), and rellocateStrip().

MsgFormat AltAlgSliceList::fFmtStp [private]
 

Definition at line 412 of file AltAlgSliceList.h.

Referenced by AltAlgSliceList(), fillSliceSeeds(), findBestSliceToHostStrip(), giveOrphanStripsForAdoption(), Merge(), printSlice(), printStrip(), and printStripList().

MsgFormat AltAlgSliceList::fFmtTime [private]
 

Definition at line 415 of file AltAlgSliceList.h.

Referenced by AltAlgSliceList(), checkPeakTimeDifference(), fillSliceSeeds(), findBestSliceToAdoptAStrip(), findMatchForMuSpecSlice(), findSmallerPeaks(), giveOrphanStripsForAdoption(), peakFinder(), printSlice(), printSliceSeed(), printSliceSeeds(), printStrip(), printStripList(), printTimeBin(), reduceTimeWindows(), RunAlg(), and updateSingleSliceSeedInfo().

int AltAlgSliceList::fGrfxDebugGraphics [private]
 

Definition at line 359 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), internalInit(), and RunAlg().

int AltAlgSliceList::fGrfxTimeProfileLogView [private]
 

Definition at line 360 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), and internalInit().

int AltAlgSliceList::fkMeansIteration [private]
 

Definition at line 398 of file AltAlgSliceList.h.

Referenced by eventClustering(), internalInit(), and singleKMeansIteration().

int AltAlgSliceList::fKMeansPlaneWindow [private]
 

Definition at line 371 of file AltAlgSliceList.h.

Referenced by checkForAlternativeSlices(), getAlgorithmConfiguration(), and internalInit().

double AltAlgSliceList::fKMeansTimeWindow [private]
 

Definition at line 385 of file AltAlgSliceList.h.

Referenced by checkForAlternativeSlices(), getAlgorithmConfiguration(), internalInit(), and selectBestCandidateSlice().

double AltAlgSliceList::fKMeansTPosWindow [private]
 

Definition at line 386 of file AltAlgSliceList.h.

Referenced by checkForAlternativeSlices(), getAlgorithmConfiguration(), internalInit(), and selectBestCandidateSlice().

double AltAlgSliceList::fMinCharge [private]
 

Definition at line 394 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), internalInit(), and smallAmountOfCharge().

int AltAlgSliceList::fMinNoHitStrips [private]
 

Definition at line 375 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), internalInit(), and smallNumberOfHitStrips().

int AltAlgSliceList::fMuSpecNHitStripsBefSpectr [private]
 

Definition at line 373 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), internalInit(), and slicesActiveUpstreamOfMuSpec().

int AltAlgSliceList::fMuSpecNPlnBefSpectr [private]
 

Definition at line 374 of file AltAlgSliceList.h.

Referenced by averageTimeAtEndOfUpstreamSlice(), getAlgorithmConfiguration(), internalInit(), and slicesActiveUpstreamOfMuSpec().

int AltAlgSliceList::fMuSpecNUpstrPlanes [private]
 

Definition at line 372 of file AltAlgSliceList.h.

Referenced by averageTimeAtBeginOfDownstreamSlice(), getAlgorithmConfiguration(), internalInit(), and sliceHasStripsInUpstreamMuSpectrometer().

bool AltAlgSliceList::fMuSpecSuppressUnmatchedSlices [private]
 

Definition at line 382 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), and internalInit().

double AltAlgSliceList::fMuSpecTimeAftUpstrActivity [private]
 

Definition at line 387 of file AltAlgSliceList.h.

Referenced by findMatchForMuSpecSlice(), getAlgorithmConfiguration(), and internalInit().

double AltAlgSliceList::fMuSpecTimeBefUpstrActivity [private]
 

Definition at line 388 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), and internalInit().

int AltAlgSliceList::fNTimeBins [private]
 

Definition at line 399 of file AltAlgSliceList.h.

Referenced by eventDisplay(), eventDisplaySingleSlice(), internalInit(), plot3DClusters(), and RunAlg().

int AltAlgSliceList::fOrphanStripsPlaneWindow [private]
 

Definition at line 370 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), giveOrphanStripsForAdoption(), and internalInit().

bool AltAlgSliceList::fOrphanStripsQWeight [private]
 

Definition at line 383 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), giveOrphanStripsForAdoption(), and internalInit().

double AltAlgSliceList::fOrphanStripsTimeWindow [private]
 

Definition at line 384 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), giveOrphanStripsForAdoption(), and internalInit().

int AltAlgSliceList::fPeakFinderNestingLevel [private]
 

Definition at line 397 of file AltAlgSliceList.h.

Referenced by getSliceSeeds(), and internalInit().

int AltAlgSliceList::fPkfLowNSuccessiveEmptyBins [private]
 

Definition at line 366 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), and internalInit().

int AltAlgSliceList::fPkfLowPeakThreshold [private]
 

Definition at line 365 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), and internalInit().

int AltAlgSliceList::fPkfMuSpecNSuccessiveEmptyBins [private]
 

Definition at line 364 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), and internalInit().

int AltAlgSliceList::fPkfMuSpecPeakThreshold [private]
 

Definition at line 363 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), and internalInit().

int AltAlgSliceList::fPkfNofMergedTimeBins [private]
 

Definition at line 367 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), internalInit(), and RunAlg().

int AltAlgSliceList::fPkfNSuccessiveEmptyBins [private]
 

Definition at line 362 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), and internalInit().

int AltAlgSliceList::fPkfPeakThreshold [private]
 

Definition at line 361 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), and internalInit().

bool AltAlgSliceList::fPkfRecursivePeakSearch [private]
 

Definition at line 377 of file AltAlgSliceList.h.

Referenced by findSmallerPeaks(), getAlgorithmConfiguration(), internalInit(), and RunAlg().

int AltAlgSliceList::fPkfTimeWindowAftPeak [private]
 

Definition at line 369 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), internalInit(), and reduceTimeWindows().

int AltAlgSliceList::fPkfTimeWindowBefPeak [private]
 

Definition at line 368 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), internalInit(), and reduceTimeWindows().

bool AltAlgSliceList::fPkfWeightProfileWithCharge [private]
 

Definition at line 376 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), and internalInit().

bool AltAlgSliceList::fRefinementDissolving [private]
 

Definition at line 378 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), and internalInit().

bool AltAlgSliceList::fRefinementKMeansClustering [private]
 

Definition at line 380 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), and internalInit().

bool AltAlgSliceList::fRefinementMerging [private]
 

Definition at line 379 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), and internalInit().

bool AltAlgSliceList::fRefinementMSTClustering [private]
 

Definition at line 381 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), and internalInit().

TH1D* AltAlgSliceList::fSubsetTimeProfile [private]
 

Definition at line 407 of file AltAlgSliceList.h.

Referenced by findSmallerPeaks(), getMuSpecSlices(), and internalInit().

double AltAlgSliceList::fSubsettmax [private]
 

Definition at line 409 of file AltAlgSliceList.h.

Referenced by getMuSpecSlices(), internalInit(), and reduceTimeWindows().

double AltAlgSliceList::fSubsettmin [private]
 

Definition at line 408 of file AltAlgSliceList.h.

Referenced by getMuSpecSlices(), internalInit(), and reduceTimeWindows().

double AltAlgSliceList::fTimeDiffBetweenPeaks [private]
 

Definition at line 390 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), internalInit(), and RunAlg().

TH1D* AltAlgSliceList::fTimeProfile [private]
 

Definition at line 403 of file AltAlgSliceList.h.

Referenced by createSubsetTimeProfile(), internalInit(), reduceTimeWindows(), and RunAlg().

double AltAlgSliceList::fTimeProfileMax [private]
 

Definition at line 401 of file AltAlgSliceList.h.

Referenced by eventDisplay(), internalInit(), and RunAlg().

double AltAlgSliceList::fTimeResolution [private]
 

Definition at line 389 of file AltAlgSliceList.h.

Referenced by eventDisplay(), eventDisplaySingleSlice(), getAlgorithmConfiguration(), internalInit(), peakFinder(), reduceTimeWindows(), and RunAlg().

double AltAlgSliceList::ftmax [private]
 

Definition at line 405 of file AltAlgSliceList.h.

Referenced by eventDisplay(), eventDisplaySingleSlice(), internalInit(), plot3DClusters(), and RunAlg().

double AltAlgSliceList::ftmin [private]
 

Definition at line 404 of file AltAlgSliceList.h.

Referenced by eventDisplay(), eventDisplaySingleSlice(), internalInit(), plot3DClusters(), and RunAlg().

bool AltAlgSliceList::fUpdateCentroids [private]
 

Definition at line 400 of file AltAlgSliceList.h.

Referenced by internalInit(), singleKMeansIteration(), and updateCentroids().

double AltAlgSliceList::fUVDiffBetweenPeaks [private]
 

Definition at line 393 of file AltAlgSliceList.h.

Referenced by checkPeakUVDifference(), getAlgorithmConfiguration(), and internalInit().

double AltAlgSliceList::fZDiffBetweenEnds [private]
 

Definition at line 392 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), and internalInit().

double AltAlgSliceList::fZDiffBetweenPeaks [private]
 

Definition at line 391 of file AltAlgSliceList.h.

Referenced by getAlgorithmConfiguration(), internalInit(), and RunAlg().


The documentation for this class was generated from the following files:
Generated on Thu Nov 1 15:55:32 2007 for loon by  doxygen 1.3.9.1