Fork me on GitHub

source: svn/trunk/Examples/Convertors_Only.cpp@ 284

Last change on this file since 284 was 266, checked in by severine ovyn, 16 years ago

convertor only first commit

File size: 10.7 KB
RevLine 
[266]1/***********************************************************************
2** **
3** /----------------------------------------------\ **
4** | Delphes, a framework for the fast simulation | **
5** | of a generic collider experiment | **
6** \----------------------------------------------/ **
7** **
8** **
9** This package uses: **
10** ------------------ **
11** FastJet algorithm: Phys. Lett. B641 (2006) [hep-ph/0512210] **
12** Hector: JINST 2:P09005 (2007) [physics.acc-ph:0707.1198v2] **
13** FROG: [hep-ex/0901.2718v1] **
14** **
15** ------------------------------------------------------------------ **
16** **
17** Main authors: **
18** ------------- **
19** **
20** Severine Ovyn Xavier Rouby **
21** severine.ovyn@uclouvain.be xavier.rouby@cern **
22** **
23** Center for Particle Physics and Phenomenology (CP3) **
24** Universite catholique de Louvain (UCL) **
25** Louvain-la-Neuve, Belgium **
26** **
27** Copyright (C) 2008-2009, **
28** All rights reserved. **
29** **
30***********************************************************************/
31
32/// \file Convertors_Only.cpp
33/// \brief Executable for Convertors
34
35#include "TChain.h"
36#include "TApplication.h"
37#include "TStopwatch.h"
38#include "TFile.h"
39
40#include "ExRootTreeReader.h"
41#include "ExRootTreeWriter.h"
42#include "ExRootTreeBranch.h"
43#include "ExRootProgressBar.h"
44
45#include "DataConverter.h"
46#include "HEPEVTConverter.h"
47#include "LHEFConverter.h"
48#include "STDHEPConverter.h"
49
50#include "SmearUtil.h"
51#include "CaloUtil.h"
52#include "BFieldProp.h"
53#include "TriggerUtil.h"
54#include "VeryForward.h"
55#include "JetsUtil.h"
56#include "FrogUtil.h"
57
58#include <vector>
59#include <iostream>
60
61using namespace std;
62
63//------------------------------------------------------------------------------
64void todo(string filename) {
65 ifstream infile(filename.c_str());
66 cout << "** TODO list ..." << endl;
67 while(infile.good()) {
68 string temp;
69 getline(infile,temp);
70 cout << "*" << temp << endl;
71 }
72 cout << "** done...\n";
73}
74
75//------------------------------------------------------------------------------
76
77int main(int argc, char *argv[])
78{
79
80 int appargc = 2;
81 char *appName= new char[20];
82 char *appOpt= new char[20];
83 sprintf(appName,"Convertors");
84 sprintf(appOpt,"-b");
85 char *appargv[] = {appName,appOpt};
86 TApplication app(appName, &appargc, appargv);
87 delete [] appName;
88 delete [] appOpt;
89
90 if(argc != 3) {
91 cout << " Usage: " << argv[0] << " input_file output_file " << endl;
92 cout << " input_list - list of files in Ntpl, StdHep of LHEF format," << endl;
93 cout << " output_file - output file." << endl;
94 exit(1);
95 }
96
97
98
99
100cout << endl << endl;
101
102cout <<"*********************************************************************"<< endl;
103cout <<"*********************************************************************"<< endl;
104cout <<"** **"<< endl;
105cout <<"** Welcome to **"<< endl;
106cout <<"** **"<< endl;
107cout <<"** **"<< endl;
108cout <<"** .ddddddd- lL hH **"<< endl;
109cout <<"** -Dd` `dD: Ll hH` **"<< endl;
110cout <<"** dDd dDd eeee. lL .pp+pp Hh+hhh` -eeee- `sssss **"<< endl;
111cout <<"** -Dd `DD ee. ee Ll .Pp. PP Hh. HH. ee. ee sSs **"<< endl;
112cout <<"** dD` dDd eEeee: lL. pP. pP hH hH` eEeee:` -sSSSs. **"<< endl;
113cout <<"** .Dd :dd eE. LlL PpppPP Hh Hh eE sSS **"<< endl;
114cout <<"** dddddd:. eee+: lL. pp. hh. hh eee+ sssssS **"<< endl;
115cout <<"** Pp **"<< endl;
116cout <<"** **"<< endl;
117cout <<"** Delphes, a framework for the fast simulation **"<< endl;
118cout <<"** of a generic collider experiment **"<< endl;
119cout <<"** **"<< endl;
120cout <<"** --- Version 1.4beta of Delphes --- **"<< endl;
121cout <<"** Last date of change: 9 February 2009 **"<< endl;
122cout <<"** **"<< endl;
123cout <<"** **"<< endl;
124cout <<"** This package uses: **"<< endl;
125cout <<"** ------------------ **"<< endl;
126cout <<"** FastJet algorithm: Phys. Lett. B641 (2006) [hep-ph/0512210] **"<< endl;
127cout <<"** Hector: JINST 2:P09005 (2007) [physics.acc-ph:0707.1198v2] **"<< endl;
128cout <<"** FROG: [hep-ex/0901.2718v1] **"<< endl;
129cout <<"** **"<< endl;
130cout <<"**-----------------------------------------------------------------**"<< endl;
131cout <<"** **"<< endl;
132cout <<"** Main authors: **"<< endl;
133cout <<"** ------------- **"<< endl;
134cout <<"** **"<< endl;
135cout <<"** Séverine Ovyn Xavier Rouby **"<< endl;
136cout <<"** severine.ovyn@uclouvain.be xavier.rouby@cern **"<< endl;
137cout <<"** Center for Particle Physics and Phenomenology (CP3) **"<< endl;
138cout <<"** Universite Catholique de Louvain (UCL) **"<< endl;
139cout <<"** Louvain-la-Neuve, Belgium **"<< endl;
140cout <<"** **"<< endl;
141cout <<"**-----------------------------------------------------------------**"<< endl;
142cout <<"** **"<< endl;
143cout <<"** Former Delphes versions and documentation can be found on : **"<< endl;
144cout <<"** http://www.fynu.ucl.ac.be/delphes.html **"<< endl;
145cout <<"** **"<< endl;
146cout <<"** **"<< endl;
147cout <<"** Disclaimer: this program is a beta version of Delphes and **"<< endl;
148cout <<"** therefore comes without guarantees. Beware of errors and please **"<< endl;
149cout <<"** give us your feedbacks about potential bugs **"<< endl;
150cout <<"** **"<< endl;
151cout <<"*********************************************************************"<< endl;
152cout <<"*********************************************************************"<< endl;
153
154// 1. ********** initialisation ***********
155
156 srand (time (NULL)); /* Initialisation du générateur */
157 TStopwatch globalwatch, loopwatch, triggerwatch, frogwatch;
158 globalwatch.Start();
159
160
161 //read the output TROOT file
162 string inputFileList(argv[1]), outputfilename(argv[2]);
163 if(outputfilename.find(".root") > outputfilename.length()) {
164 cout <<"** ERROR: 'output_file' should be a .root file. Exiting... **"<< endl;
165 exit(1);
166 }
167
168 TFile *outputFile = TFile::Open(outputfilename.c_str(), "RECREATE"); // Creates the file, but should be closed just after
169 outputFile->Close();
170
171 string line;
172 ifstream infile(inputFileList.c_str());
173 infile >> line; // the first line determines the type of input files
174
175 // data converters
176 DataConverter *converter=NULL;
177 cout <<"** **"<<endl;
178 cout <<"** ####### Start convertion to TRoot format ######## **"<< endl;
179
180 if(strstr(line.c_str(),".hep"))
181 {
182 cout <<"** StdHEP file format detected **"<<endl;
183 cout <<"** This can take several minutes **"<< endl;
184 converter = new STDHEPConverter(inputFileList,outputfilename);//case ntpl file in input list
185 }
186 else if(strstr(line.c_str(),".lhe"))
187 {
188 cout <<"** LHEF file format detected **"<<endl;
189 cout <<"** This can take several minutes **"<< endl;
190 converter = new LHEFConverter(inputFileList,outputfilename);//case ntpl file in input list
191 }
192 else if(strstr(line.c_str(),".root"))
193 {
194 cout <<"** h2root file format detected **"<<endl;
195 cout <<"** This can take several minutes **"<< endl;
196 converter = new HEPEVTConverter(inputFileList,outputfilename);//case ntpl file in input list
197 }
198 else {
199 cerr << left << setw(4) <<"** "<<""
200 << left << setw(63) << line.c_str() <<""
201 << right << setw(2) <<"**"<<endl;
202 cerr <<"** ERROR: File format not identified -- Exiting... **"<< endl;
203 cout <<"** **"<< endl;
204 cout <<"*********************************************************************"<< endl;
205 return -1;};
206 cout <<"** Exiting conversion... **"<< endl;
207 cout <<"*********************************************************************"<< endl;
208 cout <<"*********************************************************************"<< endl;
209
210
211 delete converter;
212
213}
Note: See TracBrowser for help on using the repository browser.