Apply clang-format to source tree
[alexxy/gromacs.git] / src / gromacs / trajectoryanalysis / modules / angle.cpp
index ff81c402e453f8b76f1c5efb5ff7d90d134e95b8..344c4ee748fec8faff2de3a1989342518091272f 100644 (file)
@@ -1,7 +1,8 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2011,2012,2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2011-2018, The GROMACS development team.
+ * Copyright (c) 2019, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -104,138 +105,131 @@ namespace
  */
 class AnglePositionIterator
 {
-    public:
-        /*! \brief
-         * Creates an iterator to loop over input selection positions.
-         *
-         * \param[in] selections       List of selections.
-         * \param[in] posCountPerValue Number of selection positions that
-         *     constitute a single value for the iteration.
-         *
-         * If \p selections is empty, and/or \p posCountPerValue is zero, the
-         * iterator can still be advanced and hasValue()/hasSingleValue()
-         * called, but values cannot be accessed.
-         */
-        AnglePositionIterator(const SelectionList &selections,
-                              int                  posCountPerValue)
-            : selections_(selections), posCountPerValue_(posCountPerValue),
-              currentSelection_(0), nextPosition_(0)
-        {
-        }
+public:
+    /*! \brief
+     * Creates an iterator to loop over input selection positions.
+     *
+     * \param[in] selections       List of selections.
+     * \param[in] posCountPerValue Number of selection positions that
+     *     constitute a single value for the iteration.
+     *
+     * If \p selections is empty, and/or \p posCountPerValue is zero, the
+     * iterator can still be advanced and hasValue()/hasSingleValue()
+     * called, but values cannot be accessed.
+     */
+    AnglePositionIterator(const SelectionList& selections, int posCountPerValue) :
+        selections_(selections),
+        posCountPerValue_(posCountPerValue),
+        currentSelection_(0),
+        nextPosition_(0)
+    {
+    }
 
-        //! Advances the iterator to the next group of angles.
-        void nextGroup()
+    //! Advances the iterator to the next group of angles.
+    void nextGroup()
+    {
+        if (selections_.size() > 1)
         {
-            if (selections_.size() > 1)
-            {
-                ++currentSelection_;
-            }
-            nextPosition_ = 0;
+            ++currentSelection_;
         }
-        //! Advances the iterator to the next angle in the current group.
-        void nextValue()
+        nextPosition_ = 0;
+    }
+    //! Advances the iterator to the next angle in the current group.
+    void nextValue()
+    {
+        if (!hasSingleValue())
         {
-            if (!hasSingleValue())
-            {
-                nextPosition_ += posCountPerValue_;
-            }
+            nextPosition_ += posCountPerValue_;
         }
+    }
 
-        /*! \brief
-         * Returns whether this iterator represents any values.
-         *
-         * If the return value is `false`, only nextGroup(), nextValue() and
-         * hasSingleValue() are allowed to be called.
-         */
-        bool hasValue() const
-        {
-            return !selections_.empty();
-        }
-        /*! \brief
-         * Returns whether the current selection only contains a single value.
-         *
-         * Returns `false` if hasValue() returns false, which allows cutting
-         * some corners in consistency checks.
-         */
-        bool hasSingleValue() const
-        {
-            return hasValue() && currentSelection().posCount() == posCountPerValue_;
-        }
-        //! Returns whether the current selection is dynamic.
-        bool isDynamic() const
+    /*! \brief
+     * Returns whether this iterator represents any values.
+     *
+     * If the return value is `false`, only nextGroup(), nextValue() and
+     * hasSingleValue() are allowed to be called.
+     */
+    bool hasValue() const { return !selections_.empty(); }
+    /*! \brief
+     * Returns whether the current selection only contains a single value.
+     *
+     * Returns `false` if hasValue() returns false, which allows cutting
+     * some corners in consistency checks.
+     */
+    bool hasSingleValue() const
+    {
+        return hasValue() && currentSelection().posCount() == posCountPerValue_;
+    }
+    //! Returns whether the current selection is dynamic.
+    bool isDynamic() const { return currentSelection().isDynamic(); }
+    /*! \brief
+     * Returns whether positions in the current value are either all
+     * selected or all unselected.
+     */
+    bool allValuesConsistentlySelected() const
+    {
+        if (posCountPerValue_ <= 1)
         {
-            return currentSelection().isDynamic();
+            return true;
         }
-        /*! \brief
-         * Returns whether positions in the current value are either all
-         * selected or all unselected.
-         */
-        bool allValuesConsistentlySelected() const
+        const bool bSelected = currentPosition(0).selected();
+        for (int i = 1; i < posCountPerValue_; ++i)
         {
-            if (posCountPerValue_ <= 1)
+            if (currentPosition(i).selected() != bSelected)
             {
-                return true;
+                return false;
             }
-            const bool bSelected = currentPosition(0).selected();
-            for (int i = 1; i < posCountPerValue_; ++i)
-            {
-                if (currentPosition(i).selected() != bSelected)
-                {
-                    return false;
-                }
-            }
-            return true;
-        }
-        /*! \brief
-         * Returns whether positions in the current value are selected.
-         *
-         * Only works reliably if allValuesConsistentlySelected() returns
-         * `true`.
-         */
-        bool currentValuesSelected() const
-        {
-            return selections_.empty() || currentPosition(0).selected();
         }
+        return true;
+    }
+    /*! \brief
+     * Returns whether positions in the current value are selected.
+     *
+     * Only works reliably if allValuesConsistentlySelected() returns
+     * `true`.
+     */
+    bool currentValuesSelected() const
+    {
+        return selections_.empty() || currentPosition(0).selected();
+    }
 
-        //! Returns the currently active selection.
-        const Selection &currentSelection() const
-        {
-            GMX_ASSERT(currentSelection_ < ssize(selections_),
-                       "Accessing an invalid selection");
-            return selections_[currentSelection_];
-        }
-        //! Returns the `i`th position for the current value.
-        SelectionPosition currentPosition(int i) const
-        {
-            return currentSelection().position(nextPosition_ + i);
-        }
-        /*! \brief
-         * Extracts all coordinates corresponding to the current value.
-         *
-         * \param[out] x  Array to which the positions are extracted.
-         *
-         * \p x should contain at minimum the number of positions per value
-         * passed to the constructor.
-         */
-        void getCurrentPositions(rvec x[]) const
+    //! Returns the currently active selection.
+    const Selection& currentSelection() const
+    {
+        GMX_ASSERT(currentSelection_ < ssize(selections_), "Accessing an invalid selection");
+        return selections_[currentSelection_];
+    }
+    //! Returns the `i`th position for the current value.
+    SelectionPosition currentPosition(int i) const
+    {
+        return currentSelection().position(nextPosition_ + i);
+    }
+    /*! \brief
+     * Extracts all coordinates corresponding to the current value.
+     *
+     * \param[out] x  Array to which the positions are extracted.
+     *
+     * \p x should contain at minimum the number of positions per value
+     * passed to the constructor.
+     */
+    void getCurrentPositions(rvec x[]) const
+    {
+        GMX_ASSERT(posCountPerValue_ > 0, "Accessing positions for an invalid angle type");
+        GMX_ASSERT(nextPosition_ + posCountPerValue_ <= currentSelection().posCount(),
+                   "Accessing an invalid position");
+        for (int i = 0; i < posCountPerValue_; ++i)
         {
-            GMX_ASSERT(posCountPerValue_ > 0,
-                       "Accessing positions for an invalid angle type");
-            GMX_ASSERT(nextPosition_ + posCountPerValue_ <= currentSelection().posCount(),
-                       "Accessing an invalid position");
-            for (int i = 0; i < posCountPerValue_; ++i)
-            {
-                copy_rvec(currentPosition(i).x(), x[i]);
-            }
+            copy_rvec(currentPosition(i).x(), x[i]);
         }
+    }
 
-    private:
-        const SelectionList &selections_;
-        const int            posCountPerValue_;
-        int                  currentSelection_;
-        int                  nextPosition_;
+private:
+    const SelectionList& selections_;
+    const int            posCountPerValue_;
+    int                  currentSelection_;
+    int                  nextPosition_;
 
-        GMX_DISALLOW_COPY_AND_ASSIGN(AnglePositionIterator);
+    GMX_DISALLOW_COPY_AND_ASSIGN(AnglePositionIterator);
 };
 
 /********************************************************************
@@ -261,63 +255,60 @@ enum Group2Type
     Group2Type_SphereNormal
 };
 //! String values corresponding to Group1Type.
-const char *const cGroup1TypeEnum[] =
-{ "angle", "dihedral", "vector", "plane" };
+const char* const cGroup1TypeEnum[] = { "angle", "dihedral", "vector", "plane" };
 //! String values corresponding to Group2Type.
-const char *const cGroup2TypeEnum[] =
-{ "none", "vector", "plane", "t0", "z", "sphnorm" };
+const char* const cGroup2TypeEnum[] = { "none", "vector", "plane", "t0", "z", "sphnorm" };
 
 class Angle : public TrajectoryAnalysisModule
 {
-    public:
-        Angle();
-
-        void initOptions(IOptionsContainer          *options,
-                         TrajectoryAnalysisSettings *settings) override;
-        void optionsFinished(TrajectoryAnalysisSettings *settings) override;
-        void initAnalysis(const TrajectoryAnalysisSettings &settings,
-                          const TopologyInformation        &top) override;
-
-        void analyzeFrame(int frnr, const t_trxframe &fr, t_pbc *pbc,
-                          TrajectoryAnalysisModuleData *pdata) override;
-
-        void finishAnalysis(int nframes) override;
-        void writeOutput() override;
-
-    private:
-        void initFromSelections(const SelectionList &sel1,
-                                const SelectionList &sel2);
-        void checkSelections(const SelectionList &sel1,
-                             const SelectionList &sel2) const;
-
-        SelectionList                            sel1_;
-        SelectionList                            sel2_;
-        SelectionOptionInfo                     *sel1info_;
-        SelectionOptionInfo                     *sel2info_;
-        std::string                              fnAverage_;
-        std::string                              fnAll_;
-        std::string                              fnHistogram_;
-
-        Group1Type                               g1type_;
-        Group2Type                               g2type_;
-        double                                   binWidth_;
-
-        AnalysisData                             angles_;
-        AnalysisDataFrameAverageModulePointer    averageModule_;
-        AnalysisDataSimpleHistogramModulePointer histogramModule_;
-
-        std::vector<int>                         angleCount_;
-        int                                      natoms1_;
-        int                                      natoms2_;
-        std::vector<std::vector<RVec> >          vt0_;
-
-        // Copy and assign disallowed by base.
+public:
+    Angle();
+
+    void initOptions(IOptionsContainer* options, TrajectoryAnalysisSettings* settings) override;
+    void optionsFinished(TrajectoryAnalysisSettings* settings) override;
+    void initAnalysis(const TrajectoryAnalysisSettings& settings, const TopologyInformation& top) override;
+
+    void analyzeFrame(int frnr, const t_trxframe& fr, t_pbc* pbc, TrajectoryAnalysisModuleData* pdata) override;
+
+    void finishAnalysis(int nframes) override;
+    void writeOutput() override;
+
+private:
+    void initFromSelections(const SelectionList& sel1, const SelectionList& sel2);
+    void checkSelections(const SelectionList& sel1, const SelectionList& sel2) const;
+
+    SelectionList        sel1_;
+    SelectionList        sel2_;
+    SelectionOptionInfo* sel1info_;
+    SelectionOptionInfo* sel2info_;
+    std::string          fnAverage_;
+    std::string          fnAll_;
+    std::string          fnHistogram_;
+
+    Group1Type g1type_;
+    Group2Type g2type_;
+    double     binWidth_;
+
+    AnalysisData                             angles_;
+    AnalysisDataFrameAverageModulePointer    averageModule_;
+    AnalysisDataSimpleHistogramModulePointer histogramModule_;
+
+    std::vector<int>               angleCount_;
+    int                            natoms1_;
+    int                            natoms2_;
+    std::vector<std::vector<RVec>> vt0_;
+
+    // Copy and assign disallowed by base.
 };
 
-Angle::Angle()
-    : sel1info_(nullptr), sel2info_(nullptr),
-      g1type_(Group1Type_Angle), g2type_(Group2Type_None),
-      binWidth_(1.0), natoms1_(0), natoms2_(0)
+Angle::Angle() :
+    sel1info_(nullptr),
+    sel2info_(nullptr),
+    g1type_(Group1Type_Angle),
+    g2type_(Group2Type_None),
+    binWidth_(1.0),
+    natoms1_(0),
+    natoms2_(0)
 {
     averageModule_ = std::make_unique<AnalysisDataFrameAverageModule>();
     angles_.addModule(averageModule_);
@@ -330,10 +321,9 @@ Angle::Angle()
 }
 
 
-void
-Angle::initOptions(IOptionsContainer *options, TrajectoryAnalysisSettings *settings)
+void Angle::initOptions(IOptionsContainer* options, TrajectoryAnalysisSettings* settings)
 {
-    static const char *const desc[] = {
+    static const charconst desc[] = {
         "[THISMODULE] computes different types of angles between vectors.",
         "It supports both vectors defined by two positions and normals of",
         "planes defined by three positions.",
@@ -384,99 +374,102 @@ Angle::initOptions(IOptionsContainer *options, TrajectoryAnalysisSettings *setti
 
     settings->setHelpText(desc);
 
-    options->addOption(FileNameOption("oav").filetype(eftPlot).outputFile()
-                           .store(&fnAverage_).defaultBasename("angaver")
-                           .description("Average angles as a function of time"));
-    options->addOption(FileNameOption("oall").filetype(eftPlot).outputFile()
-                           .store(&fnAll_).defaultBasename("angles")
-                           .description("All angles as a function of time"));
-    options->addOption(FileNameOption("oh").filetype(eftPlot).outputFile()
-                           .store(&fnHistogram_).defaultBasename("anghist")
-                           .description("Histogram of the angles"));
-
-    options->addOption(EnumOption<Group1Type>("g1").enumValue(cGroup1TypeEnum)
-                           .store(&g1type_)
-                           .description("Type of analysis/first vector group"));
-    options->addOption(EnumOption<Group2Type>("g2").enumValue(cGroup2TypeEnum)
-                           .store(&g2type_)
-                           .description("Type of second vector group"));
-    options->addOption(DoubleOption("binw").store(&binWidth_)
-                           .description("Binwidth for -oh in degrees"));
-
-    sel1info_ = options->addOption(SelectionOption("group1")
-                                       .required().dynamicMask().storeVector(&sel1_)
-                                       .multiValue()
-                                       .description("First analysis/vector selection"));
-    sel2info_ = options->addOption(SelectionOption("group2")
-                                       .dynamicMask().storeVector(&sel2_)
-                                       .multiValue()
-                                       .description("Second analysis/vector selection"));
+    options->addOption(FileNameOption("oav")
+                               .filetype(eftPlot)
+                               .outputFile()
+                               .store(&fnAverage_)
+                               .defaultBasename("angaver")
+                               .description("Average angles as a function of time"));
+    options->addOption(FileNameOption("oall")
+                               .filetype(eftPlot)
+                               .outputFile()
+                               .store(&fnAll_)
+                               .defaultBasename("angles")
+                               .description("All angles as a function of time"));
+    options->addOption(FileNameOption("oh")
+                               .filetype(eftPlot)
+                               .outputFile()
+                               .store(&fnHistogram_)
+                               .defaultBasename("anghist")
+                               .description("Histogram of the angles"));
+
+    options->addOption(
+            EnumOption<Group1Type>("g1").enumValue(cGroup1TypeEnum).store(&g1type_).description("Type of analysis/first vector group"));
+    options->addOption(
+            EnumOption<Group2Type>("g2").enumValue(cGroup2TypeEnum).store(&g2type_).description("Type of second vector group"));
+    options->addOption(
+            DoubleOption("binw").store(&binWidth_).description("Binwidth for -oh in degrees"));
+
+    sel1info_ = options->addOption(
+            SelectionOption("group1").required().dynamicMask().storeVector(&sel1_).multiValue().description(
+                    "First analysis/vector selection"));
+    sel2info_ = options->addOption(
+            SelectionOption("group2").dynamicMask().storeVector(&sel2_).multiValue().description(
+                    "Second analysis/vector selection"));
 }
 
 
-void
-Angle::optionsFinished(TrajectoryAnalysisSettings * /* settings */)
+void Angle::optionsFinished(TrajectoryAnalysisSettings* /* settings */)
 {
     const bool bSingle = (g1type_ == Group1Type_Angle || g1type_ == Group1Type_Dihedral);
 
     if (bSingle && g2type_ != Group2Type_None)
     {
-        GMX_THROW(InconsistentInputError("Cannot use a second group (-g2) with "
-                                         "-g1 angle or dihedral"));
+        GMX_THROW(
+                InconsistentInputError("Cannot use a second group (-g2) with "
+                                       "-g1 angle or dihedral"));
     }
     if (bSingle && sel2info_->isSet())
     {
-        GMX_THROW(InconsistentInputError("Cannot provide a second selection "
-                                         "(-group2) with -g1 angle or dihedral"));
+        GMX_THROW(
+                InconsistentInputError("Cannot provide a second selection "
+                                       "(-group2) with -g1 angle or dihedral"));
     }
     if (!bSingle && g2type_ == Group2Type_None)
     {
-        GMX_THROW(InconsistentInputError("Should specify a second group (-g2) "
-                                         "if the first group is not an angle or a dihedral"));
+        GMX_THROW(
+                InconsistentInputError("Should specify a second group (-g2) "
+                                       "if the first group is not an angle or a dihedral"));
     }
 
     // Set up the number of positions per angle.
     switch (g1type_)
     {
-        case Group1Type_Angle:    natoms1_ = 3; break;
+        case Group1Type_Angle: natoms1_ = 3; break;
         case Group1Type_Dihedral: natoms1_ = 4; break;
-        case Group1Type_Vector:   natoms1_ = 2; break;
-        case Group1Type_Plane:    natoms1_ = 3; break;
-        default:
-            GMX_THROW(InternalError("invalid -g1 value"));
+        case Group1Type_Vector: natoms1_ = 2; break;
+        case Group1Type_Plane: natoms1_ = 3; break;
+        default: GMX_THROW(InternalError("invalid -g1 value"));
     }
     switch (g2type_)
     {
-        case Group2Type_None:         natoms2_ = 0; break;
-        case Group2Type_Vector:       natoms2_ = 2; break;
-        case Group2Type_Plane:        natoms2_ = 3; break;
-        case Group2Type_TimeZero:     natoms2_ = 0; break;
-        case Group2Type_Z:            natoms2_ = 0; break;
+        case Group2Type_None: natoms2_ = 0; break;
+        case Group2Type_Vector: natoms2_ = 2; break;
+        case Group2Type_Plane: natoms2_ = 3; break;
+        case Group2Type_TimeZero: natoms2_ = 0; break;
+        case Group2Type_Z: natoms2_ = 0; break;
         case Group2Type_SphereNormal: natoms2_ = 1; break;
-        default:
-            GMX_THROW(InternalError("invalid -g2 value"));
+        default: GMX_THROW(InternalError("invalid -g2 value"));
     }
     if (natoms2_ == 0 && sel2info_->isSet())
     {
-        GMX_THROW(InconsistentInputError("Cannot provide a second selection (-group2) with -g2 t0 or z"));
+        GMX_THROW(InconsistentInputError(
+                "Cannot provide a second selection (-group2) with -g2 t0 or z"));
     }
     // TODO: If bSingle is not set, the second selection option should be
     // required.
 }
 
 
