1 void Example_tags(TString topDir =
"/star/rcf/GC/daq/tags")
17 gSystem->Load(
"libTable");
18 gSystem->Load(
"St_base");
20 gBenchmark =
new TBenchmark();
21 gBenchmark->Start(
"total");
24 gROOT->ProcessLine(
".O4");
32 while ( (set = next()) ) {
33 if (strcmp(set->GetTitle(),
"file") ||
34 !(strstr(set->GetName(),
".tags.root")))
continue;
35 chain.Add(gSystem->ConcatFileName(topDir,set->
Path()));
37 UInt_t nEvents = chain->GetEntries();
38 cout<<
"chained "<<nEvents<<
" events "<<endl;
40 TObjArray *files = chain.GetListOfFiles();
41 UInt_t nFiles = files->GetEntriesFast();
42 cout <<
"chained " << nFiles <<
" files from " << topDir << endl;
44 TObjArray *leaves = chain.GetListOfLeaves();
45 Int_t nleaves = leaves->GetEntriesFast();
47 TString tableName =
" ";
48 TObjArray *tagTable =
new TObjArray;
51 Int_t *tableIndex =
new Int_t[nleaves];
55 for (Int_t l=0;l<nleaves;l++) {
56 TLeaf *leaf = (TLeaf*)leaves->UncheckedAt(l);
57 tagCount+=leaf->GetNdata();
58 TBranch *branch = leaf->GetBranch();
60 if ( strstr(branch->GetName(), tableName.Data()) == 0 ) {
63 tableName.Resize(tableName->Last(
'.'));
64 tagTable->AddLast(
new TObjString(tableName.Data()));
67 tableIndex[l]=tableCount-1;
69 cout <<
" tot num tables, tags = " << tableCount <<
" "
70 << tagCount << endl << endl;
73 for (l=0;l<nleaves;l++) {
74 leaf = (TLeaf*)leaves->UncheckedAt(l);
75 branch = leaf->GetBranch();
78 TString Title = leaf->GetTitle();
79 Int_t dim = leaf->GetNdata();
81 Title.ReplaceAll(
'[',
" '");
82 Title.ReplaceAll(
']',
"'");
86 cout << ((TObjString*)tagTable->UncheckedAt(tableIndex[l]))->GetString()
87 <<
" -- has tag: " << Title << endl;
88 for (Int_t i=0;i<dim;i++) {
89 cout <<
" "<< leaf->GetName();
90 if (dim>1) cout <<
'['<<i<<
']';
91 cout <<
" = " << leaf->GetValue(i) << endl;
96 c1 =
new TCanvas(
"c1",
"Beam-Gas Rejection",600,1000);
97 gStyle->SetMarkerStyle(8);
98 chain->Draw(
"n_trk_tpc[0]:n_trk_tpc[1]");
107 cout <<
"\n Events with ntrk>400 and |asim|<"<<cut<<endl;
109 gBenchmark->Start(
"loop");
110 for (Int_t i=0;i<nFiles;i++) {
111 chain.LoadTree(*(chain.GetTreeOffset()+i));
112 TTree *T = chain.GetTree();
114 TLeaf *ntrk = T->GetLeaf(
"n_trk_tpc");
115 TLeaf *run = T->GetLeaf(
"mRunNumber");
116 TLeaf *
event = T->GetLeaf(
"mEventNumber");
117 for (Int_t j=0; j<T->GetEntries(); j++){
118 ntrk->GetBranch()->GetEntry(j);
119 event->GetBranch()->GetEntry(j);
120 run->GetBranch()->GetEntry(j);
121 Int_t Nm=ntrk->GetValue(0);
122 Int_t Np=ntrk->GetValue(1);
125 Float_t asim = Np-Nm;
126 if (Ntrk>0) asim /= Ntrk;
127 if (-cut < asim&&asim < cut && Ntrk>400) {
128 cout<<
" Run "<<(UInt_t)run->GetValue()
129 <<
", Event "<<
event->GetValue() <<endl;
131 sprintf(aevent,
"%d",event->GetValue());
132 t.DrawText(Np+10,Nm+10,aevent);
136 gBenchmark->Stop(
"loop");
138 t.DrawText(50,2550,
"ntrk>400 and |(Np-Nm)/(Np+Nm)| < 0.35 ");
139 t.DrawText(500,-300,
"Ntrk with tanl<0 ");
140 cout <<
" Selected " << ncoll <<
" collision candidates out of "
141 << nEvents <<
" events" << endl;
143 gBenchmark->Print(
"loop");
144 gBenchmark->Stop(
"total");
145 gBenchmark->Print(
"total");
virtual const char * GetName() const
special overload
virtual TString Path() const
return the full path of this data set