CMS 3D CMS Logo

Public Member Functions | Private Attributes

GEMSynchronizer Class Reference

#include <GEMSynchronizer.h>

List of all members.

Public Member Functions

 GEMSynchronizer (const edm::ParameterSet &config)
GEMSimSetUpgetGEMSimSetUp ()
int getSimHitBx (const PSimHit *)
void setGEMSimSetUp (GEMSimSetUp *simsetup)
void setRandomEngine (CLHEP::HepRandomEngine &eng)
 ~GEMSynchronizer ()

Private Attributes

double averageShapingTime_
double bxwidth_
bool cosmics_
CLHEP::RandGaussQ * gauss1_
CLHEP::RandGaussQ * gauss2_
int minBunch_
double signalPropagationSpeed_
GEMSimSetUpsimSetUp_
double timeJitter_
double timeResolution_

Detailed Description

Class for the GEM strip response simulation based on a parametrized model

Author:
Vadim Khotilovich

Definition at line 24 of file GEMSynchronizer.h.


Constructor & Destructor Documentation

GEMSynchronizer::GEMSynchronizer ( const edm::ParameterSet config)

Definition at line 19 of file GEMSynchronizer.cc.

References averageShapingTime_, bxwidth_, cosmics_, alignCSCRings::e, edm::ParameterSet::getParameter(), signalPropagationSpeed_, timeJitter_, and timeResolution_.

                                                             :
  gauss1_(0), gauss2_(0)
{
  timeResolution_ = config.getParameter<double>("timeResolution");
  averageShapingTime_ = config.getParameter<double>("averageShapingTime");
  timeJitter_ = config.getParameter<double>("timeJitter");
  signalPropagationSpeed_ = config.getParameter<double>("signalPropagationSpeed");
  cosmics_ = config.getParameter<bool>("cosmics");
  bxwidth_ = config.getParameter<double>("bxwidth");

  // signal propagation speed in vacuum in [m/s]
  const double cspeed = 299792458;
  // signal propagation speed in material in [cm/ns]
  signalPropagationSpeed_ = signalPropagationSpeed_ * cspeed * 1e+2 * 1e-9;
}
GEMSynchronizer::~GEMSynchronizer ( )

Definition at line 43 of file GEMSynchronizer.cc.

References gauss1_, and gauss2_.

{
  if (gauss1_) delete gauss1_;
  if (gauss2_) delete gauss2_;
}

Member Function Documentation

GEMSimSetUp* GEMSynchronizer::getGEMSimSetUp ( ) [inline]

Definition at line 36 of file GEMSynchronizer.h.

References simSetUp_.

Referenced by getSimHitBx().

{ return simSetUp_; }
int GEMSynchronizer::getSimHitBx ( const PSimHit simhit)

Definition at line 50 of file GEMSynchronizer.cc.

References averageShapingTime_, bxwidth_, cosmics_, gather_cfg::cout, debug, GEMGeometry::dets(), PSimHit::detUnitId(), Exception, gauss1_, gauss2_, geometry, getGEMSimSetUp(), GEMSimSetUp::getGeometry(), GEMSimSetUp::getTime(), GEMEtaPartition::id(), PSimHit::localPosition(), signalPropagationSpeed_, timeJitter_, PSimHit::timeOfFlight(), timeResolution_, and PV3DBase< T, PVType, FrameType >::y().

Referenced by GEMSimAverage::simulate().

