AlgSliceSRList Class Reference

#include <AlgSliceSRList.h>

Inheritance diagram for AlgSliceSRList:
AlgBase

List of all members.

Public Member Functions

 AlgSliceSRList ()
virtual ~AlgSliceSRList ()
virtual void RunAlg (AlgConfig &ac, CandHandle &ch, CandContext &cx)
virtual void SlicetheSnarl (AlgConfig &ac, CandHandle &ch, CandContext &cx)
virtual void SlicetheSnarl_ASAP (AlgConfig &ac, CandHandle &ch, CandContext &cx)
virtual void SlicetheSnarl_MST (AlgConfig &ac, CandHandle &ch, CandContext &cx)
virtual void PassAll (AlgConfig &ac, CandHandle &ch, CandContext &cx)
virtual void Trace (const char *c) const

Private Member Functions

std::vector< TObjArray * > SubSlice (const std::vector< TObjArray * > &timeSlices)
std::vector< TObjArray * > DivideTimeSlice (const TObjArray *timeSlice)
TObjArray * clusterFromSeedIt (std::vector< CandStripHandle * > &remainingHits, TObjArray *slice)
Bool_t AreNeighbours (const CandStripHandle *stp1, const CandStripHandle *stp2)
std::vector< std::vector
< Double_t > > 
getMatchingMatrix (std::vector< TObjArray * > &uSlices, std::vector< TObjArray * > &vSlices)
void mergeSubSlices (std::vector< TObjArray * > &uSlices, std::vector< TObjArray * > &vSlices, Double_t overlapParameter)
void merge (const std::vector< UInt_t > &matches, std::vector< TObjArray * > &slices)
Double_t overlap (const TObjArray *slc1, const TObjArray *slc2)
void timeSort (TObjArray *slc1)
void appendSlice (TObjArray *slc1, const TObjArray *slc2)
std::vector< TObjArray * > matchSubSlices (std::vector< TObjArray * > uSubSlices, std::vector< TObjArray * > vSubSlices)
Double_t sliceCharge (TObjArray *slc)
std::vector< TObjArray * > associateViews (std::vector< TObjArray * > uSubSlices, std::vector< TObjArray * > vSubSlices)
Bool_t inFullyInstrumented (const CandStripHandle *stp)
Bool_t sameView (const TObjArray *slc1, const TObjArray *slc2)
void DeleteNestedVector (std::vector< std::vector< TObjArray * > > &vSlices)
void DeleteVector (std::vector< TObjArray * > &vSlices)
void DeleteNicely (TObjArray *p)

Private Attributes

Double_t maxzgap
Double_t maxtposgap
Double_t maxtimegap
Double_t fullyinstrumentedweight
Double_t minoverlap
Double_t reducedminoverlap
Double_t mincalplane

Detailed Description

Definition at line 24 of file AlgSliceSRList.h.


Constructor & Destructor Documentation

AlgSliceSRList::AlgSliceSRList (  ) 

Definition at line 69 of file AlgSliceSRList.cxx.

00070 {
00071 }

AlgSliceSRList::~AlgSliceSRList (  )  [virtual]

Definition at line 74 of file AlgSliceSRList.cxx.

00075 {
00076 }


Member Function Documentation

void AlgSliceSRList::appendSlice ( TObjArray *  slc1,
const TObjArray *  slc2 
) [private]

Definition at line 774 of file AlgSliceSRList.cxx.

References n.

Referenced by associateViews(), and merge().

00775 {
00776   // std::cout<<"Appending slices" <<std::endl;
00777   // std::cout<<"The append array has " << slc1->GetEntries() << " entries" <<std::endl;
00778   // std::cout<<"The slices to be merged have " << slc2->GetEntries() << " entries" <<std::endl;
00779   Int_t n = slc2->GetEntries();
00780   for (Int_t i = 0; i<n; i++){
00781     slc1->Add(slc2->At(i));
00782   }
00783   // std::cout<<"After appending..." <<std::endl;
00784   // std::cout<<"Now, the append array has " << slc1->GetEntries() << " entries" <<std::endl;
00785   // std::cout<<"Now, the slices to be merged have " << slc2->GetEntries() << " entries" <<std::endl;
00786 }

Bool_t AlgSliceSRList::AreNeighbours ( const CandStripHandle stp1,
const CandStripHandle stp2 
) [private]

Definition at line 1021 of file AlgSliceSRList.cxx.

References fullyinstrumentedweight, CandStripHandle::GetCorrBegTime(), CandStripHandle::GetTPos(), CandStripHandle::GetZPos(), inFullyInstrumented(), maxtimegap, maxtposgap, and maxzgap.

Referenced by clusterFromSeedIt().

01022 {
01023   //relax position cuts if in fully-instrumented region
01024   Double_t zposPar = this->maxzgap;
01025   Double_t tposPar = this->maxtposgap;
01026   Double_t timePar = this->maxtimegap;
01027   Double_t fullyInstrumentedWeight = this->fullyinstrumentedweight;
01028 
01029   //relax position and time cuts in the fully instrumented region
01030   if (inFullyInstrumented(stp1) && inFullyInstrumented(stp2)) {
01031     // std::cout << "This hit is inside fully instrumented region" << std::endl;
01032     // std::cout << "Applying weight" << std::endl;
01033     zposPar *= fullyInstrumentedWeight;
01034     tposPar *= fullyInstrumentedWeight;
01035     timePar *= fullyInstrumentedWeight;
01036   }
01037 
01038   // std::cout << " ---------------- " << std::endl;
01039   // std::cout << "Z pos difference: " << (stp1->GetZPos() - stp2->GetZPos()) << std::endl;
01040   // std::cout << "Tpos difference: " << (stp1->GetTPos() - stp2->GetTPos()) << std::endl;
01041   // std::cout << "Time difference: " << (stp1->GetCorrBegTime() - stp2->GetCorrBegTime()) << std::endl;
01042   // std::cout << " ---------------- " << std::endl;
01043   // std::cout << "Z pos square: " << pow((stp1->GetZPos() - stp2->GetZPos())/zposPar,2) << std::endl;
01044   // std::cout << "Tpos square: " << pow((stp1->GetTPos() - stp2->GetTPos())/tposPar,2) << std::endl;
01045   // std::cout << "Time square: " << pow((stp1->GetCorrBegTime() - stp2->GetCorrBegTime())/timePar,2) << std::endl;
01046   // std::cout << " ---------------- " << std::endl;
01047   // std::cout << "The 3D ellipsoid is: " << (pow((stp1->GetCorrBegTime() - stp2->GetCorrBegTime())/timePar,2) + pow((stp1->GetZPos() - stp2->GetZPos())/zposPar,2) + pow((stp1->GetTPos() - stp2->GetTPos())/tposPar,2)) << std::endl;
01048   // std::cout << " Should pass if less than 1 " << std::endl;
01049   // std::cout << " ---------------- " << std::endl;
01050 
01051   //check for neighbouring hits in a 3D ellipsoid
01052   return (pow((stp1->GetCorrBegTime() - stp2->GetCorrBegTime())/timePar,2) +
01053           pow((stp1->GetZPos() - stp2->GetZPos())/zposPar,2) +
01054           pow((stp1->GetTPos() - stp2->GetTPos())/tposPar,2)) < 1;
01055 
01056 }

std::vector< TObjArray * > AlgSliceSRList::associateViews ( std::vector< TObjArray * >  uSubSlices,
std::vector< TObjArray * >  vSubSlices 
) [private]

Definition at line 412 of file AlgSliceSRList.cxx.

References appendSlice(), getMatchingMatrix(), mergeSubSlices(), minoverlap, overlap(), reducedminoverlap, and timeSort().

Referenced by matchSubSlices().

