Fork me on GitHub

source: git/external/fastjet/plugins/ATLASCone/CommonUtils.hh@ e57c062

ImprovedOutputFile Timing dual_readout llp
Last change on this file since e57c062 was d7d2da3, checked in by pavel <pavel@…>, 11 years ago

move branches/ModularDelphes to trunk

  • Property mode set to 100644
File size: 2.4 KB
Line 
1//----------------------------------------------------------------------
2// This file distributed with FastJet has been obtained from SpartyJet
3// v2.20.0 by Pierre-Antoine Delsart, Kurtis L. Geerlings, Joey
4// Huston, Brian T. Martin and Chris Vermilion
5// For details, see http://www.pa.msu.edu/~huston/SpartyJet/
6// http://projects.hepforge.org/spartyjet/
7//
8// Changes from the original file are listed below.
9//----------------------------------------------------------------------
10
11// History of changes from the original CommonUtils.hh file in
12// SpartyJet v2.20
13//
14// 2009-01-15 Gregory Soyez <soyez@fastjet.fr>
15//
16// * put the code in the fastjet::atlas namespace
17
18#ifndef _JETCOMMONUTILS_HH_
19#define _JETCOMMONUTILS_HH_
20
21#include <ctime>
22#include <algorithm>
23#include <cmath>
24
25#include <fastjet/internal/base.hh>
26
27FASTJET_BEGIN_NAMESPACE
28
29namespace atlas{
30
31// **************************************************************
32// phi conversions
33// **************************************************************
34inline float to_minusPI_PI(float phi){
35 while(phi < -M_PI) phi += 2*M_PI;
36 while(phi >= M_PI) phi -= 2*M_PI;
37 return phi;
38}
39inline float to_zero_2PI(float phi){
40 while(phi < 0) phi += 2*M_PI;
41 while(phi >= 2*M_PI) phi -= 2*M_PI;
42 return phi;
43}
44
45
46
47// **************************************************************
48// List utils
49// **************************************************************
50// Destroy all pointers in a container, and clear it
51// T must be a container of pointers ex. list<T2*>
52template<class T>
53void clear_list(T & list){
54 typedef typename T::iterator it_t;
55 it_t it = list.begin();
56 it_t itE = list.end();
57 for(; it != itE; ++it){
58 delete *it;
59 }
60 list.clear();
61}
62
63
64
65
66
67// **************************************************************
68// timing
69// **************************************************************
70class stopwatch {
71public :
72 stopwatch() : m_total(0){};
73 void start(){m_last = std::clock();};
74 void resume(){m_last = std::clock();};
75 float pause() {
76 std::clock_t now=std::clock();
77 m_total = m_total + now - m_last;
78 m_last = now;
79 return convert();
80 }
81 float stop(){float t=pause(); m_total = std::clock_t(0); return t;}
82protected:
83 std::clock_t m_last;
84 std::clock_t m_total;
85
86 float convert(){ return float(m_total)*1000/CLOCKS_PER_SEC;}
87};
88
89
90} // namespace atlas
91
92FASTJET_END_NAMESPACE
93#endif
Note: See TracBrowser for help on using the repository browser.