#include <memory>
#include <string>
#include <vector>
#include <sstream>
#include <fstream>
#include <iostream>
#include <stdlib.h>
#include <TH1F.h>
#include <TROOT.h>
#include <TFile.h>
#include <TSystem.h>
#include "FWCore/FWLite/interface/AutoLibraryLoader.h"
#include "MuonAnalysis/MomentumScaleCalibration/interface/RootTreeHandler.h"
Go to the source code of this file.
Functions | |
lorentzVector | fromPtEtaPhiToPxPyPz (const double *ptEtaPhiE) |
int | main (int argc, char *argv[]) |
lorentzVector fromPtEtaPhiToPxPyPz | ( | const double * | ptEtaPhiE | ) |
Builds a tree from the dump in the TreeDump.txt file produced by the TreeDump macro.
Definition at line 23 of file TreeFromDump.cc.
References funct::cos(), funct::exp(), funct::sin(), mathSSE::sqrt(), and tmp.
int main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 35 of file TreeFromDump.cc.
References gather_cfg::cout, AutoLibraryLoader::enable(), cmsRelvalreport::exit, convertXMLtoSQLite_cfg::fileName, fromPtEtaPhiToPxPyPz(), i, analyzePatCleaning_cfg::inputFile, geometryCSVtoXML::line, relativeConstraints::value, and RootTreeHandler::writeTree().
{ if( argc != 3 ) { std::cout << "Please provide the name of the file and if there is generator information (0 is false)" << std::endl; exit(1); } std::string fileName(argv[1]); std::stringstream ss; ss << argv[2]; bool genInfo = false; ss >> genInfo; std::cout << "Reading tree dump with genInfo = " << genInfo << std::endl; // load framework libraries gSystem->Load( "libFWCoreFWLite" ); AutoLibraryLoader::enable(); // MuonPairVector pairVector; std::vector<MuonPair> pairVector; std::vector<GenMuonPair> genPairVector; // Create the RootTreeHandler to save the events in the root tree RootTreeHandler treeHandler; ifstream inputFile; inputFile.open(fileName.c_str()); std::string line; double value[6]; double genValue[6]; // Read the information from a txt file while( !inputFile.eof() ) { getline(inputFile, line); if( line != "" ) { // std::cout << "line = " << line << std::endl; std::stringstream ss(line); for( int i=0; i<6; ++i ) { ss >> value[i]; // std::cout << "value["<<i<<"] = " << value[i] << std::endl; } pairVector.push_back(MuonPair(fromPtEtaPhiToPxPyPz(value), fromPtEtaPhiToPxPyPz(&(value[3])), 0, 0)); if( genInfo ) { for( int i=0; i<6; ++i ) { ss >> genValue[i]; // std::cout << "genValue["<<i<<"] = " << genValue[i] << std::endl; } genPairVector.push_back(GenMuonPair(fromPtEtaPhiToPxPyPz(genValue), fromPtEtaPhiToPxPyPz(&(genValue[3])), 0)); } } } inputFile.close(); if( (pairVector.size() != genPairVector.size()) && genInfo ) { std::cout << "Error: the size of pairVector and genPairVector is different" << std::endl; } if( genInfo ) { treeHandler.writeTree("TreeFromDump.root", &pairVector, 0, &genPairVector); std::cout << "Filling tree with genInfo" << std::endl; } else { treeHandler.writeTree("TreeFromDump.root", &pairVector); std::cout << "Filling tree" << std::endl; } // close input file inputFile.close(); return 0; }