00413 {
00414 
00415   // std::cout<<"Trying to associate views."<<std::endl;
00416   std::vector<TObjArray*> matchedSlices;
00417   // std::cout<<"Calculating matrix again..."<<std::endl;
00418   std::vector< std::vector<Double_t> > matchingMatrix = getMatchingMatrix(uSubSlices,vSubSlices);
00419 
00420   if (matchingMatrix.size()==1 || matchingMatrix.at(0).size()==1){
00421     // std::cout<<"Only one U or one V slice"<<std::endl;
00422     // std::cout<<"Merge and associate everything, regardless of overlap"<<std::endl;
00424     //if only one u slice, one v slice, or both:
00425     //merge and associate everything, regardless of overlap.
00426     TObjArray* newSlice = new TObjArray();
00427     for (UInt_t i = 0; i<uSubSlices.size(); i++){
00428       for (UInt_t j = 0; j<vSubSlices.size(); j++){
00429         appendSlice(newSlice, vSubSlices.at(j));
00430         appendSlice(newSlice, uSubSlices.at(i));
00431       }
00432     }
00433     timeSort(newSlice);
00434     matchedSlices.push_back(newSlice);
00435     // std::cout<<"Done associating views!"<<std::endl;
00436     return matchedSlices;
00437   }
00438 
00439 
00440   //check each view for slices with no matches  
00441   // std::cout<<"Checking each view for slices with no matches"<<std::endl;  
00442   std::vector<TObjArray*> unassociatedSlicesU;
00443   std::vector<TObjArray*> unassociatedSlicesV;
00444   for (UInt_t i = 0; i<uSubSlices.size(); i++){
00445     // std::cout<<"This U slice " << i << "/" << uSubSlices.size() << "(total)" <<std::endl;  
00446     bool isEmpty = true;
00447     for (UInt_t j = 0; j<vSubSlices.size(); j++){
00448       // std::cout<<"And this V slice " << j << "/" << vSubSlices.size() << "(total)" <<std::endl;  
00449       if (matchingMatrix[i][j] >= minoverlap) {
00450         // std::cout<<"Overlap!"<<std::endl;  
00451         isEmpty = false;
00452       } else {
00453          // std::cout<<"Do NOT overlap!"<<std::endl;  
00454       }
00455     }
00456     if (isEmpty) {
00457       unassociatedSlicesU.push_back(uSubSlices.at(i));
00458       // std::cout<<"U slice "<<i<<" has no matches"<<std::endl;
00459     }
00460   }
00461   for (UInt_t j = 0; j<vSubSlices.size(); j++){
00462     // std::cout<<"This V slice " << j << "/" << vSubSlices.size() << "(total)" <<std::endl;  
00463     bool isEmpty = true;
00464     for (UInt_t i = 0; i<uSubSlices.size(); i++){
00465       // std::cout<<"And this U slice " << i << "/" << uSubSlices.size() << "(total)" <<std::endl;  
00466       if (matchingMatrix[i][j] >= minoverlap){
00467         // std::cout<<"Overlap!"<<std::endl;  
00468         isEmpty = false;
00469       } else {
00470          // std::cout<<"Do NOT overlap!"<<std::endl;  
00471       }
00472     }
00473     if (isEmpty) {
00474       unassociatedSlicesV.push_back(vSubSlices.at(j));
00475       // std::cout<<"V slice "<<j<<" has no matches"<<std::endl;
00476     }
00477   }
00478 
00479   for (UInt_t i = 0; i<uSubSlices.size(); i++){
00480     TObjArray* newSlice = new TObjArray();
00481     int nMatches = 0;
00482     for (UInt_t j = 0; j<vSubSlices.size(); j++){
00483       if (matchingMatrix[i][j] >= minoverlap){
00484         // std::cout<<"U slice "<< i << " (entries) and V slice " << j << " (entries) overlap" <<std::endl;  
00485         nMatches++;
00486         appendSlice(newSlice, vSubSlices.at(j));
00487         appendSlice(newSlice, uSubSlices.at(i));
00488         timeSort(newSlice);
00489         matchedSlices.push_back(newSlice);
00490         // std::cout<<"Merged slice has "<< matchedSlices.size() <<std::endl;
00492       }
00493       if (nMatches>1){
00494         // std::cout<<"Ambiguous match. Bailing"<<std::endl;
00495         assert(0);
00496       }
00497     }
00498   }
00499 
00501 
00502   //now relax the overlap condition for unmatched slices
00503 
00504   // std::cout<<"Finished associating obvious matches"<<std::endl;
00505   // std::cout<<"Trying to associate the leftovers..."<<std::endl;
00506 
00507   Double_t reducedOverlapPar = this->reducedminoverlap;
00508   mergeSubSlices(unassociatedSlicesU, unassociatedSlicesV, reducedOverlapPar); // reduced overlap condition
00509   // std::cout<<"Calculating matrix again, again..."<<std::endl;
00510   std::vector< std::vector<Double_t> > reducedMatchingMatrix = getMatchingMatrix(unassociatedSlicesU, unassociatedSlicesV);
00511     // std::cout<<"Reduced minimum overlap is: " << reducedOverlapPar <<std::endl;
00512 
00513   if (!(unassociatedSlicesU.size()==1 || unassociatedSlicesV.size()==1)){
00514     // std::cout<<"More than one unassociated U and unassociated V slice"<<std::endl;
00515     for (UInt_t i = 0; i<unassociatedSlicesU.size(); i++){
00516       TObjArray* newSlice = new TObjArray();
00517       int nMatches = 0;
00518       for (UInt_t j = 0; j<unassociatedSlicesV.size(); j++){
00519         if (reducedMatchingMatrix[i][j] >= reducedOverlapPar){
00520           // std::cout<<"unassociated U slice "<< i << " (entries) and unassociated V slice " << j << " (entries) overlap" <<std::endl; 
00521           nMatches++;
00522           appendSlice(newSlice, unassociatedSlicesV.at(j));
00523           appendSlice(newSlice, unassociatedSlicesU.at(i));
00524           timeSort(newSlice);
00525           // std::cout<<"Merged slice has "<< newSlice->GetEntries() <<std::endl;
00526           matchedSlices.push_back(newSlice);
00528         }
00529         if (nMatches>1){
00530           // std::cout<<"Ambiguous match again. Bailing"<<std::endl;
00531           assert(0);
00532         }
00533       }
00534     }
00535   }
00536 
00537   //test each unmatched slice for overlap with matched slices
00538   // std::cout<<"Test each unmatched slice for overlap with matched slices"<<std::endl;
00539   for (Int_t i=unassociatedSlicesU.size()-1; i>=0; i--){
00540     Double_t bestOverlap = -999;
00541     Int_t bestMatch = -999;
00542     for (UInt_t j=0; j<matchedSlices.size(); j++){
00543       // std::cout<<"Unassociated U slice " << i <<std::endl;
00544       // std::cout<<"and matched slice " << j <<std::endl;
00545       Double_t tempOverlap = overlap(unassociatedSlicesU.at(i),matchedSlices.at(j));
00546       // std::cout<<"has overlap " << tempOverlap <<std::endl;
00547       // std::cout<<"Is this the best overlap?" <<std::endl;
00548       if (tempOverlap>bestOverlap) {
00549         // std::cout<<"For now, yes!" <<std::endl;
00550         bestOverlap = tempOverlap;
00551         bestMatch = j;
00552       }
00553     }
00554     if (bestOverlap>0){
00555       // std::cout<<"Best overlap is " << bestOverlap <<std::endl;
00556       appendSlice(matchedSlices.at(bestMatch), unassociatedSlicesU.at(i));
00557       timeSort(matchedSlices.at(bestMatch));
00558       unassociatedSlicesU.erase(unassociatedSlicesU.begin()+i);
00559       // std::cout<<"Merged these slices" <<std::endl;
00560     }
00561   }
00562   for (Int_t i=unassociatedSlicesV.size()-1; i>=0; i--){
00563     Double_t bestOverlap = -999;
00564     Int_t bestMatch = -999;
00565     for (UInt_t j=0; j<matchedSlices.size(); j++){
00566       // std::cout<<"Unassociated V slice " << i <<std::endl;
00567       // std::cout<<"and matched slice " << j <<std::endl;
00568       Double_t tempOverlap = overlap(unassociatedSlicesV.at(i),matchedSlices.at(j));
00569       // std::cout<<"has overlap " << tempOverlap <<std::endl;
00570       // std::cout<<"Is this the best overlap?" <<std::endl;
00571       if (tempOverlap>bestOverlap) {
00572         // std::cout<<"For now, yes!" <<std::endl;
00573         bestOverlap = tempOverlap;
00574         bestMatch = j;
00575       }
00576     }
00577     if (bestOverlap>0){
00578       // std::cout<<"Best overlap is " << bestOverlap <<std::endl;
00579       appendSlice(matchedSlices.at(bestMatch), unassociatedSlicesV.at(i));
00580       timeSort(matchedSlices.at(bestMatch));
00581       unassociatedSlicesV.erase(unassociatedSlicesV.begin()+i);
00582       // std::cout<<"Merged these slices" <<std::endl;
00583     }
00584   }
00585   
00586   // std::cout<<"Now left only with sparse unmatched hits with no overlap" <<std::endl;
00587   // std::cout<<"Give them to the biggest slice" <<std::endl;
00588   //now left only with sparse unmatched hits with no overlap.
00589   //give them to the biggest slice.
00590   Int_t maxSliceSize = -999;
00591   TObjArray* biggestSlice = 0;
00592   for (UInt_t i=0; i<matchedSlices.size(); i++){
00593     Int_t sliceSize = matchedSlices.at(i)->GetEntries();
00594     // std::cout<< "Matched slice " << i << " has entries " << sliceSize <<std::endl;
00596     if (sliceSize>maxSliceSize) {
00597       // std::cout<< "This slice is the biggets, for now." <<std::endl;
00598       maxSliceSize=sliceSize;
00599       biggestSlice = matchedSlices.at(i);
00600     }
00601   }
00602 
00603   if (matchedSlices.size()==0) {
00604     biggestSlice = new TObjArray();
00605     matchedSlices.push_back(biggestSlice);
00606   }
00607 
00608 
00609   for (Int_t i=unassociatedSlicesU.size()-1; i>=0; i--){
00610     appendSlice(biggestSlice, unassociatedSlicesU.at(i));
00611     timeSort(biggestSlice);
00612     //unassociatedSlicesU.erase(unassociatedSlicesU.begin()+i);
00613     // std::cout<< "Added unassociated U slice " << i << " to biggest slice" <<std::endl;
00614   }
00615   for (Int_t i=unassociatedSlicesV.size()-1; i>=0; i--){
00616     appendSlice(biggestSlice, unassociatedSlicesV.at(i));
00617     timeSort(biggestSlice);
00618     //unassociatedSlicesV.erase(unassociatedSlicesV.begin()+i);
00619     // std::cout<< "Added unassociated V slice " << i << " to biggest slice" <<std::endl;
00620   }
00621 
00622   //  assert (unassociatedSlices.size()==0);
00623   // std::cout<< "Done with matching slices!!!" <<std::endl;
00624 
00625   return matchedSlices;
00626 }

TObjArray * AlgSliceSRList::clusterFromSeedIt ( std::vector< CandStripHandle * > &  remainingHits,
TObjArray *  slice 
) [private]

Definition at line 985 of file AlgSliceSRList.cxx.

References AreNeighbours().

Referenced by DivideTimeSlice().

