IMP logo
IMP Reference Guide  2.22.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-2022 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 a particle to be the centroid of the refined particles.
24 /** Set the coordinates (or any float keys) of the particle to be the
25  centroid of the corresponding keys in a set of fine particles.
26  An exception is thrown if there are no refined particles. The weight
27  FloatKey can be used to reweight the centroid computation, or it can be set
28  to FloatKey() and then all the weights will be equal to 1.0.
29 
30  \see CoverRefined
31  \see DerivativesToRefined
32  \see DerivativesFromRefined
33  */
34 class IMPCOREEXPORT CentroidOfRefined : public SingletonModifier {
35  PointerMember<Refiner> refiner_;
36  FloatKeys ks_;
37  FloatKey w_;
38 
39  public:
40  //! Set the keys ks to be the average of the refined particles.
41  /**
42  @param r refiner used to retrieve the set of fine particles
43  @param weight a key used to reweight the contribution of each
44  fine particle to the centroid (eg, mass). In the
45  centroid, this key will be set by apply_index() to
46  the sum of all weights. A default weight of 1.0 is
47  used if weight equals FloatKey().
48  @param ks the keys over which the centroid is calculated
49  */
51  FloatKeys ks = XYZ::get_xyz_keys());
52 
53  /**
54  Compute the weighted centroid of the keys of refine particles (as passed in
55  the constructor), and store the centroid values in the corresponding keys of
56  particle pi. The sum of all weight of the refined particles are stored
57  in the corresponding weight key of pi (it is assumed that pi has this key).
58 
59  @param m the model of pi
60  @param pi the centroid particle
61  */
62  virtual void apply_index(Model *m, ParticleIndex pi) const
63  override;
64 
66  Model *m, const ParticleIndexes &pis) const override;
67 
69  Model *m, const ParticleIndexes &pis) const override;
70 
72 
74 };
75 
76 //! A particle that is the geometric centroid of other particles.
77 /** A decorator which constrains a particle to be the centroid of a
78  set of other particles. The centroid is updated before model
79  evaluation and its derivatives are copied to its children,
80  using a constraint that is created at setup time.
81 
82  \usesconstraint
83 */
85  Centroid is computed before each evaluation);
86 
87 
88 IMPCORE_END_NAMESPACE
89 
90 #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:86
#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:143
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
Set a particle to be the centroid of the refined particles.