LCOV - code coverage report
Current view: top level - vesselbase - Histogram.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 19 19 100.0 %
Date: 2018-12-19 07:49:13 Functions: 10 10 100.0 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2013-2018 The plumed team
       3             :    (see the PEOPLE file at the root of the distribution for a list of names)
       4             : 
       5             :    See http://www.plumed.org for more information.
       6             : 
       7             :    This file is part of plumed, version 2.
       8             : 
       9             :    plumed is free software: you can redistribute it and/or modify
      10             :    it under the terms of the GNU Lesser General Public License as published by
      11             :    the Free Software Foundation, either version 3 of the License, or
      12             :    (at your option) any later version.
      13             : 
      14             :    plumed is distributed in the hope that it will be useful,
      15             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      16             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17             :    GNU Lesser General Public License for more details.
      18             : 
      19             :    You should have received a copy of the GNU Lesser General Public License
      20             :    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
      21             : +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
      22             : #include "tools/HistogramBead.h"
      23             : #include "VesselRegister.h"
      24             : #include "ShortcutVessel.h"
      25             : 
      26             : namespace PLMD {
      27             : namespace vesselbase {
      28             : 
      29          20 : class Histogram : public ShortcutVessel {
      30             : public:
      31             :   static void registerKeywords( Keywords& keys );
      32             :   static void reserveKeyword( Keywords& keys );
      33             :   explicit Histogram( const VesselOptions& da );
      34             : };
      35             : 
      36        2533 : PLUMED_REGISTER_VESSEL(Histogram,"HISTOGRAM")
      37             : 
      38          10 : void Histogram::registerKeywords( Keywords& keys ) {
      39          10 :   ShortcutVessel::registerKeywords( keys );
      40          10 :   HistogramBead::registerKeywords( keys );
      41          10 :   keys.add("compulsory","NBINS","The number of equal width bins you want to divide the range into");
      42          10 :   keys.addFlag("NORM",false,"calculate the fraction of values rather than the number");
      43          10 : }
      44             : 
      45         841 : void Histogram::reserveKeyword( Keywords& keys ) {
      46             :   keys.reserve("vessel","HISTOGRAM","calculate a discretized histogram of the distribution of values. "
      47         841 :                "This shortcut allows you to calculates NBIN quantites like BETWEEN.");
      48         841 : }
      49             : 
      50          10 : Histogram::Histogram( const VesselOptions& da ):
      51          10 :   ShortcutVessel(da)
      52             : {
      53          10 :   bool norm; parseFlag("NORM",norm); std::string normstr="";
      54          10 :   if(norm) normstr=" NORM";
      55          20 :   std::vector<std::string> bins; HistogramBead::generateBins( getAllInput(), bins );
      56          20 :   for(unsigned i=0; i<bins.size(); ++i) addVessel("BETWEEN",bins[i] + normstr);
      57          10 : }
      58             : 
      59             : }
      60        2523 : }

Generated by: LCOV version 1.13