CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
CTPPSRecHitProducer Class Reference

#include <FastSimulation/CTPPSRecHitProducer/plugins/CTPPSRecHitProducer.cc>

Inheritance diagram for CTPPSRecHitProducer:
edm::stream::EDProducer<>

Public Member Functions

 CTPPSRecHitProducer (const edm::ParameterSet &)
 
 ~CTPPSRecHitProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Types

typedef std::vector< PSimHitPSimHitContainer
 

Private Member Functions

void beginStream (edm::StreamID) override
 
void endStream () override
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

edm::EDGetTokenT< CrossingFrame< PSimHit > > cf_token
 
double fBeamXRMS_ToF
 
double fBeamXRMS_Trk1
 
double fBeamXRMS_Trk2
 
double fHitSigmaX
 
double fHitSigmaY
 
double fHitSigmaZ
 
double fTimeSigma
 
double fToFCellHeight
 
std::vector< double > fToFCellWidth
 
double fToFInsertion
 
int fToFNCellX
 
int fToFNCellY
 
double fToFPitchX
 
double fToFPitchY
 
double fToFXOffset
 
double fTrackerHeight
 
double fTrackerInsertion
 
double fTrackerWidth
 
double fTrk1XOffset
 
double fTrk2XOffset
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 67 of file CTPPSRecHitProducer.cc.

Member Typedef Documentation

◆ PSimHitContainer

typedef std::vector<PSimHit> CTPPSRecHitProducer::PSimHitContainer
private

Definition at line 78 of file CTPPSRecHitProducer.cc.

Constructor & Destructor Documentation

◆ CTPPSRecHitProducer()

CTPPSRecHitProducer::CTPPSRecHitProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 93 of file CTPPSRecHitProducer.cc.

References cf_token, Exception, fBeamXRMS_ToF, fBeamXRMS_Trk1, fBeamXRMS_Trk2, fHitSigmaX, fHitSigmaY, fHitSigmaZ, fTimeSigma, fToFCellHeight, fToFCellWidth, fToFInsertion, fToFNCellX, fToFNCellY, fToFPitchX, fToFPitchY, fToFXOffset, fTrackerHeight, fTrackerInsertion, fTrackerWidth, fTrk1XOffset, fTrk2XOffset, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), HLT_2022v15_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

