Commit e4abbb5e authored by Mark Sutton's avatar Mark Sutton Committed by Graeme Stewart
Browse files

STUPID CMAKE SVN COMMIT BLOCK (HanConfigGenerator-00-00-18)

parent 5d41979e
################################################################################
# Package: HanConfigGenerator
################################################################################
# Declare the package name:
atlas_subdir( HanConfigGenerator )
# External dependencies:
find_package( ROOT COMPONENTS Graf Gpad Cint Core Tree MathCore Hist RIO pthread )
atlas_add_executable( hcg
src/hcg.cxx src/addnode.cxx
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} )
package HanConfigGenerator
# ============================================================================================
public
use AtlasPolicy AtlasPolicy-*
# ============================================================================================
private
use AtlasROOT AtlasROOT-* External
apply_tag ROOTGraphicsLibs
# apply_tag ROOTCintexLibs
# apply_tag ROOTGenVectorLibs
# apply_tag ROOTMathLibs
# apply_tag ROOTSTLDictLibs
# apply_tag ROOTBasicLibs
# ============================================================================================
public
# Specify the required ROOT components for cmake (transparent to CMT)
apply_pattern cmake_add_command command="find_package(ROOT COMPONENTS Graf Gpad)"
application hcg "../src/hcg.cxx ../src/addnode.cxx
utils
-----
contains makefile and src to build the hc executable, for
writing tamplate han config files from input root files ...
% hc
Usage: hanconfig [OPTIONS] input1.root ... inputN.root
-o FILENAME name of output (filename required)
-b, --base DIR use directory DIR as the base for the han config
-d, --dir DIR only directories below DIR where DIR is a structure such as HLT/TRIDT etc
-x, DIR exclude directory DIR
-r SRC DST remap directory SRC to directory DST
-ds, --desc DESCRIP use DESCRIP as the description
-t, --tag VALUE add the VALUE to the list of command per histogram
-wc, --wildcard print use hist * rather than a separate entry for each histogram
-dr, --deleteref delete unselected histograms
-rh, --relocate relocate selected histograms
-v, --verbose print verbose output
-h, --help display this help
for instance ...
hc hid_shifter.root -d HLT/TRIDT -x TestMon > hc.config
will take the directory structure in file eg
hid_shifter.root
and generate a config from the directory structure hanging from
run_253124/HLT/TRIDT
generating the config using HLT (ie the first directory in HLT/TRIDT )
as the base directory, and excluding any directory with the name
"TestMon"
To remap a name, eg suppose you have the directory SOME_STUFF in the file,
but want this to correspond to a menu side bar item of NICE, then including
options
-r SOME_STUFF NICE
should do this. Any number of remappings of this sort should be possible...
-r SOME_STUFF NICE -r ANOTHER EVEN_NICER
The option
--deleteref
will delete the histograms that are not selected, so do check the
provided configuration before using this option. It does save the
original file in FILEMAN.bak however for emergencies
** NB: If a config output file in not given in the command line it writes **
** the config to stdout, and all other documentation and debugging **
** information is written to stderr **
12-05-2016
//
// @file addnode.cxx
//
//
// @author M.Sutton
//
// Copyright (C) 2016 M.Sutton (sutt@cern.ch)
//
// $Id: addnode.cxx, v0.0 Thu 21 Apr 2016 20:31:53 CEST sutt $
#include "addnode.h"
#include "spacer.h"
/// check whether a subnode with this name
/// already exists
node* subnode( node* np, const std::string& name ) {
if ( np==0 ) return 0;
for ( unsigned i=np->size() ; i-- ; ) if ( np->at(i)->name()==name ) return np->at(i);
return 0;
}
/// add a submode with a specific name, or return the existing
/// node if one already exists
node* addnode( node* np, const std::string& name, TObject* td, node::TYPE t ) {
node* np_ = subnode( np, name );
if ( np_ ) return np_;
np_ = new node( np, np->depth()+spacer, td );
np_->name( name );
np_->type( t );
np->push_back( np_ );
return np_;
}
// emacs: this is -*- c++ -*-
//
// @file addnode.h
//
//
//
// Copyright (C) 2016 M.Sutton (sutt@cern.ch)
//
// $Id: addnode.h, v0.0 Thu 21 Apr 2016 20:31:49 CEST sutt $
#ifndef ADDNODE_H
#define ADDNODE_H
#include "node.h"
#include "TDirectory.h"
/// check if a subnode already exists
node* subnode( node* np, const std::string& name );
/// add a new node (or return the already existing node with this name)
node* addnode( node* np, const std::string& name, TObject* td=0, node::TYPE t=node::DIRECTORY );
#endif // ADDNODE_H
This diff is collapsed.
ROOTCFLAGS = $(shell root-config --cflags)
ROOTLIBS = $(shell root-config --libs)
SOURCES = hcg.cxx addnode.cxx
# install : hcg
# cp hcg $(HOME)/bin
hcg : $(SOURCES)
g++ $(ROOTCFLAGS) -o $@ $(SOURCES) $(ROOTLIBS)
archive : $(SOURCES) node.h addnode.h simpletimer.h spacer.h makefile README
tar -czf hcg.tgz $?
install : hcg
cp hcg $(HOME)/bin
// emacs: this is -*- c++ -*-
//
// @file node.h
//
//
//
// Copyright (C) 2016 M.Sutton (sutt@cern.ch)
//
// $Id: node.h, v0.0 Fri 8 Apr 2016 00:57:16 CEST sutt $
#ifndef NODE_H
#define NODE_H
#include <iostream>
#include <string>
#include <vector>
#include "TObject.h"
class node : public std::vector<node*> {
public:
enum TYPE { HISTOGRAM, DIRECTORY, DUFF };
public:
node( node* n=0, const std::string d="", TObject* t=0 ) :
mname("duff"), mparent(n), mtype(DUFF), mpath(""), mdepth(d), mobj(t) {
if ( t!=0 ) mname = t->GetName();
mhirate = std::pair<std::string, double>( "", 0);
}
virtual ~node() { }
void name( const std::string& n) { mname=n; }
const std::string& name() const { return mname; }
void path(const std::string& p) { mpath=p; }
std::string path() const { return mpath; }
node* parent() { return mparent; }
const node* parent() const { return mparent; }
std::string depth() const { return mdepth; }
void type(TYPE t) { mtype=t; }
virtual TYPE type() const { return mtype; }
std::string stype() const {
if ( type()==DIRECTORY ) return "DIRECTORY";
if ( type()==HISTOGRAM ) return "HISTOGRAM";
return "DUFF";
};
const TObject* object() const { return mobj; }
TObject* object() { return mobj; }
void addrate( const std::string& s, double r ) {
addrate( std::pair<std::string, double>( s, r ) );
}
void addrate( const std::pair<std::string, double>& r ) {
if ( r.second > mhirate.second ) mhirate = r;
}
const std::pair<std::string, double>& rate() const { return mhirate; }
public:
std::string mname;
node* mparent;
TYPE mtype;
std::string mpath;
std::string mdepth;
TObject* mobj;
std::pair<std::string, double> mhirate;
};
inline std::ostream& operator<<( std::ostream& s, const node& n ) {
s << n.depth() << n.name() << "::" << n.stype() << " : obj " << n.object() << " : size " << n.size() << "\tpath " << n.path();
if ( n.type()==node::HISTOGRAM ) return s;
else if ( n.size() ) {
if ( n.parent() ) s << "\t( parent " << n.parent()->name() << " )";
if ( n.rate().first!="" )s << "\t\t:::(max rate chain " << n.rate().first << " " << n.rate().second << " ):::";
for ( unsigned i=0 ; i<n.size() ; i++ ) {
// if ( n[i]->type()!=node::HISTOGRAM )
s << "\n" << i << " " << n.depth() << " " << *n[i];
}
}
return s;
}
#endif // NODE_H
// emacs: this is -*- c++ -*-
//
// @file simpletimer.h
// these functions have a precision of about 0.001 ms
//
//
// Copyright (C) 2007 M.Sutton (sutt@hep.ucl.ac.uk)
//
// $Id: simpletimer.h, v0.0 Thu 22 Jan 2009 15:51:52 GMT sutt $
#ifndef __SIMPLETIMER_H
#define __SIMPLETIMER_H
#include <time.h>
#include <sys/time.h>
//#ifdef __cplusplus
//extern "C" {
//#endif
inline struct timeval simpletimer_start(void) {
struct timeval start_time;
gettimeofday(&start_time, NULL);
return start_time;
}
inline double simpletimer_stop(const struct timeval& start_time)
{
struct timeval stop_time;
struct timeval diff_time;
gettimeofday(&stop_time, NULL);
diff_time.tv_sec = stop_time.tv_sec - start_time.tv_sec;
diff_time.tv_usec = stop_time.tv_usec - start_time.tv_usec;
return (diff_time.tv_sec*1000.0) + (diff_time.tv_usec/1000.0);
}
//#ifdef __cplusplus
//}
//#endif
#endif /* __SIMPLETIMER_H */
/**************************************************************************
**
** @file spacer.h
**
** Description:
**
**
**
** Author: M.Sutton
**
** Created: Thu 21 Apr 2016 21:34:47 CEST
** Modified:
**
**
**
**************************************************************************/
#ifndef SPACER_H
#define SPACER_H
#include "string.h"
const std::string spacer = "\t";
#endif /* SPACER_H */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment