Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:26:40

0001 #ifndef FastSimulation_MaterialEffects_NuclearInteractionSimulator_H
0002 #define FastSimulation_MaterialEffects_NuclearInteractionSimulator_H
0003 
0004 /** 
0005  * This class computes the probability for hadrons to interact with a 
0006  * nucleon of the tracker material (inelastically) and then reads a 
0007  * nuclear interaction randomly from multiple fully simulated files 
0008  * The fraction of interaction lengths traversed by the particle in this 
0009  * tracker layer is determined in MaterialEffectsSimulator as a fraction 
0010  * the radiation lengths. 
0011  *
0012  * \author Patrick Janot
0013  * $Date: 25-Jan-2007
0014  */
0015 
0016 #include "FastSimulation/MaterialEffects/interface/MaterialEffectsSimulator.h"
0017 #include "DQMServices/Core/interface/DQMStore.h"
0018 
0019 #include <vector>
0020 #include <map>
0021 #include <string>
0022 #include <fstream>
0023 
0024 class TFile;
0025 class TTree;
0026 class TBranch;
0027 class NUEvent;
0028 
0029 class ParticlePropagator;
0030 class RandomEngineAndDistribution;
0031 //class DaqMonitorBEInterface;
0032 
0033 class NuclearInteractionSimulator : public MaterialEffectsSimulator {
0034 public:
0035   /// Constructor
0036   NuclearInteractionSimulator(std::vector<double>& hadronEnergies,
0037                               std::vector<int>& hadronTypes,
0038                               std::vector<std::string>& hadronNames,
0039                               std::vector<double>& hadronMasses,
0040                               std::vector<double>& hadronPMin,
0041                               double pionEnergy,
0042                               std::vector<double>& lengthRatio,
0043                               std::vector<std::vector<double> >& ratios,
0044                               std::map<int, int>& idMap,
0045                               std::string inputFile,
0046                               unsigned int distAlgo,
0047                               double distCut);
0048 
0049   /// Default Destructor
0050   ~NuclearInteractionSimulator() override;
0051 
0052   /// Save current nuclear interaction (for later use)
0053   void save() override;
0054 
0055   /// Read former nuclear interaction (from previous run)
0056   bool read(std::string inputFile);
0057 
0058 private:
0059   /// Generate a nuclear interaction according to the probability that it happens
0060   void compute(ParticlePropagator& Particle, RandomEngineAndDistribution const*) override;
0061 
0062   /// Compute distance between secondary and primary
0063   double distanceToPrimary(const RawParticle& Particle, const RawParticle& aDaughter) const;
0064 
0065   /// Return a hashed index for a given pid
0066   unsigned index(int thePid);
0067 
0068   std::vector<double> thePionEN;
0069   std::vector<int> thePionID;
0070   std::vector<std::string> thePionNA;
0071   std::vector<double> thePionMA;
0072   std::vector<double> thePionPMin;
0073   double thePionEnergy;
0074   std::vector<double> theLengthRatio;
0075   std::vector<std::vector<double> > theRatios;
0076 
0077   TFile* theFile;
0078   std::vector<std::vector<TTree*> > theTrees;
0079   std::vector<std::vector<TBranch*> > theBranches;
0080   std::vector<std::vector<NUEvent*> > theNUEvents;
0081   std::vector<std::vector<unsigned> > theCurrentEntry;
0082   std::vector<std::vector<unsigned> > theCurrentInteraction;
0083   std::vector<std::vector<unsigned> > theNumberOfEntries;
0084   std::vector<std::vector<unsigned> > theNumberOfInteractions;
0085   std::vector<std::vector<std::string> > theFileNames;
0086   std::vector<std::vector<double> > thePionCM;
0087 
0088   std::map<int, int> theIDMap;
0089   unsigned ien4;
0090   unsigned theDistAlgo;
0091   double theDistCut;
0092 
0093   std::ofstream myOutputFile;
0094   unsigned myOutputBuffer;
0095 
0096   bool currentValuesWereSet;
0097 
0098   //  DaqMonitorBEInterface * dbe;
0099   //  MonitorElement* hAfter;
0100   //  MonitorElement* hAfter2;
0101   //  MonitorElement* hAfter3;
0102   //  MonitorElement* htot;
0103   //  MonitorElement* helas;
0104   //  MonitorElement* hinel;
0105   //  MonitorElement* hscatter;
0106   //  MonitorElement* hscatter2;
0107 };
0108 #endif