CMS 3D CMS Logo

PixelTemplateSmearerBase.h
Go to the documentation of this file.
1 #ifndef FastSimulation_TrackingRecHitProducer_PixelTemplateSmearerBase_h
2 #define FastSimulation_TrackingRecHitProducer_PixelTemplateSmearerBase_h
3 
4 //---------------------------------------------------------------------------
9 //---------------------------------------------------------------------------
10 
11 // FastSim stuff
13 
14 //Framework
16 
17 // PSimHit
19 
20 // Geometry
23 // template object
25 
26 // Vectors
29 
30 // STL. <memory> needed for uniq_ptr<>
31 #include <vector>
32 #include <string>
33 #include <memory>
34 
35 class TFile;
39 
42 {
43  public:
44  //--- Use this type to keep track of groups of hits that need to be merged:
45  struct MergeGroup{
46  std::vector<TrackingRecHitProduct::SimHitIdPair> group;
47  bool smearIt;
48  };
49 
50  protected:
51  bool mergeHitsOn = false; // if true then see if neighboring hits might merge
52 
53  //--- Template DB Object(s)
54  const SiPixelTemplateDBObject * pixelTemplateDBObject_ = nullptr; // needed for template<-->DetId map.
55  std::vector< SiPixelTemplateStore > thePixelTemp_ ; // our own template storage
56  std::vector< SiPixelTemplateStore > & thePixelTempRef = thePixelTemp_; // points to the one we will use.
57  int templateId = -1;
58 
59  //--- Flag to tell us whether we are in barrel or in forward.
60  // This is needed since the parameterization is slightly
61  // different for forward, since all forward detectors cover
62  // a smaller range of local incidence angles and thus
63  // the clusters are shorter and have less charge.
64  bool isBarrel;
65 
66  //--- The histogram storage containers.
67  std::shared_ptr<PixelResolutionHistograms> theEdgePixelResolutions;
69 
70  std::shared_ptr<PixelResolutionHistograms> theBigPixelResolutions;
72 
73  std::shared_ptr<PixelResolutionHistograms> theRegularPixelResolutions;
75 
76  //--- Files with hit merging information:
77  std::unique_ptr<TFile> theMergingProbabilityFile;
79 
80  std::unique_ptr<TFile> theMergedPixelResolutionXFile;
82 
83  std::unique_ptr<TFile> theMergedPixelResolutionYFile;
85 
86 
87  public:
88  explicit PixelTemplateSmearerBase( const std::string& name,
90  edm::ConsumesCollector& consumesCollector );
91 
92  ~PixelTemplateSmearerBase() override;
94  // void beginEvent(edm::Event& event, const edm::EventSetup& eventSetup) override;
95  void beginRun(edm::Run const& run, const edm::EventSetup& eventSetup,
96  const SiPixelTemplateDBObject * pixelTemplateDBObjectPtr,
97  std::vector< SiPixelTemplateStore > & tempStoreRef ) override;
98  // void endEvent(edm::Event& event, const edm::EventSetup& eventSetup) override;
99 
100  //--- Process all unmerged hits. Calls smearHit() for each.
102  std::vector<TrackingRecHitProduct::SimHitIdPair> & unmergedHits,
103  TrackingRecHitProductPtr product,
104  const PixelGeomDetUnit * detUnit,
105  const double boundX, const double boundY,
107  ) const;
108  //--- Process all groups of merged hits.
110  std::vector< MergeGroup* > & mergeGroups,
111  TrackingRecHitProductPtr product,
112  const PixelGeomDetUnit * detUnit,
113  const double boundX, const double boundY,
115  ) const;
116 
117 
118  //--- Process one umerged hit.
120  const PSimHit& simHit, const PixelGeomDetUnit* detUnit,
121  const double boundX, const double boundY,
123  const;
124 
125  //--- Process one merge group.
127  MergeGroup* mg,
128  const PixelGeomDetUnit * detUnit,
129  const double boundX, const double boundY,
131  ) const;
132 
133  //--- Method to decide if the two hits on the same DetUnit are merged, or not.
134  bool hitsMerge(const PSimHit& simHit1,const PSimHit& simHit2) const;
135 };
136 #endif
TrackingRecHitProductPtr process(TrackingRecHitProductPtr product) const override
void beginRun(edm::Run const &run, const edm::EventSetup &eventSetup, const SiPixelTemplateDBObject *pixelTemplateDBObjectPtr, std::vector< SiPixelTemplateStore > &tempStoreRef) override
const SiPixelTemplateDBObject * pixelTemplateDBObject_
Definition: config.py:1
TRandom random
Definition: MVATrainer.cc:138
std::vector< SiPixelTemplateStore > & thePixelTempRef
FastSingleTrackerRecHit smearMergeGroup(MergeGroup *mg, const PixelGeomDetUnit *detUnit, const double boundX, const double boundY, const RandomEngineAndDistribution *random) const
std::unique_ptr< TFile > theMergingProbabilityFile
TrackingRecHitProductPtr processUnmergedHits(std::vector< TrackingRecHitProduct::SimHitIdPair > &unmergedHits, TrackingRecHitProductPtr product, const PixelGeomDetUnit *detUnit, const double boundX, const double boundY, RandomEngineAndDistribution const *random) const
bool hitsMerge(const PSimHit &simHit1, const PSimHit &simHit2) const
std::shared_ptr< TrackingRecHitProduct > TrackingRecHitProductPtr
std::unique_ptr< TFile > theMergedPixelResolutionXFile
std::shared_ptr< PixelResolutionHistograms > theBigPixelResolutions
std::vector< SiPixelTemplateStore > thePixelTemp_
FastSingleTrackerRecHit smearHit(const PSimHit &simHit, const PixelGeomDetUnit *detUnit, const double boundX, const double boundY, RandomEngineAndDistribution const *) const
std::unique_ptr< TFile > theMergedPixelResolutionYFile
std::shared_ptr< PixelResolutionHistograms > theEdgePixelResolutions
std::shared_ptr< PixelResolutionHistograms > theRegularPixelResolutions
std::vector< TrackingRecHitProduct::SimHitIdPair > group
TrackingRecHitProductPtr processMergeGroups(std::vector< MergeGroup * > &mergeGroups, TrackingRecHitProductPtr product, const PixelGeomDetUnit *detUnit, const double boundX, const double boundY, RandomEngineAndDistribution const *random) const
PixelTemplateSmearerBase(const std::string &name, const edm::ParameterSet &config, edm::ConsumesCollector &consumesCollector)
Definition: Run.h:44