CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
CosmicGenFilterHelix Class Reference

#include <CosmicGenFilterHelix.h>

Inheritance diagram for CosmicGenFilterHelix:
edm::EDFilter edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginJob ()
 
 CosmicGenFilterHelix (const edm::ParameterSet &config)
 
virtual void endJob ()
 
virtual bool filter (edm::Event &event, const edm::EventSetup &eventSetup)
 
virtual ~CosmicGenFilterHelix ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

bool charge (int id, int &charge) const
 true if ID selected, return by value its charge More...
 
void createHistsEnd (const char *dirName, TObjArray &hists)
 
void createHistsStart (const char *dirName, TObjArray &hists)
 for final statistics: events with track reaching target More...
 
bool equidistLogBins (double *bins, int nBins, double first, double last) const
 
const MagneticFieldgetMagneticField (const edm::EventSetup &setup) const
 provide magnetic field from Event Setup More...
 
const PropagatorgetPropagator (const edm::EventSetup &setup) const
 
void monitorEnd (const GlobalPoint &endVert, const GlobalVector &endMom, const GlobalPoint &vert, const GlobalVector &mom, double path, TObjArray &hists)
 
void monitorStart (const GlobalPoint &vert, const GlobalVector &mom, int charge, TObjArray &hists)
 
bool propagateToCutCylinder (const GlobalPoint &vertStart, const GlobalVector &momStart, int charge, const MagneticField *field, const Propagator *propagator)
 actually propagate to the defined cylinder More...
 

Private Attributes

const std::vector< int > theCharges
 requested Ids More...
 
const bool theDoMonitor
 
TObjArray theHistsAfter
 hists of properties from generator More...
 
TObjArray theHistsBefore
 whether or not to fill monitor hists (needs TFileService) More...
 
const std::vector< int > theIds
 
const double theMinP2
 
const double theMinPt2
 minimal momentum^2 after propagation to cylinder More...
 
unsigned int theNumPass
 for final statistics: all seen events More...
 
unsigned int theNumTotal
 plane closing cylinder at 'positive' side More...
 
const std::string thePropagatorName
 charges, parallel to theIds More...
 
edm::EDGetTokenT
< edm::HepMCProduct
theSrcToken
 
Cylinder::ConstCylinderPointer theTargetCylinder
 minimal transverse^2 momentum after propagation to cylinder More...
 
Plane::ConstPlanePointer theTargetPlaneMax
 plane closing cylinder at 'negative' side More...
 
Plane::ConstPlanePointer theTargetPlaneMin
 target cylinder, around z-axis More...
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

-*- C++ -*-

Package: GeneratorInterface/GenFilters

Description: Event filter for generated particles reaching a certain cylinder surface (around z-axis).

Implementation: Assumes particles coming from outside of defined cylinder, but might work also otherwise. Uses SteppingHelixPropagator and IdealMagneticFieldRecord.

Original Author: Gero FLUCKE Created: Mon Mar 5 16:32:01 CET 2007

Definition at line 40 of file CosmicGenFilterHelix.h.

Constructor & Destructor Documentation

CosmicGenFilterHelix::CosmicGenFilterHelix ( const edm::ParameterSet config)
explicit

Definition at line 42 of file CosmicGenFilterHelix.cc.

References Cylinder::build(), newFWLiteAna::build, Exception, edm::ParameterSet::getParameter(), CosmicsPD_Skims::maxZ, CosmicsPD_Skims::radius, theCharges, theIds, theSrcToken, theTargetCylinder, theTargetPlaneMax, and theTargetPlaneMin.

43  : theIds(cfg.getParameter<std::vector<int> >("pdgIds")),
44  theCharges(cfg.getParameter<std::vector<int> >("charges")),
45  thePropagatorName(cfg.getParameter<std::string>("propagator")),
46  theMinP2(cfg.getParameter<double>("minP")*cfg.getParameter<double>("minP")),
47  theMinPt2(cfg.getParameter<double>("minPt")*cfg.getParameter<double>("minPt")),
48  theDoMonitor(cfg.getUntrackedParameter<bool>("doMonitor"))
49 {
50  theSrcToken = consumes<edm::HepMCProduct>(cfg.getParameter<edm::InputTag>("src"));
51 
52  if (theIds.size() != theCharges.size()) {
53  throw cms::Exception("BadConfig") << "CosmicGenFilterHelix: "
54  << "'pdgIds' and 'charges' need same length.";
55  }
56  Surface::Scalar radius = cfg.getParameter<double>("radius");
57  Surface::Scalar maxZ = cfg.getParameter<double>("maxZ");
58  Surface::Scalar minZ = cfg.getParameter<double>("minZ");
59 
60  if (maxZ < minZ) {
61  throw cms::Exception("BadConfig") << "CosmicGenFilterHelix: maxZ (" << maxZ
62  << ") smaller than minZ (" << minZ << ").";
63  }
64 
65  const Surface::RotationType dummyRot;
66  theTargetCylinder = Cylinder::build(Surface::PositionType(0.,0.,0.), dummyRot, radius);
67  theTargetPlaneMin = Plane::build(Surface::PositionType(0.,0.,minZ), dummyRot);
68  theTargetPlaneMax = Plane::build(Surface::PositionType(0.,0.,maxZ), dummyRot);
69 }
Cylinder::ConstCylinderPointer theTargetCylinder
minimal transverse^2 momentum after propagation to cylinder
tuple cfg
Definition: looper.py:293
Plane::ConstPlanePointer theTargetPlaneMax
plane closing cylinder at &#39;negative&#39; side
const double theMinPt2
minimal momentum^2 after propagation to cylinder
const std::vector< int > theIds
edm::EDGetTokenT< edm::HepMCProduct > theSrcToken
static CylinderPointer build(const PositionType &pos, const RotationType &rot, Scalar radius, Bounds *bounds=0)
Definition: Cylinder.h:51
const std::vector< int > theCharges
requested Ids
const std::string thePropagatorName
charges, parallel to theIds
Plane::ConstPlanePointer theTargetPlaneMin
target cylinder, around z-axis
CosmicGenFilterHelix::~CosmicGenFilterHelix ( )
virtual

