Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New pixel RecHit infrastructure for FastSim (for Phases 0, 1, 2, and beyond) #23799

Merged
merged 26 commits into from
Aug 11, 2018
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
288bcb9
The new FastSim rec hit producer for pixels.
pmaksim1 May 21, 2018
fecef50
The new FastSim rec hit producer for pixels.
pmaksim1 May 21, 2018
5141e13
Fixing typos in config
pmaksim1 May 22, 2018
14e94c1
Moving template's pushfile() to beginRun()
pmaksim1 Jun 4, 2018
264b975
Unpacking template DB object only once
pmaksim1 Jun 5, 2018
02b7ede
Use the reference to the template store
pmaksim1 Jun 5, 2018
eed34ac
Making everything work properly with the old resolutions files for Ed…
pmaksim1 Jul 4, 2018
0dc07b6
The new FastSim rec hit producer for pixels.
pmaksim1 May 21, 2018
4428772
The new FastSim rec hit producer for pixels.
pmaksim1 May 21, 2018
0409442
Fixing typos in config
pmaksim1 May 22, 2018
a9e8161
Moving template's pushfile() to beginRun()
pmaksim1 Jun 4, 2018
144bdf0
Unpacking template DB object only once
pmaksim1 Jun 5, 2018
136fc60
Use the reference to the template store
pmaksim1 Jun 5, 2018
f0ef0fc
Making everything work properly with the old resolutions files for Ed…
pmaksim1 Jul 4, 2018
dbef074
Caught up to 10.2.0pre6
pmaksim1 Jul 6, 2018
2b8d52f
Switch to LogError, LogInfo and LogDebug
pmaksim1 Jul 6, 2018
4f26dae
Fix verbosity
pmaksim1 Jul 9, 2018
282e896
Small tweaks
pmaksim1 Jul 11, 2018
3487c3e
Phase 0 resolution files + config
pmaksim1 Jul 12, 2018
a5467fa
Final tweaks before the PR; proper Era-dependent config of pixel plugins
pmaksim1 Jul 13, 2018
6e9b6c3
Merge branch 'master' into pixel_fastsim_10_2_X
pmaksim1 Jul 14, 2018
2ffafe8
Code-checks cleanup
pmaksim1 Jul 14, 2018
e4e1366
User correct Eras for phase1 and phase2 detectors
pmaksim1 Jul 16, 2018
e459243
User correct Eras for phase1 and phase2 detectors, take 2
pmaksim1 Jul 16, 2018
c5b10fb
Added FileInPath for all resolution histogram files
pmaksim1 Jul 21, 2018
911b726
Fixing EdmFileInPath().c_str() possible issue with GCC 7
pmaksim1 Jul 23, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
#ifndef FastSimulation_TrackingRecHitProducer_PixelResolutionHistograms_h
#define FastSimulation_TrackingRecHitProducer_PixelResolutionHistograms_h 1

class TFile;
class TH1F;
class TH2F;
class TAxis;
class RandomEngineAndDistribution;
class SimpleHistogramGenerator;

#include <memory>

/// #define COTBETA_HIST_MAX 30
/// #define COTALPHA_HIST_MAX 20
/// #define QBIN_HIST_MAX 4

static constexpr unsigned int COTBETA_HIST_MAX = 30;
static constexpr unsigned int COTALPHA_HIST_MAX = 20;
static constexpr unsigned int QBIN_HIST_MAX = 4;

