IMP  2.3.1
The Integrative Modeling Platform
CentroidOfRefined.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/CentroidOfRefined.h
3  * \brief Set the coordinates of the particle to be the centroid of the
4  * refined particles.
5  *
6  * Copyright 2007-2014 IMP Inventors. All rights reserved.
7  */
8 
9 #ifndef IMPCORE_CENTROID_OF_REFINED_H
10 #define IMPCORE_CENTROID_OF_REFINED_H
11 
12 #include <IMP/core/core_config.h>
13 #include "XYZ.h"
14 #include <IMP/Refiner.h>
15 #include <IMP/macros.h>
16 #include <IMP/base/Pointer.h>
17 #include <IMP/Decorator.h>
18 #include <IMP/SingletonModifier.h>
19 #include "DerivativesToRefined.h"
20 
21 IMPCORE_BEGIN_NAMESPACE
22 
23 //! Set the coordinates (or any float keys) of the particle to be the centroid of
24 //! the corresponding keys in a set of fine particles.
25 /** An exception is thrown if there are no refined particles. The weight
26  FloatKey can be used to reweight the centroid computation, or it can be set
27  to FloatKey() and then all the weights will be equal to 1.0.
28 
29  \see CoverRefined
30  \see DerivativesToRefined
31  \see DerivativesFromRefined
32  */
33 class IMPCOREEXPORT CentroidOfRefined : public SingletonModifier {
35  FloatKeys ks_;
36  FloatKey w_;
37 
38  public:
39  //! Set the keys ks to be the average of the refined particles.
40  /**
41  @param r refiner used to retrieve the set of fine particles
42  @param weight a key used to reweight the contribution of each
43  fine particle to the centroid (eg, mass). In the
44  centroid, this key will be set by apply_index() to
45  the sum of all weights. A default weight of 1.0 is
46  used if weight equals FloatKey().
47  @param ks the keys over which the centroid is calculated
48  */
50  FloatKeys ks = XYZ::get_xyz_keys());
51 
52  /**
53  Compute the weighted centroid of the keys of refine particles (as passed in
54  the constructor), and store the centroid values in the corresponding keys of
55  particle pi. The sum of all weight of the refined particles are stored
56  in the corresponding weight key of pi (it is assumed that pi has this key).
57 
58  @param m the model of pi
59  @param pi the centroid particle
60  */
61  virtual void apply_index(kernel::Model *m, kernel::ParticleIndex pi) const
63 
66 
69 
71 
73 };
74 
75 //! A particle that is the geometric centroid of other particles.
76 /** A decorator which constrains a particle to be the centroid of a
77  set of other particles. The centroid is updated before model
78  evaluation and its derivatives are copied to its children,
79  using a constraint that is created at setup time.
80 
81  \usesconstraint
82 */
84  Centroid is computed before each evaluation);
85 
86 
87 IMPCORE_END_NAMESPACE
88 
89 #endif /* IMPCORE_CENTROID_OF_REFINED_H */
#define IMP_SUMMARIZE_DECORATOR_DECL(Name, Parent, Members, SetupDoc)
Create a decorator that computes some sort of summary info on a set.
Import IMP/kernel/Decorator.h in the namespace.
Import IMP/kernel/SingletonModifier.h in the namespace.
Accumulate the derivatives of the refined particles.
A smart pointer to a ref-counted Object that is a class member.
Definition: Pointer.h:147
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
A particle that is the geometric centroid of other particles.
Import IMP/kernel/macros.h in the namespace.
virtual void apply_index(kernel::Model *m, kernel::ParticleIndex v) const
Simple XYZ decorator.
A base class for modifiers of kernel::ParticlesTemp.
Import IMP/kernel/Refiner.h in the namespace.
virtual ModelObjectsTemp do_get_inputs(kernel::Model *m, const ParticleIndexes &pis) const
A decorator for a particle with x,y,z coordinates.
Definition: XYZ.h:30
virtual ModelObjectsTemp do_get_outputs(kernel::Model *m, const ParticleIndexes &pis) const
A nullptr-initialized pointer to an IMP Object.
#define IMP_SINGLETON_MODIFIER_METHODS(Name)
Abstract class to implement hierarchical methods.
Key< 0, true > FloatKey
The type used to identify float attributes in the Particles.
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.
Class for storing model, its restraints, constraints, and particles.
Definition: kernel/Model.h:73