IMP logo
IMP Reference Guide  2.10.0
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-2018 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/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 {
34  PointerMember<Refiner> refiner_;
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(Model *m, ParticleIndex pi) const
63 
65  Model *m, const ParticleIndexes &pis) const IMP_OVERRIDE;
66 
68  Model *m, const ParticleIndexes &pis) const IMP_OVERRIDE;
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 */
The base class for decorators.
A base class for modifiers of ParticlesTemp.
A Modifier on ParticlesTemp.
Key< 0 > FloatKey
The type used to identify float attributes in the Particles.
Definition: base_types.h:32
Accumulate the derivatives of the refined particles.
#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.
Various general useful macros for IMP.
virtual ModelObjectsTemp do_get_outputs(Model *m, const ParticleIndexes &pis) const =0
Overload this method to specify the outputs.
Simple XYZ decorator.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
#define IMP_SINGLETON_MODIFIER_METHODS(Name)
Refine a particle into a list of particles.
A smart pointer to a ref-counted Object that is a class member.
Definition: Pointer.h:146
virtual ModelObjectsTemp do_get_inputs(Model *m, const ParticleIndexes &pis) const =0
Overload this method to specify the inputs.
A decorator for a particle with x,y,z coordinates.
Definition: XYZ.h:30
#define IMP_SUMMARIZE_DECORATOR_DECL(Name, Parent, Members, SetupDoc)
Create a decorator that computes some sort of summary info on a set.
A nullptr-initialized pointer to an IMP Object.
virtual void apply_index(Model *m, ParticleIndex v) const =0
Abstract class to implement hierarchical methods.
Definition: Refiner.h:34
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.