]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGGA/PHOSTasks/CaloCellQA/macros/ExtractPHOSCellQA.C
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGGA / PHOSTasks / CaloCellQA / macros / ExtractPHOSCellQA.C
CommitLineData
9f3c053c 1//------------------------------------------------------------------------
2bfe5463 2// PWGPP QA train produces QA histograms QAresults.root, where PHOS
9f3c053c 3// histograms for two events types are stored in
4// TObjArray *PHOSCellsQA_AnyInt and TObjArray *PHOSCellsQA_PHI7
5// As each a root file for eah run contains, by design, unique histograms
6// per run, the root files from different runs cannot be merged
7// via TFileMerger.
8// This drawback of the QA design is solved by extracting the PHOS
9// histograms from TObjArray's of QAresults.root to separate files per run
10// and per event type.
11//
12// Usage:
2bfe5463 13// 1) Create a list of files QAresults.root produced by the PWGPP QA train,
9f3c053c 14// to a text file, let say QAresults.txt
15// 2) Compile this macro:
16// .L ExtractPHOSCellQA.C++
17// 3) Run conversion of QAresults to new root files with PHOS histograms:
18// ExtractPHOSCellQA("QAresult.txt")
19// 4) On the output, the new root files will be created per run
20// with the names AnyInt_<run>.root and PHI7_<run>.root
21//
22// Author: Yuri Kharlov. 3-Oct-2011
23//------------------------------------------------------------------------
24
25#if !defined(__CINT__) || defined(__MAKECINT__)
26#include <TObjArray.h>
27#include <TString.h>
28#include <TFile.h>
29#include <TGrid.h>
30#include <Riostream.h>
31#include <stdio.h>
32using namespace std;
33#endif
34
35void ExtractPHOSCellQA(const TString QAfilelist="QAresult.list")
36{
37
38 ifstream in;
39 in.open(QAfilelist.Data());
40 char rootFileName[256];
41 TString oldRootFileName, newRootFileName;
42 TFile *oldRootFile, *newRootFile;
43 TObjArray *histAnyInt, *histPHI7;
44 Bool_t firstFile = kTRUE;
45
46 while (1) {
47 in >> rootFileName;
48 if (!in.good()) break;
49 printf("root file is %s",rootFileName);
50 oldRootFileName = rootFileName;
51 if (oldRootFileName.BeginsWith("alien://")) {
52 TGrid::Connect("alien://");
53 firstFile = kFALSE;
54 }
55 oldRootFile = TFile::Open(rootFileName,"read");
56 histAnyInt = (TObjArray*)oldRootFile->Get("PHOSCellsQA_AnyInt");
57 histPHI7 = (TObjArray*)oldRootFile->Get("PHOSCellsQA_PHI7");
58 if (histAnyInt == 0 || histPHI7 == 0) {
59 printf(" does not contain PHOSCellQA histograms\n");
60 continue;
61 }
62 else {
63 printf(" contains PHOSCellQA histograms\n");
64 }
65
66 char *runNum = strtok(rootFileName+35,"/");
67
68 newRootFileName = Form("AnyInt_%s.root",runNum);
69 newRootFile = TFile::Open(newRootFileName,"recreate");
70 histAnyInt->Write(0,0);
71 newRootFile->Close();
72
73 newRootFileName = Form("PHI7_%s.root",runNum);
74 newRootFile = TFile::Open(newRootFileName,"recreate");
75 histPHI7 ->Write(0,0);
76 newRootFile->Close();
77
78 histAnyInt->Clear();
79 histPHI7 ->Clear();
80 oldRootFile ->Close();
81 }
82}