00986 {
00987   // std::cout<<"clustering continues..."<<std::endl;
00988 //  // std::cout<<"remaining hts: "<<remainingHits.size()<<std::endl;
00989   for (int j = 0; j<slice->GetEntries(); j++) {
00990     //loop over all strips currently in the slice
00991     //each time a new one is added it is checked
00992     CandStripHandle* stp = static_cast<CandStripHandle*>(slice->At(j));
00993     for(int i = remainingHits.size()-1; i >= 0 ; --i){
00994       //check strip for proximity for all other unassigned strips
00995       //remove strip from unassigned list if added to slice
00996       CandStripHandle* otherStp = remainingHits.at(i);
00997       // std::cout << "Checking if hits should in the same slice" << std::endl;
00998       // std::cout << "Hit in array:" << std::endl;
00999       // std::cout<<"    z = "<<stp->GetZPos()<<", tpos = "<<stp->GetTPos()<<std::endl;
01000       // std::cout << "This remaining hit " << i << ":" << std::endl;
01001       // std::cout<<"    z = "<<otherStp->GetZPos()<<", tpos = "<<otherStp->GetTPos()<<std::endl;
01002 
01003       if (AreNeighbours(stp, otherStp)) {
01004         // std::cout << "These hits are inside maximum distance, should be added together" << std::endl;
01005         //std::cerr<<"Adding strip "<<i<<std::endl;
01006         //std::cerr<<"z = "<<stp->GetZPos()<<", tpos = "<<stp->GetTPos()<<std::endl;
01007         slice->Add(otherStp);
01008         remainingHits.erase(remainingHits.begin()+i);
01009         //std::cerr<<"Erased at "<<i<<std::endl;
01010         // std::cout << "Added " << i << " to array and removed it from vector of remaining" << std::endl;
01011         // std::cout << "Array entries: " << slice->GetEntries() << std::endl;
01012         // std::cout << "Remaining hits: " << remainingHits.size() << std::endl;
01013       }
01014         // std::cout << "These hits are NOT inside maximum distance." << std::endl;
01015       //      else std::cerr<<"Ignoring strip "<<i<<std::endl;
01016     }
01017   }
01018   return slice;
01019 }

void AlgSliceSRList::DeleteNestedVector ( std::vector< std::vector< TObjArray * > > &  vSlices  )  [private]

Definition at line 1430 of file AlgSliceSRList.cxx.

References DeleteVector(), and it.

Referenced by SlicetheSnarl().

01431 {
01432   for ( std::vector< std::vector<TObjArray*> >::iterator it = vSlices.begin();
01433         it != vSlices.end(); ++it ) {
01434     DeleteVector(*it);
01435   }
01436   vSlices.clear();
01437 }

void AlgSliceSRList::DeleteNicely ( TObjArray *  p  )  [private]

Definition at line 1450 of file AlgSliceSRList.cxx.

Referenced by DeleteVector(), and SlicetheSnarl().

01451 {
01452   if (p!=0) {
01453     delete p;
01454     p = 0;
01455   }
01456 }

void AlgSliceSRList::DeleteVector ( std::vector< TObjArray * > &  vSlices  )  [private]

Definition at line 1440 of file AlgSliceSRList.cxx.

References DeleteNicely(), and it.

Referenced by DeleteNestedVector(), and SlicetheSnarl().

01441 {
01442   for ( std::vector<TObjArray*>::iterator it = vSlices.begin();
01443         it != vSlices.end(); ++it ) {
01444     DeleteNicely(*it);
01445   }
01446   vSlices.clear();
01447 }

std::vector< TObjArray * > AlgSliceSRList::DivideTimeSlice ( const TObjArray *  timeSlice  )  [private]

Definition at line 940 of file AlgSliceSRList.cxx.

References clusterFromSeedIt(), and timeSort().

Referenced by SlicetheSnarl(), and SubSlice().

00941 {
00942 
00943   std::vector<TObjArray*> newSlices;
00944   Int_t nStrips = timeSlice->GetEntries();
00945 
00946   if (nStrips<=1){ //in case time slice has only one or zero hits
00947     // std::cout << "This slice has <=1 hit, cannot be divided." << std::endl;
00948     newSlices.push_back(new TObjArray(*timeSlice));
00949     return newSlices;
00950   }
00951 
00952   else{
00953     //copy timeslice elements into a vector of hits
00954     // std::cout << "This slice has more than 1 hit, lets divide it." << std::endl;
00955     std::vector<CandStripHandle*> remainingHits;
00956     for (int i = 0; i<nStrips; i++){
00957       remainingHits.push_back(static_cast<CandStripHandle*>(timeSlice->At(i)));
00958     }
00959     // std::cout << "Copied hits of first slice to a vector" << std::endl;
00960     // std::cout << "Vector entries is: " << remainingHits.size() << std::endl;
00961 
00962     //now cluster from the hits in this vector, removing as we go
00963     while(remainingHits.size()>0){
00964       //std::cerr<<"\nStarting new subslice"<<std::endl;
00965       TObjArray* slice = new TObjArray();
00966       Int_t endIndex = remainingHits.size()-1;
00967       CandStripHandle* stp = remainingHits.at(endIndex);
00968       slice->Add(stp);
00969       // std::cout << "Copied first hit to an array." << std::endl;
00970       // std::cout << "Array entries is: " << slice->GetEntries() << std::endl;
00971       remainingHits.erase(remainingHits.begin()+endIndex);
00972       // std::cout << "Removed it from vector." << std::endl;
00973       // std::cout << "Remaining hits (vector): " << remainingHits.size() << std::endl;
00974       slice = clusterFromSeedIt(remainingHits, slice);
00975       // std::cout<<"Made a subslice"<<std::endl;
00976       // std::cout<<"used "<<slice->GetEntries()<<" strips"<<std::endl;
00977       if (slice->GetEntries()>1) timeSort(slice);
00978       // std::cout << "Sorted slice regarding to time." << std::endl;
00979       newSlices.push_back(slice);
00980     }
00981     return newSlices;
00982   }
00983 }

std::vector< std::vector< Double_t > > AlgSliceSRList::getMatchingMatrix ( std::vector< TObjArray * > &  uSlices,
std::vector< TObjArray * > &  vSlices 
) [private]

Definition at line 788 of file AlgSliceSRList.cxx.

References overlap().

Referenced by associateViews(), and mergeSubSlices().

00789 {
00790   int nUslices = uSlices.size(); int nVslices = vSlices.size();
00791   std::vector< std::vector<Double_t> > matchingMatrix(nUslices, std::vector<Double_t>(nVslices, 0));
00792 
00793   // std::cout<<" *********************************** " <<std::endl;
00794   // std::cout<<"               Matrix                "<<std::endl;
00795   // std::cout<<" *********************************** " <<std::endl;
00796   for (Int_t i = 0; i<nUslices; i++){
00797     for (Int_t j = 0; j<nVslices; j++){
00798       matchingMatrix[i][j] = overlap(uSlices.at(i),vSlices.at(j));
00799       // std::cout<<matchingMatrix[i][j]<<"\t";
00800     }
00801     // std::cout<<std::endl;
00802   }
00803   // std::cout<<" *********************************** " <<std::endl;
00804 
00805   return matchingMatrix;
00806 }

Bool_t AlgSliceSRList::inFullyInstrumented ( const CandStripHandle stp  )  [private]

Definition at line 1058 of file AlgSliceSRList.cxx.

References CandStripHandle::GetPlaneView(), CandStripHandle::GetTPos(), PlaneView::kU, and PlaneView::kV.

Referenced by AreNeighbours().

01059 {
01060   if (stp->GetPlaneView()==PlaneView::kU) {
01061     return (stp->GetTPos()>2.52 || stp->GetTPos()<-0.25);
01062   }
01063   else if (stp->GetPlaneView()==PlaneView::kV) {
01064     return (stp->GetTPos()>0.3 || stp->GetTPos()<-2.5);
01065   }
01066   else {
01067     std::cerr<<"unrecognised planeview"<<std::endl;
01068     assert(0);
01069   }
01070 }

std::vector< TObjArray * > AlgSliceSRList::matchSubSlices ( std::vector< TObjArray * >  uSubSlices,
std::vector< TObjArray * >  vSubSlices 
) [private]

Definition at line 389 of file AlgSliceSRList.cxx.

References associateViews(), mergeSubSlices(), and minoverlap.

Referenced by SlicetheSnarl().

00390 {
00391   // std::cout<<"Attempting to match U and V subslices"<<std::endl;
00392   // std::cout<<"Starting with "<<uSubSlices.size()<<" U subslices"<<std::endl;
00393   // std::cout<<"and "<<vSubSlices.size()<<" V subslices"<<std::endl;
00394   mergeSubSlices(uSubSlices,vSubSlices,minoverlap);
00395   // std::cout<<" ---------------- "<<std::endl;
00396   // std::cout<<"Ending with "<<uSubSlices.size()<<" U subslices"<<std::endl;
00397   // std::cout<<"and "<<vSubSlices.size()<<" V subslices"<<std::endl;
00398 
00399   // std::cout<<"Now lets check U and V slices against each other"<<std::endl;
00400   std::vector<TObjArray*> matchedSlices = associateViews(uSubSlices,vSubSlices);
00401   // std::cout<<" ---------------- "<<std::endl;
00402   return matchedSlices;
00403 }

void AlgSliceSRList::merge ( const std::vector< UInt_t > &  matches,
std::vector< TObjArray * > &  slices 
) [private]

Definition at line 719 of file AlgSliceSRList.cxx.

References appendSlice(), and timeSort().

Referenced by mergeSubSlices().

00720 {
00721   std::vector<TObjArray*> newSlices;
00722   // std::cout<<"Merging. Start with "<<slices.size()<<" slices"<<std::endl;
00723   TObjArray* mergedSlice = new TObjArray();
00724   for (UInt_t i = 0; i<slices.size(); i++){
00725     // std::cout<<"This slice "<< i <<std::endl;
00726     bool mergingSlice = false;
00727     //if index is in matches vector
00728     for (UInt_t j = 0; j<matches.size(); j++){
00729       if (matches.at(j)==i) {
00730         // std::cout<<"is one of the matched slices to be merged." <<std::endl;
00731         appendSlice(mergedSlice, slices[i]);
00732         mergingSlice = true;
00733       } else {
00734         // std::cout<<"should not be merged." <<std::endl;
00735       }
00736     }
00737     if (!mergingSlice) newSlices.push_back(slices[i]);
00738   }
00739   newSlices.push_back(mergedSlice);
00740   // std::cout<<"Constructing the array again with the merged slices." <<std::endl;
00741   timeSort(mergedSlice);
00742   // std::cout<<"Ending with "<<newSlices.size()<<"slices"<<std::endl;
00743   //DeleteVector(slices); // clear the old slice list
00744   slices.clear();
00745   for (UInt_t i = 0; i<newSlices.size(); i++){
00746     slices.push_back(newSlices[i]);
00747   }
00748 }