Definition at line 72 of file CosmicGenFilterHelix.cc.

73 {
74 }

Member Function Documentation

void CosmicGenFilterHelix::beginJob ( void  )
virtual

Reimplemented from edm::EDFilter.

Definition at line 163 of file CosmicGenFilterHelix.cc.

References createHistsEnd(), createHistsStart(), theDoMonitor, theHistsAfter, theHistsBefore, theNumPass, and theNumTotal.

164 {
165  if (theDoMonitor) {
166  this->createHistsStart("start", theHistsBefore);
167  this->createHistsStart("startAfter", theHistsAfter);
168  // must be after the line above: hist indices are static in monitorStart(...)
169  this->createHistsEnd("end", theHistsAfter);
170  }
171 
172  theNumTotal = theNumPass = 0;
173 }
unsigned int theNumPass
for final statistics: all seen events
TObjArray theHistsAfter
hists of properties from generator
void createHistsStart(const char *dirName, TObjArray &hists)
for final statistics: events with track reaching target
void createHistsEnd(const char *dirName, TObjArray &hists)
TObjArray theHistsBefore
whether or not to fill monitor hists (needs TFileService)
unsigned int theNumTotal
plane closing cylinder at &#39;positive&#39; side
bool CosmicGenFilterHelix::charge ( int  id,
int &  charge 
) const
private

true if ID selected, return by value its charge

Definition at line 310 of file CosmicGenFilterHelix.cc.

References end, i, theCharges, and theIds.

Referenced by filter().

311 {
312  std::vector<int>::const_iterator iC = theCharges.begin();
313  for (std::vector<int>::const_iterator i = theIds.begin(), end = theIds.end(); i != end;
314  ++i,++iC) {
315  if (*i == id) {
316  charge = *iC;
317  return true;
318  }
319  }
320 
321  return false;
322 }
int i
Definition: DBlmapReader.cc:9
const std::vector< int > theIds
#define end
Definition: vmac.h:37
const std::vector< int > theCharges
requested Ids
bool charge(int id, int &charge) const
true if ID selected, return by value its charge
void CosmicGenFilterHelix::createHistsEnd ( const char *  dirName,
TObjArray &  hists 
)
private

Definition at line 222 of file CosmicGenFilterHelix.cc.

References Abs(), equidistLogBins(), ztee::fd, CosmicsPD_Skims::maxZ, TFileService::mkdir(), Pi, theTargetCylinder, theTargetPlaneMax, and theTargetPlaneMin.

Referenced by beginJob().

