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
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 68 of file CTPPSRecHitProducer.cc.

Member Typedef Documentation

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

Definition at line 79 of file CTPPSRecHitProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 96 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(), and AlCaHLTBitMon_QueryRunRegistry::string.

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

Definition at line 139 of file CTPPSRecHitProducer.cc.

140 {
141 
142 }

Member Function Documentation

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

Definition at line 272 of file CTPPSRecHitProducer.cc.

273 {
274 }
void CTPPSRecHitProducer::endStream ( )
overrideprivate

Definition at line 278 of file CTPPSRecHitProducer.cc.

References DEFINE_FWK_MODULE.

278  {
279 }
void CTPPSRecHitProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 146 of file CTPPSRecHitProducer.cc.

References cf_token, PSimHit::detUnitId(), PSimHit::entryPoint(), 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::Event::getByToken(), edm::RandomNumberGenerator::getEngine(), mps_fire::i, eostools::move(), gen::n, edm::Handle< T >::product(), edm::Event::put(), CTPPSFastRecHit::setCellId(), CTPPSFastRecHit::setDetUnitId(), CTPPSFastRecHit::setLocal3DPoint(), CTPPSFastRecHit::setTof(), rpcPointValidation_cfi::simHit, trackerHits::simHits, edm::Event::streamID(), protons_cff::t, PSimHit::tof(), um_to_mm, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

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

Member Data Documentation

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

Definition at line 84 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

double CTPPSRecHitProducer::fBeamXRMS_ToF
private

Definition at line 91 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

double CTPPSRecHitProducer::fBeamXRMS_Trk1
private

Definition at line 86 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

double CTPPSRecHitProducer::fBeamXRMS_Trk2
private

Definition at line 86 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

double CTPPSRecHitProducer::fHitSigmaX
private

Definition at line 87 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

double CTPPSRecHitProducer::fHitSigmaY
private

Definition at line 87 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

double CTPPSRecHitProducer::fHitSigmaZ
private

Definition at line 87 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer().

double CTPPSRecHitProducer::fTimeSigma
private

Definition at line 91 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

double CTPPSRecHitProducer::fToFCellHeight
private

Definition at line 89 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

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

Definition at line 88 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

double CTPPSRecHitProducer::fToFInsertion
private

Definition at line 91 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

int CTPPSRecHitProducer::fToFNCellX
private

Definition at line 90 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

int CTPPSRecHitProducer::fToFNCellY
private

Definition at line 90 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

double CTPPSRecHitProducer::fToFPitchX
private

Definition at line 89 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

double CTPPSRecHitProducer::fToFPitchY
private

Definition at line 89 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

double CTPPSRecHitProducer::fToFXOffset
private

Definition at line 91 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

double CTPPSRecHitProducer::fTrackerHeight
private

Definition at line 86 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

double CTPPSRecHitProducer::fTrackerInsertion
private

Definition at line 86 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

double CTPPSRecHitProducer::fTrackerWidth
private

Definition at line 86 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

double CTPPSRecHitProducer::fTrk1XOffset
private

Definition at line 86 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().

double CTPPSRecHitProducer::fTrk2XOffset
private

Definition at line 86 of file CTPPSRecHitProducer.cc.

Referenced by CTPPSRecHitProducer(), and produce().