FairRoot/PandaRoot
macro/softrig/qa_softtrig.C
Go to the documentation of this file.
1 // Check if file exists and readable
2 bool checkfile(TString fn)
3 {
4  bool fileok=true;
5  TFile fff(fn, "READ");
6  if (fff.IsZombie()) fileok=false;
7  TTree *t=(TTree*)fff.Get("pndsim");
8  if (t==0x0) fileok=false;
9 
10  if (!fileok) cout <<"Skipping broken file '"<<fn<<"'"<<endl;
11  fff.Close();
12 
13  return fileok;
14 }
15 
16 // Add many input files to FairRunAna
17 void attachFiles(FairRunAna* fRun, TString pref, int min, int max)
18 {
19  bool firstfile=true;
20  for (int i=min;i<=max;++i) {
21  TString fname = TString::Format("%s_%d_pid.root",pref.Data(),i);
22 
23  if (checkfile(fname) ) {
24  if (firstfile) fRun->SetInputFile(fname);
25  else fRun->AddFile(fname);
26  firstfile=false;
27  }
28  }
29 }
30 
31 int qa_softtrig(TString pref="M9999", int mode, double pmom, int from=1, int to=1, int nEvents=0, int run=0)
32 {
33  TString OutFile = TString::Format("%s_%d_%d_sof.root",pref.Data(),from, to);
34 
35  FairRunAna *fRun= new FairRunAna();
36 
37  // attach input files according to parameters
38  attachFiles(fRun, pref, from, to);
39 
40  // turn off FairLogger output
41  FairLogger::GetLogger()->SetLogToFile(kFALSE);
42 
43  // *** initialization
44  fRun->SetOutputFile(OutFile);
45 
46  //---------------------Create and Set the Field(s)----------
47  //PndMultiField *fField= new PndMultiField("FULL");
48  //fRun->SetField(fField);
49 
51 
52  // *** SoftTriggerTask ***
53 
54  // this file contains the trigger line definitions
55  TString triggercfg = TString(gSystem->Getenv("VMCWORKDIR"))+"/softrig/triggerlines.cfg";
56 
57  // this file contains the cut setup for various modes
58  // TString selectioncfg = TString(gSystem->Getenv("VMCWORKDIR"))+"/selection_10ch_tight.cfg";
59  TString selectioncfg = TString(gSystem->Getenv("VMCWORKDIR"))+"/softrig/selection_10ch_loose.cfg";
60 
61  PndSoftTriggerTask *stTask = new PndSoftTriggerTask(pmom, mode, run, triggercfg);
62  stTask->SetConfigurationFile(selectioncfg);
63 
64  TString algo = "PidAlgoEmcBayes;PidAlgoDrc;PidAlgoDisc;PidAlgoStt;PidAlgoMdtHardCuts"; // FullSim
65  //TString algo = "PidChargedProbability";
66  stTask->SetPidAlgoAll(algo);
67 
68  stTask->SetTagAll(true); // tag all modes
69  //stTask->SetTagMode(120); // switch single tags on/off; mode number has to match one from config file
70 
71  stTask->SetQAAll(true); // ntuple output for all modes
72  //stTask->SetQAMode(120); // switch single QA on/off
73 
74  stTask->SetGammaMinE(0.10); // global energy pre-cut for neutrals
75  stTask->SetTrackMinP(0.10); // global momentum pre-cut for charged
76  stTask->SetInitialPidCut(0.1); // global PID pre-cut for charged
77 
78  //stTask->McMatchAllowPhotos(1,0.05); // MC truth match shall partially ignore photos photons (here max 1 with E<50 MeV)
79 
80  fRun->AddTask(stTask);
81 
82  // *** and run analysis
83  fRun->Init();
84  fRun->Run(0,nEvents);
85  return 0;
86 }
Double_t x0
Definition: checkhelixhit.C:70
Int_t run
Definition: autocutx.C:47
Int_t i
Definition: run_full.C:25
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:26
static void ForceConstantBz(Double_t bz=0.)
Force a constant B field value for all positions.
FairRunAna * fRun
Definition: hit_dirc.C:58
Int_t mode
Definition: autocutx.C:47
void attachFiles(FairRunAna *fRun, TString pref, int min, int max)
int qa_softtrig(TString pref="M9999", int mode, double pmom, int from=1, int to=1, int nEvents=0, int run=0)
Int_t nEvents
Definition: hit_dirc.C:11
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:25
bool checkfile(TString fn)
TTree * t
Definition: bump_analys.C:13