void AlgSliceSRList::mergeSubSlices ( std::vector< TObjArray * > &  uSlices,
std::vector< TObjArray * > &  vSlices,
Double_t  overlapParameter 
) [private]

Definition at line 628 of file AlgSliceSRList.cxx.

References getMatchingMatrix(), and merge().

Referenced by associateViews(), and matchSubSlices().

00629 {
00630   if (uSlices.size()==1 || vSlices.size()==1) {
00631      // std::cout<<"We have only one U and V slices. No need to merge."<<std::endl;
00632      return; //no need to merge anything
00633   }
00634 
00635   // std::cout<<"Attempting to merge U and V subslices"<<std::endl;
00636   //want an nUslices x nVslices boolean matrix
00637 
00638   bool stillMerging = true;
00639   while(stillMerging && uSlices.size()!=1 && vSlices.size()!=1){
00640     // std::cout<<"Calculating matrix..."<<std::endl;
00641     std::vector< std::vector<Double_t> > matchingMatrix = getMatchingMatrix(uSlices,vSlices);
00642     stillMerging = false;
00643 
00644 /*
00645     // std::cout<<" ************************* " <<std::endl;
00646     // std::cout<<"          Matrix           "<<std::endl;
00647     // std::cout<<" ************************* " <<std::endl;
00648     // std::cout<<"matchingMatrix[i][j]"<<std::endl;
00649 
00650 
00651     // std::cout<<" ************************* " <<std::endl;
00652 */
00653 
00654     //check each view for slices with more than one match  
00655     // std::cout<<" ### Maximum overlap is: " << overlapParameter << " ###" <<std::endl;  
00656     // std::cout<<"Loop order: U then V" <<std::endl; 
00657     for (UInt_t i = 0; i<uSlices.size(); i++){
00658       // std::cout<<"U subslice " << i <<std::endl;
00659       std::vector<UInt_t> vMatches;
00660       for (UInt_t j = 0; j<vSlices.size(); j++){
00661         // std::cout<<"and V subslice " << j <<std::endl;
00662         // std::cout<<"have overlap = " << matchingMatrix[i][j] <<std::endl;
00663         if (matchingMatrix[i][j] >= overlapParameter) {
00664           // std::cout<<"They MATCH!" << j <<std::endl;
00665           vMatches.push_back(j);
00666         } else {
00667           // std::cout<<"They DO NOT match!" <<std::endl;
00668         }
00669       }
00670       if (vMatches.size()>1){
00671         // std::cout<<"Ops, already found a V match before" <<std::endl;
00672         // std::cout<<"So we should probably merge these V slices" <<std::endl;
00673         stillMerging = true;
00674         //std::cerr<<"More than one v match"<<std::endl;
00675         //std::cerr<<"Matches at ";
00676         //for (UInt_t iMatch = 0; iMatch<vMatches.size(); iMatch++) std::cerr<<vMatches.at(iMatch)<<" ";
00677         //std::cerr<<std::endl;
00678         merge(vMatches, vSlices);
00679         // std::cout<<"Merged and recreated slice vector." <<std::endl;
00680         // std::cout<<"Recalculating the matrix" <<std::endl;
00681         matchingMatrix = getMatchingMatrix(uSlices,vSlices); //recalculate matching matrix;
00682       }
00683     }
00684     //std::cerr<<"Not failed yet (2)"<<std::endl;
00685 
00686     // std::cout<<"Changing loop order: V then U" <<std::endl; 
00687     
00688     for (UInt_t j = 0; j<vSlices.size(); j++){
00689       // std::cout<<"V subslice " << j <<std::endl;
00690       std::vector<UInt_t> uMatches;
00691       for (UInt_t i = 0; i<uSlices.size(); i++){
00692         // std::cout<<"and U subslice " << i <<std::endl;
00693         // std::cout<<"have overlap = " << matchingMatrix[i][j] <<std::endl;
00694         if (matchingMatrix[i][j] >= overlapParameter) {
00695           // std::cout<<"They MATCH!" <<std::endl;
00696           uMatches.push_back(i);
00697         } else {
00698           // std::cout<<"They DO NOT match!" << std::endl;
00699         }
00700       }
00701       if (uMatches.size()>1){
00702         // std::cout<<"Ops, already found a U match before" <<std::endl;
00703         // std::cout<<"So we should probably merge these U slices" <<std::endl;
00704         stillMerging = true;
00705         //std::cerr<<"More than one u match"<<std::endl;
00706         //std::cerr<<"Matches at ";
00707         //for (UInt_t iMatch = 0; iMatch<uMatches.size(); iMatch++) std::cerr<<uMatches.at(iMatch)<<" ";
00708         //std::cerr<<std::endl;
00709         merge(uMatches, uSlices);
00710         // std::cout<<"Merged and recreated slice vector." <<std::endl;
00711         // std::cout<<"Recalculating the matrix" <<std::endl;
00712         matchingMatrix = getMatchingMatrix(uSlices,vSlices); //recalculate matching matrix;
00713       }
00714     }
00715   } // while stillMerging
00716   // std::cout<<"Done merging!"<<std::endl;
00717 }

Double_t AlgSliceSRList::overlap ( const TObjArray *  slc1,
const TObjArray *  slc2 
) [private]

Definition at line 808 of file AlgSliceSRList.cxx.

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

Referenced by associateViews(), and getMatchingMatrix().

00809 {
00810 
00811   // std::cout << "Starting overlap function." << std::endl;
00812 
00813   CandStripHandle* startStrip1 = static_cast<CandStripHandle*>(slc1->At(0));
00814   CandStripHandle* endStrip1 = static_cast<CandStripHandle*>(slc1->At(slc1->GetLast()));
00815   CandStripHandle* startStrip2 = static_cast<CandStripHandle*>(slc2->At(0));
00816   CandStripHandle* endStrip2 = static_cast<CandStripHandle*>(slc2->At(slc2->GetLast()));
00817 
00818   // Time overlap
00820   Double_t startTime = fmax( startStrip1->GetCorrBegTime(), startStrip2->GetCorrBegTime() );
00821   Double_t endTime = fmin( endStrip1->GetCorrBegTime(), endStrip2->GetCorrBegTime() );
00822   Double_t timeWidth1 = endStrip1->GetCorrBegTime() - startStrip1->GetCorrBegTime();
00823   Double_t timeWidth2 = endStrip2->GetCorrBegTime() - startStrip2->GetCorrBegTime();
00824 
00825   // std::cout << " ............................" << std::endl;
00826   // std::cout << "   slice 1 has start time: " << startStrip1->GetCorrBegTime() << std::endl;
00827   // std::cout << "   slice 2 has start time: " << startStrip2->GetCorrBegTime() << std::endl;
00828   // std::cout << "   We will use " << startTime << std::endl;
00829 
00830   // std::cout << " ............................" << std::endl;
00831   // std::cout << "   slice 1 has end time: " << endStrip1->GetCorrBegTime() << std::endl;
00832   // std::cout << "   slice 2 has end time: " << endStrip2->GetCorrBegTime() << std::endl;
00833   // std::cout << "   We will use " << endTime << std::endl;
00834   // std::cout << " ............................" << std::endl;
00835   // std::cout << "      time overlap is: " << endTime-startTime << std::endl;
00836 
00837   // std::cout << " ............................" << std::endl;
00838   // std::cout << "   time width for slice 1: " << timeWidth1 << std::endl;
00839   // std::cout << "   time width for slice 2: " << timeWidth2 << std::endl;
00840   // std::cout << " ............................" << std::endl;
00841 
00842   Double_t fracTimeOverlap = 0;
00843   //if both subslices are singles, match only if they are very close to one-another
00844   if (timeWidth1==0 && timeWidth2==0) fracTimeOverlap = fmax(1 - fabs((startTime-endTime)*2e8), 0);
00845   else if (endTime<startTime) fracTimeOverlap = 0;
00846   else {
00847     Double_t timeOverlap = endTime-startTime;
00848     //if one subslice has only one hit, overlap = 1 / n_hits_other_view_subslice
00849     if (timeWidth1==0||timeWidth2==0) fracTimeOverlap = ( fmin(slc1->GetEntries(),slc2->GetEntries()) /
00850                                                  fmax(slc1->GetEntries(),slc2->GetEntries())  );
00851     else fracTimeOverlap = 2*timeOverlap / (timeWidth1 + timeWidth2);
00852   }
00853 
00854   // std::cout << "   FRACTION TIME OVERLAP: " << fracTimeOverlap << std::endl;
00855   // std::cout << " ............................" << std::endl;
00856 
00857 
00858 
00859   // Z overlap
00861   Double_t stp1startZ = 999;
00862   Double_t stp2startZ = 999;
00863   Double_t stp1endZ = -999;
00864   Double_t stp2endZ = -999;
00865 
00866   for (Int_t i = 0; i<slc1->GetEntries(); i++) {
00867     CandStripHandle* stp = static_cast<CandStripHandle*>(slc1->At(i));
00868     if (stp->GetZPos() > stp1endZ) stp1endZ = stp->GetZPos();
00869     if (stp->GetZPos() < stp1startZ) stp1startZ = stp->GetZPos();
00870   }
00871 
00872   for (Int_t i = 0; i<slc2->GetEntries(); i++) {
00873     CandStripHandle* stp = static_cast<CandStripHandle*>(slc2->At(i));
00874     if (stp->GetZPos() > stp2endZ) stp2endZ = stp->GetZPos();
00875     if (stp->GetZPos() < stp2startZ) stp2startZ = stp->GetZPos();
00876   }
00877 
00878   Double_t startZ = fmax( stp1startZ, stp2startZ );
00879   Double_t endZ = fmin( stp1endZ, stp2endZ );
00880   Double_t zWidth1 = stp1endZ - stp1startZ;
00881   Double_t zWidth2 = stp2endZ - stp2startZ;
00882 
00883   // std::cout << "   slice 1 has start Z: " << stp1startZ << std::endl;
00884   // std::cout << "   slice 2 has start Z: " << stp2startZ << std::endl;
00885   // std::cout << "   We will use " << startZ << std::endl;
00886 
00887   // std::cout << " ............................" << std::endl;
00888   // std::cout << "   slice 1 has end Z: " << stp1endZ << std::endl;
00889   // std::cout << "   slice 2 has end Z: " << stp2endZ << std::endl;
00890   // std::cout << "   We will use " << endZ << std::endl;
00891   // std::cout << " ............................" << std::endl;
00892   // std::cout << "      Z overlap is: " << endZ-startZ << std::endl;
00893 
00894   // std::cout << " ............................" << std::endl;
00895   // std::cout << "    Z width for slice 1: " << zWidth1 << std::endl;
00896   // std::cout << "    Z width for slice 2: " << zWidth2 << std::endl;
00897   // std::cout << " ............................" << std::endl;
00898 
00899   Double_t fracZOverlap = 0;
00900   //if both subslices are singles, match only if they are very close to one-another
00901   if (zWidth1==0 && zWidth2==0) fracZOverlap = fmax(1-fabs(10*(startZ-endZ)),0);
00902   else if (endZ<startZ) fracZOverlap = 0;
00903   else {
00904     Double_t zOverlap = endZ-startZ;
00905     //if one subslice has only one hit, overlap = 1 / n_hits_other_view_subslice
00906     if (zWidth1==0||zWidth2==0) fracZOverlap = ( fmin(slc1->GetEntries(),slc2->GetEntries()) /
00907                                                  fmax(slc1->GetEntries(),slc2->GetEntries())  );
00908     else fracZOverlap = 2*zOverlap / (zWidth1 + zWidth2);
00909   }
00910 
00911   // std::cout << "     FRACTION Z OVERLAP: " << fracZOverlap << std::endl;
00912   // std::cout << " ............................" << std::endl;
00913 
00914   Double_t themin = fmin(fracZOverlap, fracTimeOverlap);
00915   // std::cout << " Who is minimum? Time or Z overlap?" << std::endl;
00916   if (themin == fracZOverlap) {
00917     // std::cout << "Z overlap is minimum: " << themin << std::endl;
00918   } else {
00919     // std::cout << "Time overlap is minimum: " << themin << std::endl;
00920   }
00921 
00922   //Return min of z and time overlaps to ensure good match in both.
00923   return fmin(fracZOverlap, fracTimeOverlap);
00924 }

