1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
#ifndef FastSimulation_TrackingRecHitProducer_PixelTemplateSmearerBase_h
#define FastSimulation_TrackingRecHitProducer_PixelTemplateSmearerBase_h
//---------------------------------------------------------------------------
//! \class SiTrackerGaussianSmearingRecHits
//!
//! \brief EDProducer to create RecHits from PSimHits with Gaussian smearing
//!
//---------------------------------------------------------------------------
// FastSim stuff
#include "FastSimulation/TrackingRecHitProducer/interface/TrackingRecHitAlgorithm.h"
//Framework
#include "FWCore/ParameterSet/interface/ParameterSet.h"
// PSimHit
#include "SimDataFormats/TrackingHit/interface/PSimHit.h"
// Geometry
#include "Geometry/CommonDetUnit/interface/GeomDetType.h"
#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
// template object
#include "CondFormats/SiPixelTransient/interface/SiPixelTemplate.h"
// Vectors
#include "DataFormats/GeometryVector/interface/Point3DBase.h"
#include "DataFormats/GeometrySurface/interface/LocalError.h"
// STL. <memory> needed for uniq_ptr<>
#include <vector>
#include <string>
#include <memory>
class TFile;
class RandomEngineAndDistribution;
class SimpleHistogramGenerator;
class PixelResolutionHistograms;
class PixelTemplateSmearerBase : public TrackingRecHitAlgorithm {
public:
//--- Use this type to keep track of groups of hits that need to be merged:
struct MergeGroup {
std::vector<TrackingRecHitProduct::SimHitIdPair> group;
bool smearIt;
};
protected:
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
const std::vector<SiPixelTemplateStore>* thePixelTempRef = &thePixelTemp_; // points to the one we will use.
int templateId = -1;
//--- 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;
//--- The histogram storage containers.
std::shared_ptr<PixelResolutionHistograms> theEdgePixelResolutions;
std::string theEdgePixelResolutionFileName;
std::shared_ptr<PixelResolutionHistograms> theBigPixelResolutions;
std::string theBigPixelResolutionFileName;
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;
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,
const 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(std::vector<TrackingRecHitProduct::SimHitIdPair>& unmergedHits,
TrackingRecHitProductPtr product,
const PixelGeomDetUnit* detUnit,
const double boundX,
const double boundY,
RandomEngineAndDistribution const* random) const;
//--- Process all groups of merged hits.
TrackingRecHitProductPtr processMergeGroups(std::vector<MergeGroup*>& mergeGroups,
TrackingRecHitProductPtr product,
const PixelGeomDetUnit* detUnit,
const double boundX,
const double boundY,
RandomEngineAndDistribution const* random) const;
//--- Process one umerged hit.
FastSingleTrackerRecHit smearHit(const PSimHit& simHit,
const PixelGeomDetUnit* detUnit,
const double boundX,
const double boundY,
RandomEngineAndDistribution const*) const;
//--- Process one merge group.
FastSingleTrackerRecHit smearMergeGroup(MergeGroup* mg,
const PixelGeomDetUnit* detUnit,
const double boundX,
const double boundY,
const RandomEngineAndDistribution* random) const;
//--- Method to decide if the two hits on the same DetUnit are merged, or not.
bool hitsMerge(const PSimHit& simHit1, const PSimHit& simHit2) const;
};
#endif
|