-void
-Angle::initFromSelections(const SelectionList &sel1,
-                          const SelectionList &sel2)
+void Angle::initFromSelections(const SelectionList& sel1, const SelectionList& sel2)
 {
     const int  angleGroups         = std::max(sel1.size(), sel2.size());
     const bool bHasSecondSelection = natoms2_ > 0;
 
-    if (bHasSecondSelection && sel1.size() != sel2.size()
-        && std::min(sel1.size(), sel2.size()) != 1)
+    if (bHasSecondSelection && sel1.size() != sel2.size() && std::min(sel1.size(), sel2.size()) != 1)
     {
         GMX_THROW(InconsistentInputError(
-                          "-group1 and -group2 should specify the same number of selections"));
+                "-group1 and -group2 should specify the same number of selections"));
     }
 
     AnglePositionIterator iter1(sel1, natoms1_);
@@ -487,8 +480,8 @@ Angle::initFromSelections(const SelectionList &sel1,
         if (natoms1_ > 1 && posCount1 % natoms1_ != 0)
         {
             GMX_THROW(InconsistentInputError(formatString(
-                                                     "Number of positions in selection %d in the first group not divisible by %d",
-                                                     static_cast<int>(g + 1), natoms1_)));
+                    "Number of positions in selection %d in the first group not divisible by %d",
+                    static_cast<int>(g + 1), natoms1_)));
         }
         const int angleCount1 = posCount1 / natoms1_;
         int       angleCount  = angleCount1;