void AlgSliceSRList::PassAll ( AlgConfig ac,
CandHandle ch,
CandContext cx 
) [virtual]

pass all strips in the snarl to a single slice

Definition at line 1074 of file AlgSliceSRList.cxx.

References CandHandle::AddDaughterLink(), AlgFactory::GetAlgHandle(), CandContext::GetDataIn(), CandHandle::GetDaughterIterator(), AlgFactory::GetInstance(), CandContext::GetMom(), and CandSlice::MakeCandidate().

Referenced by RunAlg().

01075 {
01076 
01077    const CandStripListHandle *cslh =
01078          dynamic_cast<const CandStripListHandle*>(cx.GetDataIn());
01079 
01080    AlgFactory &af = AlgFactory::GetInstance();
01081    AlgHandle ah = af.GetAlgHandle("AlgSliceSR","default");
01082    CandContext cxx(this,cx.GetMom());
01083 
01084    CandStripHandleItr cshItr(cslh->GetDaughterIterator());
01085 
01086 // Iterate over CandStripList daughters
01087    TObjArray striparray;
01088    striparray.Clear();
01089    while (CandStripHandle *curr = cshItr()) {
01090       striparray.Add(curr);
01091    }
01092    cxx.SetDataIn(&striparray);
01093    CandSliceHandle slicehandle = CandSlice::MakeCandidate(ah,cxx);
01094    ch.AddDaughterLink(slicehandle);
01095 }

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

Main driver routine for CandSliceList algorithm. Based on context, call is made to near or far det slicer. For far detector, value of SliceFar is used to determine whether slicing is performed, or entire snarl is passed. Default currently is to bypass slicing in the far detector.

Implements AlgBase.

Definition at line 82 of file AlgSliceSRList.cxx.

References CandContext::GetDataIn(), Registry::GetInt(), CandContext::GetMom(), Msg::kWarning, MSG, PassAll(), SlicetheSnarl(), SlicetheSnarl_ASAP(), and SlicetheSnarl_MST().

00083 {
00084    assert(cx.GetDataIn());
00085 
00086    Int_t passall  = ac.GetInt("PassAll");
00087    Int_t passasap = ac.GetInt("PassASAP");
00088    Int_t passmst  = ac.GetInt("PassMST");
00089    
00090    // Check for CandStripListHandle input
00091    if (cx.GetDataIn()->InheritsFrom("CandStripListHandle")) {
00092      const MomNavigator *mom = cx.GetMom();
00093 
00094      const RawDigitDataBlock *rddb = 
00095         DataUtil::GetRawBlock<RawDigitDataBlock>(mom);
00096      if (!rddb) {
00097        MSG("SliceSR", Msg::kWarning) << "No RawDigitDataBlock in RawRecord." << endl;
00098        return;
00099      }
00100 
00101      if(passall){
00102        PassAll(ac,ch,cx);
00103      }
00104      if(passasap){
00105        SlicetheSnarl_ASAP(ac,ch,cx);
00106      }
00107      if(passmst){
00108        SlicetheSnarl_MST(ac,ch,cx);
00109      }
00110      else if(!passall && !passasap && !passmst){
00111        SlicetheSnarl(ac,ch,cx);
00112      }
00113    }
00114 }

Bool_t AlgSliceSRList::sameView ( const TObjArray *  slc1,
const TObjArray *  slc2 
) [private]

Definition at line 405 of file AlgSliceSRList.cxx.

References CandStripHandle::GetPlaneView().

00406 {
00407   CandStripHandle* stp1 = static_cast<CandStripHandle*>(slc1->At(0));
00408   CandStripHandle* stp2 = static_cast<CandStripHandle*>(slc2->At(0));
00409   return (stp1->GetPlaneView() == stp2->GetPlaneView());
00410 }

Double_t AlgSliceSRList::sliceCharge ( TObjArray *  slc  )  [private]
void AlgSliceSRList::SlicetheSnarl ( AlgConfig ac,
CandHandle ch,
CandContext cx 
) [virtual]

Definition at line 116 of file AlgSliceSRList.cxx.

References CandHandle::AddDaughterLink(), DeleteNestedVector(), DeleteNicely(), DeleteVector(), DivideTimeSlice(), earlierThan(), fullyinstrumentedweight, AlgFactory::GetAlgHandle(), CandStripHandle::GetCharge(), CandStripHandle::GetCorrBegTime(), CandContext::GetDataIn(), CandHandle::GetDaughterIterator(), VldContext::GetDetector(), Registry::GetDouble(), AlgFactory::GetInstance(), CandContext::GetMom(), CandStripHandle::GetPlane(), CandStripHandle::GetPlaneView(), CandHandle::GetVldContext(), Msg::kDebug, Detector::kNear, CalDigitType::kNone, PlaneView::kU, PlaneView::kV, CandSlice::MakeCandidate(), matchSubSlices(), maxtimegap, maxtposgap, maxzgap, mincalplane, minoverlap, MSG, reducedminoverlap, CandHandle::RemoveDaughter(), SliceSRKeyFromForwardTime(), and StripSRKeyFromCorrTime().

Referenced by RunAlg().

