AlgFitTrackCamList Class Reference

#include <AlgFitTrackCamList.h>

Inheritance diagram for AlgFitTrackCamList:
AlgBase

List of all members.

Public Member Functions

 AlgFitTrackCamList ()
virtual ~AlgFitTrackCamList ()
virtual void RunAlg (AlgConfig &ac, CandHandle &ch, CandContext &cx)
virtual void Trace (const char *c) const
void CleanNDSlices (CandRecord *candrec)
void CheckWeights (CandRecord *candrec)

Static Private Member Functions

static bool comp_strips (const CandStripHandle *s1, const CandStripHandle *s2)

Detailed Description

Definition at line 14 of file AlgFitTrackCamList.h.


Constructor & Destructor Documentation

AlgFitTrackCamList::AlgFitTrackCamList (  ) 

Definition at line 61 of file AlgFitTrackCamList.cxx.

00062 {
00063 }

AlgFitTrackCamList::~AlgFitTrackCamList (  )  [virtual]

Definition at line 68 of file AlgFitTrackCamList.cxx.

00069 {
00070 }


Member Function Documentation

void AlgFitTrackCamList::CheckWeights ( CandRecord candrec  ) 

Definition at line 223 of file AlgFitTrackCamList.cxx.

References digit(), CandRecord::FindCandHandle(), CandHandle::GetDaughterIterator(), and CandDigitHandle::GetPlexSEIdAltLWritable().

Referenced by RunAlg().

00224 {
00225   //Not really sure what was the idea for this function
00226   //As found, it just created new CandDigitHandle and reset
00227   //non zero PlexSEIdAltL weights to 1 
00228   //(why would you want to do that?? isn't the idea of weights 
00229   // to help you decide which one is best?)
00230   //Nothing is done with this handle afterwards, so this was
00231   //all in vain anyway. 
00232   //Therefore, just jumping out of the function should have same results, 
00233   //but not leak memory. (ZP 2014/09/05)
00234 
00235   return;
00236 
00237         // Make sure that the weights in the list of alternative PlexSEIds are
00238         // good after the ND Spectrometer DeMuxing is complete
00239         CandStripListHandle* StripList = dynamic_cast<CandStripListHandle *> 
00240                 (candrec->FindCandHandle("CandStripListHandle"));
00241 
00242         if(StripList) {
00243                 CandStripHandleItr stripItr(StripList->GetDaughterIterator());
00244 
00245                 for (CandStripHandle* strip=stripItr(); strip ; strip=stripItr()) {
00246                         if(strip->GetPlane()<121) {continue;}
00247 
00248                         CandDigitHandleItr digitItr(strip->GetDaughterIterator());
00249 
00250                         for (CandDigitHandle* digit=digitItr(); digit ; digit=digitItr()) {
00251                                 CandDigitHandle* newdig=digit->DupHandle();
00252 
00253                                 PlexSEIdAltL& newaltl=newdig->GetPlexSEIdAltLWritable();
00254 
00255                                 for(unsigned int i=0; i<newaltl.size(); ++i) {
00256                                         if(newaltl[i].GetWeight()>0) {newaltl[i].SetWeight((float)1.);}
00257                                 }
00258                         }
00259                 }
00260         }
00261 }

void AlgFitTrackCamList::CleanNDSlices ( CandRecord candrec  ) 

Definition at line 164 of file AlgFitTrackCamList.cxx.

References comp_strips(), CandRecord::FindCandHandle(), CandHandle::GetDaughterIterator(), CandHandle::IsSlushyEnabled(), it, and CandHandle::SetSlushyEnabled().

Referenced by RunAlg().