@@ -498,23 +491,23 @@ Angle::initFromSelections(const SelectionList &sel1,
             const int posCount2 = iter2.currentSelection().posCount();
             if (natoms2_ > 1 && posCount2 % natoms2_ != 0)
             {
-                GMX_THROW(InconsistentInputError(formatString(
-                                                         "Number of positions in selection %d in the second group not divisible by %d",
-                                                         static_cast<int>(g + 1), natoms2_)));
+                GMX_THROW(InconsistentInputError(
+                        formatString("Number of positions in selection %d in the second group not "
+                                     "divisible by %d",
+                                     static_cast<int>(g + 1), natoms2_)));
             }
             if (g2type_ == Group2Type_SphereNormal && posCount2 != 1)
             {
                 GMX_THROW(InconsistentInputError(
-                                  "The second group should contain a single position with -g2 sphnorm"));
+                        "The second group should contain a single position with -g2 sphnorm"));
             }
 
             const int angleCount2 = posCount2 / natoms2_;
-            angleCount = std::max(angleCount1, angleCount2);
-            if (angleCount1 != angleCount2
-                && std::min(angleCount1, angleCount2) != 1)
+            angleCount            = std::max(angleCount1, angleCount2);
+            if (angleCount1 != angleCount2 && std::min(angleCount1, angleCount2) != 1)
             {
                 GMX_THROW(InconsistentInputError(
-                                  "Number of vectors defined by the two groups are not the same"));
+                        "Number of vectors defined by the two groups are not the same"));
             }
         }
         angleCount_.push_back(angleCount);
