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