1 #ifndef SimMuon_GEMDigitizer_ME0ReDigiProducer_h 2 #define SimMuon_GEMDigitizer_ME0ReDigiProducer_h 29 #include "CLHEP/Random/RandGaussQ.h" 30 #include "CLHEP/Random/RandFlat.h" 31 #include "CLHEP/Units/PhysicalConstants.h" 67 std::vector<std::vector<double>>
tofs;
83 CLHEP::HepRandomEngine* engine);
100 typedef std::tuple<unsigned int, unsigned int, unsigned int>
DigiIndicies;
104 ChamberDigiMap& chDigiMap,
unsigned int bx,
unsigned int part,
unsigned int strip,
unsigned int currentIDX)
const;
123 std::vector<std::vector<double>>
tofs;
133 <<
"ME0ReDigiProducer::TemporaryGeometry::TemporaryGeometry() - No ME0Chambers in geometry.";
134 const auto* mainChamber =
chambers.front();
138 <<
"ME0ReDigiProducer::TemporaryGeometry::TemporaryGeometry() - ME0Chamber has no layers.";
139 const auto* mainLayer = mainChamber->layers()[0];
140 if (!mainLayer->nEtaPartitions())
142 <<
"ME0ReDigiProducer::TemporaryGeometry::TemporaryGeometry() - ME0Layer has no partitions.";
143 if (mainLayer->nEtaPartitions() != 1)
144 throw cms::Exception(
"Setup") <<
"ME0ReDigiProducer::TemporaryGeometry::TemporaryGeometry() - This module is only " 145 "compatitble with geometries that contain only one partition per ME0Layer.";
147 const auto* mainPartition = mainLayer->etaPartitions()[0];
150 throw cms::Exception(
"Setup") <<
"ME0ReDigiProducer::TemporaryGeometry::TemporaryGeometry() - ME0 strip topology " 151 "must be of type TrapezoidalStripTopology. This module cannot be used";
155 throw cms::Exception(
"Setup") <<
"ME0ReDigiProducer::TemporaryGeometry::TemporaryGeometry() - Not all " 156 "ME0Chambers have the same number of layers. This module cannot be used.";
157 for (
unsigned int iL = 0; iL <
nLayers; ++iL) {
158 if (
chamber->layers()[iL]->nEtaPartitions() != mainLayer->nEtaPartitions())
159 throw cms::Exception(
"Setup") <<
"ME0ReDigiProducer::TemporaryGeometry::TemporaryGeometry() - Not all " 160 "ME0Layers have the same number of partitions. This module cannot be used.";
161 if (
chamber->layers()[iL]->etaPartitions()[0]->specs()->parameters() != mainPartition->specs()->parameters())
162 throw cms::Exception(
"Setup") <<
"ME0ReDigiProducer::TemporaryGeometry::TemporaryGeometry() - Not all ME0 ETA " 163 "partitions have the same properties. This module cannot be used.";
164 if (std::fabs(
chamber->layers()[iL]->etaPartitions()[0]->position().z()) !=
165 std::fabs(mainChamber->layers()[iL]->etaPartitions()[0]->position().z()))
167 <<
"ME0ReDigiProducer::TemporaryGeometry::TemporaryGeometry() - Not all ME0 ETA partitions in a single " 168 "layer have the same Z position. This module cannot be used.";
178 const auto globalTop = mainPartition->toGlobal(localTop);
179 const auto globalBottom = mainPartition->toGlobal(localBottom);
180 const double etaTop = globalTop.
eta();
181 const double etaBottom = globalBottom.eta();
182 const double zBottom = globalBottom.z();
187 const auto& mainPars = mainPartition->specs()->parameters();
189 const double eta = (etaTop - etaBottom) *
double(iP + 1) / double(numberOfPartitions) + etaBottom;
190 const double distFromBeam = std::fabs(zBottom / std::sinh(eta));
192 LogDebug(
"ME0ReDigiProducer::TemporaryGeometry") <<
"Top of new partition: " <<
partitionTops.back() << std::endl;
194 std::vector<float>
params(4, 0);
197 auto getWidth = [&](
float locY) ->
float {
198 return (mainPars[2] * (mainPars[1] + mainPars[0]) + locY * (mainPars[1] - mainPars[0])) / (2 * mainPars[2]);
201 params[0] = iP == 0 ? mainPars[0] : getWidth(
partitionTops[iP - 1]);
203 iP + 1 == numberOfPartitions ? mainPars[1] : getWidth(
partitionTops[iP]);
204 params[2] = ((iP + 1 == numberOfPartitions ? localTop.y() :
partitionTops[iP]) -
213 tofs.resize(nLayers);
214 LogDebug(
"ME0ReDigiProducer::TemporaryGeometry") <<
"TOF numbers [layer][partition]: ";
215 for (
unsigned int iL = 0; iL <
nLayers; ++iL) {
216 tofs[iL].resize(numberOfPartitions);
219 const GlobalPoint centralGP(mainChamber->layers()[iL]->etaPartitions()[0]->toGlobal(partCenter));
220 tofs[iL][iP] = (centralGP.mag() / (CLHEP::c_light / CLHEP::cm));
221 LogDebug(
"ME0ReDigiProducer::TemporaryGeometry")
222 <<
"[" << iL <<
"][" << iP <<
"]=" << tofs[iL][iP] <<
" " << std::endl;
229 for (
unsigned int iP = 0; iP <
stripTopos.size(); ++iP) {
252 float r0 = h * (B +
b) / (B - b);
253 float striplength = h * 2;
255 float pitch = (b +
B) / strips;
256 int nstrip =
static_cast<int>(
strips);
258 LogDebug(
"ME0ReDigiProducer::TemporaryGeometry")
259 <<
"New partition parameters: " 260 <<
"bottom width(" << 2 * b <<
") top width(" << 2 * B <<
") height(" << 2 * h <<
") radius to center(" << r0
261 <<
") nStrips(" << strips <<
") pitch(" << pitch <<
")" << std::endl;
279 produces<ME0DigiPreRecoCollection>();
280 produces<ME0DigiPreRecoMap>();
283 if (!rng.isAvailable()) {
285 <<
"ME0ReDigiProducer::ME0PreRecoDigiProducer() - RandomNumberGeneratorService is not present in configuration " 287 <<
"Add the service in the configuration file or remove the modules that require it.";
298 <<
"ME0ReDigiProducer::ME0PreRecoDigiProducer() - Must have at least one strip if using custom geometry.";
301 <<
"ME0ReDigiProducer::ME0PreRecoDigiProducer() - Must have at least one partition if using custom geometry.";
305 throw cms::Exception(
"Setup") <<
"ME0ReDigiProducer::ME0PreRecoDigiProducer() - neutronAcceptance must be >= 0.";
321 throw cms::Exception(
"Setup") <<
"ME0ReDigiProducer::beginRun() - No ME0Chambers in geometry.";
325 throw cms::Exception(
"Setup") <<
"ME0ReDigiProducer::beginRun() - No layers in ME0 geometry.";
327 const unsigned int nPartitions =
chambers.front()->layers()[0]->nEtaPartitions();
336 <<
"ME0ReDigiProducer::beginRun() - The geometry has " << nLayers <<
" layers, but the readout of " 337 <<
layerReadout.size() <<
" were specified with the layerReadout parameter.";
340 LogDebug(
"ME0ReDigiProducer") <<
"Building temporary geometry:" << std::endl;
342 LogDebug(
"ME0ReDigiProducer") <<
"Done building temporary geometry!" << std::endl;
346 <<
"ME0ReDigiProducer::beginRun() - The geometry has " <<
tempGeo->
numLayers()
347 <<
" layers, but the readout of " <<
layerReadout.size()
348 <<
" were specified with the layerReadout parameter.";
373 CLHEP::HepRandomEngine* engine) {
388 LogDebug(
"ME0ReDigiProducer::buildDigis") <<
"Begin building digis." << std::endl;
390 for (me0dgIt = input_digis.begin(); me0dgIt != input_digis.end(); ++me0dgIt) {
391 const auto& me0Id = (*me0dgIt).first;
392 LogTrace(
"ME0ReDigiProducer::buildDigis") <<
"Starting with roll: " << me0Id << std::endl;
400 LogTrace(
"ME0ReDigiProducer::buildDigis") << std::endl
401 <<
"(" << digi->x() <<
"," << digi->y() <<
"," << digi->tof() <<
"," 402 << digi->pdgid() <<
"," << digi->prompt() <<
")-> ";
421 int mapPartIDX = me0Id.roll() - 1;
432 const int bxIdx = std::round(tof /
bxWidth);
433 LogTrace(
"ME0ReDigiProducer::buildDigis") << tof <<
"(" << bxIdx <<
") ";
445 LogTrace(
"ME0ReDigiProducer::buildDigis") <<
"(" << bxIdx <<
"," << mapPartIDX <<
"," << strip <<
") ";
447 int matchIDX =
fillDigiMap(chDigiMap, bxIdx, mapPartIDX, strip, newDigiIdx);
457 const float corrCoef = digiLocalError.
xy() / (sigmaX *
sigmaY);
461 digiLocalPoint.
x(), digiLocalPoint.
y(),
sigmaX,
sigmaY, corrCoef, tof, digi->pdgid(), digi->prompt());
462 output_digis.insertDigi(me0Id, out_digi);
468 LogTrace(
"ME0ReDigiProducer::buildDigis") <<
"(" << digiLocalPoint.
x() <<
"," << digiLocalPoint.
y() <<
"," 469 << sigmaX <<
"," << sigmaY <<
"," << tof <<
") ";
477 const auto* mainChamber =
geometry->chambers().front();
478 const unsigned int nLayers = mainChamber->nLayers();
481 tofs.resize(nLayers);
482 LogDebug(
"ME0ReDigiProducer::fillCentralTOFs()") <<
"TOF numbers [layer][partition]: ";
483 for (
unsigned int iL = 0; iL <
nLayers; ++iL) {
484 const auto* layer = mainChamber->layers()[iL];
485 const unsigned int mapLayIDX = layer->id().layer() - 1;
486 const unsigned int nPartitions = layer->nEtaPartitions();
488 throw cms::Exception(
"Setup") <<
"ME0ReDigiProducer::fillCentralTOFs() - ME0Layer has no partitions.";
489 tofs[mapLayIDX].resize(nPartitions);
490 for (
unsigned int iP = 0; iP < nPartitions; ++iP) {
491 const unsigned int mapPartIDX = layer->etaPartitions()[iP]->id().roll() - 1;
492 const GlobalPoint centralGP(layer->etaPartitions()[iP]->position());
493 tofs[mapLayIDX][mapPartIDX] = (centralGP.mag() / (CLHEP::c_light / CLHEP::cm));
494 LogDebug(
"ME0ReDigiProducer::fillCentralTOFs()")
495 <<
"[" << mapLayIDX <<
"][" << mapPartIDX <<
"]=" << tofs[mapLayIDX][mapPartIDX] <<
" " << std::endl;
506 LogTrace(
"ME0ReDigiProducer::buildDigis") << partIdx <<
" ";
517 const LocalPoint partLocalPoint(inDigi->
x(), inDigi->
y() - partCenter, 0.);
518 strip = topo->channel(partLocalPoint);
519 const float stripF =
float(strip) + 0.5;
522 LocalPoint digiPartLocalPoint = topo->localPosition(stripF);
523 digiLocalError = topo->localError(
528 digiLocalPoint =
LocalPoint(digiPartLocalPoint.
x(), digiPartLocalPoint.
y() + partCenter, 0.0);
546 const LocalPoint partLocalPoint(inDigi->
x(), inDigi->
y(), 0.);
547 strip = topo.channel(partLocalPoint);
548 const float stripF =
float(strip) + 0.5;
551 digiLocalPoint = topo.localPosition(stripF);
552 digiLocalError = topo.localError(stripF, 1. /
sqrt(12.));
558 auto it1 = chDigiMap.find(newIDX);
559 if (it1 == chDigiMap.end()) {
560 chDigiMap[newIDX] = currentIDX;
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
std::vector< std::vector< double > > tofs
const StripTopology & specificTopology() const
class Point3DBase< float, LocalTag > LocalPoint
static unsigned int partIdx(const InputGenJetsParticleSelector::ParticleVector &p, const reco::Candidate *particle)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
unsigned int numLayers() const
const ME0Geometry * geometry
int getCustomStripProperties(const ME0DetId &detId, const ME0DigiPreReco *inDigi, float &tof, int &strip, LocalPoint &digiLocalPoint, LocalError &digiLocalError) const
float getCentralTOF(const ME0DetId &me0Id, unsigned int partIdx) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
float middleDistanceFromBeam
edm::EDGetTokenT< ME0DigiPreRecoCollection > token
void buildDigis(const ME0DigiPreRecoCollection &, ME0DigiPreRecoCollection &, ME0DigiPreRecoMap &, CLHEP::HepRandomEngine *engine)
std::vector< int > layerReadout
~ME0ReDigiProducer() override
std::vector< float > partitionTops
void insertDigi(const IndexType &index, const DigiType &digi)
insert a digi for a given DetUnit
unsigned int fillDigiMap(ChamberDigiMap &chDigiMap, unsigned int bx, unsigned int part, unsigned int strip, unsigned int currentIDX) const
std::tuple< unsigned int, unsigned int, unsigned int > DigiIndicies
TemporaryGeometry(const ME0Geometry *geometry, const unsigned int numberOfStrips, const unsigned int numberOfPartitions)
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
TrapezoidalStripTopology * buildTopo(const std::vector< float > &_p) const
float pitch() const override
#define DEFINE_FWK_MODULE(type)
MuonDigiCollection< ME0DetId, ME0DigiPreReco > ME0DigiPreRecoCollection
const std::vector< const ME0Chamber * > & chambers() const
Return a vector of all ME0 chambers.
float stripLength() const override
det heigth (strip length in the middle)
static const std::string B
std::map< DigiIndicies, unsigned int > ChamberDigiMap
unsigned int findEtaPartition(float locY) const
float getPartCenter(const unsigned int partIdx) const
TemporaryGeometry * tempGeo
T const * product() const
unsigned int numberOfPartitions
bool useCusGeoFor1PartGeo
unsigned int numberOfStrips
std::pair< const_iterator, const_iterator > Range
std::vector< DigiType >::const_iterator const_iterator
MuonDigiCollection< ME0DetId, int > ME0DigiPreRecoMap
std::vector< TrapezoidalStripTopology * > stripTopos
ME0ReDigiProducer(const edm::ParameterSet &ps)
StreamID streamID() const
std::vector< std::vector< double > > tofs
strips
#turn off noise in all subdetectors simHcalUnsuppressedDigis.doNoise = False mix.digitizers.hcal.doNoise = False simEcalUnsuppressedDigis.doNoise = False mix.digitizers.ecal.doNoise = False simEcalUnsuppressedDigis.doESNoise = False simSiPixelDigis.AddNoise = False mix.digitizers.pixel.AddNoise = False simSiStripDigis.Noise = False mix.digitizers.strip.AddNoise = False
int layer() const
Layer id: each chamber has six layers of chambers: layer 1 is the inner layer and layer 6 is the oute...
static char chambers[264][20]
void produce(edm::Event &, const edm::EventSetup &) override
int nstrips() const override
const TrapezoidalStripTopology * getTopo(const unsigned int partIdx) const
void getStripProperties(const ME0EtaPartition *etaPart, const ME0DigiPreReco *inDigi, float &tof, int &strip, LocalPoint &digiLocalPoint, LocalError &digiLocalError) const
void beginRun(const edm::Run &, const edm::EventSetup &) override
A container for a generic type of digis indexed by some index, implemented with a map<IndexType...