FairRoot/PandaRoot
Functions
solution/auxtut.C File Reference
#include "TGeoManager.h"

Go to the source code of this file.

Functions

void RemoveGeoManager ()
 
bool checkfile (TString fn)
 
FairRunAna * initrun (TString prefix, TString outfile, int min=-1, int max=-1)
 
void plotmyhistos (std::vector< TH1 * > h, int maxy=700, double asp=1.1)
 
void plotmyhistos (int maxy=700, double asp=1.1)
 
int writemyhistos (int maxy=800, double asp=1.1)
 
int fillM (RhoCandList &l, TH1 *h)
 
int fillP (RhoCandList &l, TH1 *h)
 

Function Documentation

bool checkfile ( TString  fn)

Definition at line 20 of file solution/auxtut.C.

References t, and x0.

21 {
22  bool fileok=true;
23  TFile fff(fn);
24  if (fff.IsZombie()) fileok=false;
25  TTree *t=(TTree*)fff.Get("pndsim");
26  if (t==0x0) fileok=false;
27 
28  if (!fileok) cout <<"Skipping broken file '"<<fn<<"'"<<endl;
29  return fileok;
30 }
Double_t x0
Definition: checkhelixhit.C:70
TTree * t
Definition: bump_analys.C:13
int fillM ( RhoCandList l,
TH1 *  h 
)

Definition at line 139 of file solution/auxtut.C.

References RhoCandList::GetLength(), and i.

140 {
141  for (int i=0;i<l.GetLength();++i) h->Fill(l[i]->M());
142 
143  return l.GetLength();
144 }
Int_t i
Definition: run_full.C:25
Int_t GetLength() const
Definition: RhoCandList.h:46
int fillP ( RhoCandList l,
TH1 *  h 
)

Definition at line 146 of file solution/auxtut.C.

References RhoCandList::GetLength(), and i.

147 {
148  for (int i=0;i<l.GetLength();++i) h->Fill(l[i]->P());
149 
150  return l.GetLength();
151 }
Int_t i
Definition: run_full.C:25
Int_t GetLength() const
Definition: RhoCandList.h:46
FairRunAna* initrun ( TString  prefix,
TString  outfile,
int  min = -1,
int  max = -1 
)

Definition at line 32 of file solution/auxtut.C.

References fRun, rtdb, and TString.

33 {
34  // *** the files coming from the simulation
35  TString inPidFile = prefix+"_pid.root"; // this file contains the PndPidCandidates and McTruth
36  TString inParFile = prefix+"_par.root";
37 
38  // *** PID table with selection thresholds; can be modified by the user
39  TString pidParFile = TString(gSystem->Getenv("VMCWORKDIR"))+"/macro/params/all.par";
40 
41  // *** initialization
42  FairLogger::GetLogger()->SetLogToFile(kFALSE);
43  FairRunAna* fRun = new FairRunAna();
44  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
45  fRun->SetSource(new FairFileSource(inPidFile));
46 
47  // *** setup parameter database
48  FairParRootFileIo* parIO = new FairParRootFileIo();
49  parIO->open(inParFile);
50  FairParAsciiFileIo* parIOPid = new FairParAsciiFileIo();
51  parIOPid->open(pidParFile.Data(),"in");
52 
53  rtdb->setFirstInput(parIO);
54  rtdb->setSecondInput(parIOPid);
55  rtdb->setOutput(parIO);
56 
57  fRun->SetOutputFile(outfile);
58 
59  return fRun;
60 }
FairRunAna * fRun
Definition: hit_dirc.C:58
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
TString outfile
void plotmyhistos ( std::vector< TH1 * >  h,
int  maxy = 700,
double  asp = 1.1 
)

Definition at line 62 of file solution/auxtut.C.

References c, i, and sqrt().

63 {
64  int N = h.size();
65  if (N<=0) return;
66 
67  int nx=sqrt(N);
68  int ny=nx;
69  while(nx*ny<N) nx++;
70 
71  int dim = maxy/ny;
72  if (dim>400) dim=400;
73 
74  TCanvas *c=new TCanvas("c","c",10,10,dim*nx*asp, dim*ny);
75 
76  c->Divide(nx,ny, 0.0005,0.0005);
77 
78  for (int i=0;i<N;++i)
79  {
80  c->cd(i+1);
81  h[i]->Draw();
82  }
83 }
Int_t i
Definition: run_full.C:25
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
void plotmyhistos ( int  maxy = 700,
double  asp = 1.1 
)

Definition at line 85 of file solution/auxtut.C.

References h, hist, i, next, plotmyhistos(), and TString.

86 {
87  std::vector<TH1*> h;
88 
89  //somehow either one or the other is filled, depending on
90  // whether a TFile was opened, or we write to one
91  int Nkey = gDirectory->GetListOfKeys()->GetSize();
92  int Nlst = gDirectory->GetList()->GetSize();
93 
94  if( Nkey==0 && Nlst==0) return;
95 
96  if (Nkey>0)
97  {
98  TIter next(gDirectory->GetListOfKeys());
99  TKey *key;
100  while ((key = (TKey*)next()))
101  {
102  TClass *cl = gROOT->GetClass(key->GetClassName());
103  if (!cl->InheritsFrom("TH1")) continue;
104  TH1 *hist = (TH1*)key->ReadObj();
105  h.push_back(hist);
106  }
107  }
108  else
109  {
110  TList *hl=gDirectory->GetList();
111  for (int i=0;i<hl->GetSize();++i)
112  {
113  TString cn = hl->At(i)->ClassName();
114  if (cn.BeginsWith("TH1") || cn.BeginsWith("TH2")) h.push_back((TH1*)hl->At(i));
115  }
116  }
117 
118  plotmyhistos(h, maxy, asp);
119 }
Int_t i
Definition: run_full.C:25
static int next[96]
Definition: ranlxd.cxx:374
TH1F * hist
void plotmyhistos(std::vector< TH1 * > h, int maxy=700, double asp=1.1)
Definition: QA/auxi.C:62
void RemoveGeoManager ( )

Definition at line 11 of file solution/auxtut.C.

References gGeoManager.

12 {
13  if (gROOT->GetVersionInt() >= 60602) {
14  gGeoManager->GetListOfVolumes()->Delete();
15  gGeoManager->GetListOfShapes()->Delete();
16  delete gGeoManager;
17  }
18 }
TGeoManager * gGeoManager
int writemyhistos ( int  maxy = 800,
double  asp = 1.1 
)

Definition at line 121 of file solution/auxtut.C.

References h, i, TString, and Write().

122 {
123  TList *hl=gDirectory->GetList();
124  std::vector<TH1*> h;
125  for (int i=0;i<hl->GetSize();++i)
126  {
127  TString cn = hl->At(i)->ClassName();
128  if (cn.BeginsWith("TH1") || cn.BeginsWith("TH2")) h.push_back((TH1*)hl->At(i));
129  }
130 
131  int N = h.size();
132  if (N==0) return 0;
133 
134  for (int i=0;i<N;++i) h[i]->Write();
135 
136  return N;
137 }
Int_t i
Definition: run_full.C:25
vTop Write()