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::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 ()
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

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...
 
const edm::InputTag theSrc
 
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
 
typedef WorkerT< EDFilterWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- 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::EDFilter
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

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

Id:
CosmicGenFilterHelix.h,v 1.7 2010/02/11 00:12:02 wmtan Exp

Definition at line 39 of file CosmicGenFilterHelix.h.

Constructor & Destructor Documentation

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

Definition at line 44 of file CosmicGenFilterHelix.cc.

References Plane::build(), Cylinder::build(), edm::hlt::Exception, edm::ParameterSet::getParameter(), CosmicsPD_Skims::maxZ, cmsRun_displayProdMFGeom_cfg::minZ, CosmicsPD_Skims::radius, theCharges, theIds, theTargetCylinder, theTargetPlaneMax, and theTargetPlaneMin.

45  : theSrc(cfg.getParameter<edm::InputTag>("src")),
46  theIds(cfg.getParameter<std::vector<int> >("pdgIds")),
47  theCharges(cfg.getParameter<std::vector<int> >("charges")),
48  thePropagatorName(cfg.getParameter<std::string>("propagator")),
49  theMinP2(cfg.getParameter<double>("minP")*cfg.getParameter<double>("minP")),
50  theMinPt2(cfg.getParameter<double>("minPt")*cfg.getParameter<double>("minPt")),
51  theDoMonitor(cfg.getUntrackedParameter<bool>("doMonitor"))
52 {
53  if (theIds.size() != theCharges.size()) {
54  throw cms::Exception("BadConfig") << "CosmicGenFilterHelix: "
55  << "'pdgIds' and 'charges' need same length.";
56  }
57  Surface::Scalar radius = cfg.getParameter<double>("radius");
58  Surface::Scalar maxZ = cfg.getParameter<double>("maxZ");
59  Surface::Scalar minZ = cfg.getParameter<double>("minZ");
60 
61  if (maxZ < minZ) {
62  throw cms::Exception("BadConfig") << "CosmicGenFilterHelix: maxZ (" << maxZ
63  << ") smaller than minZ (" << minZ << ").";
64  }
65 
66  const Surface::RotationType dummyRot;
67  theTargetCylinder = Cylinder::build(Surface::PositionType(0.,0.,0.), dummyRot, radius);
68  theTargetPlaneMin = Plane::build(Surface::PositionType(0.,0.,minZ), dummyRot);
69  theTargetPlaneMax = Plane::build(Surface::PositionType(0.,0.,maxZ), dummyRot);
70 }
Cylinder::ConstCylinderPointer theTargetCylinder
minimal transverse^2 momentum after propagation to cylinder
const edm::InputTag theSrc
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
static PlanePointer build(const PositionType &pos, const RotationType &rot, MediumProperties *mp=0)
Definition: Plane.h:25
const std::vector< int > theCharges
requested Ids
static CylinderPointer build(const PositionType &pos, const RotationType &rot, Scalar radius, MediumProperties *mp=0)
Definition: Cylinder.h:29
const std::string thePropagatorName
charges, parallel to theIds
Plane::ConstPlanePointer theTargetPlaneMin
target cylinder, around z-axis
CosmicGenFilterHelix::~CosmicGenFilterHelix ( )
virtual

Definition at line 73 of file CosmicGenFilterHelix.cc.

74 {
75 }

Member Function Documentation

void CosmicGenFilterHelix::beginJob ( void  )
virtual

Reimplemented from edm::EDFilter.

Definition at line 164 of file CosmicGenFilterHelix.cc.

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

165 {
166  if (theDoMonitor) {
167  this->createHistsStart("start", theHistsBefore);
168  this->createHistsStart("startAfter", theHistsAfter);
169  // must be after the line above: hist indices are static in monitorStart(...)
170  this->createHistsEnd("end", theHistsAfter);
171  }
172 
173  theNumTotal = theNumPass = 0;
174 }
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 311 of file CosmicGenFilterHelix.cc.

References end, i, theCharges, and theIds.

Referenced by filter().

312 {
313  std::vector<int>::const_iterator iC = theCharges.begin();
314  for (std::vector<int>::const_iterator i = theIds.begin(), end = theIds.end(); i != end;
315  ++i,++iC) {
316  if (*i == id) {
317  charge = *iC;
318  return true;
319  }
320  }
321 
322  return false;
323 }
int i
Definition: DBlmapReader.cc:9
const std::vector< int > theIds
#define end
Definition: vmac.h:38
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 223 of file CosmicGenFilterHelix.cc.

References equidistLogBins(), CosmicsPD_Skims::maxZ, cmsRun_displayProdMFGeom_cfg::minZ, TFileDirectory::mkdir(), Pi, theTargetCylinder, theTargetPlaneMax, and theTargetPlaneMin.

