CheckSizeBranches.cpp
Go to the documentation of this file.
2 {
3  // CaliceStyle();
4 
5  //Read sizes of the caf tree vectors and check that the sizes are consistent
6 
7  //if you are reading only one file, for debugging purposes: 1) comment out lines 8 through 39
8  //and then again lines 145 and 146, 2) un-comment lines 41 and 42.
9  const char *dirname="/pnfs/dune/persistent/users/ND_GAr/2020_06_21/neutrino/";
10 
11  const char *ext=".root";
12  std::vector<const char*> lista;
13  lista.clear();
14 
15  TChain *chain = new TChain("caf");
16 
17  TSystemDirectory dir(dirname, dirname);
18  TList *files = dir.GetListOfFiles();
19 
20 
21  TSystemFile *file;
22  TString fname;
23  TIter next(files);
24  while ((file = (TSystemFile*)next())) {
25  fname = file->GetName();
26  if (file->IsDirectory() && fname.EndsWith(ext)) continue;
27 
28  char result[255]; // array to hold the result.
29  strcpy(result,dirname); // copy string one into the result.
30  strcat(result,fname.Data()); // append string two to the result.
31 
32  lista.push_back(result);
33 
34  for(std::vector<const char*>::iterator it = lista.begin(); it != lista.end(); it++)
35  {
36 
37  std::cout << *it << std::endl;
38  string a(*it);
39  TFile * tf = new TFile ( Form("%s",a.c_str() ) );
40  chain->Add( Form("%s/caf", a.c_str()) );
41 
42  //TChain *chain = new TChain("caf");
43  //chain->Add("/pnfs/dune/persistent/users/ND_GAr/2020_06_21/neutrino/neutrino.nd_hall_mpd_only.volTPCGas.Ev336000.Ev336999.11141.caf.root");
44 
45  //std::cout << *it << std::endl;
46 
47  int evt;
48  std::vector<double>* mctime = 0;
49  std::vector<int> *_nFSP = 0;
50  std::vector<double> *theta = 0;
51  std::vector<int> *detected = 0;
52  std::vector<int> *pdgmother = 0;
53  std::vector<int> *truepdg = 0;
54  std::vector<int> * _MCPStartX = 0;
55  std::vector<int> *_MCPStartY = 0;
56  std::vector<int> *_MCPStartZ = 0;
57  std::vector<int> *_MCPEndX = 0;
58  std::vector<int> *_MCPEndY = 0;
59  std::vector<int> *_MCPEndZ = 0;
60  std::vector<std::string> *_MCProc = 0;
61  std::vector<std::string> *_MCEndProc = 0;
62  std::vector<float> *trkLen = 0;
63  std::vector<float> *trkLenPerp = 0;
64  std::vector<float> *truep = 0;
65  std::vector<float> *truepx = 0;
66  std::vector<float> *truepy = 0;
67  std::vector<float> *truepz = 0;
68  std::vector<float> *_angle = 0;
69  //Reco values
70  std::vector<int> *recopid = 0;
71  std::vector<float> *prob_arr = 0;
72  std::vector<float> *partereco = 0;
73  std::vector<float> *anglereco = 0;
74  std::vector<float> *_preco = 0;
75  std::vector<float> *erecon = 0;
76 
77  chain->SetBranchAddress("Event", &evt);
78  chain->SetBranchAddress("theta", &theta);
79  chain->SetBranchAddress("nFSP", &_nFSP);
80  chain->SetBranchAddress("detected", &detected);
81  chain->SetBranchAddress("pdgmother", &pdgmother);
82  chain->SetBranchAddress("MCPTime", &mctime);
83  chain->SetBranchAddress("MCPStartX", &_MCPStartX);
84  chain->SetBranchAddress("MCPStartY", &_MCPStartY);
85  chain->SetBranchAddress("MCPStartZ", &_MCPStartZ);
86  chain->SetBranchAddress("truepx", &truepx);
87  chain->SetBranchAddress("truepy", &truepy);
88  chain->SetBranchAddress("truepz", &truepz);
89  chain->SetBranchAddress("MCPEndX", &_MCPEndX);
90  chain->SetBranchAddress("MCPEndY", &_MCPEndY);
91  chain->SetBranchAddress("MCPEndZ", &_MCPEndZ);
92  chain->SetBranchAddress("MCProc", &_MCProc);
93  chain->SetBranchAddress("MCEndProc", &_MCEndProc);
94  chain->SetBranchAddress("angle", &_angle);
95  chain->SetBranchAddress("truep", &truep);
96  chain->SetBranchAddress("truepdg", &truepdg);
97  //Reco info
98  chain->SetBranchAddress("recopid", &recopid);
99  chain->SetBranchAddress("trkLen", &trkLen);
100  chain->SetBranchAddress("trkLenPerp", &trkLenPerp);
101  chain->SetBranchAddress("preco", &_preco);
102  chain->SetBranchAddress("anglereco", &anglereco);
103  chain->SetBranchAddress("erecon", &erecon);
104  chain->SetBranchAddress("prob_arr", &prob_arr);
105 
106  for(int itree = 0; itree < chain->GetEntries(); itree++)
107  {
108  chain->GetEntry(itree);
109 
110  std::cout << "Event " << evt << std::endl;
111  std::cout << "theta " << theta->size() << std::endl;
112  std::cout << "Size pdgmother: " << pdgmother->size() << std::endl;
113  std::cout << "Size MCPTime: " << mctime->size() << std::endl;
114  std::cout << "Size MCPStartX: " << _MCPStartX->size() << std::endl;
115  std::cout << "Size MCPStartY: " << _MCPStartY->size() << std::endl;
116  std::cout << "Size MCPStartZ: " << _MCPStartZ->size() << std::endl;
117  std::cout << "Size truepx: " << truepx->size() << std::endl;
118  std::cout << "Size truepy: " << truepy->size() << std::endl;
119  std::cout << "Size truepz: " << truepz->size() << std::endl;
120  std::cout << "Size MCPEndX: " << _MCPEndX->size() << std::endl;
121  std::cout << "Size MCPEndY: " << _MCPEndY->size() << std::endl;
122  std::cout << "Size MCPEndZ: " << _MCPEndZ->size() << std::endl;
123  std::cout << "Size _MCProc: " << _MCProc->size() << std::endl;
124  std::cout << "Size _MCEndProc: " << _MCEndProc->size() << std::endl;
125  std::cout << "Size _angle: " << _angle->size() << std::endl;
126  std::cout << "Size truep: " << truep->size() << std::endl;
127  std::cout << "Size truepdg: " << truepdg->size() << std::endl;
128  std::cout << "Size recopid: " << recopid->size() << std::endl;
129  std::cout << "Size trkLen: " << trkLen->size() << std::endl;
130  std::cout << "Size trkLenPerp: " << trkLenPerp->size() << std::endl;
131  std::cout << "Size _preco: " << _preco->size() << std::endl;
132  std::cout << "Size anglereco: " << anglereco->size() << std::endl;
133  std::cout << "Size erecon: " << erecon->size() << std::endl;
134  std::cout << "Size prob_arr: " << prob_arr->size() << std::endl;
135  std::cout << "Size _nFSP: " << _nFSP->size() << " value " << _nFSP->at(0) << std::endl;
136  std::cout << "Size detected: " << detected->size() << std::endl;
137 
138  for(int i = 0; i < theta->size(); i++)
139  {
140 
141  std::cout << "value of theta is: " << theta->at(i) << std::endl;
142 
143  }
144  }
145 }
146 }
147 }
intermediate_table::iterator iterator
static QCString result
void CheckSizeBranches()
string dir
Definition: tf_graph.h:23
list files
Definition: languages.py:9
const double a
TCEvent evt
Definition: DataStructs.cxx:7
QTextStream & endl(QTextStream &s)