Fork me on GitHub

Changeset 95b4e9f in git for modules


Ignore:
Timestamp:
Aug 31, 2016, 4:25:59 PM (8 years ago)
Author:
Pavel Demin <pavel.demin@…>
Branches:
ImprovedOutputFile, Timing, dual_readout, llp, master
Children:
4154bbd
Parents:
b195ba1
Message:

reorganize includes in vertexing modules

Location:
modules
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • modules/VertexFinder.cc

    rb195ba1 r95b4e9f  
    2828#include "TVector3.h"
    2929
     30#include <utility>
     31#include <algorithm>
     32#include <stdexcept>
     33#include <iostream>
     34#include <vector>
     35#include <map>
     36#include <string>
     37
     38using namespace std;
     39
    3040static const Double_t mm  = 1.;
    3141static const Double_t m = 1000.*mm;
     
    7383
    7484//------------------------------------------------------------------------------
    75 //
    76 Bool_t VertexFinder::secondAscending (pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)
     85
     86static Bool_t secondAscending (pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)
    7787{
    7888  return (pair0.second < pair1.second);
    7989}
    8090
    81 Bool_t VertexFinder::secondDescending (pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)
     91static Bool_t secondDescending (pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)
    8292{
    8393  return (pair0.second > pair1.second);
    8494}
    8595
     96//------------------------------------------------------------------------------
     97
    8698void VertexFinder::Process()
    8799{
    88100  Candidate *candidate;
    89101
    90 ////////////////////////////////////////////////////////////////////////////////
    91 // Clear the track and cluster maps before starting
    92 ////////////////////////////////////////////////////////////////////////////////
     102  // Clear the track and cluster maps before starting
    93103  trackIDToDouble.clear ();
    94104  trackIDToInt.clear ();
     
    99109  trackPT.clear ();
    100110  clusterSumPT2.clear ();
    101 ////////////////////////////////////////////////////////////////////////////////
    102 
    103 ////////////////////////////////////////////////////////////////////////////////
    104 // Create the initial cluster seeds
    105 ////////////////////////////////////////////////////////////////////////////////
     111
     112  // Create the initial cluster seeds
    106113  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.
    113117  sort (clusterSumPT2.begin (), clusterSumPT2.end (), secondDescending);
    114118  for (vector<pair<UInt_t, Double_t> >::const_iterator cluster = clusterSumPT2.begin (); cluster != clusterSumPT2.end (); cluster++)
     
    138142        trackIDToBool[clusterIDToInt.at (cluster->first).at ("seed")]["claimed"] = true;
    139143    }
    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.
    145146  fItInputArray->Reset ();
    146147  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     
    151152      fOutputArray->Add(candidate);
    152153    }
    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).
    159157  clusterSumPT2.clear ();
    160158  for (map<UInt_t, map<string, Int_t> >::const_iterator cluster = clusterIDToInt.begin (); cluster != clusterIDToInt.end (); cluster++)
     
    181179    fVertexOutputArray->Add(candidate);
    182180  }
    183 ////////////////////////////////////////////////////////////////////////////////
    184 }
    185 
    186 void
    187 VertexFinder::createSeeds ()
     181}
     182
     183//------------------------------------------------------------------------------
     184
     185void VertexFinder::createSeeds ()
    188186{
    189187  Candidate *candidate;
    190188  UInt_t clusterIndex = 0, maxSeeds = 0;
    191189
    192 ////////////////////////////////////////////////////////////////////////////////
    193 // Loop over all tracks, initializing some variables.
    194 ////////////////////////////////////////////////////////////////////////////////
     190  // Loop over all tracks, initializing some variables.
    195191  fItInputArray->Reset();
    196192  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     
    213209      trackPT.push_back (make_pair (candidate->GetUniqueID (), candidate->Momentum.Pt ()));
    214210    }
    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.
    221214  sort (trackPT.begin (), trackPT.end (), secondDescending);
    222215  for (vector<pair<UInt_t, Double_t> >::const_iterator track = trackPT.begin (); track != trackPT.end (); track++, maxSeeds++)
     
    233226      trackPT.erase (trackPT.begin () + maxSeeds, trackPT.end ());
    234227    }
    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.
    240230  for (vector<pair<UInt_t, Double_t> >::const_iterator track = trackPT.begin (); track != trackPT.end (); track++, clusterIndex++)
    241231    {
     
    243233      clusterSumPT2.push_back (make_pair (clusterIndex, track->second * track->second));
    244234    }
    245 ////////////////////////////////////////////////////////////////////////////////
    246 }
    247 
    248 void
    249 VertexFinder::growCluster (const UInt_t clusterIndex)
     235}
     236
     237//------------------------------------------------------------------------------
     238
     239void VertexFinder::growCluster (const UInt_t clusterIndex)
    250240{
    251241  Bool_t done = false;
     
    256246  nearTracks.clear ();
    257247
    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.
    262250  while (!done)
    263251    {
     
    323311        }
    324312    }
    325 ////////////////////////////////////////////////////////////////////////////////
    326 }
    327 
    328 Double_t
    329 VertexFinder::weight (const UInt_t trackID)
     313}
     314
     315//------------------------------------------------------------------------------
     316
     317Double_t VertexFinder::weight (const UInt_t trackID)
    330318{
    331319  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"))));
    332320}
    333321
    334 void
    335 VertexFinder::removeTrackFromCluster (const UInt_t trackID, const UInt_t clusterID)
     322//------------------------------------------------------------------------------
     323
     324void VertexFinder::removeTrackFromCluster (const UInt_t trackID, const UInt_t clusterID)
    336325{
    337326  Double_t wz = weight (trackID);
     
    348337}
    349338
    350 void
    351 VertexFinder::addTrackToCluster (const UInt_t trackID, const UInt_t clusterID)
     339//------------------------------------------------------------------------------
     340
     341void VertexFinder::addTrackToCluster (const UInt_t trackID, const UInt_t clusterID)
    352342{
    353343  Double_t wz = weight (trackID);
  • modules/VertexFinder.h

    rb195ba1 r95b4e9f  
    1212
    1313#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>
    1916#include <vector>
    20 #include <unordered_map>
    21 
    22 using namespace std;
     17#include <map>
    2318
    2419class TObjArray;
    25 class Candidate;
    26 class TVector3;
     20class TIterator;
    2721
    2822class VertexFinder: public DelphesModule
     
    3630  void Process();
    3731  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>);
    4132
    4233private:
     
    6152  TObjArray *fVertexOutputArray;
    6253
    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;
    6657
    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;
    7263
    7364  ClassDef(VertexFinder, 1)
  • modules/VertexFinderDA4D.cc

    rb195ba1 r95b4e9f  
    2727#include "TMatrixT.h"
    2828#include "TVector3.h"
     29
     30#include <utility>
     31#include <algorithm>
     32#include <stdexcept>
     33#include <iostream>
     34#include <vector>
     35
     36using namespace std;
    2937
    3038static const Double_t mm  = 1.;
  • modules/VertexFinderDA4D.h

    rb195ba1 r95b4e9f  
    1111
    1212
     13#include "classes/DelphesModule.h"
    1314
    14 #include "classes/DelphesModule.h"
    15 #include "classes/DelphesClasses.h"
    16 #include <utility>
    17 #include <algorithm>
    18 #include <stdexcept>
    19 #include <iostream>
    2015#include <vector>
    21 #include <unordered_map>
    22 
    23 using namespace std;
    2416
    2517class TObjArray;
     18class TIterator;
    2619class Candidate;
    27 class TVector3;
    2820
    2921class VertexFinderDA4D: public DelphesModule
     
    3830  void Finish();
    3931
    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  };
    5546
    5647
    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  };
    7363
    7464  void clusterize(const TObjArray & tracks, TObjArray & clusters);
     
    7868  std::vector<track_t> fill() const;
    7969
    80   bool split( double beta,
     70  bool split(double beta,
    8171             std::vector<track_t> & tks,
    8272             std::vector<vertex_t> & y) const;
    8373
    84   double update( double beta,
     74  double update(double beta,
    8575                std::vector<track_t> & tks,
    86                 std::vector<vertex_t> & y ) const;
     76                std::vector<vertex_t> & y) const;
    8777
    8878  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;
    9282
    9383  void dump(const double beta, const std::vector<vertex_t> & y, const std::vector<track_t> & tks) const;
    9484  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 ) const;
     85  bool merge(std::vector<vertex_t> &, double &) const;
     86  bool purge(std::vector<vertex_t> &, std::vector<track_t> & , double &, const double) const;
    9787
    98   void splitAll( std::vector<vertex_t> & y ) const;
     88  void splitAll(std::vector<vertex_t> &y) const;
    9989
    10090  double beta0(const double betamax,
    101                std::vector<track_t> & tks,
    102                std::vector<vertex_t> & y )const;
     91               std::vector<track_t> &tks,
     92               std::vector<vertex_t> &y)const;
    10393
    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;
    10695
    10796private:
  • modules/VertexSorter.cc

    rb195ba1 r95b4e9f  
    2929#include "TMatrixT.h"
    3030#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
     40using namespace std;
    3141
    3242static const Double_t mm  = 1.;
     
    7686  fOutputArray = ExportArray(GetString("OutputArray", "clusters"));
    7787
    78   fMethod = GetString ("Method", "BTV");
     88  fMethod = GetString("Method", "BTV");
    7989}
    8090
     
    8898
    8999//------------------------------------------------------------------------------
    90 //
    91 Bool_t VertexSorter::secondDescending (pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)
     100
     101static Bool_t secondDescending (pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)
    92102{
    93103  return (pair0.second > pair1.second);
    94104}
    95 Bool_t VertexSorter::secondAscending (pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)
     105
     106static Bool_t secondAscending (pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)
    96107{
    97108  return (pair0.second < pair1.second);
    98109}
    99110
     111//------------------------------------------------------------------------------
     112
    100113void VertexSorter::Process()
    101114{
    102115  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;
    105118  vector<pair<Int_t, Double_t> > sortedClusterIDs;
    106119
     
    112125    }
    113126
    114   if (fMethod == "BTV")
     127  if(fMethod == "BTV")
    115128    {
    116129      if (!fJetInputArray)
  • modules/VertexSorter.h

    rb195ba1 r95b4e9f  
    1313
    1414#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
    2116#include <string>
    22 #include <unordered_map>
    23 
    24 
    25 using namespace std;
    2617
    2718class TObjArray;
     19class TIterator;
    2820class Candidate;
    29 class TVector3;
    3021
    3122class VertexSorter: public DelphesModule
     
    3930  void Process();
    4031  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>);
    4432
    4533private:
     
    5846  TObjArray *fOutputArray;
    5947
    60   string fMethod;
     48  std::string fMethod;
    6149
    6250  ClassDef(VertexSorter, 1)
Note: See TracChangeset for help on using the changeset viewer.