00117 {
00118   const CandStripListHandle *cslh =
00119         dynamic_cast<const CandStripListHandle*>(cx.GetDataIn());
00120 
00121   MSG("AlgSliceSR",Msg::kDebug) << "Starting SR Slicer!" << endl;
00122 
00123   // Sort by time
00124   CandStripHandleItr cshItr(cslh->GetDaughterIterator());
00125   CandStripHandleKeyFunc *cshKf = cshItr.CreateKeyFunc();
00126   cshKf->SetFun(StripSRKeyFromCorrTime);
00127   cshItr.GetSet()->AdoptSortKeyFunc(cshKf);
00128   cshKf = 0;
00129 
00130   AlgFactory &af = AlgFactory::GetInstance();
00131   AlgHandle ah = af.GetAlgHandle("AlgSliceSR","default");
00132   CandContext cxx(this,cx.GetMom());
00133 
00134   mincalplane                   = ac.GetDouble("MinCalPlane");
00135   maxtposgap                    = ac.GetDouble("MaxTPosGap");
00136   maxzgap                       = ac.GetDouble("MaxZGap");
00137   fullyinstrumentedweight       = ac.GetDouble("FullyInstrumentedWeight");
00138   minoverlap                    = ac.GetDouble("MinOverlap");
00139   reducedminoverlap             = ac.GetDouble("ReducedMinOverlap");
00140   Double_t mincharge            = ac.GetDouble("MinCharge");
00141   maxtimegap                    = ac.GetDouble("MaxTimeGap");
00142   Double_t earlytimediff        = ac.GetDouble("EarlyTimeDiff");
00143   Double_t timediffspect        = ac.GetDouble("TimeDiffSpect");
00144   earlytimediff                 = fabs(earlytimediff); // make sure this is a positive quantity
00145   
00146   Int_t specplane = 999;
00147   if (cslh->GetVldContext()->GetDetector() == Detector::kNear) specplane = 121;
00148   
00149   std::vector<TObjArray*> uTimeSlices;
00150   std::vector<TObjArray*> vTimeSlices;
00151 
00152   Int_t nStp = 0;
00153   Int_t nStrips = 0;
00154 
00155   std::vector<CandStripHandle*> vStrips;
00156 
00157   while (CandStripHandle *curr = cshItr()) {
00158     nStrips++;
00159     vStrips.push_back(curr);
00160   }
00161 
00162   // std::cout << "Filled vector of strips" << std::endl;
00163   // std::cout << "Vector of strips has " << vStrips.size() << " entries." << std::endl;
00164 
00165   std::stable_sort(vStrips.begin(), vStrips.end(), earlierThan);
00166 
00167   CandStripHandle *firstrip = vStrips.at(0);
00168   // std::cout << "Got first hit." << std::endl;
00169 
00170   Double_t startTime = firstrip->GetCorrBegTime(); // this will be used for timewindow
00171   // std::cout << "Time of first hit: " << startTime << std::endl;
00172 
00173   //std::cerr<<"Starting initial time slicing"<<std::endl;
00174   //std::cerr<<vStrips.size()<<" strips in snarl"<<std::endl;
00175 
00176   // std::cout << "==================================" << std::endl;
00177   // std::cout << "Starting initial time slicing" << std::endl;
00178 
00179   while (nStp<nStrips){
00180     TObjArray* uSlice = new TObjArray();
00181     TObjArray* vSlice = new TObjArray();
00182     Double_t timediff = 0;
00183     while (timediff < maxtimegap && nStp<nStrips){
00184       // std::cout << "This hit is inside maxtimegap" << std::endl;
00185       CandStripHandle *stp = vStrips.at(nStp);
00186       if ((stp->GetPlane() < specplane)&&(stp->GetCharge() > mincharge)){
00187         // std::cout << "This hit is in calorimeter and have charge > 2pe." << std::endl;
00188         timediff = fabs(stp->GetCorrBegTime() - startTime);
00189         // std::cout << "Time difference between this hit and last one is: " << timediff << std::endl;
00190         if (stp->GetPlaneView() == PlaneView::kU) {
00191           uSlice->Add(stp);
00192           // std::cout << "This hit is in U view" << std::endl;
00193         } else if (stp->GetPlaneView() == PlaneView::kV) {
00194           vSlice->Add(stp);
00195           // std::cout << "This hit is in V view" << std::endl;
00196         }
00197         startTime = stp->GetCorrBegTime();
00198       }
00199       // std::cout << "But it's not in calorimeter or have charge < 2pe." << std::endl;
00200       nStp++;
00201     }
00202     uTimeSlices.push_back(uSlice);
00203     vTimeSlices.push_back(vSlice);
00204   }
00205 
00206   // std::cout<<"Split snarl into "<< uTimeSlices.size() <<" U time slices" << std::endl;
00207   // std::cout<<"and "<< vTimeSlices.size() <<" V time slices" << std::endl;
00208 //  // std::cout<<"Slice 1 has "<< vTimeSlices.at(10)->GetEntries() <<" strips" << std::endl;
00209 
00210   // std::cout << "Time slicing done!" << std::endl;
00211   // std::cout << "==================================" << std::endl;
00212 
00213   UInt_t nTimeSlices = uTimeSlices.size();
00214   assert (nTimeSlices==vTimeSlices.size());
00215 
00216   std::vector< std::vector<TObjArray*> > uSlices;
00217   std::vector< std::vector<TObjArray*> > vSlices;
00218   for (UInt_t i = 0; i<nTimeSlices; i++){
00219     // std::cout << "Dividing U time slice" << std::endl;
00220     uSlices.push_back(DivideTimeSlice(uTimeSlices[i]));
00221     // std::cout << "Dividing V time slice" << std::endl;
00222     vSlices.push_back(DivideTimeSlice(vTimeSlices[i]));
00223   }
00224 
00225   // std::cout << "Done dividing U and V slices" << std::endl;
00226   // std::cout << "==================================" << std::endl;
00227 
00228   std::vector<bool> emptyTimeSlice(nTimeSlices,false);
00229   Int_t nEmpty = 0;
00230   // std::cout << "Checking for empty slices" << std::endl;
00231 
00232   for (UInt_t i = 0; i<nTimeSlices; i++){
00233     // std::cout<<"U timeslice "<<i<<" split into "<<uSlices[i].size()<<std::endl;
00234     // std::cout<<"V timeslice "<<i<<" split into "<<vSlices[i].size()<<std::endl;
00235     if (uSlices[i].at(0)->GetEntries()==0) {
00236       nEmpty++;
00237       // std::cout<<"empty U slice"<<std::endl;
00238       emptyTimeSlice[i] = true;
00239     }
00240     if (vSlices[i].at(0)->GetEntries()==0) {
00241       nEmpty++;
00242       // std::cout<<"empty V slice"<<std::endl;
00243       emptyTimeSlice[i] = true;
00244     }
00245   }
00246 
00247   for (Int_t i = nTimeSlices-1; i>=0; i--){
00248     // std::cout << "Checking for empty slices" << std::endl;
00249     if (emptyTimeSlice[i]) {
00250       // std::cout << "This slice is empty, erasing it" << std::endl;
00251       DeleteVector(uSlices.at(i));
00252       DeleteVector(vSlices.at(i));
00253       uSlices.erase(uSlices.begin()+i);
00254       vSlices.erase(vSlices.begin()+i);
00255       DeleteNicely(uTimeSlices.at(i));
00256       DeleteNicely(vTimeSlices.at(i));
00257       uTimeSlices.erase(uTimeSlices.begin()+i);
00258       vTimeSlices.erase(vTimeSlices.begin()+i);
00259     } else {
00260       // std::cout << "This is not an empty slice" << std::endl;
00261     }
00262   }
00263 
00264   // std::cout << "Done deleting empty slices" << std::endl;
00265   // std::cout << "==================================" << std::endl;
00266   // std::cout << "Starting slices matching" << std::endl;
00267 
00268   std::vector< std::vector<TObjArray*> > finalSlices;
00269   for (UInt_t i = 0; i<vSlices.size(); i++){
00270     // std::cout<<"This loop is on V slices, check if this is correct" << std::endl;
00271     // std::cout<<"Matching subslices for timeslice "<<i<<std::endl;
00272     // std::cout<<"U split into "<<uSlices[i].size()<<std::endl;
00273     // std::cout<<"V split into "<<vSlices[i].size()<<std::endl;
00274     std::vector<TObjArray*> matchedSlices = matchSubSlices(uSlices[i],vSlices[i]);
00276     //    finalSlices.insert(finalSlices.end(), matchedSlices.begin(), matchedSlices.end() );
00277     finalSlices.push_back(matchedSlices);
00278   }
00279 
00280   //write slice objects
00281   // std::cout << "Writing final slices" << std::endl;
00282   for (UInt_t i = 0; i<finalSlices.size(); i++){
00283     for (UInt_t j = 0; j<finalSlices.at(i).size(); j++){
00284       TObjArray* slice = finalSlices[i][j];
00285           cxx.SetDataIn(slice);
00286           CandSliceHandle slicehandle =
00287             CandSlice::MakeCandidate(ah,cxx);
00288           ch.AddDaughterLink(slicehandle);
00289     }
00290   }
00291   // std::cout << "Number of final slices: " << finalSlices.size() << std::endl;
00292   // std::cout << "==================================" << std::endl;
00293 
00294   // Prepare slice iterator for next phase
00295   // std::cout << "Prepare slice iterator for next phase" << std::endl;
00296   CandSliceHandleItr sliceItr2(ch.GetDaughterIterator());
00297   CandSliceHandleKeyFunc *sliceKf2 = sliceItr2.CreateKeyFunc();
00298   sliceKf2->SetFun(SliceSRKeyFromForwardTime);
00299   sliceItr2.GetSet()->AdoptSortKeyFunc(sliceKf2);
00300   sliceKf2 = 0;
00301 
00302   /* We now pick up CandStrips in the spectrometer. To do this, we iterate over CandSlices constructed in the previous stage, and determine which remaining CandStrips should be added. For each CandSlice, a time interval bounded by the CandSlice start time minus EarlyTimeDiff and the CandSlice start time plus TimeDiffSpect is defined, and CandStrips in the spectrometer within this time range are added to the slice */
00303 
00304   if (cslh->GetVldContext()->GetDetector() == Detector::kNear){
00305     MSG("AlgSliceSR",Msg::kDebug) << "Adding Spectro Hits!" << endl;
00306     // std::cout << "Adding Spectro Hits!" << std::endl;
00307 
00308     sliceItr2.Reset();
00309     while (CandSliceHandle *slice = sliceItr2()) {
00310       if (slice->GetEndPlane() > mincalplane){
00311       // std::cout << "End plane for this slice: " << slice->GetEndPlane() << std::endl;
00312 
00313 
00314        cshItr.GetSet()->Slice();
00315        cshItr.GetSet()->Slice(slice->GetCorrBegTime()-earlytimediff, slice->GetCorrBegTime()+timediffspect);
00316 
00317         // std::cout << "Time window is from " << slice->GetCorrTime()-earlytimediff << " to " << slice->GetCorrTime()+timediffspect << std::endl;
00318         // std::cout << "Should it be " << slice->GetCorrBegTime()-earlytimediff << " to " << slice->GetCorrBegTime()+timediffspect << "?" << std::endl;
00319         //        // std::cout << "New time window is from " << slice->GetCorrBegTime()-(earlytimediff/2.0) << " to " << slice->GetCorrBegTime()+tickera-(earlytimediff/2.0) << std::endl;
00320 
00321         while (CandStripHandle *strip1 = cshItr()) {
00322           if (strip1->GetPlane()>= specplane && strip1->GetCharge() > mincharge){
00323             // std::cout << "This hit is in spectrometer and has charge > 2pe" << std::endl;
00324             // std::cout << "Time: " << strip1->GetCorrBegTime() << ", charge: " << strip1->GetCharge() << std::endl;
00325             // std::cout << "Plane: " << strip1->GetPlane() << ", TPos: " << strip1->GetTPos() << std::endl;
00326             slice->AddDaughterLink(*strip1);
00327           }   
00328         }
00329       }
00330     }
00331   }
00332 
00333   /* we next pick up low pulse height strips. To do this, we iterate over CandSlices constructed in the previous stage, and determine which remaining CandStrips should be added. For each CandSlice, a time interval bounded by the CandSlice start time and the start time of the NEXT CandSlice is defined, and CandStrips with q<mincharge within this time range are added to the slice */
00334 
00335   MSG("AlgSliceSR",Msg::kDebug) << "Adding Small Hits" << endl;
00336   // std::cout << "Adding Small Hits" << std::endl;
00337   Double_t SliceTime[100] = {0.0};
00338   Int_t counter = 0;
00339   sliceItr2.Reset();
00340   while (CandSliceHandle *slice = sliceItr2()) {
00341     SliceTime[counter] = slice->GetCorrBegTime()*1e9;
00342     counter++;
00343   }
00344   SliceTime[counter] = 30000.0;
00345   counter = 0;
00346   sliceItr2.Reset();
00347   while (CandSliceHandle *slice = sliceItr2()) {
00348     MSG("AlgSliceSR",Msg::kDebug) << " ## slice ## " << counter << " time " << SliceTime[counter] << " next time " << SliceTime[counter+1] <<  endl;
00349     // std::cout << " ## slice ## " << counter << " time " << SliceTime[counter] << " next time " << SliceTime[counter+1] << std::endl;
00350     Float_t ticker = fabs(SliceTime[counter+1]/1e9-SliceTime[counter]/1e9);
00351     cshItr.GetSet()->Slice();
00352     cshItr.GetSet()->Slice(slice->GetCorrBegTime()-(earlytimediff/2.0), slice->GetCorrBegTime()+ticker-(earlytimediff/2.0));
00353 
00354         // std::cout << "Time window now is from " << slice->GetCorrBegTime()-(earlytimediff/2.0) << " to " << slice->GetCorrBegTime()+ticker-(earlytimediff/2.0) << std::endl;
00355 
00356     while (CandStripHandle *strip = cshItr()) {
00357       MSG("AlgSliceSR",Msg::kDebug) << " strip plane " << strip->GetPlane() << " strip " << strip->GetStrip() << " charge " << strip->GetCharge() << " time " << strip->GetCorrBegTime()*1e9 <<  endl;
00358       // std::cout << " strip plane " << strip->GetPlane() << " strip " << strip->GetStrip() << " charge " << strip->GetCharge() << " time " << strip->GetCorrBegTime()*1e9 << std::endl;
00359 //      if ((strip->GetPlane() >= specplane)&&(strip->GetCharge() <= mincharge)) {
00360       if (strip->GetCharge() <= mincharge) { //Leigh: Allow them in the calorimeter too
00361         slice->AddDaughterLink(*strip);
00362         MSG("AlgSliceSR",Msg::kDebug) << " adding " << endl;
00363         // std::cout << "adding" << std::endl;
00364       } 
00365     }
00366     counter++;
00367   }
00368   
00369   /* Here we get rid of slices with  < 2000 ADC counts (mostly junk anyway) */
00370 
00371   MSG("AlgSliceSR",Msg::kDebug) << "Killing Small Slices" << endl;
00372   // std::cout << "Killing Small Slices" << std::endl;
00373   sliceItr2.Reset();
00374   while( CandSliceHandle *slice = sliceItr2()) {
00375     if(slice->GetCharge(CalDigitType::kNone) < 2000) {
00376       ch.RemoveDaughter(slice);
00377     }
00378   }
00379 
00380   // delete all the heap memory
00381   DeleteNestedVector(finalSlices);
00382   DeleteNestedVector(uSlices);
00383   DeleteNestedVector(vSlices);
00384   DeleteVector(uTimeSlices);
00385   DeleteVector(vTimeSlices);
00386 
00387 }