223 {
226 
227  const int kNumBins = 50;
228  double pBinsLog[kNumBins+1] = {0.}; // fully initialised with 0.
229  this->equidistLogBins(pBinsLog, kNumBins, 1., 4000.);
230 
231  // take care: hist names must differ from those in createHistsStart!
232  hists.Add(fd.make<TH1F>("pathEnd", "path until cylinder;s [cm]", 100, 0., 2000.));
233  hists.Add(fd.make<TH1F>("momEnd", "|p_{end}|;p [GeV]", 100, 0., 1000.));
234  hists.Add(fd.make<TH1F>("momEndLog", "|p_{end}|;p [GeV]", kNumBins, pBinsLog));
235  hists.Add(fd.make<TH1F>("ptEnd", "p_{t} (end);p_{t} [GeV]", 100, 0., 750.));
236  hists.Add(fd.make<TH1F>("ptEndLog", "p_{t} (end);p_{t} [GeV]", kNumBins, pBinsLog));
237  hists.Add(fd.make<TH1F>("phiXzEnd", "#phi_{xz} (end);#phi_{xz}", 100,-TMath::Pi(),TMath::Pi()));
238  hists.Add(fd.make<TH1F>("thetaYEnd","#theta_{y} (end);#theta_{y}", 100, 0., TMath::Pi()));
239 
240  hists.Add(fd.make<TH1F>("momStartEnd", "|p_{start}|-|p_{end}|;#Deltap [GeV]",100,0.,15.));
241  hists.Add(fd.make<TH1F>("momStartEndRel", "(p_{start}-p_{end})/p_{start};#Deltap_{rel}",
242  100,.0,1.));
243  hists.Add(fd.make<TH1F>("phiXzStartEnd", "#phi_{xz,start}-#phi_{xz,end};#Delta#phi_{xz}",
244  100,-1.,1.));
245  hists.Add(fd.make<TH1F>("thetaYStartEnd","#theta_{y,start}-#theta_{y,end};#Delta#theta_{y}",
246  100,-1.,1.));
247 
248  hists.Add(fd.make<TH2F>("phiXzStartVsEnd",
249  "#phi_{xz} start vs end;#phi_{xz}^{end};#phi_{xz}^{start}",
250  50, -TMath::Pi(), TMath::Pi(), 50, -TMath::Pi(), TMath::Pi()));
251  hists.Add(fd.make<TH2F>("thetaYStartVsEnd",
252  "#theta_{y} start vs end;#theta_{y}^{end};#theta_{y}^{start}",
253  50, 0., TMath::Pi(), 50, 0., TMath::Pi()/2.));
254 
255  hists.Add(fd.make<TH2F>("momStartEndRelVsZ",
256  "(p_{start}-p_{end})/p_{start} vs z_{start};z [cm];#Deltap_{rel}",
257  50, -1600., 1600., 50,.0,.8));
258  hists.Add(fd.make<TH2F>("phiXzStartEndVsZ",
259  "#phi_{xz,start}-#phi_{xz,end} vs z_{start};z [cm];#Delta#phi_{xz}",
260  50, -1600., 1600., 50,-1., 1.));
261  hists.Add(fd.make<TH2F>("thetaYStartEndVsZ",
262  "#theta_{y,start}-#theta_{y,end} vs z_{start};z [cm];#Delta#theta_{y}",
263  50, -1600., 1600., 50,-.5,.5));
264  hists.Add(fd.make<TH2F>("momStartEndRelVsP",
265  "(p_{start}-p_{end})/p_{start} vs p_{start};p [GeV];#Deltap_{rel}",
266  kNumBins, pBinsLog, 50, .0, .8));
267  hists.Add(fd.make<TH2F>("phiXzStartEndVsP",
268  "#phi_{xz,start}-#phi_{xz,end} vs |p|_{start};p [GeV];#Delta#phi_{xz}",
269  kNumBins, pBinsLog, 100,-1.5, 1.5));
270  hists.Add(fd.make<TH2F>("thetaYStartEndVsP",
271  "#theta_{y,start}-#theta_{y,end} vs |p|_{start};p [GeV];#Delta#theta_{y}",
272  kNumBins, pBinsLog, 100,-1.,1.));
273 
274  const double maxR = theTargetCylinder->radius() * 1.1;
275  hists.Add(fd.make<TH1F>("radiusEnd", "end radius;r [cm]", 100, 0., maxR));
276  double minZ = theTargetPlaneMin->position().z();
277  minZ -= TMath::Abs(minZ) * 0.1;
278  double maxZ = theTargetPlaneMax->position().z();
279  maxZ += TMath::Abs(maxZ) * 0.1;
280  hists.Add(fd.make<TH1F>("zEnd", "end z;z [cm]", 100, minZ, maxZ));
281  hists.Add(fd.make<TH1F>("zDiff", "z_{start}-z_{end};#Deltaz [cm]", 100, -1000., 1000.));
282  hists.Add(fd.make<TH2F>("xyPlaneEnd", "end xy;x [cm];y [cm]", 100, -maxR, maxR, 100,-maxR,maxR));
283 
284  hists.Add(fd.make<TH2F>("rzPlaneEnd", "end rz (y<0 #Rightarrow r_{#pm}=-r);z [cm];r_{#pm} [cm]",
285  50, minZ, maxZ, 50, -maxR, maxR));
286  hists.Add(fd.make<TH2F>("thetaVsZend", "#theta vs z (end);z [cm];#theta",
287  50, minZ, maxZ, 50, 0., TMath::Pi()));
288 }
Cylinder::ConstCylinderPointer theTargetCylinder
minimal transverse^2 momentum after propagation to cylinder
const double Pi
Plane::ConstPlanePointer theTargetPlaneMax
plane closing cylinder at &#39;negative&#39; side
T Abs(T a)
Definition: MathUtil.h:49
tuple fd
Definition: ztee.py:136
bool equidistLogBins(double *bins, int nBins, double first, double last) const
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Definition: TFileService.h:69
Plane::ConstPlanePointer theTargetPlaneMin
target cylinder, around z-axis
void CosmicGenFilterHelix::createHistsStart ( const char *  dirName,
TObjArray &  hists 
)
private

for final statistics: events with track reaching target

Definition at line 176 of file CosmicGenFilterHelix.cc.

References equidistLogBins(), ztee::fd, TFileService::mkdir(), and Pi.

Referenced by beginJob().

177 {
180 
181  hists.Add(fd.make<TH1F>("momentumP", "|p(#mu^{+})| (start);|p| [GeV]",100, 0., 1000.));
182  hists.Add(fd.make<TH1F>("momentumM", "|p(#mu^{-})| (start);|p| [GeV]",100, 0., 1000.));
183  hists.Add(fd.make<TH1F>("momentum2", "|p(#mu)| (start);|p| [GeV]",100, 0., 25.));
184  const int kNumBins = 50;
185  double pBinsLog[kNumBins+1] = {0.}; // fully initialised with 0.
186  this->equidistLogBins(pBinsLog, kNumBins, 1., 4000.);
187  hists.Add(fd.make<TH1F>("momentumLog", "|p(#mu)| (start);|p| [GeV]", kNumBins, pBinsLog));
188  hists.Add(fd.make<TH1F>("phi", "start p_{#phi(#mu)};#phi", 100, -TMath::Pi(), TMath::Pi()));
189  hists.Add(fd.make<TH1F>("cosPhi", "cos(p_{#phi(#mu)}) (start);cos(#phi)", 100, -1., 1.));
190  hists.Add(fd.make<TH1F>("phiXz", "start p_{#phi_{xz}(#mu)};#phi_{xz}",
191  100, -TMath::Pi(), TMath::Pi()));
192  hists.Add(fd.make<TH1F>("theta", "#theta(#mu) (start);#theta", 100, 0., TMath::Pi()));
193  hists.Add(fd.make<TH1F>("thetaY", "#theta_{y}(#mu) (start);#theta_{y}", 100,0.,TMath::Pi()/2.));
194 
195  hists.Add(fd.make<TH2F>("momVsPhi", "|p(#mu)| vs #phi (start);#phi;|p| [GeV]",
196  50, -TMath::Pi(), TMath::Pi(), 50, 1.5, 1000.));
197  hists.Add(fd.make<TH2F>("momVsTheta", "|p(#mu)| vs #theta (start);#theta;|p| [GeV]",
198  50, 0., TMath::Pi(), 50, 1.5, 1000.));
199  hists.Add(fd.make<TH2F>("momVsThetaY", "|p(#mu)| vs #theta_{y} (start);#theta_{y};|p| [GeV]",
200  50, 0., TMath::Pi()/2., 50, 1.5, 1000.));
201  hists.Add(fd.make<TH2F>("momVsZ", "|p(#mu)| vs z (start);z [cm];|p| [GeV]",
202  50, -1600., 1600., 50, 1.5, 1000.));
203  hists.Add(fd.make<TH2F>("thetaVsZ", "#theta vs z (start);z [cm];#theta",
204  50, -1600., 1600., 50, 0., TMath::Pi()));
205  hists.Add(fd.make<TH2F>("thetaYvsZ", "#theta_{y} vs z (start);z [cm];#theta",
206  50, -1600., 1600., 50, 0., TMath::PiOver2()));
207  hists.Add(fd.make<TH2F>("yVsThetaY", "#theta_{y}(#mu) vs y (start);#theta_{y};y [cm]",
208  50, 0., TMath::Pi()/2., 50, -1000., 1000.));
209  hists.Add(fd.make<TH2F>("yVsThetaYnoR", "#theta_{y}(#mu) vs y (start, barrel);#theta_{y};y [cm]",
210  50, 0., TMath::Pi()/2., 50, -1000., 1000.));
211 
212  hists.Add(fd.make<TH1F>("radius", "start radius;r [cm]", 100, 0., 1000.));
213  hists.Add(fd.make<TH1F>("z", "start z;z [cm]", 100, -1600., 1600.));
214  hists.Add(fd.make<TH2F>("xyPlane", "start xy;x [cm];y [cm]", 50, -1000., 1000.,
215  50, -1000., 1000.));
216  hists.Add(fd.make<TH2F>("rzPlane",
217  "start rz (y < 0 #Rightarrow r_{#pm} = -r);z [cm];r_{#pm} [cm]",
218  50, -1600., 1600., 50, -1000., 1000.));
219 }
const double Pi
tuple fd
Definition: ztee.py:136
bool equidistLogBins(double *bins, int nBins, double first, double last) const
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Definition: TFileService.h:69
void CosmicGenFilterHelix::endJob ( void  )
virtual

