Skip to content

Commit

Permalink
Merge pull request cms-sw#159 from makortel/cmsswIntegration
Browse files Browse the repository at this point in the history
Developments needed for interfacing with CMSSW
  • Loading branch information
kmcdermo authored Aug 7, 2018
2 parents 35fd183 + c63598d commit f013f1a
Show file tree
Hide file tree
Showing 103 changed files with 677 additions and 166 deletions.
4 changes: 4 additions & 0 deletions BinInfoUtils.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "BinInfoUtils.h"

namespace mkfit {

std::vector<int> getCandHitIndices(const int & etaBinMinus, const int & etaBinPlus, const int & phiBinMinus, const int & phiBinPlus, const BinInfoLayerMap& segLayMap){
std::vector<int> cand_hit_indices;
for (int ieta = etaBinMinus; ieta <= etaBinPlus; ++ieta){
Expand Down Expand Up @@ -30,3 +32,5 @@ std::vector<int> getCandHitIndices(const int & etaBinMinus, const int & etaBinPl
}
return cand_hit_indices;
}

} // end namespace mkfit
3 changes: 3 additions & 0 deletions BinInfoUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "Config.h"
#include <iostream>

namespace mkfit {

typedef std::pair<int, int> BinInfo;
typedef std::vector<std::vector<BinInfo>> BinInfoLayerMap;
typedef std::vector<BinInfoLayerMap> BinInfoMap;
Expand Down Expand Up @@ -68,4 +70,5 @@ inline int getEtaPartition(float eta)

std::vector<int> getCandHitIndices(const int &, const int &, const int &, const int &, const BinInfoLayerMap &);

} // end namespace mkfit
#endif
6 changes: 6 additions & 0 deletions Config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "TrackerInfo.h"

namespace mkfit {

namespace Config
{
TrackerInfo TrkInfo;
Expand Down Expand Up @@ -71,6 +73,7 @@ namespace Config
bool sim_val_for_cmssw = false;
bool sim_val = false;
bool cmssw_val = false;
bool cmssw_export = false;
bool fit_val = false;
bool readSimTrackStates = false;
bool inclusiveShorts = false;
Expand All @@ -80,9 +83,12 @@ namespace Config

bool kludgeCmsHitErrors = false;
bool backwardFit = false;
bool backwardFitPCA = false;

void RecalculateDependentConstants()
{
maxCandsPerEtaBin = std::max(100, maxCandsPerSeed * (nTracks+100) / nEtaPart);
}
}

} // end namespace mkfit
10 changes: 7 additions & 3 deletions Config.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#ifndef _config_
#define _config_

// Cram this in here for now ...
class TrackerInfo;

#include <algorithm>
#include <cmath>
#include <string> // won't compile on clang gcc for mac OS w/o this!
Expand All @@ -15,6 +12,10 @@ class TrackerInfo;
#define CUDA_CALLABLE
#endif

namespace mkfit {

// Cram this in here for now ...
class TrackerInfo;

//------------------------------------------------------------------------------

Expand Down Expand Up @@ -310,6 +311,7 @@ namespace Config
extern bool sim_val_for_cmssw;
extern bool sim_val;
extern bool cmssw_val;
extern bool cmssw_export;
extern bool fit_val;
extern bool readSimTrackStates; // need this to fill pulls
extern bool inclusiveShorts;
Expand Down Expand Up @@ -368,6 +370,7 @@ namespace Config

extern bool kludgeCmsHitErrors;
extern bool backwardFit;
extern bool backwardFitPCA;

// NAN and silly track parameter tracking options
constexpr bool nan_etc_sigs_enable = false;
Expand Down Expand Up @@ -417,4 +420,5 @@ namespace Config

inline float cdist(float a) { return a > Config::PI ? Config::TwoPI - a : a; }

} // end namespace mkfit
#endif
41 changes: 41 additions & 0 deletions ConfigWrapper.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include "ConfigWrapper.h"
#include "Config.h"
#include "MaterialEffects.h"
#include "TrackerInfo.h"

namespace mkfit {
namespace ConfigWrapper {
void initializeForCMSSW(SeedCleaningOpts seedClean, BackwardFit backfit, bool silent) {
Config::seedInput = cmsswSeeds;
Config::geomPlugin = "CMS-2017";
Config::silent = silent;
Config::cmssw_export = true;

if(seedClean == SeedCleaningOpts::cleanSeedsN2) {
Config::seedCleaning = cleanSeedsN2;
}

switch(backfit) {
case BackwardFit::noFit:
Config::backwardFit = false;
break;
case BackwardFit::toFirstLayer:
Config::backwardFit = true;
Config::backwardFitPCA = false;
break;
case BackwardFit::toPCA:
Config::backwardFit = true;
Config::backwardFitPCA = true;
break;
}

TrackerInfo::ExecTrackerInfoCreatorPlugin(Config::geomPlugin, Config::TrkInfo);

fillZRgridME();
}

void setNTotalLayers(int nTotalLayers) {
Config::nTotalLayers = nTotalLayers;
}
}
}
28 changes: 28 additions & 0 deletions ConfigWrapper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef ConfigWrapper_h
#define ConfigWrapper_h

namespace mkfit {
/**
* The purpose of this namespace is to hide the header of Config.h
* from CMSSW. This header contain uses of the build-time
* configuration macros, that should remain as internal details of
* MkFit package.
*/
namespace ConfigWrapper {
enum class SeedCleaningOpts {
noCleaning,
cleanSeedsN2
};
enum class BackwardFit {
noFit,
toFirstLayer,
toPCA
};

void initializeForCMSSW(SeedCleaningOpts seedClean, BackwardFit backfit, bool silent);

void setNTotalLayers(int nTotalLayers);
}
}

#endif
4 changes: 4 additions & 0 deletions ConformalUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
//M. Hansroul, H. Jeremie and D. Savard, NIM A 270 (1988) 498
//http://www.sciencedirect.com/science/article/pii/016890028890722X

namespace mkfit {

void conformalFit(const Hit& hit0, const Hit& hit1, const Hit& hit2, TrackState& fitStateHit0, bool fiterrs) {

// store hit info
Expand Down Expand Up @@ -96,3 +98,5 @@ void conformalFit(const Hit& hit0, const Hit& hit1, const Hit& hit2, TrackState&
fitStateHit0.errors[4][4] = (fiterrs ? Config::phierr049 * Config::phierr049 : Config::phierr012 * Config::phierr012);
fitStateHit0.errors[5][5] = (fiterrs ? Config::thetaerr049 * Config::thetaerr049 : Config::thetaerr012 * Config::thetaerr012);
}

} // end namespace mkfit
3 changes: 3 additions & 0 deletions ConformalUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#include "Track.h"
#include "Matrix.h"

namespace mkfit {

void conformalFit(const Hit& hit0, const Hit& hit1, const Hit& hit2, TrackState& fitStateHit0, bool fiterrs = 1);

} // end namespace mkfit
#endif
22 changes: 16 additions & 6 deletions Event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@

#include <memory>

namespace
{
mkfit::Geometry dummyGeometry;
std::unique_ptr<mkfit::Validation> dummyValidation( mkfit::Validation::make_validation("dummy") );
}

namespace mkfit {

std::mutex Event::printmutex;

inline bool sortByPhi(const Hit& hit1, const Hit& hit2)
Expand All @@ -38,12 +46,6 @@ inline bool sortByZ(const Hit& hit1, const Hit& hit2){
return hit1.z()<hit2.z();
}

namespace
{
Geometry dummyGeometry;
std::unique_ptr<Validation> dummyValidation( Validation::make_validation("dummy") );
}

void Event::reset_nan_n_silly_counters()
{
nan_n_silly_per_layer_count_ = 0;
Expand Down Expand Up @@ -657,6 +659,12 @@ void Event::read_in(DataFile &data_file, FILE *in_fp)
if (!Config::silent) printf("Read complete, %d simtracks on file.\n", nt);
}

void Event::setInputFromCMSSW(std::vector<HitVec>&& hits, TrackVec&& seeds)
{
layerHits_ = std::move(hits);
seedTracks_ = std::move(seeds);
}

//------------------------------------------------------------------------------

void Event::kludge_cms_hit_errors()
Expand Down Expand Up @@ -1110,3 +1118,5 @@ void DataFile::CloseWrite(int n_written){
}
Close();
}

} // end namespace mkfit
7 changes: 7 additions & 0 deletions Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#include <mutex>

namespace mkfit {

struct DataFile;

class Event
Expand All @@ -34,6 +36,7 @@ class Event

void write_out(DataFile &data_file);
void read_in (DataFile &data_file, FILE *in_fp=0);
void setInputFromCMSSW(std::vector<HitVec>&& hits, TrackVec&& seeds);

void kludge_cms_hit_errors();

Expand All @@ -43,6 +46,9 @@ class Event
int clean_cms_seedtracks_badlabel(); //operates on seedTracks_, removes those with label == -1;
void relabel_bad_seedtracks();
void relabel_cmsswtracks_from_seeds();

inline bool is_trackvec_empty(const TrackVec & tracks) { return tracks.empty(); }

void print_tracks(const TrackVec& tracks, bool print_hits) const;

const Geometry& geom_;
Expand Down Expand Up @@ -132,4 +138,5 @@ struct DataFile
void CloseWrite(int n_written); //override nevents in the header and close
};

} // end namespace mkfit
#endif
8 changes: 8 additions & 0 deletions Geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//#define DEBUG
#include "Debug.h"