class PixelResolutionHistograms {
public:

//--- Constructor to use when generating resolution histograms.
// We make empty histograms (which we own), but generator pointers
// remain null.
//
PixelResolutionHistograms( const char * filename, // ROOT file for histograms
const char * rootdir, // Subdirectory in the file, "" if none
const char * descTitle, // Descriptive title
unsigned int detType, // Where we are... (&&& do we need this?)
double cotbetaBinWidth, // cot(beta) : bin width,
double cotbetaLowEdge, // : low endpoint,
int cotbetaBins, // : # of bins
double cotalphaBinWidth, // cot(alpha): bin width,
double cotalphaLowEdge, // : low endpoint,
int cotalphaBins ); // : # of bins
//int qbinWidth,
//int qbins )


//--- Constructor to use when reading the histograms from a file (e.g. when
// inside a running FastSim job). We get the histograms from a
// ROOT file, and we do *not* own them. But we do own the
// generators.
//
PixelResolutionHistograms( const char * filename, // ROOT file for histograms
const char * rootdir = "", // ROOT dir, "" if none
int detType = -1, // default: read from ROOT file.
bool ignore_multi = false, // Forward Big is always single
bool ignore_single = false, // Edge does not need single pixels
bool ignore_qBin = false ); // qBin histograms not used right now (future expansion)


//--- Destructor (virtual, just in case)
virtual ~PixelResolutionHistograms();

//--- Status after construction (esp.loading from file). Non-zero if there
// were problems.
inline int status() { return status_ ; }

//--- Fill one entry in one resolution histogram. Use when making histograms.
int Fill( double dx, double dy, // the difference wrt true hit
double cotalpha, double cotbeta, // cotangent of local angles
int qbin, // Qbin = category for how much charge we have
int nxpix, int nypix ); // length of cluster along x,y (only care if ==1 or not)


//--- Get generators, for resolution in X and Y. Use in FastSim.
const SimpleHistogramGenerator * getGeneratorX( double cotalpha,
double cotbeta,
int qbin,
bool singlex );

const SimpleHistogramGenerator * getGeneratorY( double cotalpha,
double cotbeta,
int qbin,
bool singley );


private:
// Do we own the histograms, or not?
bool weOwnHistograms_ ;

// Where we are.
unsigned int detType_ ; // 1 for barrel, 0 for forward /// May not need this?

// Resolution binning
double cotbetaBinWidth_ ;
double cotbetaLowEdge_ ;
int cotbetaBins_ ;
double cotalphaBinWidth_ ;
double cotalphaLowEdge_ ;
int cotalphaBins_ ;
int qbinWidth_ ;
int qbins_ ;

// The dummy histogram to hold the binning, and the two cached axes.
TH2F * binningHisto_ ;
TAxis * cotbetaAxis_ ;
TAxis * cotalphaAxis_ ;

// Resolution histograms. I (Petar) tried to dynamically allocate
// these histograms, but all possible implementations were somewhat
// complicated, which would make the code harder to understand,
// debug, and thus support in the long term. Since we are here only
// booking pointers of histograms, we will instead book larger
// matrices, and leave them partially empty. But who cares -- the
// wasted memory of a few hundred null pointers is negligible.
//
// The constructor will then fill only the first cotbetaBins_ x
// cotalphaBins_ x qbinBins_ histograms in the matrix, and we'll
// ignore the rest.
//
TH1F * resMultiPixelXHist_ [ COTBETA_HIST_MAX ][ COTALPHA_HIST_MAX ][ QBIN_HIST_MAX ] ;
TH1F * resSinglePixelXHist_ [ COTBETA_HIST_MAX ][ COTALPHA_HIST_MAX ];
TH1F * resMultiPixelYHist_ [ COTBETA_HIST_MAX ][ COTALPHA_HIST_MAX ][ QBIN_HIST_MAX ];
TH1F * resSinglePixelYHist_ [ COTBETA_HIST_MAX ][ COTALPHA_HIST_MAX ];
TH1F * qbinHist_ [ COTBETA_HIST_MAX ][ COTALPHA_HIST_MAX ];

// File with histograms to load.
std::unique_ptr<TFile> file_ ;

// Status of loading. Check if there were errors.
int status_ ;

// Identical binning and parameterization for FastSim generators.
SimpleHistogramGenerator * resMultiPixelXGen_ [ COTBETA_HIST_MAX ][ COTALPHA_HIST_MAX ][ QBIN_HIST_MAX ] ;
SimpleHistogramGenerator * resSinglePixelXGen_ [ COTBETA_HIST_MAX ][ COTALPHA_HIST_MAX ];
SimpleHistogramGenerator * resMultiPixelYGen_ [ COTBETA_HIST_MAX ][ COTALPHA_HIST_MAX ][ QBIN_HIST_MAX ];
SimpleHistogramGenerator * resSinglePixelYGen_ [ COTBETA_HIST_MAX ][ COTALPHA_HIST_MAX ];
SimpleHistogramGenerator * qbinGen_ [ COTBETA_HIST_MAX ][ COTALPHA_HIST_MAX ];

};
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@
#include "DataFormats/GeometryVector/interface/Point3DBase.h"
#include "DataFormats/GeometrySurface/interface/LocalError.h"

// STL
// STL. <memory> needed for uniq_ptr<>
#include <vector>
#include <string>
#include <memory>

class TFile;
class RandomEngineAndDistribution;
class SimpleHistogramGenerator;
class PixelResolutionHistograms;

class PixelTemplateSmearerBase:
public TrackingRecHitAlgorithm
Expand All @@ -47,48 +48,54 @@ class PixelTemplateSmearerBase:
};