Reimplemented from edm::EDFilter.

Definition at line 291 of file CosmicGenFilterHelix.cc.

References geometryCSVtoXML::line, theMinP2, theMinPt2, theNumPass, theNumTotal, theTargetCylinder, theTargetPlaneMax, and theTargetPlaneMin.

292 {
293  const char *border = "////////////////////////////////////////////////////////";
294  const char *line = "\n// ";
295  edm::LogInfo("Filter") << "@SUB=CosmicGenFilterHelix::endJob"
296  << border << line
297  << theNumPass << " events out of " << theNumTotal
298  << ", i.e. " << theNumPass*100./theNumTotal << "%, "
299  << "reached target cylinder,"
300  << line << "defined by r < "
301  << theTargetCylinder->radius() << " cm and "
302  << theTargetPlaneMin->position().z() << " < z < "
303  << theTargetPlaneMax->position().z() << " cm."
304  << line << "Minimal required (transverse) momentum was "
305  << TMath::Sqrt(theMinP2) << " (" << TMath::Sqrt(theMinPt2) << ") GeV."
306  << "\n" << border;
307 }
Cylinder::ConstCylinderPointer theTargetCylinder
minimal transverse^2 momentum after propagation to cylinder
unsigned int theNumPass
for final statistics: all seen events
Plane::ConstPlanePointer theTargetPlaneMax
plane closing cylinder at &#39;negative&#39; side
const double theMinPt2
minimal momentum^2 after propagation to cylinder
Plane::ConstPlanePointer theTargetPlaneMin
target cylinder, around z-axis
unsigned int theNumTotal
plane closing cylinder at &#39;positive&#39; side
bool CosmicGenFilterHelix::equidistLogBins ( double *  bins,
int  nBins,
double  first,
double  last 
) const
private

Definition at line 487 of file CosmicGenFilterHelix.cc.

References plotBeamSpotDB::first, i, and prof2calltree::last.

Referenced by createHistsEnd(), and createHistsStart().

489 {
490  // Filling 'bins' with borders of 'nBins' bins between 'first' and 'last'
491  // that are equidistant when viewed in log scale,
492  // so 'bins' must have length nBins+1;
493  // If 'first', 'last' or 'nBins' are not positive, failure is reported.
494 
495  if (nBins < 1 || first <= 0. || last <= 0.) return false;
496 
497  bins[0] = first;
498  bins[nBins] = last;
499  const double firstLog = TMath::Log10(bins[0]);
500  const double lastLog = TMath::Log10(bins[nBins]);
501  for (int i = 1; i < nBins; ++i) {
502  bins[i] = TMath::Power(10., firstLog + i*(lastLog-firstLog)/(nBins));
503  }
504 
505  return true;
506 }
int i
Definition: DBlmapReader.cc:9
bool CosmicGenFilterHelix::filter ( edm::Event event,
const edm::EventSetup eventSetup 
)
virtual

Implements edm::EDFilter.

Definition at line 82 of file CosmicGenFilterHelix.cc.

References ecalTB2006H4_GenSimDigiReco_cfg::bField, charge(), edm::Event::getByToken(), getMagneticField(), getPropagator(), monitorStart(), propagateToCutCylinder(), HLT_25ns14e33_v1_cff::propagator, query::result, theDoMonitor, theHistsBefore, theNumPass, theNumTotal, and theSrcToken.