void AlgSliceSRList::SlicetheSnarl_ASAP ( AlgConfig ac,
CandHandle ch,
CandContext cx 
) [virtual]

Really simple slicing which gives lower efficiency and higher purity than SR. As it is, it is difficult to tune it further to get better results. Sort Strips by BegTime and simply cut when difference between one strip and the previous one is greater than one bycket. Simple and quick way with results slighly lower in efficiency than SR and higher in purity. Overall they are comparable.

Definition at line 1178 of file AlgSliceSRList.cxx.

References CandHandle::AddDaughterLink(), AlgFactory::GetAlgHandle(), CandContext::GetDataIn(), CandHandle::GetDaughterIterator(), Registry::GetDouble(), AlgFactory::GetInstance(), Registry::GetInt(), CandContext::GetMom(), CandSlice::MakeCandidate(), nentries, Munits::ns, and StripSRKeyFromBegTime().

Referenced by RunAlg().

01179 {
01180 
01181   cout << " IN SLICE ASAP " <<endl;
01182   const CandStripListHandle *cslh =
01183         dynamic_cast<const CandStripListHandle*>(cx.GetDataIn());
01184 
01185 // Sort by Plane and Strip
01186   CandStripHandleItr cshItr(cslh->GetDaughterIterator());
01187   CandStripHandleKeyFunc *cshKf = cshItr.CreateKeyFunc();
01188   cshKf->SetFun(StripSRKeyFromBegTime);
01189   cshItr.GetSet()->AdoptSortKeyFunc(cshKf);
01190   cshKf = 0;
01191 
01192   AlgFactory &af = AlgFactory::GetInstance();
01193   AlgHandle ah = af.GetAlgHandle("AlgSliceSR","default");
01194   CandContext cxx(this,cx.GetMom());
01195 
01196   Double_t nbuck = ac.GetDouble("NBuck"); 
01197   Int_t minstrip = ac.GetInt("MinStrip");
01198   Double_t mincharge = ac.GetDouble("MinCharge");
01199 
01200   TObjArray striparraysl;
01201   striparraysl.Clear();
01202   
01203   Double_t prevtime = 0;
01204   Bool_t first=true;
01205   Double_t timediff=0;
01206   Double_t timeu;
01207   Int_t ncount=-1;
01208   Int_t nentries=-1;
01209   Double_t cuttime=nbuck*19.*Munits::ns;
01210  // NBuck is be number of buckets 
01211  while(CandStripHandle *currstrip = cshItr()){ 
01212     if(currstrip->GetCharge()>=mincharge) nentries=nentries+1;
01213   }
01214   
01215   cshItr.Reset();
01216    
01217  
01218    
01219     while(CandStripHandle *currstrip = cshItr()){   
01220       if(currstrip->GetCharge()>=mincharge){ 
01221         ncount=ncount+1;
01222         if(first) {
01223          first=false;
01224          prevtime=currstrip->GetBegTime();      
01225         }
01226         timeu=currstrip->GetBegTime();          
01227         timediff  = timeu-prevtime;     
01228           if(timediff<cuttime){ 
01229            striparraysl.Add(currstrip);    
01230           }
01231           if(timediff>=cuttime || nentries==ncount){
01232             if(striparraysl.GetLast()+1>=minstrip){
01233             cxx.SetDataIn(&striparraysl); 
01234             CandSliceHandle slicehandle = CandSlice::MakeCandidate(ah,cxx);
01235             ch.AddDaughterLink(slicehandle);  
01236             }
01237            striparraysl.Clear();
01238            striparraysl.Add(currstrip);
01239            }         
01240          prevtime  = timeu;
01241       }
01242     }
01243 
01244 }

void AlgSliceSRList::SlicetheSnarl_MST ( AlgConfig ac,
CandHandle ch,
CandContext cx 
) [virtual]

Slicing using MSTs with a metric definition (d_mst) that is tunable and at the moment takes into account time and z difference of strips. Gives results the same or slightly better than the SR in both purity and completeness and can be further tuned in various ways. Quite sophisticated algorithm using MSTs that performs slicing with results comparable or some times better than the SR. The MaxLen and Zfact are tunable parameters. I (Niki) will soon describe that in a write up the describes the whole method.

Definition at line 1254 of file AlgSliceSRList.cxx.

References CandHandle::AddDaughterLink(), AlgFactory::GetAlgHandle(), CandContext::GetDataIn(), CandHandle::GetDaughterIterator(), Registry::GetDouble(), AlgFactory::GetInstance(), Registry::GetInt(), CandContext::GetMom(), Munits::m, CandSlice::MakeCandidate(), n, and StripSRKeyFromCorrTime().

Referenced by RunAlg().

