Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:30:14

0001 /*
0002  *  \author G. Bevilacqua, N. Amapane - INFN Torino
0003  */
0004 
0005 #include "Utils.h"
0006 
0007 #include "DTTime2DriftParametrization.h"
0008 #include "SimMuon/DTDigitizer/src/DTDriftTimeParametrization.h"
0009 
0010 #include <CLHEP/Random/RandFlat.h>
0011 #include <CLHEP/Random/RandGaussQ.h>
0012 #include <cmath>
0013 
0014 void *driftTime(double x, double theta, double bWire, double bNorm, short interpolate) {
0015   static DTDriftTimeParametrization::drift_time DT;
0016 
0017   // Convert coordinates...
0018   x *= 10.;  // cm->mm
0019   double by_par = bNorm;
0020   double bz_par = -bWire;
0021 
0022   DTDriftTimeParametrization param;
0023 
0024   //  unsigned short flag =
0025   param.MB_DT_drift_time(x, theta, by_par, bz_par, 0, &DT, interpolate);
0026   return &DT;
0027 }
0028 
0029 void *trackDistance(double t, double theta, double bWire, double bNorm, short interpolate) {
0030   static DTTime2DriftParametrization::drift_distance DX;
0031 
0032   // Convert coordinates...
0033   double by_par = bNorm;
0034   double bz_par = -bWire;
0035 
0036   DTTime2DriftParametrization param;
0037 
0038   // unsigned short flag =
0039   param.MB_DT_drift_distance(t, theta, by_par, bz_par, &DX, interpolate);
0040   return &DX;
0041 }
0042 
0043 double smearedTime(double x, double theta, double Bwire, double Bnorm, short interpolate) {
0044   DTDriftTimeParametrization::drift_time *DT;
0045   DT = (DTDriftTimeParametrization::drift_time *)driftTime(x, theta, Bwire, Bnorm, interpolate);
0046   return asymGausSample(DT->t_drift, DT->t_width_m, DT->t_width_p);
0047 }
0048 
0049 double asymGausSample(double mean, double sigma1, double sigma2) {
0050   double f = sigma1 / (sigma1 + sigma2);
0051   double t;
0052 
0053   if (CLHEP::RandFlat::shoot() <= f) {
0054     t = CLHEP::RandGaussQ::shoot(mean, sigma1);
0055     return mean - fabs(t - mean);
0056   } else {
0057     t = CLHEP::RandGaussQ::shoot(mean, sigma2);
0058     return mean + fabs(t - mean);
0059   }
0060 }
0061 
0062 #include <iomanip>
0063 #include <sstream>
0064 #include <string>
0065 
0066 #include <iostream>
0067 
0068 TString dToTString(double f, int precision) {
0069   std::stringstream StrStm;
0070   std::string Str;
0071 
0072   StrStm << std::setprecision(precision);  // (Actually the default is 6);
0073   StrStm << f;
0074   Str = StrStm.str();
0075   TString tStr(Str.c_str());
0076   return tStr;
0077 }