Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:48:25

0001 /// -*- C++ -*-
0002 ///
0003 /// Package:    GeneratorInterface/GenFilters
0004 /// \class      CosmicGenFilterHelix
0005 ///
0006 /// Description:
0007 ///     Event filter for generated particles reaching a certain cylinder surface (around z-axis).
0008 ///
0009 /// Implementation:
0010 ///     Assumes particles coming from outside of defined cylinder, but might work also otherwise.
0011 ///     Uses SteppingHelixPropagator and IdealMagneticFieldRecord.
0012 ///
0013 ///
0014 /// Original Author:  Gero FLUCKE
0015 ///     Created:  Mon Mar  5 16:32:01 CET 2007
0016 ///
0017 
0018 #include "FWCore/Framework/interface/one/EDFilter.h"
0019 #include "FWCore/Framework/interface/EventSetup.h"
0020 #include "FWCore/Framework/interface/Event.h"
0021 
0022 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0023 #include "FWCore/Utilities/interface/EDGetToken.h"
0024 
0025 #include "DataFormats/GeometrySurface/interface/Plane.h"
0026 #include "DataFormats/GeometrySurface/interface/Cylinder.h"
0027 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0028 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
0029 
0030 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
0031 
0032 #include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
0033 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0034 
0035 #include <TObjArray.h>
0036 
0037 #include <vector>
0038 
0039 class MagneticField;
0040 class Propagator;
0041 
0042 class CosmicGenFilterHelix : public edm::one::EDFilter<edm::one::SharedResources> {
0043 public:
0044   explicit CosmicGenFilterHelix(const edm::ParameterSet &config);
0045   ~CosmicGenFilterHelix() override;
0046 
0047   void beginJob() override;
0048   bool filter(edm::Event &event, const edm::EventSetup &eventSetup) override;
0049   void endJob() override;
0050 
0051 private:
0052   /// actually propagate to the defined cylinder
0053   bool propagateToCutCylinder(const GlobalPoint &vertStart,
0054                               const GlobalVector &momStart,
0055                               int charge,
0056                               const MagneticField *field,
0057                               const Propagator *propagator);  //non-const: monitorEnd
0058   /// true if ID selected, return by value its charge
0059   bool charge(int id, int &charge) const;
0060   /// provide magnetic field from Event Setup
0061   const MagneticField *getMagneticField(const edm::EventSetup &setup) const;
0062   const Propagator *getPropagator(const edm::EventSetup &setup) const;
0063   // ----------member data ---------------------------
0064 
0065   const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> theMFToken;
0066   const edm::ESGetToken<Propagator, TrackingComponentsRecord> thePropToken;
0067 
0068   edm::EDGetTokenT<edm::HepMCProduct> theSrcToken;
0069   const std::vector<int> theIds;      /// requested Ids
0070   const std::vector<int> theCharges;  /// charges, parallel to theIds
0071   const double theMinP2;              /// minimal momentum^2 after propagation to cylinder
0072   const double theMinPt2;             /// minimal transverse^2 momentum after propagation to cylinder
0073 
0074   Cylinder::ConstCylinderPointer theTargetCylinder;  /// target cylinder, around z-axis
0075   Plane::ConstPlanePointer theTargetPlaneMin;        /// plane closing cylinder at 'negative' side
0076   Plane::ConstPlanePointer theTargetPlaneMax;        /// plane closing cylinder at 'positive' side
0077 
0078   unsigned int theNumTotal;  /// for final statistics: all seen events
0079   unsigned int theNumPass;   /// for final statistics: events with track reaching target
0080 
0081   // for monitoring:
0082   void createHistsStart(const char *dirName, TObjArray &hists);
0083   void createHistsEnd(const char *dirName, TObjArray &hists);
0084   void monitorStart(const GlobalPoint &vert, const GlobalVector &mom, int charge, TObjArray &hists);
0085   void monitorEnd(const GlobalPoint &endVert,
0086                   const GlobalVector &endMom,
0087                   const GlobalPoint &vert,
0088                   const GlobalVector &mom,
0089                   double path,
0090                   TObjArray &hists);
0091   bool equidistLogBins(double *bins, int nBins, double first, double last) const;
0092   const bool theDoMonitor;   /// whether or not to fill monitor hists (needs TFileService)
0093   TObjArray theHistsBefore;  /// hists of properties from generator
0094   TObjArray theHistsAfter;   /// hists after successfull propagation
0095 };