83 {
85  iEvent.getByToken(theSrcToken, hepMCEvt);
86  const HepMC::GenEvent *mCEvt = hepMCEvt->GetEvent();
87  const MagneticField *bField = this->getMagneticField(iSetup); // should be fast (?)
88  const Propagator *propagator = this->getPropagator(iSetup);
89 
90  ++theNumTotal;
91  bool result = false;
92  for (HepMC::GenEvent::particle_const_iterator iPart = mCEvt->particles_begin(),
93  endPart = mCEvt->particles_end(); iPart != endPart; ++iPart) {
94  int charge = 0; // there is no method providing charge in GenParticle :-(
95  if ((*iPart)->status() != 1) continue; // look only at stable particles
96  if (!this->charge((*iPart)->pdg_id(), charge)) continue;
97 
98  // Get the position and momentum
99  const HepMC::ThreeVector hepVertex((*iPart)->production_vertex()->point3d());
100  const GlobalPoint vert(hepVertex.x()/10., hepVertex.y()/10., hepVertex.z()/10.); // to cm
101  const HepMC::FourVector hepMomentum((*iPart)->momentum());
102  const GlobalVector mom(hepMomentum.x(), hepMomentum.y(), hepMomentum.z());
103 
104  if (theDoMonitor) this->monitorStart(vert, mom, charge, theHistsBefore);
105 
106  if (this->propagateToCutCylinder(vert, mom, charge, bField, propagator)) {
107  result = true;
108  }
109  }
110 
111  if (result) ++theNumPass;
112  return result;
113 }
unsigned int theNumPass
for final statistics: all seen events
const Propagator * getPropagator(const edm::EventSetup &setup) const
const MagneticField * getMagneticField(const edm::EventSetup &setup) const
provide magnetic field from Event Setup
bool propagateToCutCylinder(const GlobalPoint &vertStart, const GlobalVector &momStart, int charge, const MagneticField *field, const Propagator *propagator)
actually propagate to the defined cylinder
edm::EDGetTokenT< edm::HepMCProduct > theSrcToken
int iEvent
Definition: GenABIO.cc:230
tuple result
Definition: query.py:137
TObjArray theHistsBefore
whether or not to fill monitor hists (needs TFileService)
bool charge(int id, int &charge) const
true if ID selected, return by value its charge
void monitorStart(const GlobalPoint &vert, const GlobalVector &mom, int charge, TObjArray &hists)
unsigned int theNumTotal
plane closing cylinder at &#39;positive&#39; side
const MagneticField * CosmicGenFilterHelix::getMagneticField ( const edm::EventSetup setup) const
private

provide magnetic field from Event Setup

Definition at line 325 of file CosmicGenFilterHelix.cc.

References fieldHandle, edm::EventSetup::get(), and edm::ESHandle< class >::product().

Referenced by filter().

326 {
328  setup.get<IdealMagneticFieldRecord>().get(fieldHandle);
329 
330  return fieldHandle.product();
331 }
ESHandle< MagneticField > fieldHandle
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
const Propagator * CosmicGenFilterHelix::getPropagator ( const edm::EventSetup setup) const
private

Definition at line 334 of file CosmicGenFilterHelix.cc.

References edm::EventSetup::get(), edm::ESHandle< class >::product(), and thePropagatorName.

Referenced by filter().

335 {
336  edm::ESHandle<Propagator> propHandle;
337  setup.get<TrackingComponentsRecord>().get(thePropagatorName, propHandle);
338 
339  const Propagator *prop = propHandle.product();
340  if (!dynamic_cast<const SteppingHelixPropagator*>(prop)) {
341  edm::LogWarning("BadConfig") << "@SUB=CosmicGenFilterHelix::getPropagator"
342  << "Not a SteppingHelixPropagator!";
343 
344  }
345  return prop;
346 }
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
const std::string thePropagatorName
charges, parallel to theIds
void CosmicGenFilterHelix::monitorEnd ( const GlobalPoint endVert,
const GlobalVector endMom,
const GlobalPoint vert,
const GlobalVector mom,
double  path,
TObjArray &  hists 
)
private

Definition at line 410 of file CosmicGenFilterHelix.cc.