Referenced by beginJob().

224 {
227 
228  const int kNumBins = 50;
229  double pBinsLog[kNumBins+1] = {0.}; // fully initialised with 0.
230  this->equidistLogBins(pBinsLog, kNumBins, 1., 4000.);
231 
232  // take care: hist names must differ from those in createHistsStart!
233  hists.Add(fd.make<TH1F>("pathEnd", "path until cylinder;s [cm]", 100, 0., 2000.));
234  hists.Add(fd.make<TH1F>("momEnd", "|p_{end}|;p [GeV]", 100, 0., 1000.));
235  hists.Add(fd.make<TH1F>("momEndLog", "|p_{end}|;p [GeV]", kNumBins, pBinsLog));
236  hists.Add(fd.make<TH1F>("ptEnd", "p_{t} (end);p_{t} [GeV]", 100, 0., 750.));
237  hists.Add(fd.make<TH1F>("ptEndLog", "p_{t} (end);p_{t} [GeV]", kNumBins, pBinsLog));
238  hists.Add(fd.make<TH1F>("phiXzEnd", "#phi_{xz} (end);#phi_{xz}", 100,-TMath::Pi(),TMath::Pi()));
239  hists.Add(fd.make<TH1F>("thetaYEnd","#theta_{y} (end);#theta_{y}", 100, 0., TMath::Pi()));
240 
241  hists.Add(fd.make<TH1F>("momStartEnd", "|p_{start}|-|p_{end}|;#Deltap [GeV]",100,0.,15.));
242  hists.Add(fd.make<TH1F>("momStartEndRel", "(p_{start}-p_{end})/p_{start};#Deltap_{rel}",
243  100,.0,1.));
244  hists.Add(fd.make<TH1F>("phiXzStartEnd", "#phi_{xz,start}-#phi_{xz,end};#Delta#phi_{xz}",
245  100,-1.,1.));
246  hists.Add(fd.make<TH1F>("thetaYStartEnd","#theta_{y,start}-#theta_{y,end};#Delta#theta_{y}",
247  100,-1.,1.));
248 
249  hists.Add(fd.make<TH2F>("phiXzStartVsEnd",
250  "#phi_{xz} start vs end;#phi_{xz}^{end};#phi_{xz}^{start}",
251  50, -TMath::Pi(), TMath::Pi(), 50, -TMath::Pi(), TMath::Pi()));
252  hists.Add(fd.make<TH2F>("thetaYStartVsEnd",
253  "#theta_{y} start vs end;#theta_{y}^{end};#theta_{y}^{start}",
254  50, 0., TMath::Pi(), 50, 0., TMath::Pi()/2.));
255 
256  hists.Add(fd.make<TH2F>("momStartEndRelVsZ",
257  "(p_{start}-p_{end})/p_{start} vs z_{start};z [cm];#Deltap_{rel}",
258  50, -1600., 1600., 50,.0,.8));
259  hists.Add(fd.make<TH2F>("phiXzStartEndVsZ",
260  "#phi_{xz,start}-#phi_{xz,end} vs z_{start};z [cm];#Delta#phi_{xz}",
261  50, -1600., 1600., 50,-1., 1.));
262  hists.Add(fd.make<TH2F>("thetaYStartEndVsZ",
263  "#theta_{y,start}-#theta_{y,end} vs z_{start};z [cm];#Delta#theta_{y}",
264  50, -1600., 1600., 50,-.5,.5));
265  hists.Add(fd.make<TH2F>("momStartEndRelVsP",
266  "(p_{start}-p_{end})/p_{start} vs p_{start};p [GeV];#Deltap_{rel}",
267  kNumBins, pBinsLog, 50, .0, .8));
268  hists.Add(fd.make<TH2F>("phiXzStartEndVsP",
269  "#phi_{xz,start}-#phi_{xz,end} vs |p|_{start};p [GeV];#Delta#phi_{xz}",
270  kNumBins, pBinsLog, 100,-1.5, 1.5));
271  hists.Add(fd.make<TH2F>("thetaYStartEndVsP",
272  "#theta_{y,start}-#theta_{y,end} vs |p|_{start};p [GeV];#Delta#theta_{y}",
273  kNumBins, pBinsLog, 100,-1.,1.));
274 
275  const double maxR = theTargetCylinder->radius() * 1.1;
276  hists.Add(fd.make<TH1F>("radiusEnd", "end radius;r [cm]", 100, 0., maxR));
277  double minZ = theTargetPlaneMin->position().z();
278  minZ -= TMath::Abs(minZ) * 0.1;
279  double maxZ = theTargetPlaneMax->position().z();
280  maxZ += TMath::Abs(maxZ) * 0.1;
281  hists.Add(fd.make<TH1F>("zEnd", "end z;z [cm]", 100, minZ, maxZ));
282  hists.Add(fd.make<TH1F>("zDiff", "z_{start}-z_{end};#Deltaz [cm]", 100, -1000., 1000.));
283  hists.Add(fd.make<TH2F>("xyPlaneEnd", "end xy;x [cm];y [cm]", 100, -maxR, maxR, 100,-maxR,maxR));
284 
285  hists.Add(fd.make<TH2F>("rzPlaneEnd", "end rz (y<0 #Rightarrow r_{#pm}=-r);z [cm];r_{#pm} [cm]",
286  50, minZ, maxZ, 50, -maxR, maxR));
287  hists.Add(fd.make<TH2F>("thetaVsZend", "#theta vs z (end);z [cm];#theta",
288  50, minZ, maxZ, 50, 0., TMath::Pi()));
289 }
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
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
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 177 of file CosmicGenFilterHelix.cc.