@@ -522,9 +515,7 @@ Angle::initFromSelections(const SelectionList &sel1,
 }
 
 
-void
-Angle::checkSelections(const SelectionList &sel1,
-                       const SelectionList &sel2) const
+void Angle::checkSelections(const SelectionList& sel1, const SelectionList& sel2) const
 {
     AnglePositionIterator iter1(sel1, natoms1_);
     AnglePositionIterator iter2(sel2, natoms2_);
@@ -555,18 +546,17 @@ Angle::checkSelections(const SelectionList &sel1,
                     }
                 }
                 if (iter2.hasValue()
-                    && (angleCount_[g] == 1
-                        || (!iter1.hasSingleValue() && !iter2.hasSingleValue()))
+                    && (angleCount_[g] == 1 || (!iter1.hasSingleValue() && !iter2.hasSingleValue()))
                     && iter1.currentValuesSelected() != iter2.currentValuesSelected())
                 {
                     bOk = false;
                 }
                 if (!bOk)
                 {
-                    std::string message =
-                        formatString("Dynamic selection %d does not select "
-                                     "a consistent set of angles over the frames",
-                                     static_cast<int>(g + 1));
+                    std::string message = formatString(
+                            "Dynamic selection %d does not select "
+                            "a consistent set of angles over the frames",
+                            static_cast<int>(g + 1));
                     GMX_THROW(InconsistentInputError(message));
                 }
             }