{
  GEMSimSetUp* simsetup = getGEMSimSetUp();
  const GEMGeometry * geometry = simsetup->getGeometry();
  // calibration offset for a particular detector part
  float calibrationTime = simsetup->getTime(simhit->detUnitId());

  int bx = -999;
  LocalPoint simHitPos = simhit->localPosition();
  float tof = simhit->timeOfFlight();
  // random Gaussian time correction due to electronics jitter
  float randomJitterTime = gauss1_->fire(0., timeJitter_);
  
  GEMDetId shdetid(simhit->detUnitId());

  const GEMEtaPartition* shRoll = 0;

  for(const auto &det: geometry->dets())
  {
    if( dynamic_cast< GEMEtaPartition* >( det ) != 0 )
    {
      GEMEtaPartition* roll = dynamic_cast< GEMEtaPartition* >( det );

      if(roll->id() == shdetid)
      {
        shRoll = roll;
        break;
      }
    }
  }

  if(shRoll != 0)
  {
    float distanceFromEdge = 0;
    float halfStripLength = 0.;

    if(shRoll->id().region() == 0)
    {
      throw cms::Exception("Geometry")
        << "GEMSynchronizer::getSimHitBx() - this GEM id is from barrel, which cannot happen:  "<<shRoll->id()<< "\n";
    }
    else
    {
      const TrapezoidalStripTopology* top = dynamic_cast<const TrapezoidalStripTopology*> (&(shRoll->topology()));
      halfStripLength = 0.5 * top->stripLength();
      distanceFromEdge = halfStripLength - simHitPos.y();
    }
    
    // average time for the signal to propagate from the SimHit to the top of a strip
    float averagePropagationTime =  distanceFromEdge/signalPropagationSpeed_;
    // random Gaussian time correction due to the finite timing resolution of the detector
    float randomResolutionTime = gauss2_->fire(0., timeResolution_);

    float simhitTime = tof + (averageShapingTime_ + randomResolutionTime) + (averagePropagationTime + randomJitterTime);
    float referenceTime = calibrationTime + halfStripLength/signalPropagationSpeed_ + averageShapingTime_;
    float timeDifference = cosmics_ ? (simhitTime - referenceTime)/COSMIC_PAR : simhitTime - referenceTime;

    // assign the bunch crossing
    bx = static_cast<int>( std::round((timeDifference)/bxwidth_) );

    // check time
    const bool debug( false );
    if (debug)
      {
        std::cout<<"checktime "<<bx<<" "<<timeDifference<<" "<<simhitTime<<" "<<referenceTime<<" "<<tof<<" "<<averagePropagationTime<<std::endl;
      }
  }
  return bx;
}
void GEMSynchronizer::setGEMSimSetUp ( GEMSimSetUp simsetup) [inline]

Definition at line 34 of file GEMSynchronizer.h.

References simSetUp_.

Referenced by GEMSimAverage::simulate().

{ simSetUp_ = simsetup; }
void GEMSynchronizer::setRandomEngine ( CLHEP::HepRandomEngine &  eng)

Definition at line 36 of file GEMSynchronizer.cc.

References gauss1_, and gauss2_.

Referenced by GEMSimTriv::setRandomEngine(), and GEMSimAverage::setRandomEngine().

{
  gauss1_ = new CLHEP::RandGaussQ(eng);
  gauss2_ = new CLHEP::RandGaussQ(eng);
}

Member Data Documentation

Definition at line 43 of file GEMSynchronizer.h.

Referenced by GEMSynchronizer(), and getSimHitBx().

double GEMSynchronizer::bxwidth_ [private]

Definition at line 47 of file GEMSynchronizer.h.

Referenced by GEMSynchronizer(), and getSimHitBx().

bool GEMSynchronizer::cosmics_ [private]

Definition at line 46 of file GEMSynchronizer.h.

Referenced by GEMSynchronizer(), and getSimHitBx().

CLHEP::RandGaussQ* GEMSynchronizer::gauss1_ [private]

Definition at line 50 of file GEMSynchronizer.h.

Referenced by getSimHitBx(), setRandomEngine(), and ~GEMSynchronizer().

CLHEP::RandGaussQ* GEMSynchronizer::gauss2_ [private]

Definition at line 51 of file GEMSynchronizer.h.

Referenced by getSimHitBx(), setRandomEngine(), and ~GEMSynchronizer().

Definition at line 48 of file GEMSynchronizer.h.

Definition at line 45 of file GEMSynchronizer.h.

Referenced by GEMSynchronizer(), and getSimHitBx().

Definition at line 53 of file GEMSynchronizer.h.

Referenced by getGEMSimSetUp(), and setGEMSimSetUp().

double GEMSynchronizer::timeJitter_ [private]

Definition at line 44 of file GEMSynchronizer.h.

Referenced by GEMSynchronizer(), and getSimHitBx().

Definition at line 42 of file GEMSynchronizer.h.

Referenced by GEMSynchronizer(), and getSimHitBx().