Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:31

0001 #ifndef GlobalPointProvider_h
0002 #define GlobalPointProvider_h
0003 
0004 /** \class GlobalPointProvider
0005  *
0006  *  No description available.
0007  *
0008  *  \author N. Amapane - CERN
0009  */
0010 
0011 #include <CLHEP/Random/RandFlat.h>
0012 #include "DataFormats/GeometryVector/interface/Pi.h"
0013 
0014 #include <string>
0015 
0016 class GlobalPointProvider {
0017 public:
0018   GlobalPointProvider(double minR, double maxR, double minPhi, double maxPhi, double minZ, double maxZ)
0019       : theMinR(minR), theMaxR(maxR), theMinPhi(minPhi), theMaxPhi(maxPhi), theMinZ(minZ), theMaxZ(maxZ) {}
0020 
0021   GlobalPointProvider(bool zSymmetric = true, bool barrelOnly = false) {
0022     theMinR = 0.;
0023     theMaxR = 1000.;
0024     theMinPhi = -Geom::pi();
0025     theMaxPhi = Geom::pi();
0026     theMinZ = -1600;
0027     theMaxZ = 1600;
0028 
0029     if (barrelOnly) {
0030       theMinZ = -662.;
0031       theMaxZ = 662.;
0032     }
0033     if (zSymmetric)
0034       theMaxZ = 0.;
0035   }
0036 
0037   GlobalPoint getPoint() {
0038     //Turn
0039     double R = CLHEP::RandFlat::shoot(theMinR, theMaxR);
0040     double Z = CLHEP::RandFlat::shoot(theMinZ, theMaxZ);
0041     double phi = CLHEP::RandFlat::shoot(theMinPhi, theMaxPhi);
0042 
0043     GlobalPoint gp(GlobalPoint::Cylindrical(R, phi, Z));
0044 
0045     // if not in barrel, retry
0046     //    if (barrelOnly && !(theGeometry->inBarrel(gp))) gp=getPoint();
0047 
0048     return gp;
0049   }
0050 
0051 private:
0052   double theMinR;
0053   double theMaxR;
0054   double theMinPhi;
0055   double theMaxPhi;
0056   double theMinZ;
0057   double theMaxZ;
0058 };
0059 
0060 #endif