protected:
bool mergeHitsOn;
std::vector< SiPixelTemplateStore > thePixelTemp_;
int templateId;
bool isFlipped(const PixelGeomDetUnit* theDet) const;
//isForward, true for forward, false for barrel
bool isForward;
bool mergeHitsOn = false; // if true then see if neighboring hits might merge

//--- Template DB Object(s)
const SiPixelTemplateDBObject * pixelTemplateDBObject_ = nullptr; // needed for template<-->DetId map.
std::vector< SiPixelTemplateStore > thePixelTemp_ ; // our own template storage
std::vector< SiPixelTemplateStore > & thePixelTempRef = thePixelTemp_; // points to the one we will use.
int templateId = -1;

double rescotAlpha_binMin , rescotAlpha_binWidth;
unsigned int rescotAlpha_binN;
double rescotBeta_binMin , rescotBeta_binWidth;
unsigned int rescotBeta_binN;
int resqbin_binMin, resqbin_binWidth;
unsigned int resqbin_binN;
//--- Flag to tell us whether we are in barrel or in forward.
// This is needed since the parameterization is slightly
// different for forward, since all forward detectors cover
// a smaller range of local incidence angles and thus
// the clusters are shorter and have less charge.
bool isBarrel;


std::map<unsigned int, const SimpleHistogramGenerator*> theXHistos;
std::map<unsigned int, const SimpleHistogramGenerator*> theYHistos;

std::unique_ptr<TFile> theEdgePixelResolutionFile;
//--- The histogram storage containers.
std::shared_ptr<PixelResolutionHistograms> theEdgePixelResolutions;
std::string theEdgePixelResolutionFileName;
std::unique_ptr<TFile> theBigPixelResolutionFile;

std::shared_ptr<PixelResolutionHistograms> theBigPixelResolutions;
std::string theBigPixelResolutionFileName;
std::unique_ptr<TFile> theRegularPixelResolutionFile;

std::shared_ptr<PixelResolutionHistograms> theRegularPixelResolutions;
std::string theRegularPixelResolutionFileName;

//--- Files with hit merging information:
std::unique_ptr<TFile> theMergingProbabilityFile;
std::string theMergingProbabilityFileName;

std::unique_ptr<TFile> theMergedPixelResolutionXFile;
std::string theMergedPixelResolutionXFileName;
std::unique_ptr<TFile> theMergedPixelResolutionYFile;
std::string theMergedPixelResolutionYFileName;

unsigned int theLayer;
std::unique_ptr<TFile> theMergedPixelResolutionYFile;
std::string theMergedPixelResolutionYFileName;


public:

explicit PixelTemplateSmearerBase( const std::string& name,
const edm::ParameterSet& config,
edm::ConsumesCollector& consumesCollector );

~PixelTemplateSmearerBase() override;
TrackingRecHitProductPtr process(TrackingRecHitProductPtr product) const override;
// void beginEvent(edm::Event& event, const edm::EventSetup& eventSetup) override;
void beginRun(edm::Run const& run, const edm::EventSetup& eventSetup,
const SiPixelTemplateDBObject * pixelTemplateDBObjectPtr,
std::vector< SiPixelTemplateStore > & tempStoreRef ) override;
// void endEvent(edm::Event& event, const edm::EventSetup& eventSetup) override;

//--- Process all unmerged hits. Calls smearHit() for each.
TrackingRecHitProductPtr processUnmergedHits(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@

#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"

#include "FWCore/Framework/interface/ProducerBase.h"
#include "FastSimulation/TrackingRecHitProducer/interface/TrackingRecHitProduct.h"

#include "FastSimulation/Utilities/interface/RandomEngineAndDistribution.h"

// Pixel-related stuff:
#include "CondFormats/SiPixelObjects/interface/SiPixelTemplateDBObject.h"
#include "CondFormats/SiPixelTransient/interface/SiPixelTemplate.h"

#include <string>
#include <memory>

Expand Down Expand Up @@ -52,9 +56,15 @@ class TrackingRecHitAlgorithm
//this function will only be called once per stream
virtual void beginStream(const edm::StreamID& id);

//this function will only be called once per run
virtual void beginRun(edm::Run const& run, const edm::EventSetup& eventSetup,
const SiPixelTemplateDBObject * pixelTemplateDBObjectPtr,
std::vector< SiPixelTemplateStore > & tempStoreRef );

//this function will only be called once per event
virtual void beginEvent(edm::Event& event, const edm::EventSetup& eventSetup);

//the main action is here
virtual TrackingRecHitProductPtr process(TrackingRecHitProductPtr product) const;

//this function will only be called once per event
Expand Down

This file was deleted.

Loading