#include <stdlib.h>
#include <TH1F.h>
#include <TROOT.h>
#include <TFile.h>
#include <TSystem.h>
#include <sstream>
#include <fstream>
#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 | ) |
Dumps the content of a tree to a local TreeDump.txt file.
The txt file contains one pair per row and the values are:
Definition at line 24 of file TreeDump.cc.
References funct::cos(), funct::exp(), funct::sin(), mathSSE::sqrt(), and tmp.
Referenced by TestCorrection::correctMuon(), and main().
int main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 36 of file TreeDump.cc.
References gather_cfg::cout, AutoLibraryLoader::enable(), cmsRelvalreport::exit, convertXMLtoSQLite_cfg::fileName, download_sqlite_cfg::outputFile, RootTreeHandler::readTree(), and AlCaHLTBitMon_QueryRunRegistry::string.
{ if( argc != 3 ) { std::cout << "Please provide the name of the file (with file: or rfio: as needed) and if there is generator information (0 is false)" << std::endl; exit(1); } std::string fileName(argv[1]); if( fileName.find("file:") != 0 && fileName.find("rfio:") != 0 ) { std::cout << "Please provide the name of the file with file: or rfio: as needed" << std::endl; exit(1); } std::stringstream ss; ss << argv[2]; bool genInfo = false; ss >> genInfo; std::cout << "Dumping tree with genInfo = " << genInfo << std::endl; // load framework libraries gSystem->Load( "libFWCoreFWLite" ); AutoLibraryLoader::enable(); // open input file (can be located on castor) TFile* inFile = TFile::Open(fileName.c_str()); // MuonPairVector pairVector; MuonPairVector pairVector; MuonPairVector genPairVector; // Create the RootTreeHandler to save the events in the root tree RootTreeHandler treeHandler; // treeHandler.readTree(-1, fileName, &pairVector, &genPairVector); treeHandler.readTree(-1, fileName, &pairVector, -20, &genPairVector); if( (pairVector.size() != genPairVector.size()) && genInfo ) { std::cout << "Error: the size of pairVector and genPairVector is different" << std::endl; } ofstream outputFile; outputFile.open("TreeDump.txt"); MuonPairVector::const_iterator it = pairVector.begin(); MuonPairVector::const_iterator genIt = genPairVector.begin(); for( ; it != pairVector.end(); ++it, ++genIt ) { // Write the information to a txt file outputFile << it->first.pt() << " " << it->first.eta() << " " << it->first.phi() << " " << it->second.pt() << " " << it->second.eta() << " " << it->second.phi() << " "; if( genInfo ) { outputFile << genIt->first.pt() << " " << genIt->first.eta() << " " << genIt->first.phi() << " " << genIt->second.pt() << " " << genIt->second.eta() << " " << genIt->second.phi() << " "; } outputFile << std::endl; } // size_t namePos = fileName.find_last_of("/"); // treeHandler.writeTree(("tree_"+fileName.substr(namePos+1, fileName.size())).c_str(), &pairVector); // close input and output files inFile->Close(); outputFile.close(); return 0; }