namespace mkfit {

VUSolid::EnumInside Geometry::Inside (const UVector3 &aPoint) const {
VUSolid::EnumInside in = VUSolid::eOutside;
for (auto i = solids_.begin(); i != solids_.end(); ++i) {
Expand Down Expand Up @@ -97,10 +99,14 @@ Geometry Geometry::clone() const
return NewGeo;
}

} // end namespace mkfit

//==============================================================================

#include "TrackerInfo.h"

namespace mkfit {

void Geometry::BuildFromTrackerInfo(const TrackerInfo& tracker_info)
{
#ifndef WITH_USOLIDS
Expand All @@ -117,3 +123,5 @@ void Geometry::BuildFromTrackerInfo(const TrackerInfo& tracker_info)
exit(1);
#endif
}

} // end namespace mkfit
3 changes: 3 additions & 0 deletions Geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "SimpleGeom.h"
#endif

namespace mkfit {

class TrackerInfo;

// XXXX MT: What it the purpose of zPlanes?
Expand Down Expand Up @@ -47,4 +49,5 @@ class Geometry
std::vector<float> zPlanes_;
};

} // end namespace mkfit
#endif
2 changes: 2 additions & 0 deletions Geoms/CMS-2017.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "Config.h"
#include "TrackerInfo.h"