References equidistLogBins(), TFileDirectory::mkdir(), and Pi.

Referenced by beginJob().

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

Reimplemented from edm::EDFilter.

Definition at line 292 of file CosmicGenFilterHelix.cc.

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

293 {
294  const char *border = "////////////////////////////////////////////////////////";
295  const char *line = "\n// ";
296  edm::LogInfo("Filter") << "@SUB=CosmicGenFilterHelix::endJob"
297  << border << line
298  << theNumPass << " events out of " << theNumTotal
299  << ", i.e. " << theNumPass*100./theNumTotal << "%, "
300  << "reached target cylinder,"
301  << line << "defined by r < "
302  << theTargetCylinder->radius() << " cm and "
303  << theTargetPlaneMin->position().z() << " < z < "
304  << theTargetPlaneMax->position().z() << " cm."
305  << line << "Minimal required (transverse) momentum was "
306  << TMath::Sqrt(theMinP2) << " (" << TMath::Sqrt(theMinPt2) << ") GeV."
307  << "\n" << border;
308 }
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 488 of file CosmicGenFilterHelix.cc.

References first, i, and prof2calltree::last.

Referenced by createHistsEnd(), and createHistsStart().

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

Implements edm::EDFilter.

Definition at line 83 of file CosmicGenFilterHelix.cc.

References ecalTB2006H4_GenSimDigiReco_cfg::bField, charge(), edm::Event::getByLabel(), getMagneticField(), getPropagator(), monitorStart(), propagateToCutCylinder(), LargeD0_PixelPairStep_cff::propagator, query::result, theDoMonitor, theHistsBefore, theNumPass, theNumTotal, and theSrc.

84 {
86  iEvent.getByLabel(theSrc, hepMCEvt);
87  const HepMC::GenEvent *mCEvt = hepMCEvt->GetEvent();
88  const MagneticField *bField = this->getMagneticField(iSetup); // should be fast (?)
89  const Propagator *propagator = this->getPropagator(iSetup);
90 
91  ++theNumTotal;
92  bool result = false;
93  for (HepMC::GenEvent::particle_const_iterator iPart = mCEvt->particles_begin(),
94  endPart = mCEvt->particles_end(); iPart != endPart; ++iPart) {
95  int charge = 0; // there is no method providing charge in GenParticle :-(
96  if ((*iPart)->status() != 1) continue; // look only at stable particles
97  if (!this->charge((*iPart)->pdg_id(), charge)) continue;
98 
99  // Get the position and momentum
100  const HepMC::ThreeVector hepVertex((*iPart)->production_vertex()->point3d());
101  const GlobalPoint vert(hepVertex.x()/10., hepVertex.y()/10., hepVertex.z()/10.); // to cm
102  const HepMC::FourVector hepMomentum((*iPart)->momentum());
103  const GlobalVector mom(hepMomentum.x(), hepMomentum.y(), hepMomentum.z());
104 
105  if (theDoMonitor) this->monitorStart(vert, mom, charge, theHistsBefore);
106 
107  if (this->propagateToCutCylinder(vert, mom, charge, bField, propagator)) {
108  result = true;
109  }
110  }
111 
112  if (result) ++theNumPass;
113  return result;
114 }
const edm::InputTag theSrc
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
int iEvent
Definition: GenABIO.cc:243
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 326 of file CosmicGenFilterHelix.cc.

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

Referenced by filter().

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

Definition at line 335 of file CosmicGenFilterHelix.cc.

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

Referenced by filter().

336 {
337  edm::ESHandle<Propagator> propHandle;
338  setup.get<TrackingComponentsRecord>().get(thePropagatorName, propHandle);
339 
340  const Propagator *prop = propHandle.product();
341  if (!dynamic_cast<const SteppingHelixPropagator*>(prop)) {
342  edm::LogWarning("BadConfig") << "@SUB=CosmicGenFilterHelix::getPropagator"
343  << "Not a SteppingHelixPropagator!";
344 
345  }
346  return prop;
347 }
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
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 411 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().

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