01255 {
01256   cout << " IN SLICE MST " << endl;
01257   const CandStripListHandle *cslh =
01258         dynamic_cast<const CandStripListHandle*>(cx.GetDataIn());
01259 // Sort by Plane and Strip
01260   CandStripHandleItr cshItr(cslh->GetDaughterIterator());
01261   CandStripHandleKeyFunc *cshKf = cshItr.CreateKeyFunc();
01262   cshKf->SetFun(StripSRKeyFromCorrTime);
01263   cshItr.GetSet()->AdoptSortKeyFunc(cshKf);
01264   cshKf = 0;
01265 
01266   AlgFactory &af = AlgFactory::GetInstance();
01267   AlgHandle ah = af.GetAlgHandle("AlgSliceSR","default");
01268   CandContext cxx(this,cx.GetMom());
01269  
01270   Int_t minstrip     = ac.GetInt("MinStrip");
01271   Double_t mincharge = ac.GetDouble("MinCharge");
01272   Double_t zfact     = ac.GetDouble("Zfact");
01273   Double_t maxlen    = ac.GetDouble("MaxLen");
01274 
01275   cout << " zfact " << zfact << " maxlen " << maxlen << endl;
01276   TObjArray striparrayn;
01277   striparrayn.Clear();
01278   Int_t n_strip=-1;
01279   while(CandStripHandle *currstrip = cshItr()){
01280     if(currstrip->GetCharge()>=mincharge){
01281       striparrayn.Add(currstrip);
01282       n_strip++;
01283     }
01284   }
01285   
01286   // Create lower triangular matrix of MST distances.
01287   
01288   Int_t n=-1;
01289   Double_t cc=3.*1.e8;     
01290   Int_t kMax_d=((n_strip+1)*n_strip)/2;
01291   Double_t *d_mst = new Double_t[kMax_d];
01292   for(Int_t i=0;i<=(n_strip-1);i++){ // 
01293     for(Int_t j=0;j<=n_strip;j++) {
01294       if((i+1)>j) {
01295         n++;
01296         Double_t zpos1=dynamic_cast<CandStripHandle*>(striparrayn.At(i+1))->GetZPos();
01297         Double_t zpos2=dynamic_cast<CandStripHandle*>(striparrayn.At(j))->GetZPos();
01298         Double_t t1=dynamic_cast<CandStripHandle*>(striparrayn.At(i+1))->GetCorrBegTime(); 
01299         Double_t t2=dynamic_cast<CandStripHandle*>(striparrayn.At(j))->GetCorrBegTime();
01300         d_mst[n]=sqrt((t1*cc-t2*cc)*(t1*cc-t2*cc))+((zpos1-zpos2)*(zpos1-zpos2)*zfact*zfact);   
01301       }
01302     }
01303   }
01304   //    
01305   // Create the MST
01306   Bool_t    *a_mst      = new Bool_t   [n_strip+1];
01307   Int_t     *b_mst      = new Int_t [n_strip+1];
01308   Double_t  *c_mst      = new Double_t [n_strip+1];
01309   Int_t     *hist_mst   = new Int_t [n_strip+1];
01310   Int_t     *route_mst  = new Int_t [n_strip+1];
01311   Int_t     *bb_mst     = new Int_t [n_strip+1];
01312   Int_t     *ii_mst     = new Int_t [n_strip+1];
01313   Double_t  *cc_mst     = new Double_t [n_strip+1];
01314   
01315   Double_t dlarge=99999999.;
01316   Double_t am,dist;
01317   Int_t next = 0;
01318   // Initialization
01319   for(Int_t i=1;i<=n_strip;i++){
01320     a_mst[i]=true;
01321     b_mst[i]=0;
01322     c_mst[i]=dlarge;
01323   } 
01324   // Make the tree
01325   Int_t j=0;
01326   Int_t l;
01327   for(Int_t i=1;i<=n_strip;i++){ 
01328     am=dlarge; 
01329     for(Int_t k=1;k<=n_strip;k++){
01330       if(a_mst[k]) {
01331         if(j>k) l=(j-0)*(j-1)/2+k;
01332         if(j<=k) l=(k-0)*(k-1)/2+j;
01333         dist=d_mst[l];
01334         if(dist<c_mst[k]) {
01335           c_mst[k]=dist;
01336           b_mst[k]=j;
01337         }
01338         if(am>c_mst[k]){ 
01339           am=c_mst[k];
01340           next=k;
01341         }
01342       }  
01343     }
01344     j=next;
01345     a_mst[j]=false;
01346   }
01347   
01348   delete [] d_mst;
01349   delete [] a_mst;
01350   
01351   // DO MST REORDERING
01352   
01353   for (Int_t i=0;i<=n_strip;i++){
01354     hist_mst[i]=0; 
01355   }
01356   for (Int_t i=1;i<=n_strip;i++){
01357     j=b_mst[i];
01358     hist_mst[j]=hist_mst[j]+1; 
01359   } 
01360   route_mst[0]=0;
01361   j=0;
01362   Int_t k=0;
01363   Int_t kkk=0;
01364   for(Int_t i=1;i<=n_strip;i++){
01365     while(hist_mst[k]==0){
01366       j=j-1;
01367       k=route_mst[j]; 
01368     }
01369     hist_mst[k]=hist_mst[k]-1;   
01370     
01371     Int_t m=1;
01372     Bool_t foundk=false;
01373     while(m<=n_strip && !foundk){
01374       if(k==b_mst[m]) {
01375         foundk=true;
01376       }
01377       else m=m+1; 
01378     }
01379     kkk=kkk+1;
01380     bb_mst[kkk]=k;
01381     ii_mst[kkk]=m;
01382     cc_mst[kkk]=c_mst[m];
01383     
01384     j=j+1;
01385     route_mst[j]=m;
01386     k=m;
01387     b_mst[m]=-b_mst[m];
01388     if(b_mst[m]==0) b_mst[m]=9999999;
01389   }
01390   delete [] b_mst;
01391   delete [] c_mst;
01392   delete [] hist_mst;
01393   delete [] route_mst;
01394   
01395   // NOW CUT BRANCHES AND MAKE THE CLUSTERS
01396   
01397   TObjArray striparraysl;
01398   striparraysl.Clear();
01399   
01400   for(Int_t i=1;i<=n_strip;i++){
01401     if(cc_mst[i]<maxlen) {
01402       if(i==1) {
01403         striparraysl.Add(dynamic_cast<CandStripHandle*>(striparrayn.At(ii_mst[i]))); 
01404         striparraysl.Add(dynamic_cast<CandStripHandle*>(striparrayn.At(bb_mst[i]))); 
01405       }
01406       else  striparraysl.Add(dynamic_cast<CandStripHandle*>(striparrayn.At(ii_mst[i])));  
01407     }
01408     else if(cc_mst[i]>=maxlen || i==n_strip) {
01409       if(i==1) {
01410         striparraysl.Add(dynamic_cast<CandStripHandle*>(striparrayn.At(ii_mst[i])));
01411       }
01412       else {
01413         // new slice
01414         if(striparraysl.GetLast()+1>=minstrip){    
01415           cxx.SetDataIn(&striparraysl);
01416           CandSliceHandle slicehandle = CandSlice::MakeCandidate(ah,cxx);
01417           ch.AddDaughterLink(slicehandle);  
01418         }
01419         striparraysl.Clear();  
01420         striparraysl.Add(dynamic_cast<CandStripHandle*>(striparrayn.At(ii_mst[i]))); 
01421       } 
01422     }
01423   }
01424   
01425   delete [] bb_mst;
01426   delete [] cc_mst;
01427   delete [] ii_mst;
01428 }

std::vector< TObjArray * > AlgSliceSRList::SubSlice ( const std::vector< TObjArray * > &  timeSlices  )  [private]

Definition at line 927 of file AlgSliceSRList.cxx.

References DivideTimeSlice(), and it.

00928 {
00929   std::vector<TObjArray*> subSlices;
00930   for (std::vector<TObjArray*>::const_iterator it = timeSlices.begin();
00931        it != timeSlices.end(); ++it) {
00932     // std::cout<<"Subdividing timeslice with "<<(*it)->GetEntries()<<" entries..."<<std::endl;
00933     std::vector<TObjArray*> newSlices = DivideTimeSlice(*it);
00934     // std::cout<<"Subdivided into "<<newSlices.size()<<" slices"<<std::endl;
00935     subSlices.insert( subSlices.end(), newSlices.begin(), newSlices.end() );
00936   }
00937   return subSlices;
00938 }

void AlgSliceSRList::timeSort ( TObjArray *  slc1  )  [private]

Definition at line 750 of file AlgSliceSRList.cxx.

References earlierThan(), and n.

Referenced by associateViews(), DivideTimeSlice(), and merge().

00751 {
00752   //just use STL sort -- need to copy the strips into a vector
00753   Int_t nStrips = slc1->GetEntries();
00754   //std::cerr<<nStrips<<std::endl;
00755   std::vector<CandStripHandle*> vStrips;
00756   for (int n = 0; n<nStrips; n++){
00757     CandStripHandle* s = dynamic_cast<CandStripHandle*>(slc1->At(n));
00758     //std::cerr<<s->GetCorrBegTime()<<std::endl;;
00759     vStrips.push_back(s);
00760   }
00761   //std::cerr<<"loaded strips into vector. sorting vector"<<std::endl;
00762 
00763   std::stable_sort(vStrips.begin(), vStrips.end(), earlierThan);
00764 
00765   //std::cerr<<"sorted vector. sticking strips back into tobjarray"<<std::endl;
00766 
00767   slc1->Clear();
00768   for (int n = 0; n<nStrips; n++){
00769     slc1->Add(vStrips.at(n));
00770   }
00771   //std::cerr<<slc1->GetEntries()<<std::endl;
00772 }

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

Reimplemented from AlgBase.

Definition at line 1099 of file AlgSliceSRList.cxx.

01100 {
01101 }


Member Data Documentation

Definition at line 42 of file AlgSliceSRList.h.

Referenced by AreNeighbours(), and SlicetheSnarl().

Double_t AlgSliceSRList::maxtimegap [private]

Definition at line 41 of file AlgSliceSRList.h.

Referenced by AreNeighbours(), and SlicetheSnarl().

Double_t AlgSliceSRList::maxtposgap [private]

Definition at line 40 of file AlgSliceSRList.h.

Referenced by AreNeighbours(), and SlicetheSnarl().

Double_t AlgSliceSRList::maxzgap [private]

Definition at line 39 of file AlgSliceSRList.h.

Referenced by AreNeighbours(), and SlicetheSnarl().

Double_t AlgSliceSRList::mincalplane [private]

Definition at line 45 of file AlgSliceSRList.h.

Referenced by SlicetheSnarl().

Double_t AlgSliceSRList::minoverlap [private]

Definition at line 43 of file AlgSliceSRList.h.

Referenced by associateViews(), matchSubSlices(), and SlicetheSnarl().

Definition at line 44 of file AlgSliceSRList.h.

Referenced by associateViews(), and SlicetheSnarl().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1