using namespace mkfit;

namespace
{
#include "CMS-2017.acc"
Expand Down
2 changes: 2 additions & 0 deletions Geoms/CylCowWLids.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#include <cmath>

using namespace mkfit;

namespace
{
float getTheta(float r, float z)
Expand Down
2 changes: 1 addition & 1 deletion Geoms/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ all: ${TGTS}
${CXX} ${CPPFLAGS} ${CXXFLAGS} ${VEC_HOST} -c -o $@ $<

%.so: %.o
${CXX} -shared -L.. -lMicCore -o $@ $<
${CXX} -shared -L../lib -lMicCore -o $@ $<

%.om: %.cc %.d
${CXX} ${CPPFLAGS_NO_ROOT} ${CXXFLAGS} ${VEC_MIC} -c -o $@ $<
Expand Down
4 changes: 4 additions & 0 deletions Hit.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "Hit.h"

namespace mkfit {

void MCHitInfo::reset()
{
}
Expand All @@ -14,3 +16,5 @@ void print(std::string label, const MeasurementState& s)
dumpMatrix(s.errors());
std::cout << std::endl;
}

} // end namespace mkfit
3 changes: 3 additions & 0 deletions Hit.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <atomic>
#include <array>

namespace mkfit {

template<typename T> inline T sqr(T x) { return x*x; }
template<typename T> inline T cube(T x) { return x*x*x; }

Expand Down Expand Up @@ -271,4 +273,5 @@ typedef std::vector<HitOnTrack> HoTVec;

void print(std::string label, const MeasurementState& s);

} // end namespace mkfit
#endif
4 changes: 4 additions & 0 deletions KalmanUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//#define DEBUG
#include "Debug.h"

namespace mkfit {

static const SMatrix36 projMatrix = ROOT::Math::SMatrixIdentity();
static const SMatrix63 projMatrixT = ROOT::Math::Transpose(projMatrix);

Expand Down Expand Up @@ -230,3 +232,5 @@ float computeChi2Endcap(const TrackState& propagatedState, const MeasurementStat
const SVector2 res(hpos.At(0)-propagatedState.x(), hpos.At(1)-propagatedState.y());
return ROOT::Math::Similarity(res,resErrInv);
}

} // end namespace mkfit
Loading

0 comments on commit f013f1a

Please sign in to comment.