]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/macros/RunAliTPCCalibKrTask.C
Update master to aliroot
[u/mrichter/AliRoot.git] / TPC / macros / RunAliTPCCalibKrTask.C
1 /// \file RunAliTPCCalibKrTask.C
2 ///
3 /// Example usage:
4 ///
5 /// 0. Load neccessary libraries
6 ///
7 /// ~~~{.cpp}
8 /// gSystem->Load("libANALYSIS");
9 /// gSystem->Load("libANALYSISalice");
10 /// gSystem->Load("libTPCcalib");
11 /// gSystem->Load("libXrdClient");
12 /// gSystem->Load("libNetx");
13 /// TGrid::Connect("alien://",0,0,"t");
14 /// gSystem->Load("$ROOTSYS/lib/libXrdClient");
15 /// ~~~
16 ///
17 /// 1. Make list of the files
18 ///
19 /// ~~~{.cpp}
20 /// .L $ALICE_ROOT/TPC/macros/testTPC/AlienToolkit.cxx+
21 /// gSystem->Load("libXrdClient");
22 /// gSystem->Load("libNetx");
23 /// AlienToolkit toolkit;
24 /// char *path = "/alice/cern.ch/user/a/amatyja/alice/data/"
25 /// toolkit.MakeCollection(path,"32129*Krypton.root");
26 /// toolkit.MakeCollection(path,"32231*Krypton.root");
27 /// toolkit.MakeCollection(path,"32284*Krypton.root");
28 /// toolkit.PrintPFN(); > list.txt
29 /// ~~~
30 ///
31 /// 2. Initialization of proof
32 ///
33 /// ~~~{.cpp}
34 /// TProofMgr * proofmgr = TProof::Mgr("lxgrid5.gsi.de");
35 /// TProof * proof = proofmgr->CreateSession();
36 /// proof->SetParameter("PROOF_MaxSlavesPerNode", (Long_t)1000);
37 /// .L /u/miranov/macros/ProofEnableAliRoot.C
38 /// ProofEnableAliRoot("/usr/local/grid/AliRoot/HEAD0108");
39 /// gProof->Exec("gSystem->Load(\"libANALYSIS\")",kTRUE);
40 /// gProof->Exec("gSystem->Load(\"libSTAT\")",kTRUE);
41 /// gProof->Exec("gSystem->Load(\"libTPCcalib\")",kTRUE);
42 /// gProof->Exec(".x $ALICE_ROOT/TPC/macros/ConfigOCDB.C");
43 /// ~~~
44 ///
45 /// 3. Run analysis on PROOF
46 ///
47 /// ~~~{.cpp}
48 /// // Create chain of input files
49 /// gSystem->AddIncludePath("-I$ALICE_ROOT/TPC/macros");
50 /// gROOT->LoadMacro("$ALICE_ROOT/TPC/macros/AliXRDPROOFtoolkit.cxx+");
51 /// .L $ALICE_ROOT/TPC/macros/RunAliTPCCalibKrTask.C
52 /// RunAliTPCCalibKrTask(kTRUE);
53 ///
54 /// // Check the cuts for clusters
55 /// AliXRDPROOFtoolkit tool;
56 /// TChain * chain = tool.MakeChain("list.txt","Kr",0,1000);
57 /// chain->Lookup();
58 /// chain->SetProof(kTRUE);
59 ///
60 /// TCut cutR0("cutR0","fADCcluster/fSize<200");        // adjust it according v seetings -
61 /// TCut cutR1("cutR1","fADCcluster/fSize>7");          // cosmic tracks and noise removal
62 /// TCut cutR2("cutR2","fMax.fAdc/fADCcluster<0.4");    // digital noise removal
63 /// TCut cutR3("cutR3","fMax.fAdc/fADCcluster>0.01");   // noise removal
64 /// TCut cutR4("cutR4","fMax.fTime>200");   // noise removal
65 /// TCut cutR5("cutR5","fMax.fTime<600");   // noise removal
66 /// TCut cutS1("cutS1","fSize<200");    // adjust it according v seetings - cosmic tracks
67 /// TCut cutAll = cutR0+cutR1+cutR2+cutR3+cutR4+cutR5+cutS1;
68 ///
69 /// // Example usage
70 /// TFile f("KrHisto.root");
71 /// AliTPCCalibKr *kr = f.Get("AliTPCCalibKr");
72 ///
73 /// kr->ProjectHisto(kr->GetHistoKr(71),"aaa",30,36,30,40)->Draw()
74 ///
75 /// MakeTree();
76 ///
77 /// //default cuts
78 /// TCut cutKr("cutKr","entries.fElements<5000&&fitNormChi2.fElements<3&&fitNormChi2.fElements>0.2&&abs(fitRMS.fElements/fitMean.fElements-0.06)<0.025");
79 ///
80 /// TObjArray * array = AliTPCCalibViewerGUI::ShowGUI("kryptonTree.root");
81 /// AliTPCCalibViewerGUI * viewer = (AliTPCCalibViewerGUI*)array->At(0);
82 /// TTree * tree = viewer->GetViewer()->GetTree();
83 ///
84 /// tree->SetAlias("cutAll","abs(fitNormChi2.fElements-2.)<1.8&&entries.fElements/entries_Median.fElements<4&&entries.fElements/entries_Median.fElements>0.4&&fitRMS.fElements/fitMean.fElements<0.09&&fitRMS.fElements/fitMean.fElements>0.02")
85 /// ~~~
86
87 TChain * chain = 0;
88
89 void RunAliTPCCalibKrTask(Bool_t bProof = kFALSE)
90 {
91   ///
92
93   AliXRDPROOFtoolkit tool;
94   chain = tool.MakeChain("list.txt","Kr","",20000,0);
95   chain->Lookup();
96   chain->SetBranchStatus("Cl.fCluster",kFALSE);
97
98   //
99   // Create the analysis manager
100   //
101   AliAnalysisManager *mgr = new AliAnalysisManager("testAnalysis");
102
103   // Calibration component
104   AliTPCCalibKr *calibObj = new AliTPCCalibKr;
105   //calibObj->SetASide(kFALSE);
106
107   // Add task
108   AliTPCCalibKrTask *task = new AliTPCCalibKrTask;
109   task->SetInputChain(chain);
110   task->SetTPCCalibKr(calibObj);
111   mgr->AddTask(task);
112
113   // Attach input
114   cInput  = mgr->CreateContainer("cInput", TChain::Class(), AliAnalysisManager::kInputContainer);
115   mgr->ConnectInput(task, 0, cInput);
116
117   // Attach output
118   cOutput = mgr->CreateContainer("cOutput", TList::Class(), AliAnalysisManager::kOutputContainer,"outHistFile.root");
119   mgr->ConnectOutput(task, 0, cOutput);
120   //
121   cOutput->SetSpecialOutput(kTRUE);
122   cOutput->SetFileName("CalibObjectFile.root");
123   //
124   // Run analysis
125   if (!mgr->InitAnalysis()) return;
126   mgr->PrintStatus();
127   mgr->SetDebugLevel(1);
128
129   if(bProof) {
130     mgr->StartAnalysis("proof", chain);
131   }
132   else mgr->StartAnalysis("local", chain);
133 }
134
135
136
137 void MakeTree(){
138
139   TFile fpad("calibKr.root");
140   AliTPCPreprocessorOnline * preprocesor = new AliTPCPreprocessorOnline;
141   preprocesor->AddComponent(spectrMean->Clone());
142   preprocesor->AddComponent(spectrRMS->Clone());
143   preprocesor->AddComponent(fitMean->Clone());
144   preprocesor->AddComponent(fitRMS->Clone());
145   preprocesor->AddComponent(fitNormChi2->Clone());
146   preprocesor->AddComponent(entries->Clone());
147   preprocesor->DumpToFile("kryptonTree.root");
148
149 }