93  {
94  produces<edm::CTPPSFastRecHitContainer>("CTPPSFastRecHits");
95 
96  //Name of Collection use for create the XF
97  std::string mix_ = iConfig.getParameter<std::string>("mixLabel");
98  std::string collection_for_XF = iConfig.getParameter<std::string>("InputCollection");
99  cf_token = consumes<CrossingFrame<PSimHit> >(edm::InputTag(mix_, collection_for_XF));
100 
101  // Read the detector parameters
102  fTrackerWidth = iConfig.getParameter<double>("TrackerWidth");
103  fTrackerHeight = iConfig.getParameter<double>("TrackerHeight");
104  fTrackerInsertion = iConfig.getParameter<double>("TrackerInsertion");
105  fBeamXRMS_Trk1 = iConfig.getParameter<double>("BeamXRMS_Trk1");
106  fBeamXRMS_Trk2 = iConfig.getParameter<double>("BeamXRMS_Trk2");
107  fTrk1XOffset = iConfig.getParameter<double>("Trk1XOffset");
108  fTrk2XOffset = iConfig.getParameter<double>("Trk2XOffset");
109  fHitSigmaX = iConfig.getParameter<double>("HitSigmaX");
110  fHitSigmaY = iConfig.getParameter<double>("HitSigmaY");
111  fHitSigmaZ = iConfig.getParameter<double>("HitSigmaZ");
112  fToFCellWidth = iConfig.getUntrackedParameter<std::vector<double> >("ToFCellWidth");
113  fToFCellHeight = iConfig.getParameter<double>("ToFCellHeight");
114  fToFPitchX = iConfig.getParameter<double>("ToFPitchX");
115  fToFPitchY = iConfig.getParameter<double>("ToFPitchY");
116  fToFNCellX = iConfig.getParameter<int>("ToFNCellX");
117  fToFNCellY = iConfig.getParameter<int>("ToFNCellY");
118  fToFInsertion = iConfig.getParameter<double>("ToFInsertion");
119  fBeamXRMS_ToF = iConfig.getParameter<double>("BeamXRMS_ToF");
120  fToFXOffset = iConfig.getParameter<double>("ToFXOffset");
121  fTimeSigma = iConfig.getParameter<double>("TimeSigma");
122 
124  if (!rng.isAvailable()) {
125  throw cms::Exception("Configuration")
126  << "CTPPSRecHitProducer requires the RandomNumberGeneratorService\n"
127  "which is not present in the configuration file. You must add the service\n"
128  "in the configuration file or remove the modules that require it.";
129  }
130 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< CrossingFrame< PSimHit > > cf_token
T getUntrackedParameter(std::string const &, T const &) const
std::vector< double > fToFCellWidth

◆ ~CTPPSRecHitProducer()

CTPPSRecHitProducer::~CTPPSRecHitProducer ( )
override

Definition at line 132 of file CTPPSRecHitProducer.cc.

132 {}

Member Function Documentation

◆ beginStream()

void CTPPSRecHitProducer::beginStream ( edm::StreamID  )
overrideprivate

Definition at line 259 of file CTPPSRecHitProducer.cc.

259 {}

◆ endStream()

void CTPPSRecHitProducer::endStream ( )
overrideprivate

Definition at line 262 of file CTPPSRecHitProducer.cc.

262 {}

◆ produce()

void CTPPSRecHitProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 134 of file CTPPSRecHitProducer.cc.

References cf_token, Exception, fBeamXRMS_ToF, fBeamXRMS_Trk1, fBeamXRMS_Trk2, fHitSigmaX, fHitSigmaY, CTPPSToFDetector::findCellId(), fTimeSigma, fToFCellHeight, fToFCellWidth, fToFInsertion, fToFNCellX, fToFNCellY, fToFPitchX, fToFPitchY, fToFXOffset, fTrackerHeight, fTrackerInsertion, fTrackerWidth, fTrk1XOffset, fTrk2XOffset, CTPPSToFDetector::get_CellCenter(), edm::RandomNumberGenerator::getEngine(), mps_fire::i, iEvent, eostools::move(), dqmiodumpmetadata::n, edm::Handle< T >::product(), CTPPSFastRecHit::setCellId(), CTPPSFastRecHit::setDetUnitId(), CTPPSFastRecHit::setLocal3DPoint(), CTPPSFastRecHit::setTof(), rpcPointValidation_cfi::simHit, FastTrackerRecHitCombiner_cfi::simHits, submitPVValidationJobs::t, and um_to_mm.

134  {
135  using namespace edm;
136 
138  CLHEP::HepRandomEngine* engine = &rng->getEngine(iEvent.streamID());
139  if (engine->name() != "TRandom3") {
140  throw cms::Exception("Configuration") << "The TRandom3 engine type must be used with CTPPSRecHitProducer, Random "
141  "Number Generator Service not correctly configured!";
142  }
143 
144  //Mix the PSimHits for pileup
146  iEvent.getByToken(cf_token, xFrame);
147 
148  std::unique_ptr<MixCollection<PSimHit> > simHits(new MixCollection<PSimHit>(xFrame.product()));
149 
150  std::vector<CTPPSFastRecHit> theCTPPSFastRecHit;
151 
152  for (MixCollection<PSimHit>::MixItr ihit = simHits->begin(); ihit != simHits->end(); ihit++)
153 
154  {
155  const PSimHit* simHit = &(*ihit);
156  unsigned int detlayerId = simHit->detUnitId();
157  // DetId layer codification for PSimHit
158  // 2014314496 -> Tracker1 zPositive
159  // 2014838784 -> Tracker2 zPositive
160  // 2046820352 -> Timing zPositive
161  // 2031091712 -> Tracker1 zNegative
162  // 2031616000 -> Tracker2 zNegative
163  // 2063597568 -> Timing zNegative
164  bool outside = false;
165 
166  //Make Tracker RecHits by smearing the SimHits positions and applying fiducial cuts
167  CTPPSFastRecHit rechit; // (const Local3DPoint& entry, unsigned int detId, float tof, unsigned int cellId)
168  if (detlayerId == 2014314496 || detlayerId == 2031091712) {
169  // Apply position smearing
170  float x_trk1 = simHit->entryPoint().x() + CLHEP::RandGauss::shoot(engine, 0, fHitSigmaX * um_to_mm);
171  float y_trk1 = simHit->entryPoint().y() + CLHEP::RandGauss::shoot(engine, 0, fHitSigmaY * um_to_mm);
172  float z_trk1 = simHit->entryPoint().z();
173 
174  // Apply fiducial cuts
175  double pos_trk1 = fTrackerInsertion * fBeamXRMS_Trk1 + fTrk1XOffset;
176  if (x_trk1 > 0 || fabs(x_trk1) < pos_trk1 || fabs(x_trk1) > (fTrackerWidth + pos_trk1) ||
177  fabs(y_trk1) > fTrackerHeight / 2.)
178  outside = true;
179 
180  float tof = 0.0;
181  unsigned int cellId = 1;
182  Local3DPoint xyzzy = Local3DPoint(x_trk1, y_trk1, z_trk1);
183  if (!outside) {
184  rechit.setLocal3DPoint(xyzzy);
185  rechit.setTof(tof);
186  rechit.setDetUnitId(detlayerId);
187  rechit.setCellId(cellId);
188  theCTPPSFastRecHit.push_back(rechit);
189  }
190  }
191  if (detlayerId == 2014838784 || detlayerId == 2031616000) {
192  // Apply position smearing
193  double x_trk2 = simHit->entryPoint().x() + CLHEP::RandGauss::shoot(engine, 0, fHitSigmaX * um_to_mm);
194  double y_trk2 = simHit->entryPoint().y() + CLHEP::RandGauss::shoot(engine, 0, fHitSigmaY * um_to_mm);
195  double z_trk2 = simHit->entryPoint().z();
196  // Apply fiducial cuts
197  double pos_trk2 = fTrackerInsertion * fBeamXRMS_Trk2 + fTrk2XOffset;
198  if (x_trk2 > 0 || fabs(x_trk2) < pos_trk2 || fabs(x_trk2) > (fTrackerWidth + pos_trk2) ||
199  fabs(y_trk2) > fTrackerHeight / 2.)
200  outside = true;
201 
202  float tof = 0.0;
203  unsigned int cellId = 2;
204  Local3DPoint xyzzy = Local3DPoint(x_trk2, y_trk2, z_trk2);
205  if (!outside) {
206  rechit.setLocal3DPoint(xyzzy);
207  rechit.setTof(tof);
208  rechit.setDetUnitId(detlayerId);
209  rechit.setCellId(cellId);
210  theCTPPSFastRecHit.push_back(rechit);
211  }
212  }
213  //Make Timing RecHits by smearing the SimHits time of flight and checking the cell of the hit
214  //The RecHit position is the centre of the cell
215  if (detlayerId == 2046820352 || detlayerId == 2063597568) {
216  float t = simHit->tof();
217  unsigned int cellId = 0;
218  float tof = CLHEP::RandGauss::shoot(engine, t, fTimeSigma);
219  double x_tof = simHit->entryPoint().x();
220  double y_tof = simHit->entryPoint().y();
221 
222  double pos_tof = fToFInsertion * fBeamXRMS_ToF + fToFXOffset;
223 
224  std::vector<double> vToFCellWidth;
225  vToFCellWidth.reserve(8);
226  for (int i = 0; i < 8; i++) {
227  vToFCellWidth.push_back(fToFCellWidth[i]);
228  }
229  CTPPSToFDetector* ToFDet = new CTPPSToFDetector(
230  fToFNCellX, fToFNCellY, vToFCellWidth, fToFCellHeight, fToFPitchX, fToFPitchY, pos_tof, fTimeSigma);
231  cellId = ToFDet->findCellId(x_tof, y_tof);
232  if (cellId > 0) {
233  double xc_tof = 0., yc_tof = 0.;
234  ToFDet->get_CellCenter(cellId, xc_tof, yc_tof);
235  Local3DPoint xyzzy = Local3DPoint(xc_tof, yc_tof, simHit->entryPoint().z());
236  rechit.setLocal3DPoint(xyzzy);
237  rechit.setTof(tof);
238  rechit.setDetUnitId(detlayerId);
239  rechit.setCellId(cellId);
240  theCTPPSFastRecHit.push_back(rechit);
241  }
242  }
243  }
244 
245  std::unique_ptr<CTPPSFastRecHitContainer> output_recHits(new edm::CTPPSFastRecHitContainer);
246  output_recHits->reserve(simHits->size());
247 
248  int n = 0;
249  for (std::vector<CTPPSFastRecHit>::const_iterator i = theCTPPSFastRecHit.begin(); i != theCTPPSFastRecHit.end();
250  i++) {
251  output_recHits->push_back(*i);
252  n += 1;
253  }
254 
255  iEvent.put(std::move(output_recHits), "CTPPSFastRecHits");
256 }
bool get_CellCenter(int cell_id, double &x, double &y)
edm::EDGetTokenT< CrossingFrame< PSimHit > > cf_token
int findCellId(double x, double y)
std::vector< CTPPSFastRecHit > CTPPSFastRecHitContainer
T const * product() const
Definition: Handle.h:70
void setTof(float tof)
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
int iEvent
Definition: GenABIO.cc:224
void setCellId(unsigned int cellId)
void setDetUnitId(unsigned int detId)
static const double um_to_mm
std::vector< double > fToFCellWidth
HLT enums.
void setLocal3DPoint(const Local3DPoint &entry)
def move(src, dest)
Definition: eostools.py:511
Point3DBase< float, LocalTag > Local3DPoint
Definition: LocalPoint.h:9

Member Data Documentation

◆ cf_token

edm::EDGetTokenT<CrossingFrame<PSimHit> > CTPPSRecHitProducer::cf_token
private

Definition at line 83 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

◆ fBeamXRMS_ToF

double CTPPSRecHitProducer::fBeamXRMS_ToF
private

Definition at line 90 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

◆ fBeamXRMS_Trk1

double CTPPSRecHitProducer::fBeamXRMS_Trk1
private

Definition at line 85 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

◆ fBeamXRMS_Trk2

double CTPPSRecHitProducer::fBeamXRMS_Trk2
private

Definition at line 85 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

◆ fHitSigmaX

double CTPPSRecHitProducer::fHitSigmaX
private

Definition at line 86 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

◆ fHitSigmaY

double CTPPSRecHitProducer::fHitSigmaY
private

Definition at line 86 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

◆ fHitSigmaZ

double CTPPSRecHitProducer::fHitSigmaZ
private

Definition at line 86 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer().

◆ fTimeSigma

double CTPPSRecHitProducer::fTimeSigma
private

Definition at line 90 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

◆ fToFCellHeight

double CTPPSRecHitProducer::fToFCellHeight
private

Definition at line 88 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

◆ fToFCellWidth

std::vector<double> CTPPSRecHitProducer::fToFCellWidth
private

Definition at line 87 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

◆ fToFInsertion

double CTPPSRecHitProducer::fToFInsertion
private

Definition at line 90 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

◆ fToFNCellX

int CTPPSRecHitProducer::fToFNCellX
private

Definition at line 89 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

◆ fToFNCellY

int CTPPSRecHitProducer::fToFNCellY
private

Definition at line 89 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

◆ fToFPitchX

double CTPPSRecHitProducer::fToFPitchX
private

Definition at line 88 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

◆ fToFPitchY

double CTPPSRecHitProducer::fToFPitchY
private

Definition at line 88 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

◆ fToFXOffset

double CTPPSRecHitProducer::fToFXOffset
private

Definition at line 90 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

◆ fTrackerHeight

double CTPPSRecHitProducer::fTrackerHeight
private

Definition at line 85 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

◆ fTrackerInsertion

double CTPPSRecHitProducer::fTrackerInsertion
private

Definition at line 85 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

◆ fTrackerWidth

double CTPPSRecHitProducer::fTrackerWidth
private

Definition at line 85 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

◆ fTrk1XOffset

double CTPPSRecHitProducer::fTrk1XOffset
private

Definition at line 85 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

◆ fTrk2XOffset

double CTPPSRecHitProducer::fTrk2XOffset
private

Definition at line 85 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().