@@ -575,9 +565,7 @@ Angle::checkSelections(const SelectionList &sel1,
 }
 
 
-void
-Angle::initAnalysis(const TrajectoryAnalysisSettings &settings,
-                    const TopologyInformation         & /* top */)
+void Angle::initAnalysis(const TrajectoryAnalysisSettings& settings, const TopologyInformation& /* top */)
 {
     initFromSelections(sel1_, sel2_);
 
@@ -588,8 +576,7 @@ Angle::initAnalysis(const TrajectoryAnalysisSettings &settings,
         angles_.setColumnCount(i, angleCount_[i]);
     }
     double histogramMin = (g1type_ == Group1Type_Dihedral ? -180.0 : 0);
-    histogramModule_->init(histogramFromRange(histogramMin, 180.0)
-                               .binWidth(binWidth_).includeAll());
+    histogramModule_->init(histogramFromRange(histogramMin, 180.0).binWidth(binWidth_).includeAll());
 
     if (g2type_ == Group2Type_TimeZero)
     {
@@ -602,8 +589,7 @@ Angle::initAnalysis(const TrajectoryAnalysisSettings &settings,
 
     if (!fnAverage_.empty())
     {
-        AnalysisDataPlotModulePointer plotm(
-                new AnalysisDataPlotModule(settings.plotSettings()));
+        AnalysisDataPlotModulePointer plotm(new AnalysisDataPlotModule(settings.plotSettings()));
         plotm->setFileName(fnAverage_);
         plotm->setTitle("Average angle");
         plotm->setXAxisIsTime();
@@ -619,8 +605,7 @@ Angle::initAnalysis(const TrajectoryAnalysisSettings &settings,
 
     if (!fnAll_.empty())
     {
-        AnalysisDataPlotModulePointer plotm(
-                new AnalysisDataPlotModule(settings.plotSettings()));
+        AnalysisDataPlotModulePointer plotm(new AnalysisDataPlotModule(settings.plotSettings()));
         plotm->setFileName(fnAll_);
         plotm->setTitle("Angle");
         plotm->setXAxisIsTime();
@@ -631,8 +616,7 @@ Angle::initAnalysis(const TrajectoryAnalysisSettings &settings,
 
     if (!fnHistogram_.empty())
     {
-        AnalysisDataPlotModulePointer plotm(
-                new AnalysisDataPlotModule(settings.plotSettings()));
+        AnalysisDataPlotModulePointer plotm(new AnalysisDataPlotModule(settings.plotSettings()));
         plotm->setFileName(fnHistogram_);
         plotm->setTitle("Angle histogram");
         plotm->setXLabel("Angle (degrees)");
@@ -649,8 +633,7 @@ Angle::initAnalysis(const TrajectoryAnalysisSettings &settings,
 
 
 //! Helper method to calculate a vector from two or three positions.
-void
-calc_vec(int natoms, rvec x[], t_pbc *pbc, rvec xout, rvec cout)
+void calc_vec(int natoms, rvec x[], t_pbc* pbc, rvec xout, rvec cout)
 {
     switch (natoms)
     {
@@ -682,22 +665,19 @@ calc_vec(int natoms, rvec x[], t_pbc *pbc, rvec xout, rvec cout)
             cprod(v1, v2, xout);
             rvec_add(x[0], x[1], cout);
             rvec_add(cout, x[2], cout);
-            svmul(1.0/3.0, cout, cout);
+            svmul(1.0 / 3.0, cout, cout);
             break;
         }
-        default:
-            GMX_RELEASE_ASSERT(false, "Incorrectly initialized number of atoms");
+        default: GMX_RELEASE_ASSERT(false, "Incorrectly initialized number of atoms");
     }
 }
 
 
-void
-Angle::analyzeFrame(int frnr, const t_trxframe &fr, t_pbc *pbc,
-                    TrajectoryAnalysisModuleData *pdata)
+void Angle::analyzeFrame(int frnr, const t_trxframe& fr, t_pbc* pbc, TrajectoryAnalysisModuleData* pdata)
 {
-    AnalysisDataHandle       dh   = pdata->dataHandle(angles_);
-    const SelectionList     &sel1 = pdata->parallelSelections(sel1_);
-    const SelectionList     &sel2 = pdata->parallelSelections(sel2_);
+    AnalysisDataHandle   dh   = pdata->dataHandle(angles_);
+    const SelectionListsel1 = pdata->parallelSelections(sel1_);
+    const SelectionListsel2 = pdata->parallelSelections(sel2_);
 
     checkSelections(sel1, sel2);
 
@@ -707,8 +687,8 @@ Angle::analyzeFrame(int frnr, const t_trxframe &fr, t_pbc *pbc,
     AnglePositionIterator iter2(sel2, natoms2_);
     for (size_t g = 0; g < angleCount_.size(); ++g, iter1.nextGroup(), iter2.nextGroup())
     {
-        rvec  v1, v2;
-        rvec  c1, c2;
+        rvec v1, v2;
+        rvec c1, c2;
 
         // v2 & c2 are conditionally set in the switch statement below, and conditionally
         // used in a different switch statement later. Apparently the clang static analyzer
@@ -721,12 +701,8 @@ Angle::analyzeFrame(int frnr, const t_trxframe &fr, t_pbc *pbc,
 
         switch (g2type_)
         {
-            case Group2Type_Z:
-                v2[ZZ] = 1.0;
-                break;
-            case Group2Type_SphereNormal:
-                copy_rvec(sel2_[g].position(0).x(), c2);
-                break;
+            case Group2Type_Z: v2[ZZ] = 1.0; break;
+            case Group2Type_SphereNormal: copy_rvec(sel2_[g].position(0).x(), c2); break;
             default:
                 // do nothing
                 break;
@@ -737,15 +713,14 @@ Angle::analyzeFrame(int frnr, const t_trxframe &fr, t_pbc *pbc,
         {
             rvec x[4];
             // x[] will be assigned below based on the number of atoms used to initialize iter1,
-            // which in turn should correspond perfectly to g1type_ (which determines how many we read),
-            // but unsurprisingly the static analyzer chokes a bit on that.
+            // which in turn should correspond perfectly to g1type_ (which determines how many we
+            // read), but unsurprisingly the static analyzer chokes a bit on that.
             clear_rvecs(4, x);
 
             real angle;
             // checkSelections() ensures that this reflects all the involved
             // positions.
-            const bool bPresent =
-                iter1.currentValuesSelected() && iter2.currentValuesSelected();
+            const bool bPresent = iter1.currentValuesSelected() && iter2.currentValuesSelected();
             iter1.getCurrentPositions(x);
             switch (g1type_)
             {
@@ -779,7 +754,7 @@ Angle::analyzeFrame(int frnr, const t_trxframe &fr, t_pbc *pbc,
                     }
                     cprod(dx[0], dx[1], v1);
                     cprod(dx[1], dx[2], v2);
-                    angle = gmx_angle(v1, v2);
+                    angle    = gmx_angle(v1, v2);
                     real ipr = iprod(dx[0], v2);
                     if (ipr < 0)
                     {
@@ -805,9 +780,7 @@ Angle::analyzeFrame(int frnr, const t_trxframe &fr, t_pbc *pbc,
                             }
                             copy_rvec(vt0_[g][n], v2);
                             break;
-                        case Group2Type_Z:
-                            c1[XX] = c1[YY] = 0.0;
-                            break;
+                        case Group2Type_Z: c1[XX] = c1[YY] = 0.0; break;
                         case Group2Type_SphereNormal:
                             if (pbc)
                             {
@@ -818,13 +791,11 @@ Angle::analyzeFrame(int frnr, const t_trxframe &fr, t_pbc *pbc,
                                 rvec_sub(c1, c2, v2);
                             }
                             break;
-                        default:
-                            GMX_THROW(InternalError("invalid -g2 value"));
+                        default: GMX_THROW(InternalError("invalid -g2 value"));
                     }
                     angle = gmx_angle(v1, v2);
                     break;
-                default:
-                    GMX_THROW(InternalError("invalid -g1 value"));
+                default: GMX_THROW(InternalError("invalid -g1 value"));
             }
             dh.setPoint(n, angle * RAD2DEG, bPresent);
         }
@@ -833,25 +804,20 @@ Angle::analyzeFrame(int frnr, const t_trxframe &fr, t_pbc *pbc,
 }
 
 
-void
-Angle::finishAnalysis(int /*nframes*/)
+void Angle::finishAnalysis(int /*nframes*/)
 {
-    AbstractAverageHistogram &averageHistogram = histogramModule_->averager();
+    AbstractAverageHistogramaverageHistogram = histogramModule_->averager();
     averageHistogram.normalizeProbability();
     averageHistogram.done();
 }
 
 
-void
-Angle::writeOutput()
-{
-}
+void Angle::writeOutput() {}
 
-}       // namespace
+} // namespace
 
 const char AngleInfo::name[]             = "gangle";
-const char AngleInfo::shortDescription[] =
-    "Calculate angles";
+const char AngleInfo::shortDescription[] = "Calculate angles";
 
 TrajectoryAnalysisModulePointer AngleInfo::create()
 {