Definition at line 350 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(), detailsBasic3DVector::z, and PV3DBase< T, PVType, FrameType >::z().

Referenced by filter(), and propagateToCutCylinder().

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

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

Referenced by filter().

121 {
122  typedef std::pair<TrajectoryStateOnSurface, double> TsosPath;
123 
124  const FreeTrajectoryState fts(GlobalTrajectoryParameters(vertStart, momStart, charge, field));
125 
126  bool result = true;
127  TsosPath aTsosPath(propagator->propagateWithPath(fts, *theTargetCylinder));
128  if (!aTsosPath.first.isValid()) {
129  result = false;
130  } else if (aTsosPath.first.globalPosition().z() < theTargetPlaneMin->position().z()) {
131  // If on cylinder, but outside minimum z, try minimum z-plane:
132  // (Would it be possible to miss radius on plane, but reach cylinder afterwards in z-range?
133  // No, at least not in B-field parallel to z-axis which is cylinder axis.)
134  aTsosPath = propagator->propagateWithPath(fts, *theTargetPlaneMin);
135  if (!aTsosPath.first.isValid()
136  || aTsosPath.first.globalPosition().perp() > theTargetCylinder->radius()) {
137  result = false;
138  }
139  } else if (aTsosPath.first.globalPosition().z() > theTargetPlaneMax->position().z()) {
140  // Analog for outside maximum z:
141  aTsosPath = propagator->propagateWithPath(fts, *theTargetPlaneMax);
142  if (!aTsosPath.first.isValid()
143  || aTsosPath.first.globalPosition().perp() > theTargetCylinder->radius()) {
144  result = false;
145  }
146  }
147 
148  if (result) {
149  const GlobalVector momEnd(aTsosPath.first.globalMomentum());
150  if (momEnd.perp2() < theMinPt2 || momEnd.mag2() < theMinP2) {
151  result = false;
152  } else if (theDoMonitor) {
153  const GlobalPoint vertEnd(aTsosPath.first.globalPosition());
154  this->monitorStart(vertStart, momStart, charge, theHistsAfter);
155  this->monitorEnd(vertEnd, momEnd, vertStart, momStart, aTsosPath.second, theHistsAfter);
156  }
157  }
158 
159  return result;
160 }
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)
virtual std::pair< TrajectoryStateOnSurface, double > propagateWithPath(const FreeTrajectoryState &, const Surface &) const
Definition: Propagator.cc:77
tuple result
Definition: query.py:137
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 62 of file CosmicGenFilterHelix.h.

Referenced by charge(), and CosmicGenFilterHelix().

const bool CosmicGenFilterHelix::theDoMonitor
private

Definition at line 81 of file CosmicGenFilterHelix.h.

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

TObjArray CosmicGenFilterHelix::theHistsAfter
private

hists of properties from generator

Definition at line 83 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 82 of file CosmicGenFilterHelix.h.

Referenced by beginJob(), and filter().

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

Definition at line 61 of file CosmicGenFilterHelix.h.

Referenced by charge(), and CosmicGenFilterHelix().

const double CosmicGenFilterHelix::theMinP2
private

Definition at line 64 of file CosmicGenFilterHelix.h.

Referenced by endJob(), and propagateToCutCylinder().

const double CosmicGenFilterHelix::theMinPt2
private

minimal momentum^2 after propagation to cylinder

Definition at line 65 of file CosmicGenFilterHelix.h.

Referenced by endJob(), and propagateToCutCylinder().

unsigned int CosmicGenFilterHelix::theNumPass
private

for final statistics: all seen events

Definition at line 72 of file CosmicGenFilterHelix.h.

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

unsigned int CosmicGenFilterHelix::theNumTotal
private

plane closing cylinder at 'positive' side

Definition at line 71 of file CosmicGenFilterHelix.h.

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

const std::string CosmicGenFilterHelix::thePropagatorName
private

charges, parallel to theIds

Definition at line 63 of file CosmicGenFilterHelix.h.

Referenced by getPropagator().

const edm::InputTag CosmicGenFilterHelix::theSrc
private

Definition at line 60 of file CosmicGenFilterHelix.h.

Referenced by filter().

Cylinder::ConstCylinderPointer CosmicGenFilterHelix::theTargetCylinder
private

minimal transverse^2 momentum after propagation to cylinder

Definition at line 67 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 69 of file CosmicGenFilterHelix.h.

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

Plane::ConstPlanePointer CosmicGenFilterHelix::theTargetPlaneMin
private

target cylinder, around z-axis

Definition at line 68 of file CosmicGenFilterHelix.h.

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