Changeset 95b4e9f in git for modules/VertexFinder.cc
- Timestamp:
- Aug 31, 2016, 4:25:59 PM (8 years ago)
- Branches:
- ImprovedOutputFile, Timing, dual_readout, llp, master
- Children:
- 4154bbd
- Parents:
- b195ba1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/VertexFinder.cc
rb195ba1 r95b4e9f 28 28 #include "TVector3.h" 29 29 30 #include <utility> 31 #include <algorithm> 32 #include <stdexcept> 33 #include <iostream> 34 #include <vector> 35 #include <map> 36 #include <string> 37 38 using namespace std; 39 30 40 static const Double_t mm = 1.; 31 41 static const Double_t m = 1000.*mm; … … 73 83 74 84 //------------------------------------------------------------------------------ 75 // 76 Bool_t VertexFinder::secondAscending (pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)85 86 static Bool_t secondAscending (pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1) 77 87 { 78 88 return (pair0.second < pair1.second); 79 89 } 80 90 81 Bool_t VertexFinder::secondDescending (pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)91 static Bool_t secondDescending (pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1) 82 92 { 83 93 return (pair0.second > pair1.second); 84 94 } 85 95 96 //------------------------------------------------------------------------------ 97 86 98 void VertexFinder::Process() 87 99 { 88 100 Candidate *candidate; 89 101 90 //////////////////////////////////////////////////////////////////////////////// 91 // Clear the track and cluster maps before starting 92 //////////////////////////////////////////////////////////////////////////////// 102 // Clear the track and cluster maps before starting 93 103 trackIDToDouble.clear (); 94 104 trackIDToInt.clear (); … … 99 109 trackPT.clear (); 100 110 clusterSumPT2.clear (); 101 //////////////////////////////////////////////////////////////////////////////// 102 103 //////////////////////////////////////////////////////////////////////////////// 104 // Create the initial cluster seeds 105 //////////////////////////////////////////////////////////////////////////////// 111 112 // Create the initial cluster seeds 106 113 createSeeds (); 107 //////////////////////////////////////////////////////////////////////////////// 108 109 //////////////////////////////////////////////////////////////////////////////// 110 // In order of descending seed pt, grow each cluster. If a cluster ends up with 111 // fewer than MinNDF tracks, release the tracks for other clusters to claim. 112 //////////////////////////////////////////////////////////////////////////////// 114 115 // In order of descending seed pt, grow each cluster. If a cluster ends up with 116 // fewer than MinNDF tracks, release the tracks for other clusters to claim. 113 117 sort (clusterSumPT2.begin (), clusterSumPT2.end (), secondDescending); 114 118 for (vector<pair<UInt_t, Double_t> >::const_iterator cluster = clusterSumPT2.begin (); cluster != clusterSumPT2.end (); cluster++) … … 138 142 trackIDToBool[clusterIDToInt.at (cluster->first).at ("seed")]["claimed"] = true; 139 143 } 140 //////////////////////////////////////////////////////////////////////////////// 141 142 //////////////////////////////////////////////////////////////////////////////// 143 // Add tracks to the output array after updating their ClusterIndex. 144 //////////////////////////////////////////////////////////////////////////////// 144 145 // Add tracks to the output array after updating their ClusterIndex. 145 146 fItInputArray->Reset (); 146 147 while((candidate = static_cast<Candidate*>(fItInputArray->Next()))) … … 151 152 fOutputArray->Add(candidate); 152 153 } 153 //////////////////////////////////////////////////////////////////////////////// 154 155 //////////////////////////////////////////////////////////////////////////////// 156 // Add clusters with at least MinNDF tracks to the output array in order of 157 // descending sum(pt**2). 158 //////////////////////////////////////////////////////////////////////////////// 154 155 // Add clusters with at least MinNDF tracks to the output array in order of 156 // descending sum(pt**2). 159 157 clusterSumPT2.clear (); 160 158 for (map<UInt_t, map<string, Int_t> >::const_iterator cluster = clusterIDToInt.begin (); cluster != clusterIDToInt.end (); cluster++) … … 181 179 fVertexOutputArray->Add(candidate); 182 180 } 183 //////////////////////////////////////////////////////////////////////////////// 184 } 185 186 void 187 VertexFinder::createSeeds ()181 } 182 183 //------------------------------------------------------------------------------ 184 185 void VertexFinder::createSeeds () 188 186 { 189 187 Candidate *candidate; 190 188 UInt_t clusterIndex = 0, maxSeeds = 0; 191 189 192 //////////////////////////////////////////////////////////////////////////////// 193 // Loop over all tracks, initializing some variables. 194 //////////////////////////////////////////////////////////////////////////////// 190 // Loop over all tracks, initializing some variables. 195 191 fItInputArray->Reset(); 196 192 while((candidate = static_cast<Candidate*>(fItInputArray->Next()))) … … 213 209 trackPT.push_back (make_pair (candidate->GetUniqueID (), candidate->Momentum.Pt ())); 214 210 } 215 //////////////////////////////////////////////////////////////////////////////// 216 217 //////////////////////////////////////////////////////////////////////////////// 218 // Sort tracks by pt and leave only the SeedMinPT highest pt ones in the 219 // trackPT vector. 220 //////////////////////////////////////////////////////////////////////////////// 211 212 // Sort tracks by pt and leave only the SeedMinPT highest pt ones in the 213 // trackPT vector. 221 214 sort (trackPT.begin (), trackPT.end (), secondDescending); 222 215 for (vector<pair<UInt_t, Double_t> >::const_iterator track = trackPT.begin (); track != trackPT.end (); track++, maxSeeds++) … … 233 226 trackPT.erase (trackPT.begin () + maxSeeds, trackPT.end ()); 234 227 } 235 //////////////////////////////////////////////////////////////////////////////// 236 237 //////////////////////////////////////////////////////////////////////////////// 238 // Create the seeds from the SeedMinPT highest pt tracks. 239 //////////////////////////////////////////////////////////////////////////////// 228 229 // Create the seeds from the SeedMinPT highest pt tracks. 240 230 for (vector<pair<UInt_t, Double_t> >::const_iterator track = trackPT.begin (); track != trackPT.end (); track++, clusterIndex++) 241 231 { … … 243 233 clusterSumPT2.push_back (make_pair (clusterIndex, track->second * track->second)); 244 234 } 245 //////////////////////////////////////////////////////////////////////////////// 246 } 247 248 void 249 VertexFinder::growCluster (const UInt_t clusterIndex)235 } 236 237 //------------------------------------------------------------------------------ 238 239 void VertexFinder::growCluster (const UInt_t clusterIndex) 250 240 { 251 241 Bool_t done = false; … … 256 246 nearTracks.clear (); 257 247 258 //////////////////////////////////////////////////////////////////////////////// 259 // Grow the cluster until there are no more tracks within Sigma standard 260 // deviations of the cluster. 261 //////////////////////////////////////////////////////////////////////////////// 248 // Grow the cluster until there are no more tracks within Sigma standard 249 // deviations of the cluster. 262 250 while (!done) 263 251 { … … 323 311 } 324 312 } 325 //////////////////////////////////////////////////////////////////////////////// 326 } 327 328 Double_t 329 VertexFinder::weight (const UInt_t trackID)313 } 314 315 //------------------------------------------------------------------------------ 316 317 Double_t VertexFinder::weight (const UInt_t trackID) 330 318 { 331 319 return ((trackIDToDouble.at (trackID).at ("pt") / (trackIDToDouble.at (trackID).at ("ept") * trackIDToDouble.at (trackID).at ("ez"))) * (trackIDToDouble.at (trackID).at ("pt") / (trackIDToDouble.at (trackID).at ("ept") * trackIDToDouble.at (trackID).at ("ez")))); 332 320 } 333 321 334 void 335 VertexFinder::removeTrackFromCluster (const UInt_t trackID, const UInt_t clusterID) 322 //------------------------------------------------------------------------------ 323 324 void VertexFinder::removeTrackFromCluster (const UInt_t trackID, const UInt_t clusterID) 336 325 { 337 326 Double_t wz = weight (trackID); … … 348 337 } 349 338 350 void 351 VertexFinder::addTrackToCluster (const UInt_t trackID, const UInt_t clusterID) 339 //------------------------------------------------------------------------------ 340 341 void VertexFinder::addTrackToCluster (const UInt_t trackID, const UInt_t clusterID) 352 342 { 353 343 Double_t wz = weight (trackID);
Note:
See TracChangeset
for help on using the changeset viewer.