Fork me on GitHub

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

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

petites corrections S.O. Heidelberg

File size: 3.8 KB
RevLine 
[457]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"
[535]41#include "stdlib.h"
42
[457]43using namespace std;
44
45DelphesRootConverter::DelphesRootConverter(const string& inputFileList, const string& outputFileName, const int& Nevents)
46{
47
48 // Open a stream connected to an event file:
49 ifstream infile(inputFileList.c_str());
50 string filename;
51 if(!infile.is_open()) {
52 cerr << left << setw(30) <<"** ERROR: Can't open "<<""
53 << left << setw(20) << inputFileList <<""
54 << right << setw(19) <<"for input **"<<""<<endl;
55 exit(1);
56 }
57
58 TChain chainGEN("GEN");
59 while(1)
60 {
61 infile >> filename;
62 if(!infile.good()) break;
63 ifstream checking_the_file(filename.c_str());
64 if(!checking_the_file.good())
65 {
66 cerr << left << setw(30) <<"** ERROR: Can't find file "<<""
[480]67 << left << setw(36) << filename <<""
68 << right << setw(3) <<" **"<<""<<endl;
[457]69 continue;
70 }
71 else checking_the_file.close();
72
73 chainGEN.Add(filename.c_str());
74 }
75
76 TFile * newFile = TFile::Open(outputFileName.c_str(),"RECREATE");
77 newFile->cd();
78 TTree * copiedChain;
79 int nevents = min(Nevents,(int)chainGEN.GetEntries());
80 if(nevents<0) copiedChain = chainGEN.CopyTree(""); // copy the whole chain
81 else copiedChain = chainGEN.CopyTree("","",nevents); // copy a smaller part of the chain
82 copiedChain->Write();
83 newFile->Close();
84
85}
86
87
88
89
Note: See TracBrowser for help on using the repository browser.