00165 {
00166         // Check that there is nothing in slicelist that isn't in striplist
00167         bool SlushyOnEntry = CandHandle::IsSlushyEnabled();
00168         CandHandle::SetSlushyEnabled(kTRUE);
00169 
00170         CandStripListHandle* StripList = dynamic_cast<CandStripListHandle *> (candrec->FindCandHandle("CandStripListHandle"));
00171         CandSliceListHandle* SliceList = dynamic_cast<CandSliceListHandle *> (candrec->FindCandHandle("CandSliceListHandle"));
00172 
00173         if(SliceList && StripList)
00174         {
00175                 std::list<CandStripHandle*> StripsInRec;
00176                 //first fill StripsInRec
00177                 CandStripHandleItr stripItr(StripList->GetDaughterIterator());
00178                 CandStripHandle* strip;
00179 
00180                 while(strip=stripItr())
00181                 {
00182                         if (strip->GetPlane() > 120) StripsInRec.push_back(strip);
00183                 }
00184                 StripsInRec.sort( comp_strips );
00185 
00186                 CandSliceHandleItr sliceItr(SliceList->GetDaughterIterator());
00187                 CandSliceHandle* slice;
00188 
00189                 while (slice=sliceItr())
00190                 {
00191                         std::list<CandStripHandle*> StripsRemove;
00192                         std::list<CandStripHandle*> StripsInSlice;
00193 
00194                         //copy strips in slice into a list
00195                         CandStripHandleItr slicestripItr(slice->GetDaughterIterator());
00196                         CandStripHandle* slicestrip;
00197                         while (slicestrip=slicestripItr())
00198                         {
00199                                 if (slicestrip->GetPlane() > 120) StripsInSlice.push_back(slicestrip);
00200                         }
00201                         StripsInSlice.sort( comp_strips );
00202 
00203                         //find all strips in slice not in the record
00204                         std::set_difference(StripsInSlice.begin(), StripsInSlice.end(),
00205                                         StripsInRec.begin(), StripsInRec.end(),
00206                                         std::inserter(StripsRemove, StripsRemove.begin()),
00207                                         comp_strips);
00208 
00209                         //remove those strips from the slice
00210                         for (std::list<CandStripHandle*>::iterator it = StripsRemove.begin(); it != StripsRemove.end(); ++it)
00211                         {
00212                                 slice->RemoveDaughter( *it );
00213                         }
00214                 }
00215         }
00216 
00217         if(!SlushyOnEntry) {CandHandle::SetSlushyEnabled(kFALSE);}
00218 }

bool AlgFitTrackCamList::comp_strips ( const CandStripHandle s1,
const CandStripHandle s2 
) [static, private]

Definition at line 52 of file AlgFitTrackCamList.cxx.

Referenced by CleanNDSlices().

00053 {
00054         return s1->GetUidInt() < s2->GetUidInt();
00055 }

void AlgFitTrackCamList::RunAlg ( AlgConfig ac,
CandHandle ch,
CandContext cx 
) [virtual]

Implements AlgBase.

Definition at line 75 of file AlgFitTrackCamList.cxx.

References CandHandle::AddDaughterLink(), CheckWeights(), CleanNDSlices(), Registry::Get(), AlgFactory::GetAlgHandle(), CandContext::GetCandRecord(), CandContext::GetDataIn(), CandHandle::GetDaughterIterator(), VldContext::GetDetector(), AlgFactory::GetInstance(), CandContext::GetMom(), CandHandle::GetNDaughters(), RecMinos::GetVldContext(), Detector::kNear, Msg::kWarning, CandFitTrackCam::MakeCandidate(), MSG, CandContext::SetCandRecord(), CandFitTrackHandle::SetCPUTime(), CandContext::SetDataIn(), CandHandle::SetName(), CandHandle::SetTitle(), SortTracksByNStrips(), and AlgFitTrackCam::usedSlcStrips.