References HcalObjRepresent::Fill(), PV3DBase< T, PVType, FrameType >::mag(), PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::theta(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by propagateToCutCylinder().

413 {
414  const double scalarMomStart = mom.mag();
415  const double phiXzStart = TMath::ATan2(mom.z(), mom.x());
416  const double thetaYStart = TMath::ATan2(TMath::Sqrt(mom.x()*mom.x()+mom.z()*mom.z()), -mom.y());
417  const double scalarMomEnd = endMom.mag();
418  const double ptEnd = endMom.perp();
419  const double phiXzEnd = TMath::ATan2(endMom.z(), endMom.x());
420  const double thetaYEnd = TMath::ATan2(TMath::Sqrt(endMom.x()*endMom.x()+endMom.z()*endMom.z()),
421  -endMom.y());
422  const double thetaEnd = endMom.theta();
423 
424  const double diffMomRel = (scalarMomStart-scalarMomEnd)/scalarMomStart;
425 
426  const double zEnd = endVert.z();
427  const double rEnd = endVert.perp();
428  const double diffZ = zEnd - vert.z();
429 
430  const static int iPathEnd = hists.IndexOf(hists.FindObject("pathEnd"));
431  static_cast<TH1*>(hists[iPathEnd])->Fill(path);
432  const static int iMomEnd = hists.IndexOf(hists.FindObject("momEnd"));
433  static_cast<TH1*>(hists[iMomEnd])->Fill(scalarMomEnd);
434  const static int iMomEndLog = hists.IndexOf(hists.FindObject("momEndLog"));
435  static_cast<TH1*>(hists[iMomEndLog])->Fill(scalarMomEnd);
436  const static int iPtEnd = hists.IndexOf(hists.FindObject("ptEnd"));
437  static_cast<TH1*>(hists[iPtEnd])->Fill(ptEnd);
438  const static int iPtEndLog = hists.IndexOf(hists.FindObject("ptEndLog"));
439  static_cast<TH1*>(hists[iPtEndLog])->Fill(ptEnd);
440  const static int iPhiXzEnd = hists.IndexOf(hists.FindObject("phiXzEnd"));
441  static_cast<TH1*>(hists[iPhiXzEnd])->Fill(phiXzEnd);
442  const static int iThetaYEnd = hists.IndexOf(hists.FindObject("thetaYEnd"));
443  static_cast<TH1*>(hists[iThetaYEnd])->Fill(thetaYEnd);
444 
445  const static int iMomStartEnd = hists.IndexOf(hists.FindObject("momStartEnd"));
446  static_cast<TH1*>(hists[iMomStartEnd])->Fill(scalarMomStart-scalarMomEnd);
447  const static int iMomStartEndRel = hists.IndexOf(hists.FindObject("momStartEndRel"));
448  static_cast<TH1*>(hists[iMomStartEndRel])->Fill(diffMomRel);
449  const static int iPhiStartEnd = hists.IndexOf(hists.FindObject("phiXzStartEnd"));
450  static_cast<TH1*>(hists[iPhiStartEnd])->Fill(phiXzStart-phiXzEnd);
451  const static int iThetaStartEnd = hists.IndexOf(hists.FindObject("thetaYStartEnd"));
452  static_cast<TH1*>(hists[iThetaStartEnd])->Fill(thetaYStart-thetaYEnd);
453 
454  const static int iPhiStartVsEnd = hists.IndexOf(hists.FindObject("phiXzStartVsEnd"));
455  static_cast<TH2*>(hists[iPhiStartVsEnd])->Fill(phiXzEnd, phiXzStart);
456  const static int iThetaStartVsEnd = hists.IndexOf(hists.FindObject("thetaYStartVsEnd"));
457  static_cast<TH2*>(hists[iThetaStartVsEnd])->Fill(thetaYEnd, thetaYStart);
458 
459  const static int iMomStartEndRelVsZ = hists.IndexOf(hists.FindObject("momStartEndRelVsZ"));
460  static_cast<TH2*>(hists[iMomStartEndRelVsZ])->Fill(vert.z(), diffMomRel);
461  const static int iPhiStartEndVsZ = hists.IndexOf(hists.FindObject("phiXzStartEndVsZ"));
462  static_cast<TH2*>(hists[iPhiStartEndVsZ])->Fill(vert.z(), phiXzStart-phiXzEnd);
463  const static int iThetaStartEndVsZ = hists.IndexOf(hists.FindObject("thetaYStartEndVsZ"));
464  static_cast<TH2*>(hists[iThetaStartEndVsZ])->Fill(vert.z(), thetaYStart-thetaYEnd);
465  const static int iMomStartEndRelVsP = hists.IndexOf(hists.FindObject("momStartEndRelVsP"));
466  static_cast<TH2*>(hists[iMomStartEndRelVsP])->Fill(scalarMomStart, diffMomRel);
467  const static int iPhiStartEndVsP = hists.IndexOf(hists.FindObject("phiXzStartEndVsP"));
468  static_cast<TH2*>(hists[iPhiStartEndVsP])->Fill(scalarMomStart, phiXzStart-phiXzEnd);
469  const static int iThetaStartEndVsP = hists.IndexOf(hists.FindObject("thetaYStartEndVsP"));
470  static_cast<TH2*>(hists[iThetaStartEndVsP])->Fill(scalarMomStart, thetaYStart-thetaYEnd);
471 
472  const static int iRadiusEnd = hists.IndexOf(hists.FindObject("radiusEnd"));
473  static_cast<TH1*>(hists[iRadiusEnd])->Fill(rEnd);
474  const static int iZend = hists.IndexOf(hists.FindObject("zEnd"));
475  static_cast<TH1*>(hists[iZend])->Fill(zEnd);
476  const static int iZdiff = hists.IndexOf(hists.FindObject("zDiff"));
477  static_cast<TH1*>(hists[iZdiff])->Fill(diffZ);
478  const static int iXyPlaneEnd = hists.IndexOf(hists.FindObject("xyPlaneEnd"));
479  static_cast<TH1*>(hists[iXyPlaneEnd])->Fill(endVert.x(), endVert.y());
480  const static int iRzPlaneEnd = hists.IndexOf(hists.FindObject("rzPlaneEnd"));
481  static_cast<TH1*>(hists[iRzPlaneEnd])->Fill(zEnd, (endVert.y() > 0 ? rEnd : -rEnd));
482  const static int iThetaVsZend = hists.IndexOf(hists.FindObject("thetaVsZend"));
483  static_cast<TH2*>(hists[iThetaVsZend])->Fill(zEnd, thetaEnd);
484 }
T perp() const
Definition: PV3DBase.h:72
T y() const
Definition: PV3DBase.h:63
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
T mag() const
Definition: PV3DBase.h:67
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
T z() const
Definition: PV3DBase.h:64
T x() const
Definition: PV3DBase.h:62
void CosmicGenFilterHelix::monitorStart ( const GlobalPoint vert,
const GlobalVector mom,
int  charge,
TObjArray &  hists 
)
private

Definition at line 349 of file CosmicGenFilterHelix.cc.

References HcalObjRepresent::Fill(), PV3DBase< T, PVType, FrameType >::mag(), PV3DBase< T, PVType, FrameType >::perp(), phi, PV3DBase< T, PVType, FrameType >::phi(), alignCSCRings::r, PV3DBase< T, PVType, FrameType >::theta(), theta(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), z, and PV3DBase< T, PVType, FrameType >::z().

Referenced by filter(), and propagateToCutCylinder().

351 {
352  const double scalarMom = mom.mag();
353  const double phi = mom.phi();
354  const double phiXz = TMath::ATan2(mom.z(), mom.x());
355  const double theta = mom.theta();
356  const double thetaY = TMath::ATan2(TMath::Sqrt(mom.x()*mom.x()+mom.z()*mom.z()), -mom.y());
357 
358  const double z = vert.z();
359  const double r = vert.perp();
360 
361  const static int iMomP = hists.IndexOf(hists.FindObject("momentumP"));
362  const static int iMomM = hists.IndexOf(hists.FindObject("momentumM"));
363  if (charge > 0) static_cast<TH1*>(hists[iMomP])->Fill(scalarMom);
364  else static_cast<TH1*>(hists[iMomM])->Fill(scalarMom);
365  const static int iMom2 = hists.IndexOf(hists.FindObject("momentum2"));
366  static_cast<TH1*>(hists[iMom2])->Fill(scalarMom);
367  const static int iMomLog = hists.IndexOf(hists.FindObject("momentumLog"));
368  static_cast<TH1*>(hists[iMomLog])->Fill(scalarMom);
369  const static int iPhi = hists.IndexOf(hists.FindObject("phi"));
370  static_cast<TH1*>(hists[iPhi])->Fill(phi);
371  const static int iCosPhi = hists.IndexOf(hists.FindObject("cosPhi"));
372  static_cast<TH1*>(hists[iCosPhi])->Fill(TMath::Cos(phi));
373  const static int iPhiXz = hists.IndexOf(hists.FindObject("phiXz"));
374  static_cast<TH1*>(hists[iPhiXz])->Fill(phiXz);
375  const static int iTheta = hists.IndexOf(hists.FindObject("theta"));
376  static_cast<TH1*>(hists[iTheta])->Fill(theta);
377  const static int iThetaY = hists.IndexOf(hists.FindObject("thetaY"));
378  static_cast<TH1*>(hists[iThetaY])->Fill(thetaY);
379 
380  const static int iMomVsTheta = hists.IndexOf(hists.FindObject("momVsTheta"));
381  static_cast<TH2*>(hists[iMomVsTheta])->Fill(theta, scalarMom);
382  const static int iMomVsThetaY = hists.IndexOf(hists.FindObject("momVsThetaY"));
383  static_cast<TH2*>(hists[iMomVsThetaY])->Fill(thetaY, scalarMom);
384  const static int iMomVsPhi = hists.IndexOf(hists.FindObject("momVsPhi"));
385  static_cast<TH2*>(hists[iMomVsPhi])->Fill(phi, scalarMom);
386  const static int iMomVsZ = hists.IndexOf(hists.FindObject("momVsZ"));
387  static_cast<TH2*>(hists[iMomVsZ])->Fill(z, scalarMom);
388  const static int iThetaVsZ = hists.IndexOf(hists.FindObject("thetaVsZ"));
389  static_cast<TH2*>(hists[iThetaVsZ])->Fill(z, theta);
390  const static int iThetaYvsZ = hists.IndexOf(hists.FindObject("thetaYvsZ"));
391  static_cast<TH2*>(hists[iThetaYvsZ])->Fill(z, thetaY);
392  const static int iYvsThetaY = hists.IndexOf(hists.FindObject("yVsThetaY"));
393  static_cast<TH2*>(hists[iYvsThetaY])->Fill(thetaY, vert.y());
394  const static int iYvsThetaYnoR = hists.IndexOf(hists.FindObject("yVsThetaYnoR"));
395  if (z > -1400. && z < 1400.) {
396  static_cast<TH2*>(hists[iYvsThetaYnoR])->Fill(thetaY, vert.y());
397  }
398 
399  const static int iRadius = hists.IndexOf(hists.FindObject("radius"));
400  static_cast<TH1*>(hists[iRadius])->Fill(r);
401  const static int iZ = hists.IndexOf(hists.FindObject("z"));
402  static_cast<TH1*>(hists[iZ])->Fill(z);
403  const static int iXy = hists.IndexOf(hists.FindObject("xyPlane"));
404  static_cast<TH1*>(hists[iXy])->Fill(vert.x(), vert.y());
405  const static int iRz = hists.IndexOf(hists.FindObject("rzPlane"));
406  static_cast<TH1*>(hists[iRz])->Fill(z, (vert.y() > 0 ? r : -r));
407 }
T perp() const
Definition: PV3DBase.h:72
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
Geom::Theta< T > theta() const
T y() const
Definition: PV3DBase.h:63
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
T mag() const
Definition: PV3DBase.h:67
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
T z() const
Definition: PV3DBase.h:64
bool charge(int id, int &charge) const
true if ID selected, return by value its charge
T x() const
Definition: PV3DBase.h:62
bool CosmicGenFilterHelix::propagateToCutCylinder ( const GlobalPoint vertStart,
const GlobalVector momStart,
int  charge,
const MagneticField field,
const Propagator propagator 
)
private

actually propagate to the defined cylinder

Definition at line 116 of file CosmicGenFilterHelix.cc.

References monitorEnd(), monitorStart(), Propagator::propagateWithPath(), query::result, theDoMonitor, theHistsAfter, theMinP2, theMinPt2, theTargetCylinder, theTargetPlaneMax, and theTargetPlaneMin.

Referenced by filter().

120 {
121  typedef std::pair<TrajectoryStateOnSurface, double> TsosPath;
122 
123  const FreeTrajectoryState fts(GlobalTrajectoryParameters(vertStart, momStart, charge, field));
124 
125  bool result = true;
126  TsosPath aTsosPath(propagator->propagateWithPath(fts, *theTargetCylinder));
127  if (!aTsosPath.first.isValid()) {
128  result = false;
129  } else if (aTsosPath.first.globalPosition().z() < theTargetPlaneMin->position().z()) {
130  // If on cylinder, but outside minimum z, try minimum z-plane:
131  // (Would it be possible to miss radius on plane, but reach cylinder afterwards in z-range?
132  // No, at least not in B-field parallel to z-axis which is cylinder axis.)
133  aTsosPath = propagator->propagateWithPath(fts, *theTargetPlaneMin);
134  if (!aTsosPath.first.isValid()
135  || aTsosPath.first.globalPosition().perp() > theTargetCylinder->radius()) {
136  result = false;
137  }
138  } else if (aTsosPath.first.globalPosition().z() > theTargetPlaneMax->position().z()) {
139  // Analog for outside maximum z:
140  aTsosPath = propagator->propagateWithPath(fts, *theTargetPlaneMax);
141  if (!aTsosPath.first.isValid()
142  || aTsosPath.first.globalPosition().perp() > theTargetCylinder->radius()) {
143  result = false;
144  }
145  }
146 
147  if (result) {
148  const GlobalVector momEnd(aTsosPath.first.globalMomentum());
149  if (momEnd.perp2() < theMinPt2 || momEnd.mag2() < theMinP2) {
150  result = false;
151  } else if (theDoMonitor) {
152  const GlobalPoint vertEnd(aTsosPath.first.globalPosition());
153  this->monitorStart(vertStart, momStart, charge, theHistsAfter);
154  this->monitorEnd(vertEnd, momEnd, vertStart, momStart, aTsosPath.second, theHistsAfter);
155  }
156  }
157 
158  return result;
159 }
Cylinder::ConstCylinderPointer theTargetCylinder
minimal transverse^2 momentum after propagation to cylinder
Plane::ConstPlanePointer theTargetPlaneMax
plane closing cylinder at &#39;negative&#39; side
const double theMinPt2
minimal momentum^2 after propagation to cylinder
TObjArray theHistsAfter
hists of properties from generator
void monitorEnd(const GlobalPoint &endVert, const GlobalVector &endMom, const GlobalPoint &vert, const GlobalVector &mom, double path, TObjArray &hists)
tuple result
Definition: query.py:137
virtual std::pair< TrajectoryStateOnSurface, double > propagateWithPath(const FreeTrajectoryState &, const Surface &) const final
Definition: Propagator.cc:15
bool charge(int id, int &charge) const
true if ID selected, return by value its charge
void monitorStart(const GlobalPoint &vert, const GlobalVector &mom, int charge, TObjArray &hists)
Plane::ConstPlanePointer theTargetPlaneMin
target cylinder, around z-axis

Member Data Documentation

const std::vector<int> CosmicGenFilterHelix::theCharges
private

requested Ids

Definition at line 63 of file CosmicGenFilterHelix.h.

Referenced by charge(), and CosmicGenFilterHelix().

const bool CosmicGenFilterHelix::theDoMonitor
private

Definition at line 82 of file CosmicGenFilterHelix.h.

Referenced by beginJob(), filter(), and propagateToCutCylinder().

TObjArray CosmicGenFilterHelix::theHistsAfter
private

hists of properties from generator

Definition at line 84 of file CosmicGenFilterHelix.h.

Referenced by beginJob(), and propagateToCutCylinder().

TObjArray CosmicGenFilterHelix::theHistsBefore
private

whether or not to fill monitor hists (needs TFileService)

Definition at line 83 of file CosmicGenFilterHelix.h.

Referenced by beginJob(), and filter().

const std::vector<int> CosmicGenFilterHelix::theIds
private

Definition at line 62 of file CosmicGenFilterHelix.h.

Referenced by charge(), and CosmicGenFilterHelix().

const double CosmicGenFilterHelix::theMinP2
private

Definition at line 65 of file CosmicGenFilterHelix.h.

Referenced by endJob(), and propagateToCutCylinder().

const double CosmicGenFilterHelix::theMinPt2
private

minimal momentum^2 after propagation to cylinder

Definition at line 66 of file CosmicGenFilterHelix.h.

Referenced by endJob(), and propagateToCutCylinder().

unsigned int CosmicGenFilterHelix::theNumPass
private

for final statistics: all seen events

Definition at line 73 of file CosmicGenFilterHelix.h.

Referenced by beginJob(), endJob(), and filter().

unsigned int CosmicGenFilterHelix::theNumTotal
private

plane closing cylinder at 'positive' side

Definition at line 72 of file CosmicGenFilterHelix.h.

Referenced by beginJob(), endJob(), and filter().

const std::string CosmicGenFilterHelix::thePropagatorName
private

charges, parallel to theIds

Definition at line 64 of file CosmicGenFilterHelix.h.

Referenced by getPropagator().

edm::EDGetTokenT<edm::HepMCProduct> CosmicGenFilterHelix::theSrcToken
private

Definition at line 61 of file CosmicGenFilterHelix.h.

Referenced by CosmicGenFilterHelix(), and filter().

Cylinder::ConstCylinderPointer CosmicGenFilterHelix::theTargetCylinder
private

minimal transverse^2 momentum after propagation to cylinder

Definition at line 68 of file CosmicGenFilterHelix.h.

Referenced by CosmicGenFilterHelix(), createHistsEnd(), endJob(), and propagateToCutCylinder().

Plane::ConstPlanePointer CosmicGenFilterHelix::theTargetPlaneMax
private

plane closing cylinder at 'negative' side

Definition at line 70 of file CosmicGenFilterHelix.h.

Referenced by CosmicGenFilterHelix(), createHistsEnd(), endJob(), and propagateToCutCylinder().

Plane::ConstPlanePointer CosmicGenFilterHelix::theTargetPlaneMin
private

target cylinder, around z-axis

Definition at line 69 of file CosmicGenFilterHelix.h.

Referenced by CosmicGenFilterHelix(), createHistsEnd(), endJob(), and propagateToCutCylinder().