-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added Analysis/include/AnalyzerData.h - added files for the new project - added env.sh to set the environment - added runx.sh to run (to be modified)
- Loading branch information
Showing
8 changed files
with
220 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
*.pyc | ||
__init__.py | ||
HHbbTauTau.creator.user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
/*! | ||
* \class AnalyzerData AnalyzerData.h | ||
* \brief Base class for Analyzer data containers. | ||
* \author Konstantin Androsov (INFN Pisa, Siena University) | ||
* \author Maria Teresa Grippo (INFN Pisa, Siena University) | ||
* \date 2013-03-29 created | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <map> | ||
#include <stdexcept> | ||
#include <sstream> | ||
#include <TFile.h> | ||
#include <TH1D.h> | ||
#include <TH2D.h> | ||
#include <TList.h> | ||
|
||
#define DATA_ENTRY(type, name, ...) \ | ||
type& name() { \ | ||
if(!Contains(#name)) \ | ||
data[#name] = new type(__VA_ARGS__); \ | ||
return Get< type >(#name); } \ | ||
/**/ | ||
|
||
#define VECTOR_DATA_ENTRY(type, name, n_elem, ...) \ | ||
type& name(unsigned i) { \ | ||
if(!Contains(#name)){ \ | ||
TList* list = new TList(); \ | ||
for (unsigned k= 0; k < n_elem; ++k) {\ | ||
TObject* object = new type(__VA_ARGS__);\ | ||
std::ostringstream ss;\ | ||
ss << #name << "_" << k;\ | ||
TObject* clone = object->Clone(ss.str().c_str());\ | ||
delete object;\ | ||
list->Add(clone);\ | ||
}\ | ||
data[#name] = list;\ | ||
}\ | ||
return *(type*)(Get< TList >(#name).At(i)); \ | ||
} \ | ||
/**/ | ||
|
||
#define MAP_DATA_ENTRY(type, name, ...) \ | ||
template<typename Key> \ | ||
type& name(const Key& key) { \ | ||
std::ostringstream ss; \ | ||
ss << #name << "_" << key; \ | ||
const std::string& full_name = ss.str(); \ | ||
if(!Contains(full_name)) { \ | ||
type* object = new type(__VA_ARGS__); \ | ||
TObject* clone = object->Clone(full_name.c_str()); \ | ||
delete object; \ | ||
data[full_name] = clone; \ | ||
} \ | ||
return Get< type >(full_name); \ | ||
} \ | ||
/**/ | ||
|
||
#define TH1D_ENTRY(name, nbinsx, xlow, xup) DATA_ENTRY(TH1D, name, #name, #name, nbinsx, xlow, xup) | ||
#define TH1D_ENTRY_FIX(name, binsizex, nbinsx, xlow) TH1D_ENTRY(name, nbinsx, xlow, (xlow+binsizex*nbinsx)) | ||
#define TH1D_VECTOR_ENTRY(name,n_elem, nbinsx, xlow, xup) VECTOR_DATA_ENTRY(TH1D,name,n_elem, #name, #name, \ | ||
nbinsx, xlow, xup) | ||
#define TH1D_VECTOR_ENTRY_FIX(name,n_elem, binsizex, nbinsx, xlow) TH1D_VECTOR_ENTRY(name,n_elem, nbinsx, xlow,\ | ||
(xlow+binsizex*nbinsx)) | ||
#define TH1D_MAP_ENTRY(name, nbinsx, xlow, xup) MAP_DATA_ENTRY(TH1D,name, #name, #name, nbinsx, xlow, xup) | ||
#define TH1D_MAP_ENTRY_FIX(name, binsizex, nbinsx, xlow) TH1D_MAP_ENTRY(name, nbinsx, xlow, (xlow+binsizex*nbinsx)) | ||
|
||
#define TH2D_ENTRY(name, nbinsx, xlow, xup, nbinsy, ylow, yup) DATA_ENTRY(TH2D, name, #name, #name, nbinsx, xlow, xup,\ | ||
nbinsy, ylow, yup) | ||
#define TH2D_ENTRY_FIX(name, binsizex, nbinsx, xlow, binsizey, nbinsy, ylow) \ | ||
TH2D_ENTRY(name, nbinsx, xlow, (xlow+binsizex*nbinsx), nbinsy, ylow, (ylow+binsizey*nbinsy)) | ||
#define TH2D_VECTOR_ENTRY(name, n_elem, nbinsx, xlow, xup, nbinsy, ylow, yup) \ | ||
VECTOR_DATA_ENTRY(TH2D, name,n_elem, #name, #name, nbinsx, xlow, xup, nbinsy, ylow, yup) | ||
#define TH2D_VECTOR_ENTRY_FIX(name,n_elem, binsizex, nbinsx, xlow, binsizey, nbinsy, ylow) \ | ||
TH2D_VECTOR_ENTRY(name,n_elem, nbinsx, xlow, (xlow+binsizex*nbinsx), nbinsy, ylow, (ylow+binsizey*nbinsy)) | ||
#define TH2D_MAP_ENTRY(name, nbinsx, xlow, xup, nbinsy, ylow, yup) \ | ||
MAP_DATA_ENTRY(TH2D, name, #name, #name, nbinsx, xlow, xup, nbinsy, ylow, yup) | ||
#define TH2D_MAP_ENTRY_FIX(name, binsizex, nbinsx, xlow, binsizey, nbinsy, ylow) \ | ||
TH2D_MAP_ENTRY(name, nbinsx, xlow, (xlow+binsizex*nbinsx), nbinsy, ylow, (ylow+binsizey*nbinsy)) | ||
|
||
|
||
namespace root_ext { | ||
class AnalyzerData { | ||
protected: | ||
typedef std::map<std::string, TObject*> DataMap; | ||
DataMap data; | ||
|
||
bool Contains(const std::string& name) const | ||
{ | ||
return data.find(name) != data.end(); | ||
} | ||
|
||
template<typename T> | ||
T& Get(const std::string& name) | ||
{ | ||
return *static_cast<T*>(data[name]); | ||
} | ||
|
||
public: | ||
AnalyzerData() : outputFile(nullptr), ownOutputFile(false) {} | ||
AnalyzerData(const std::string& outputFileName) | ||
: outputFile(new TFile(outputFileName.c_str(), "RECREATE")), ownOutputFile(true) | ||
{ | ||
if(outputFile->IsZombie()) | ||
throw std::runtime_error("Output file not created."); | ||
outputFile->cd(); | ||
} | ||
AnalyzerData(TFile& _outputFile, const std::string& _directoryName) | ||
: outputFile(&_outputFile), ownOutputFile(false), directoryName(_directoryName) | ||
{ | ||
outputFile->cd(); | ||
outputFile->mkdir(directoryName.c_str()); | ||
outputFile->cd(directoryName.c_str()); | ||
} | ||
|
||
virtual ~AnalyzerData() | ||
{ | ||
cd(); | ||
for(DataMap::iterator iter = data.begin(); iter != data.end(); ++iter) { | ||
iter->second->Write(); | ||
delete iter->second; | ||
} | ||
if(ownOutputFile) | ||
delete outputFile; | ||
} | ||
|
||
TFile& getOutputFile(){return *outputFile;} | ||
void cd() const | ||
{ | ||
if(outputFile) | ||
outputFile->cd(); | ||
if(directoryName.size()) | ||
outputFile->cd(directoryName.c_str()); | ||
} | ||
private: | ||
TFile* outputFile; | ||
bool ownOutputFile; | ||
std::string directoryName; | ||
}; | ||
} // root_ext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// ADD PREDEFINED MACROS HERE! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[General] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Analysis/source/SimpleVHAnalyser.C | ||
Analysis/source/SimpleVHAnalyser.h | ||
Analysis/source/VHAnalyzer_WH_New.C | ||
Analysis/source/VHAnalyzer_WH_New.h | ||
Analysis/include/AnalyzerData.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
src | ||
$$(CMSSW_RELEASE_BASE)/src | ||
$$(GCC_INCLUDE_PATH) | ||
$$(GCC_INCLUDE_PATH)/x86_64-unknown-linux-gnu | ||
$$(BOOST_INCLUDE_PATH) | ||
$$(ROOT_INCLUDE_PATH) | ||
$$(HEPMC_INCLUDE_PATH) | ||
/usr/include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
cmsenv | ||
export GCC_INCLUDE_PATH=$( echo $CMSSW_RELEASE_BASE/../../../external/gcc/*/include/c++/* ) | ||
export BOOST_INCLUDE_PATH=$( echo $CMSSW_RELEASE_BASE/../../../external/boost/*/include ) | ||
export ROOT_INCLUDE_PATH=$( echo $CMSSW_RELEASE_BASE/../../../lcg/root/*/include ) | ||
export HEPMC_INCLUDE_PATH=$( echo $CMSSW_RELEASE_BASE/../../../external/hepmc/*/include ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/bash | ||
|
||
function get_arg_value { | ||
if [ "${ARGS[$1]:0:1}" == "@" ] ; then | ||
arg_value="${ARGS[$1]:1}" | ||
else | ||
arg_value="\"${ARGS[$1]}\"" | ||
fi | ||
|
||
} | ||
|
||
NAME=$1 | ||
ARGS=($*) | ||
SCRIPT_PATH="$CMSSW_BASE/script" | ||
SCRIPT_RUN_PATH="$SCRIPT_PATH/run" | ||
mkdir -p $SCRIPT_RUN_PATH | ||
|
||
SOURCE=$( find $SCRIPT_PATH -name "${NAME}.C" ) | ||
n=${#ARGS[@]} | ||
arg_list="" | ||
if (( n > 1 )) ; then | ||
get_arg_value 1 | ||
arg_list="$arg_value" | ||
for (( i = 2; i < n; i++ )) ; do | ||
get_arg_value i | ||
arg_list="$arg_list, $arg_value" | ||
done | ||
fi | ||
|
||
CODE_OUT="$SCRIPT_RUN_PATH/${NAME}.cpp" | ||
EXE_NAME="$SCRIPT_RUN_PATH/$NAME" | ||
rm -f $EXE_NAME | ||
|
||
printf \ | ||
"#include \"${SOURCE}\" | ||
#include <TROOT.h> | ||
#include <iostream> | ||
int main() | ||
{ | ||
try { | ||
gROOT->ProcessLine(\"#include <vector>\"); | ||
$NAME a( $arg_list ); | ||
a.Run(); | ||
} | ||
catch(std::exception& e) { | ||
std::cerr << \"ERROR: \" << e.what() << std::endl; | ||
} | ||
return 0; | ||
} | ||
" > $CODE_OUT | ||
|
||
g++ -std=c++11 -Wall -pedantic -Werror \ | ||
-Isrc/ -I$CMSSW_RELEASE_BASE/src -I$ROOT_INCLUDE_PATH -I$BOOST_INCLUDE_PATH \ | ||
`root-config --libs` \ | ||
-o $EXE_NAME $CODE_OUT | ||
|
||
$EXE_NAME |