-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo.cpp
125 lines (96 loc) · 2.66 KB
/
demo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include <iostream>
#include <cstring>
// pythia8 header files
#include <Pythia8/Pythia.h>
#include <Pythia8/Pythia8ToHepMC.h>
using std::cout;
using std::endl;
using namespace HepMC;
#include "src/AcerDET.h"
using namespace AcerDet;
using namespace AcerDet::conf;
using namespace AcerDet::core;
using namespace AcerDet::io;
#include "external/HepMC_InputConverter.h"
#include "external/Pythia8_ParticleDataProviderFactory.h"
#include "external/Root_HistogramManager.h"
#include "external/Root_NTupleManager.h"
#include <TROOT.h>
#include <TChain.h>
#include <TFile.h>
// -----------------------
// -- clean temp record --
// -----------------------
void resetRecord( io::OutputRecord& rec ) {
rec.clear();
}
int main( int argc, char **argv ) {
if( argc < 3 ) {
cout << "Usage: " << argv[0] << " <config_file> <events_count> " << endl;
return -1;
}
int events_limit = atoi( argv[2] );
//
// Initialize pythia
//
Pythia8::Pythia pythia;
Pythia8::Event& event = pythia.event;
Pythia8ToHepMC toHepMC;
// Use this line to output all available options and their default values
//pythia.settings.listAll(); exit(0);
pythia.readFile(argv[1]);
pythia.init();
//
// Initialize AcerDET
//
const std::string configFileName = "acerdet.dat";
Configuration configuration = Configuration::fromFile( configFileName );
IParticleDataProviderFactory *pdpFactory =
new external::Pythia8_ParticleDataProviderFactory();
IHistogramManager *histoManager =
new external::Root_HistogramManager();
external::Root_NTupleManager nTuple;
AcerDET acerDet(
configuration,
pdpFactory,
histoManager
);
nTuple.init();
acerDet.printInfo();
OutputRecord oRec;
for( int iEvent = 0; iEvent < events_limit; ++iEvent ) {
// printf("Event %d\n", iEvent);
if( !pythia.next() ) {
printf("continue ...\n");
continue;
}
resetRecord(oRec);
GenEvent *hepmc = new GenEvent();
toHepMC.fill_next_event( event, hepmc );
// printf (" ---- PRINTING --- \n");
// hepmc->print();
const Real64_t weigth = 1.0;
const Int32_t processId = 1;
InputRecord iRec = external::HepMC_InputConverter::convert( *hepmc );
// wypisz iRec
if (iEvent == 0) {
cout << iRec;
}
acerDet.analyseRecord(iRec, oRec, weigth);
nTuple.fill(iRec, oRec, weigth, processId);
delete hepmc;
}
acerDet.printResults();
char inputname[1000] = "";
sprintf( inputname, argv[1] );
char outputname[1000] = "";
strcat( outputname, inputname );
strcat( outputname, ".root" );
TFile scanMiniTreeFile( outputname, "recreate" );
scanMiniTreeFile.cd();
acerDet.storeHistograms();
nTuple.write();
delete pdpFactory;
delete histoManager;
return 0;
}