Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // Very basic test of CSCGasCollisions
0002 // Updated Mar-2015 now CSCGasCollisions has a dump flag.
0003 // This runs despite error messages from CSCGasCollisions
0004 // due to lack of real ParticleDataTable. (It doesn't matter
0005 // because CSCGasCollisions continues to run assuming muon mass
0006 // if table is bad or particle type does not exist in it.)
0007 
0008 #include "CLHEP/Random/JamesRandom.h"
0009 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0010 #include "SimMuon/CSCDigitizer/src/CSCGasCollisions.h"
0011 #include <algorithm>
0012 #include <functional>
0013 #include <numeric>
0014 
0015 int main() {
0016   // Set up pset param explicitly required by CSCGasCollisions.
0017   // Note that it has no effect because this stand-alone program
0018   // does not activate MessageLogger which now controls output
0019   // in CSCGasCollisions.
0020   edm::ParameterSet pset;
0021   pset.addUntrackedParameter<bool>("dumpGasCollisions", false);
0022   pset.registerIt();
0023 
0024   CSCGasCollisions collisions(pset);
0025 
0026   ParticleDataTable dummyTable;
0027   // let the code assume a muon
0028   collisions.setParticleDataTable(&dummyTable);
0029 
0030   CLHEP::HepJamesRandom engine;
0031 
0032   PSimHit simHit(
0033       LocalPoint(0., 0., -0.5), LocalPoint(0., 0., 0.5), 4., 0., 0.000005, 13, CSCDetId(1, 1, 1, 1, 1), 0, 0., 0., 0);
0034 
0035   /*
0036   PSimHit( const Local3DPoint& entry, const Local3DPoint& exit,
0037            float pabs, float tof, float eloss, int particleType,
0038            unsigned int detId, unsigned int trackId,
0039            float theta, float phi, unsigned short processType=0) :
0040   */
0041 
0042   int n = 100;
0043   int sumElectrons = 0;
0044   int sumClusters = 0;
0045   for (int i = 0; i < n; ++i) {
0046     std::vector<LocalPoint> clusters;
0047     std::vector<int> electrons;
0048     collisions.simulate(simHit, clusters, electrons, &engine);
0049 
0050     sumElectrons += std::accumulate(electrons.begin(), electrons.end(), 0);
0051     sumClusters += clusters.size();
0052   }
0053 
0054   std::cout << "Clusters: " << sumClusters / n << "  electrons: " << sumElectrons / n << std::endl;
0055   return 0;
0056 }