All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Histogram.cpp
Go to the documentation of this file.
1 /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2  Copyright (c) 2013 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-code.org for more information.
6 
7  This file is part of plumed, version 2.0.
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 class Histogram : public ShortcutVessel {
30 public:
31  static void registerKeywords( Keywords& keys );
32  static void reserveKeyword( Keywords& keys );
33  Histogram( const VesselOptions& da );
34 };
35 
37 
38 void Histogram::registerKeywords( Keywords& keys ){
41  keys.add("compulsory","NBINS","The number of equal width bins you want to divide the range into");
42  keys.addFlag("NORM",false,"calculate the fraction of values rather than the number");
43 }
44 
46  keys.reserve("optional","HISTOGRAM","calculate a discretized histogram of the distribution of values. "
47  "This shortcut allows you to calculates NBIN quantites like BETWEEN.");
48 }
49 
52 {
53  bool norm; parseFlag("NORM",norm); std::string normstr="";
54  if(norm) normstr=" NORM";
55  std::vector<std::string> bins; HistogramBead::generateBins( getAllInput(), "", bins );
56  for(unsigned i=0;i<bins.size();++i) addVessel("BETWEEN",bins[i] + normstr);
57 }
58 
59 }
60 }
static void registerKeywords(Keywords &keys)
static void registerKeywords(Keywords &keys)
static void generateBins(const std::string &params, const std::string &dd, std::vector< std::string > &bins)
static void reserveKeyword(Keywords &keys)
Definition: Histogram.cpp:45
This class holds the keywords and their documentation.
Definition: Keywords.h:36
void parseFlag(const std::string &key, bool &t)
Parse one keyword as boolean flag.
Definition: Vessel.cpp:93
#define PLUMED_REGISTER_VESSEL(classname, keyword)
void addVessel(const std::string &name, const std::string &intput)
void reserve(const std::string &t, const std::string &k, const std::string &d, const bool isvessel=false)
Reserve a keyword.
Definition: Keywords.cpp:110
This class is used to pass the input to Vessels.
Definition: Vessel.h:53
Histogram(const VesselOptions &da)
Definition: Histogram.cpp:50
void int double * da
Definition: Matrix.h:47
static void registerKeywords(Keywords &keys)
Definition: Histogram.cpp:38
std::string getAllInput()
This returns the whole input line (it is used for less_than/more_than/between)
Definition: Vessel.cpp:84
T norm(const std::vector< T > &A)
Calculate the dot product between a vector and itself.
Definition: Matrix.h:61