00076 {
00077         assert(cx.GetDataIn());
00078 
00079         // Check for CandTrackListHandle input
00080         if (cx.GetDataIn()->InheritsFrom("CandTrackListHandle")) 
00081         {
00082                 const CandTrackListHandle *ctlh = dynamic_cast<const CandTrackListHandle*>(cx.GetDataIn());
00083                 const MomNavigator *mom = cx.GetMom();
00084 
00085                 CandRecord* candrec = (CandRecord*)(cx.GetCandRecord());
00086                 assert(candrec);
00087 
00088                 VldContext* vldc = (VldContext*)(candrec->GetVldContext());
00089                 Detector::Detector_t detector = vldc->GetDetector();
00090 
00091 
00092                 // Create the new tracklist
00094                 CandFitTrackCamListHandle& tracklist = dynamic_cast<CandFitTrackCamListHandle&>(ch);
00095                 if( !ctlh || ctlh->GetNDaughters()<1 ) {
00096                         // Require number of CandTracks to be non-zero to do anything more
00097                         MSG("AlgFitTrackCamList", Msg::kWarning) << " !ctlh || ctlh->GetNDaughters()<1 " << endl;
00098                         return;
00099                 }
00101                 // Set-up for calculating CPUTime
00103                 clock_t dummyt;
00104                 struct tms t1;
00105                 struct tms t2;
00106                 static double ticksPerSecond = sysconf(_SC_CLK_TCK);
00108 
00109                 // Need to order the tracks from the same slice together, ordered by number of hits.
00110                 CandTrackHandleItr trkItr(ctlh->GetDaughterIterator());
00111                 CandTrackHandleKeyFunc *trkKf = trkItr.CreateKeyFunc();
00112 
00113                 // Now sort by number of hits
00114                 trkKf->SetFun(SortTracksByNStrips);
00115                 trkItr.GetSet()->AdoptSortKeyFunc(trkKf);
00116                 trkKf = 0;
00117 
00118                 // Reset the list of strips that have been assigned to tracks in this snarl.
00119                 for(int p = 0; p < 490; ++p){
00120                         AlgFitTrackCam::usedSlcStrips[p].clear();
00121                 }
00122 
00123                 while(CandTrackHandle *track = dynamic_cast<CandTrackHandle*>(trkItr())){
00124 
00125                         if(track!=0) {
00126                                 AlgFactory &af = AlgFactory::GetInstance();
00127 
00128                                 const char *configname;
00129                                 AlgHandle ah_trk;
00130                                 if (ac.Get("AlgFitTrackCamConfig", configname))
00131                                         ah_trk = af.GetAlgHandle("AlgFitTrackCam", configname);
00132                                 else
00133                                         ah_trk = af.GetAlgHandle("AlgFitTrackCam", "default");
00134 
00135                                 // Create complete track
00136                                 CandContext cx0(this, mom);
00137                                 cx0.SetDataIn(track);
00138                                 cx0.SetCandRecord(candrec);
00139 
00140                                 dummyt = times(&t1);
00141                                 CandFitTrackCamHandle cth = CandFitTrackCam::MakeCandidate(ah_trk, cx0);
00142                                 dummyt = times(&t2);
00143                                 cth.SetCPUTime((Double_t)(t2.tms_utime+t2.tms_stime-t1.tms_utime-t1.tms_stime)/ticksPerSecond);
00144 
00145                                 cth.SetName(TString("CandFitTrackCamHandle"));
00146                                 cth.SetTitle(TString("Created by AlgFitTrackCamList"));
00147                                 // Add candtrack to candtracklist
00148                                 tracklist.AddDaughterLink(cth);
00149 
00150                                 if(detector==Detector::kNear) {CleanNDSlices(candrec);}
00151                         }
00152                 }
00153 
00154                 if(detector==Detector::kNear) {CheckWeights(candrec);}
00155 
00157 
00158         }
00159 
00160 }

void AlgFitTrackCamList::Trace ( const char *  c  )  const [virtual]

Reimplemented from AlgBase.

Definition at line 266 of file AlgFitTrackCamList.cxx.

00267 {
00268 }


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1