Fork me on GitHub

source: svn/trunk/src/DelphesRootConverter.cc@ 496

Last change on this file since 496 was 480, checked in by Xavier Rouby, 15 years ago

minor change: cleaning of the 'cout' and 'cerr'

File size: 3.8 KB
Line 
1/***********************************************************************
2** **
3** /----------------------------------------------\ **
4** | Delphes, a framework for the fast simulation | **
5** | of a generic collider experiment | **
6** \------------- arXiv:0903.2225v1 ------------/ **
7** **
8** **
9** This package uses: **
10** ------------------ **
11** ROOT: Nucl. Inst. & Meth. in Phys. Res. A389 (1997) 81-86 **
12** FastJet algorithm: Phys. Lett. B641 (2006) [hep-ph/0512210] **
13** Hector: JINST 2:P09005 (2007) [physics.acc-ph:0707.1198v2] **
14** FROG: [hep-ex/0901.2718v1] **
15** HepMC: Comput. Phys. Commun.134 (2001) 41 **
16** **
17** ------------------------------------------------------------------ **
18** **
19** Main authors: **
20** ------------- **
21** **
22** Severine Ovyn Xavier Rouby **
23** severine.ovyn@uclouvain.be xavier.rouby@cern **
24** **
25** Center for Particle Physics and Phenomenology (CP3) **
26** Universite catholique de Louvain (UCL) **
27** Louvain-la-Neuve, Belgium **
28** **
29** Copyright (C) 2008-2009, **
30** All rights reserved. **
31** **
32***********************************************************************/
33
34#include <iostream>
35#include <fstream>
36#include <iomanip>
37#include <cmath>
38#include "TChain.h"
39#include "TFile.h"
40#include "DelphesRootConverter.h"
41using namespace std;
42
43DelphesRootConverter::DelphesRootConverter(const string& inputFileList, const string& outputFileName, const int& Nevents)
44{
45
46 // Open a stream connected to an event file:
47 ifstream infile(inputFileList.c_str());
48 string filename;
49 if(!infile.is_open()) {
50 cerr << left << setw(30) <<"** ERROR: Can't open "<<""
51 << left << setw(20) << inputFileList <<""
52 << right << setw(19) <<"for input **"<<""<<endl;
53 exit(1);
54 }
55
56 TChain chainGEN("GEN");
57 while(1)
58 {
59 infile >> filename;
60 if(!infile.good()) break;
61 ifstream checking_the_file(filename.c_str());
62 if(!checking_the_file.good())
63 {
64 cerr << left << setw(30) <<"** ERROR: Can't find file "<<""
65 << left << setw(36) << filename <<""
66 << right << setw(3) <<" **"<<""<<endl;
67 continue;
68 }
69 else checking_the_file.close();
70
71 chainGEN.Add(filename.c_str());
72 }
73
74 TFile * newFile = TFile::Open(outputFileName.c_str(),"RECREATE");
75 newFile->cd();
76 TTree * copiedChain;
77 int nevents = min(Nevents,(int)chainGEN.GetEntries());
78 if(nevents<0) copiedChain = chainGEN.CopyTree(""); // copy the whole chain
79 else copiedChain = chainGEN.CopyTree("","",nevents); // copy a smaller part of the chain
80 copiedChain->Write();
81 newFile->Close();
82
83}
84
85
86
87
Note: See TracBrowser for help on using the repository browser.