Added D* systematic errors (Alessandro, Yifei)
[u/mrichter/AliRoot.git] / ITS / macrosSDD / ITSQArecoparam.C
CommitLineData
88522cc1 1#if !defined(__CINT__) || defined(__MAKECINT__)
2#include <TFile.h>
3#include <TAlienFile.h>
4#include <TSystem.h>
5#include <TGrid.h>
6#include <TGridResult.h>
7#include <Riostream.h>
8#include <TObjArray.h>
9#include <TKey.h>
10#include <TStyle.h>
11#include <TTree.h>
12#include <TROOT.h>
13#include <TPluginManager.h>
14#include <TClass.h>
15#include <iostream>
16#include <stdio.h>
17#include "AliRawReader.h"
18#include "AliRawReaderRoot.h"
19#include "AliRawReaderDate.h"
20#include "AliITSQADataMakerRec.h"
21#include "AliITSQASDDDataMakerRec.h"
22#include "AliITSQAChecker.h"
23#include "AliQAChecker.h"
24#include "AliITSQASDDChecker.h"
25#include "AliReconstructor.h"
26#include "AliCDBManager.h"
27#include "AliQAv1.h"
28#include "AliGeomManager.h"
29#include "AliITSInitGeometry.h"
30#include "AliITSgeom.h"
31#include "AliRecoParam.h"
32#include "AliCDBPath.h"
33#include "AliCDBEntry.h"
34#include "AliRecoParam.h"
35#include "AliDetectorRecoParam.h"
36#include "AliITSReconstructor.h"
37#include "AliITSRecPointContainer.h"
38#include "AliLog.h"
39#endif
40void ITSQArecoparam(char *iFile,Int_t idet=2,Int_t FirstEvt=0, Int_t MaxEvts=1000000)
41{
42 TString namefile(iFile);
43 if(namefile.Contains("alien"))
44 {
45 TGrid::Connect("alien://");
46 if(!gGrid) {
47 printf("gGrid not found! exit macro\n");
48 return;
49 }
50 }
51 gStyle->SetPalette(1);
52 Int_t ic=0;
53 AliRawReader *rd=NULL;
54 if(strstr(iFile,".root")!=0){rd = new AliRawReaderRoot(iFile,FirstEvt);}
55 else{rd=new AliRawReaderDate(iFile,FirstEvt);}
56 Int_t runNumber = rd->GetRunNumber();
57 cout << "ITS Quality Assurance Prototype" << endl;
58 //TStopwatch mytimer;
59 //TString namefile(iFile);
60 // Set OCDB if needed
61 AliCDBManager* man = AliCDBManager::Instance();
62 if (!man->IsDefaultStorageSet()) {
63 printf("Setting a local default storage and run number \n");
64 if(namefile.Contains("alien")){
65 man->SetDefaultStorage("raw://");
66 }
67 else{man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");}
68 man->SetRun(runNumber);
69 AliQAv1::SetQARefStorage("local://$ALICE_ROOT/QARef") ;
70 }
71
72 AliITSQADataMakerRec *itsQAdm = new AliITSQADataMakerRec(kTRUE,idet,0); //online kTRUE
73 itsQAdm->SetWriteExpert() ;
74 itsQAdm->SetRunNumber(runNumber);
75 //________________________For the RecPoints____________________________________
76 /************************************************/
77 TPluginManager* pluginManager=NULL;
78 TPluginHandler* pluginHandler=NULL;
79 AliReconstructor* reconstructor = NULL;
80 AliITSRecPointContainer* rpcont=NULL;
81 AliGeomManager::LoadGeometry("geometry.root");
82 AliGeomManager::ApplyAlignObjsFromCDB("ITS");
83 // ITS initializations
84
85 AliITSInitGeometry initgeom;
86 AliITSgeom *geom = initgeom.CreateAliITSgeom();
87 printf("Geometry name: %s\n",(initgeom.GetGeometryName()).Data());
88
89 printf("Loading reconstruction parameter objects for detector ITS\n");
90 AliRecoParam fRecoParam;
91 AliCDBPath path("ITS","Calib","RecoParam");
92 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
93 Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
94 if(!entry){printf("Couldn't find RecoParam entry in OCDB for detector ITS");entry=NULL;}
95 else {
96 TObject *recoParamObj = entry->GetObject();
97 if (dynamic_cast<TObjArray*>(recoParamObj)) {
98 printf("RecoParam TObjArray\n");
99 fRecoParam.AddDetRecoParamArray(0,dynamic_cast<TObjArray*>(recoParamObj));
100 }
101 else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
102 printf("RecoParam AliDetectorRecoParam\n");
103 printf("Single set of reconstruction parameters found for detector ITS");
104 (dynamic_cast<AliDetectorRecoParam*>(recoParamObj))->SetAsDefault();
105 fRecoParam.AddDetRecoParam(0,(dynamic_cast<AliDetectorRecoParam*>(recoParamObj)));
106 }
107 else {printf("Error: No valid RecoParam object found in the OCDB for detector ITS");}
108 entry->SetOwner(0);
109 }
110 if(!cacheStatus)entry->SetObject(NULL);
111 if(!cacheStatus){ delete entry;}
112
113 // load the reconstructor object
114 pluginManager = gROOT->GetPluginManager();
115 TString detName = "ITS";
116 TString recName = "Ali" + detName + "Reconstructor";
117
118pluginHandler = pluginManager->FindHandler("AliReconstructor", "ITS");
119 // if not, add a plugin for it
120 if (!pluginHandler) {
121 printf("defining plugin for ITS\n");
122 TString libs = gSystem->GetLibraries();
123 if (libs.Contains("lib" + detName + "base.so") ||
124 (gSystem->Load("lib" + detName + "base.so") >= 0)) {pluginManager->AddHandler("AliReconstructor", detName,recName, detName + "rec", recName + "()");}
125 else {pluginManager->AddHandler("AliReconstructor", detName,recName, detName, recName + "()");}
126 pluginHandler = pluginManager->FindHandler("AliReconstructor", detName);
127 }
128 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {reconstructor = (AliReconstructor*) pluginHandler->ExecPlugin(0);}
129 if (fRecoParam.GetDetRecoParamArray(0) && !AliReconstructor::GetRecoParam(0)) {
130 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(0);
131 reconstructor->Init();
132 reconstructor->SetRecoParam(par);
133 }
134
135 /*AliITSRecPointContainer**/ rpcont=AliITSRecPointContainer::Instance();
136 rpcont->PrepareToRead();
137
138 Int_t cycleLength = 5;
139 //cout << "Processing Run " << runNumber << endl;
140 cout << "Init: " << AliQAv1::kRAWS << endl;
141
142 TObjArray **objArray= itsQAdm->Init(AliQAv1::kRAWS, cycleLength);
143 cout<<"raw tobjarray :"<<objArray<<"\n"<<endl;
144 for(Int_t spec = 0 ; spec < 5 ; spec++){
145 if(spec==1){
146 itsQAdm->SetEventSpecie(AliRecoParam::kLowMult);
147 AliQAv1::Instance()->SetEventSpecie(AliRecoParam::kLowMult);
148 itsQAdm->InitRaws();
149 }
150 else{continue;}
151 }
152 itsQAdm->StartOfCycle(AliQAv1::kRAWS,runNumber,kFALSE);
153 /*********************************************************************/
154
155 cout << "Init: " << AliQAv1::kRECPOINTS << endl;
156 TObjArray **objArray1= itsQAdm->Init(AliQAv1::kRECPOINTS, cycleLength);
157 cout<<"recpoint tobjarray :"<<objArray1<<"\n"<<endl;
158 for(Int_t spec = 0 ; spec < 5 ; spec++){
159 if(spec==1){
160 itsQAdm->SetEventSpecie(AliRecoParam::kLowMult);
161 AliQAv1::Instance()->SetEventSpecie(AliRecoParam::kLowMult);
162 itsQAdm->InitRecPoints();
163 }
164 else{continue;}
165 }
166 itsQAdm->StartOfCycle(AliQAv1::kRECPOINTS,runNumber,kTRUE);
167
168 /*********************************************************************/
169 Int_t iev = 0;
170 while(rd->NextEvent() && iev < MaxEvts ) {
171 cout<<">>>>>>> Processing event number: "<<++iev<<endl;
172 /*******************************************************/
173 if(itsQAdm->IsCycleDone()) {
174 cout << "end of cycle" << endl;
175 AliQAChecker::Instance()->SetRunNumber(AliCDBManager::Instance()->GetRun());
176 itsQAdm->EndOfCycle(AliQAv1::kRAWS);
177 itsQAdm->StartOfCycle(AliQAv1::kRAWS,ic++,kFALSE);
178 }
179 /******************************************************/
180 /*************************************************/
181
182 if(itsQAdm->IsCycleDone()) {
183 cout << "end of cycle" << endl;
184 AliQAChecker::Instance()->SetRunNumber(AliCDBManager::Instance()->GetRun());
185 itsQAdm->EndOfCycle(AliQAv1::kRECPOINTS);
186 itsQAdm->StartOfCycle(AliQAv1::kRECPOINTS,ic,kTRUE);
187 }
188
189 /*************************************************/
190 cout<<"Beginning Exec"<<endl;
191 cout<<"AliQAv1::kRAWS "<<AliQAv1::kRAWS<<endl;
192 itsQAdm->SetEventSpecie(AliRecoParam::kLowMult);
193 AliQAv1::Instance()->SetEventSpecie(AliRecoParam::kLowMult);
194 itsQAdm->Exec(AliQAv1::kRAWS,rd);
195 /***************************************************/
196 // if(kRecPoints){
197 cout<<"AliQAv1::kRECPOINTS "<<AliQAv1::kRECPOINTS<<endl;
198 cout << "DigitsToRecPoints" << endl;
199 TTree* fTreeR = new TTree("TreeR", "Reconstructed Points Container"); //make a tree
200 Char_t option[5];
201
202 if(idet==0)sprintf(option,"ALL");
203 else if(idet==1)sprintf(option,"SPD");
204 else if(idet==2)sprintf(option,"SDD");
205 else if(idet==3)sprintf(option,"SSD");
206 printf("\t\t===========>option is %s\n",option);
207
208 rpcont->PrepareToRead();
209 reconstructor->Reconstruct(rd,fTreeR);
210
211 itsQAdm->SetEventSpecie(AliRecoParam::kLowMult);
212 AliQAv1::Instance()->SetEventSpecie(AliRecoParam::kLowMult) ;
213 itsQAdm->Exec(AliQAv1::kRECPOINTS,fTreeR);
214 cout<<"Finishing Exec"<<endl;
215
216 ((AliITSReconstructor*)reconstructor)->ResetRecPoints();
217 delete fTreeR;
218 fTreeR=NULL;
219 /*****************************************************/
220 }
221
222 cout << "end RAWS cycle: " << AliQAv1::kRAWS << endl;
223 cout << "refStorage: " << AliQAv1::GetQARefStorage() << endl;
224 cout << "end of cycle 2" << endl;
225 AliQAChecker::Instance()->SetRunNumber(AliCDBManager::Instance()->GetRun());
226 itsQAdm->EndOfCycle(AliQAv1::kRAWS);
227 cout << "Raws QA completed for " << iev << " events" << endl;
228 /*******************************************************************/
229
230 AliQAChecker::Instance()->SetRunNumber(AliCDBManager::Instance()->GetRun());
231 itsQAdm->EndOfCycle(AliQAv1::kRECPOINTS);
232 cout << "RecPoints QA completed for " << iev << " events" << endl;
233
234 /*******************************************************************/
235 itsQAdm->Finish(); // write to the output File
236
237 cout << "Call AliITSQASDDDataMakerRec destructor" << endl;
238 delete itsQAdm;
239 itsQAdm=NULL;
240
241}
242