FairRoot/PandaRoot
GammaSpectraAnalysis_NoH_Task.C
Go to the documentation of this file.
1 //void GammaSpectraAnalysis_NoH_Task(TString Filename = "Sim_Geo36_E0.500MeV_Evts1000_FileEvts1000_Gen1_ST0__0.root", TString SubFolder ="Sim_Geo36_E0.500MeV_Evts1000_FileEvts1000_Gen1_ST0")//, Double_t Energy)
3  TString Filename = "Sim_Geo43_E0.519MeV_Evts2860000_FileEvts11440_Gen1_ST12__248.root",
4  TString SubFolder ="Sim_Geo43_E0.519MeV_Evts2860000_FileEvts11440_Gen1_ST12",
5  Bool_t OmegaQuadrupolMode = 1,
6  Double_t PeakWidthStretchfactor=1
7  )//, Double_t Energy)
8 
9 {
10 
11  Int_t iVerbose = 0;
12 
13  gROOT->LoadMacro("$VMCWORKDIR/gconfig/rootlogon.C");
14  //rootlogon();
15  gROOT->LoadMacro("$VMCWORKDIR/macro/hypGe/Marcell/SharedMacros/SharedMacroFunctions.C");
16 
17  gSystem->Load("libHypGe");
18  gSystem->Load("librazhyp");
19  gSystem->Load("libHyp");
20  gSystem->Load("libSpectrum");
21  // ----- Timer --------------------------------------------------------
22  TStopwatch timer;
23  timer.Start();
24 
25  // get energy from filename
26  Double_t Energy = GetEnergyFromFilename(Filename); // now in MeV
27 
28  // get number of events from filename
29 
31 
32  Int_t TargetSimulated= GetIfTargetIsSimulated(Filename);
33  cout << "TargetSimulated " << TargetSimulated << endl;
34  if(Filename.EndsWith(".root",1))
35  {
36  Filename.ReplaceAll(".root","");
37  cout << "Filename ending chopped!" << endl;
38  }
39  TString CompleteFilename = "$SIMDATADIR/Gamma/"+SubFolder+"/"+Filename+".root";
40  TString CompleteParameterFilename = "$SIMDATADIR/Gamma/"+SubFolder+"/"+Filename+"__Simparams.root";
41  //Output Files
42  Filename.ReplaceAll("Sim","Ana");
43  SubFolder.ReplaceAll("Sim","Ana");
44  TString TextAdd = "_OQP_Psf"; //text added to files /folders in Omega Quadropole mode
45  TextAdd +=PeakWidthStretchfactor;
46  if (OmegaQuadrupolMode)
47  {
48  SubFolder+=TextAdd;
49  }
50  TString Path = getenv("SIMDATADIR");
51  TString FullPath= Path+"/Gamma/Ana/"+SubFolder;
52  char CommandBuffer[400];
53  sprintf(CommandBuffer,".!mkdir -p %s",FullPath.Data());
54  cout << "Processing " << CommandBuffer<< endl;
55  gROOT->ProcessLine(CommandBuffer); // create subfolder for the output
57  TString txtfileName;
58  if (OmegaQuadrupolMode)
59  {
60 
61  outfile = FullPath + "/" + Filename;
62  outfile.Insert(outfile.Index("__"),TextAdd.Data());
63  //cout << outfile.Data()<<endl;
64 
65  txtfileName = outfile+ ".txt";
66  outfile+=".root";
67 
68  }
69  else
70  {
71  outfile = FullPath + "/" + Filename + ".root";
72  txtfileName = FullPath + "/" + Filename + ".txt";
73  }
74  //--------- gamma ana run
75  FairRunAna *fRun= new FairRunAna();
76  fRun->SetInputFile(CompleteFilename.Data());
77  fRun->SetOutputFile(outfile.Data());
78 
79  // ----- Parameter database --------------------------------------------
80 
81  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
82  FairParRootFileIo* parInput1 = new FairParRootFileIo();
83  parInput1->open(CompleteParameterFilename.Data());
84 
86  rtdb->setFirstInput(parInput1);
87 
88 
89 
90  //--------analysis task----------------------------------------------------
91  PndHypGeGammaAna* GammaAna = new PndHypGeGammaAna(txtfileName,Energy,nEvents);
92  GammaAna->SetVerbose(iVerbose);
93  GammaAna->SetTarget(TargetSimulated);
94  if (OmegaQuadrupolMode)
95  {
96  GammaAna->SetOmegaQuadrupolMode(1);
97  GammaAna->SetPeakWidtchStrechFactor(PeakWidthStretchfactor);
98  }
99  fRun->AddTask(GammaAna);
100 
101 
102  fRun->Init();
103 
104  fRun->Run(0,nEvents);
105 
106 
107  // ----- Finish -------------------------------------------------------
108  timer.Stop();
109  Double_t rtime = timer.RealTime();
110  Double_t ctime = timer.CpuTime();
111  cout << endl << endl;
112  cout << "Macro finished succesfully." << endl;
113  cout << "Output file is " << outfile << endl;
114  cout << "Text file is " << txtfileName << endl;
115  //cout << "Parameter file is " << parFile << endl;
116  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
117  cout << endl;
118  return 0;
119 }
void SetTarget(Bool_t TargetAvailable=1)
Bool_t kParameterMerged
Definition: sim_emc_apd.C:113
int GammaSpectraAnalysis_NoH_Task(TString Filename="Sim_Geo43_E0.519MeV_Evts2860000_FileEvts11440_Gen1_ST12__248.root", TString SubFolder="Sim_Geo43_E0.519MeV_Evts2860000_FileEvts11440_Gen1_ST12", Bool_t OmegaQuadrupolMode=1, Double_t PeakWidthStretchfactor=1)
FairRunAna * fRun
Definition: hit_dirc.C:58
void SetPeakWidtchStrechFactor(Double_t PeakWidtchStrechFactor_ext=1)
TString CompleteFilename(TString mu, TString Q, TString Psf)
Double_t
void SetOmegaQuadrupolMode(Bool_t useOmegaQuadrupolMode_ext=1)
Int_t nEvents
Definition: hit_dirc.C:11
TStopwatch timer
Definition: hit_dirc.C:51
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
FairParRootFileIo * parInput1
Definition: hit_dirc.C:67
Double_t ctime
Definition: hit_dirc.C:114
Int_t GetNumberOfEventsInFileFromFilename(TString Filename)
Int_t GetIfTargetIsSimulated(TString Filename)
Double_t GetEnergyFromFilename(TString Filename)
Int_t iVerbose
Double_t rtime
Definition: hit_dirc.C:113
TString outfile