-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathana.cxx
96 lines (79 loc) · 2.62 KB
/
ana.cxx
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
#include "TROOT.h"
#include "TRint.h"
#include "TTree.h"
#include <TH2.h>
#include "TSelector.h"
#include <TStyle.h>
#include <TString.h>
#include "TLorentzVector.h"
#include "ana_clas12.h"
#include <fstream> // for fstream
#include <iostream> // for cout, endl
#include <TChain.h>
#include <TFile.h>
#include <TTreeReader.h>
#include <TTreeReaderValue.h>
#include <TTreeReaderArray.h>
#include <stdio.h>
#include <string>
using namespace std;
int main(Int_t argc, Char_t *argv[])
{
ana_clas12 *basic = new ana_clas12();
TString OutputListName = "LAST_OUTPUT";
ofstream OutputList(OutputListName.Data());
TString FileNameIn = "runList";
Int_t Nlist;
Nlist = atoi(argv[1]);
FileNameIn.Append(Form("%d",Nlist));
ifstream ListFile(FileNameIn.Data());
Int_t Nruns;
Nruns = atoi(argv[2]);
/*********************************************************/
/* d'abord on cherche h10 ou h25 dans le premier fichier */
/*********************************************************/
TString FileName;
ListFile>>FileName;
//FileName.Prepend("");
//FileName.Prepend("/work/clas/disk1/hyonsuk/dvcs/production/pass1/v1/root/ep/");
OutputList<<"Checking whether "<<FileName.Data()<<" is a good file."<<endl;
TFile* FirstFile = new TFile(FileName,"READ");
TList *FileContent;
FileContent = FirstFile->GetListOfKeys();
TChain *chain;
if(FileContent->Contains("clas12"))
{
cout << "making a clas12 chain to analyse the " << Nruns << " runs"<< endl;
chain = new TChain("clas12","Analysis chain");
if(FirstFile){OutputList<<"Adding "<<FileName.Data()<<" to tree."<<endl;
chain->Add(FileName.Data());}
}
else
{
cout << "Problem indetermining the the chain ID...fix problem " << endl;
return 1;
}
/***************************************************************/
/* ensuite on ajoute tous les autres arbres a la chaine */
/* en supposant qu'on ne travaille que avec des h?? identiques */
/* en particulier ici on commence a 1 et pas a 0 dans la liste */
/***************************************************************/
for(Int_t i=1;i<Nruns;i++)
{
TString FileName;
ListFile>>FileName;
/******************/
/* chemin au CCPN */
/******************/
// FileName.Prepend("/sps/clas/fx/");
// FileName.Prepend("rootFiles/");
OutputList<<"Checking whether "<<FileName.Data()<<" is a good file."<<endl;
TFile* file = new TFile(FileName,"READ");
if(file){OutputList<<"Adding "<<FileName.Data()<<" to tree."<<endl;
chain->Add(FileName.Data());}
}
OutputList << "Number of events in chain : " << chain->GetEntries() << endl;
//chain->Process(basic,"",200000);
chain->Process(basic);
return 0;
}