- Timestamp:
- Aug 31, 2016, 4:25:59 PM (8 years ago)
- Branches:
- ImprovedOutputFile, Timing, dual_readout, llp, master
- Children:
- 4154bbd
- Parents:
- b195ba1
- Location:
- modules
- Files:
-
- 6 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); -
modules/VertexFinder.h
rb195ba1 r95b4e9f 12 12 13 13 #include "classes/DelphesModule.h" 14 #include "classes/DelphesClasses.h" 15 #include <utility> 16 #include <algorithm> 17 #include <stdexcept> 18 #include <iostream> 14 15 #include <string> 19 16 #include <vector> 20 #include <unordered_map> 21 22 using namespace std; 17 #include <map> 23 18 24 19 class TObjArray; 25 class Candidate; 26 class TVector3; 20 class TIterator; 27 21 28 22 class VertexFinder: public DelphesModule … … 36 30 void Process(); 37 31 void Finish(); 38 39 static Bool_t secondDescending (pair<UInt_t, Double_t>, pair<UInt_t, Double_t>);40 static Bool_t secondAscending (pair<UInt_t, Double_t>, pair<UInt_t, Double_t>);41 32 42 33 private: … … 61 52 TObjArray *fVertexOutputArray; 62 53 63 map<UInt_t, map<string, Double_t> > trackIDToDouble;64 map<UInt_t, map<string, Int_t> > trackIDToInt;65 map<UInt_t, map<string, Bool_t> > trackIDToBool;54 std::map<UInt_t, std::map<std::string, Double_t> > trackIDToDouble; 55 std::map<UInt_t, std::map<std::string, Int_t> > trackIDToInt; 56 std::map<UInt_t, std::map<std::string, Bool_t> > trackIDToBool; 66 57 67 map<UInt_t, map<string, Double_t> > clusterIDToDouble;68 map<UInt_t, map<string, Int_t> > clusterIDToInt;69 map<UInt_t, map<string, Bool_t> > clusterIDToBool;70 vector<pair<UInt_t, Double_t> > trackPT;71 vector<pair<UInt_t, Double_t> > clusterSumPT2;58 std::map<UInt_t, std::map<std::string, Double_t> > clusterIDToDouble; 59 std::map<UInt_t, std::map<std::string, Int_t> > clusterIDToInt; 60 std::map<UInt_t, std::map<std::string, Bool_t> > clusterIDToBool; 61 std::vector<std::pair<UInt_t, Double_t> > trackPT; 62 std::vector<std::pair<UInt_t, Double_t> > clusterSumPT2; 72 63 73 64 ClassDef(VertexFinder, 1) -
modules/VertexFinderDA4D.cc
rb195ba1 r95b4e9f 27 27 #include "TMatrixT.h" 28 28 #include "TVector3.h" 29 30 #include <utility> 31 #include <algorithm> 32 #include <stdexcept> 33 #include <iostream> 34 #include <vector> 35 36 using namespace std; 29 37 30 38 static const Double_t mm = 1.; -
modules/VertexFinderDA4D.h
rb195ba1 r95b4e9f 11 11 12 12 13 #include "classes/DelphesModule.h" 13 14 14 #include "classes/DelphesModule.h"15 #include "classes/DelphesClasses.h"16 #include <utility>17 #include <algorithm>18 #include <stdexcept>19 #include <iostream>20 15 #include <vector> 21 #include <unordered_map>22 23 using namespace std;24 16 25 17 class TObjArray; 18 class TIterator; 26 19 class Candidate; 27 class TVector3;28 20 29 21 class VertexFinderDA4D: public DelphesModule … … 38 30 void Finish(); 39 31 40 struct track_t{ 41 double z; // z-coordinate at point of closest approach to the beamline 42 double t; // t-coordinate at point of closest approach to the beamline 43 double dz2; // square of the error of z(pca) 44 double dtz; // covariance of z-t 45 double dt2; // square of the error of t(pca) 46 //const reco::TransientTrack* tt; // a pointer to the Transient Track 47 Candidate* tt; // a pointer to the Candidate Track 48 double Z; // Z[i] for DA clustering 49 double pi; // track weight 50 double pt; 51 double eta; 52 double phi; 53 54 }; 32 struct track_t 33 { 34 double z; // z-coordinate at point of closest approach to the beamline 35 double t; // t-coordinate at point of closest approach to the beamline 36 double dz2; // square of the error of z(pca) 37 double dtz; // covariance of z-t 38 double dt2; // square of the error of t(pca) 39 Candidate* tt; // a pointer to the Candidate Track 40 double Z; // Z[i] for DA clustering 41 double pi; // track weight 42 double pt; 43 double eta; 44 double phi; 45 }; 55 46 56 47 57 struct vertex_t{ 58 double z; // z coordinate 59 double t; // t coordinate 60 double pk; // vertex weight for "constrained" clustering 61 // --- temporary numbers, used during update 62 double ei; 63 double sw; 64 double swz; 65 double swt; 66 double se; 67 // ---for Tc 68 double swE; 69 double Tc; 70 }; 71 72 48 struct vertex_t 49 { 50 double z; 51 double t; 52 double pk; // vertex weight for "constrained" clustering 53 // --- temporary numbers, used during update 54 double ei; 55 double sw; 56 double swz; 57 double swt; 58 double se; 59 // ---for Tc 60 double swE; 61 double Tc; 62 }; 73 63 74 64 void clusterize(const TObjArray & tracks, TObjArray & clusters); … … 78 68 std::vector<track_t> fill() const; 79 69 80 bool split( 70 bool split(double beta, 81 71 std::vector<track_t> & tks, 82 72 std::vector<vertex_t> & y) const; 83 73 84 double update( 74 double update(double beta, 85 75 std::vector<track_t> & tks, 86 std::vector<vertex_t> & y 76 std::vector<vertex_t> & y) const; 87 77 88 78 double update(double beta, 89 std::vector<track_t> & tks,90 std::vector<vertex_t> & y,91 double &)const;79 std::vector<track_t> & tks, 80 std::vector<vertex_t> & y, 81 double &)const; 92 82 93 83 void dump(const double beta, const std::vector<vertex_t> & y, const std::vector<track_t> & tks) const; 94 84 bool merge(std::vector<vertex_t> &) const; 95 bool merge(std::vector<vertex_t> &, double &) const;96 bool purge(std::vector<vertex_t> &, std::vector<track_t> & , double &, const double 85 bool merge(std::vector<vertex_t> &, double &) const; 86 bool purge(std::vector<vertex_t> &, std::vector<track_t> & , double &, const double) const; 97 87 98 void splitAll( std::vector<vertex_t> & y) const;88 void splitAll(std::vector<vertex_t> &y) const; 99 89 100 90 double beta0(const double betamax, 101 std::vector<track_t> & 102 std::vector<vertex_t> & y)const;91 std::vector<track_t> &tks, 92 std::vector<vertex_t> &y)const; 103 93 104 double Eik(const track_t & t, const vertex_t & k)const; 105 94 double Eik(const track_t &t, const vertex_t &k)const; 106 95 107 96 private: -
modules/VertexSorter.cc
rb195ba1 r95b4e9f 29 29 #include "TMatrixT.h" 30 30 #include "TVector3.h" 31 32 #include <utility> 33 #include <algorithm> 34 #include <stdexcept> 35 #include <iostream> 36 #include <vector> 37 #include <map> 38 #include <string> 39 40 using namespace std; 31 41 32 42 static const Double_t mm = 1.; … … 76 86 fOutputArray = ExportArray(GetString("OutputArray", "clusters")); 77 87 78 fMethod = GetString 88 fMethod = GetString("Method", "BTV"); 79 89 } 80 90 … … 88 98 89 99 //------------------------------------------------------------------------------ 90 // 91 Bool_t VertexSorter::secondDescending (pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)100 101 static Bool_t secondDescending (pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1) 92 102 { 93 103 return (pair0.second > pair1.second); 94 104 } 95 Bool_t VertexSorter::secondAscending (pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1) 105 106 static Bool_t secondAscending (pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1) 96 107 { 97 108 return (pair0.second < pair1.second); 98 109 } 99 110 111 //------------------------------------------------------------------------------ 112 100 113 void VertexSorter::Process() 101 114 { 102 115 Candidate *candidate, *jetCandidate, *beamSpotCandidate; 103 unordered_map<Int_t, UInt_t> clusterIDToIndex;104 unordered_map<Int_t, Double_t> clusterIDToSumPT2;116 map<Int_t, UInt_t> clusterIDToIndex; 117 map<Int_t, Double_t> clusterIDToSumPT2; 105 118 vector<pair<Int_t, Double_t> > sortedClusterIDs; 106 119 … … 112 125 } 113 126 114 if 127 if(fMethod == "BTV") 115 128 { 116 129 if (!fJetInputArray) -
modules/VertexSorter.h
rb195ba1 r95b4e9f 13 13 14 14 #include "classes/DelphesModule.h" 15 #include "classes/DelphesClasses.h" 16 #include <utility> 17 #include <algorithm> 18 #include <stdexcept> 19 #include <iostream> 20 #include <vector> 15 21 16 #include <string> 22 #include <unordered_map>23 24 25 using namespace std;26 17 27 18 class TObjArray; 19 class TIterator; 28 20 class Candidate; 29 class TVector3;30 21 31 22 class VertexSorter: public DelphesModule … … 39 30 void Process(); 40 31 void Finish(); 41 42 static Bool_t secondDescending (pair<UInt_t, Double_t>, pair<UInt_t, Double_t>);43 static Bool_t secondAscending (pair<UInt_t, Double_t>, pair<UInt_t, Double_t>);44 32 45 33 private: … … 58 46 TObjArray *fOutputArray; 59 47 60 st ring fMethod;48 std::string fMethod; 61 49 62 50 ClassDef(VertexSorter, 1)
Note:
See TracChangeset
for help on using the changeset viewer.