Added method GetConsErrFractionUnScaled which will be used by Amore (H. Tydesjo)
[u/mrichter/AliRoot.git] / ITS / AliITSQADataMakerRec.cxx
CommitLineData
04236e67 1/**************************************************************************
2 * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
18// *************************************************************
19// Checks the quality assurance
20// by comparing with reference data
21// contained in a DB
22// -------------------------------------------------------------
23// W. Ferrarese Nov 2007
24// INFN Torino
25
26// --- ROOT system ---
27#include <TH2D.h>
28#include <TBranch.h>
29#include <TTree.h>
30#include <TGaxis.h>
31
32// --- Standard library ---
33
34// --- AliRoot header files ---
35#include "AliITSQADataMakerRec.h"
36#include "AliLog.h"
37#include "AliQA.h"
38#include "AliQAChecker.h"
39#include "AliRawReader.h"
40#include "AliITSRawStreamSDD.h"
41#include "AliITSRecPoint.h"
42#include "AliITSgeomTGeo.h"
43#include "AliRawReader.h"
44
45
46ClassImp(AliITSQADataMakerRec)
47
48//____________________________________________________________________________
49AliITSQADataMakerRec::AliITSQADataMakerRec() :
9db10425 50AliQADataMakerRec(AliQA::GetDetName(AliQA::kITS), "SDD Quality Assurance Data Maker"),
51fkOnline(kFALSE),
52fLDC(0),
53fnSDDHistos(0)
04236e67 54{
9db10425 55 // Default constructor
04236e67 56}
57
58//____________________________________________________________________________
59AliITSQADataMakerRec::AliITSQADataMakerRec(Int_t ldc, Bool_t kMode) :
9db10425 60 AliQADataMakerRec(AliQA::GetDetName(AliQA::kITS), "SDD Quality Assurance Data Maker"),
61fkOnline(kMode),
62fLDC(ldc),
63fnSDDHistos(0)
04236e67 64{
65 //ctor used to discriminate OnLine-Offline analysis
04236e67 66}
67
68//____________________________________________________________________________
69AliITSQADataMakerRec::AliITSQADataMakerRec(const AliITSQADataMakerRec& qadm) :
9db10425 70AliQADataMakerRec(qadm),
71fkOnline(qadm.fkOnline),
72fLDC(qadm.fLDC),
73fnSDDHistos(qadm.fnSDDHistos)
04236e67 74{
75 //copy ctor
76 SetName((const char*)qadm.GetName()) ;
77 SetTitle((const char*)qadm.GetTitle());
78}
79
80//__________________________________________________________________
81AliITSQADataMakerRec& AliITSQADataMakerRec::operator = (const AliITSQADataMakerRec& qac )
82{
83 // Equal operator.
84 this->~AliITSQADataMakerRec();
85 new(this) AliITSQADataMakerRec(qac);
86 return *this;
87}
88
89//____________________________________________________________________________
90void AliITSQADataMakerRec::StartOfDetectorCycle() const
91{
92 //Detector specific actions at start of cycle
93 AliDebug(1,"AliITSQADM::Start of ITS Cycle\n");
94}
95
96//____________________________________________________________________________
97void AliITSQADataMakerRec::EndOfDetectorCycle(AliQA::TASKINDEX task, TObjArray *list)
98{
99 // launch the QA checking
100 AliDebug(1,"AliITSDM instantiates checker with Run(AliQA::kITS, task, list)\n");
101
102 AliQAChecker::Instance()->Run( AliQA::kITS , task, list);
103}
104
105//____________________________________________________________________________
9db10425 106void AliITSQADataMakerRec::EndOfDetectorCycle(const char * /* fgDataName */)
04236e67 107{
9db10425 108 //possibly used for different AliQAChecker::Instance()->Run
04236e67 109}
110
111//____________________________________________________________________________
112void AliITSQADataMakerRec::InitRaws()
113{
114 // create SDD histo of raw
115
116 Int_t lay, lad, det;
117
118 if(fkOnline) {
119 AliInfo("Book Online Histograms\n");
120 }
121 else {
122 AliInfo("Book Offline Histograms\n ");
123 }
124
125 TH1F *h0 = new TH1F("ModPattern","Modules pattern",fgknSDDmodules,-0.5,259.5);
126 Add2RawsList(h0,0);
127 fnSDDHistos++;
128 TH1F *h1 = new TH1F("ModPatternL3","Modules pattern L3",14,0.5,14.5);
129 Add2RawsList(h1,1);
130 fnSDDHistos++;
131 TH1F *h2 = new TH1F("ModPatternL4","Modules pattern L4",22,0.5,22.5);
132 Add2RawsList(h2,2);
133 fnSDDHistos++;
134
135 Char_t *hname0[fgkLADDonLAY3] ;
136 TH1D *h3[fgkLADDonLAY3] ;
137 for(Int_t i=1; i<=fgkLADDonLAY3; i++) {
138 hname0[i-1] = new Char_t[20];
139 sprintf(hname0[i-1],"ModPattern_L3_%d",i);
140 h3[i-1] = new TH1D(hname0[i-1],hname0[i-1],6,0.5,6.5);
141 Add2RawsList(h3[i-1],i-1+3);
142 fnSDDHistos++;
143 }
144
145 Char_t *hname1[fgkLADDonLAY4] ;
146 TH1D *h4[fgkLADDonLAY4] ;
147 for(Int_t i=1; i<=fgkLADDonLAY4; i++) {
148 hname1[i-1] = new Char_t[20];
149 sprintf(hname1[i-1],"ModPattern_L4_%d",i);
150 h4[i-1] = new TH1D(hname1[i-1],hname1[i-1],8,0.5,8.5);
151 Add2RawsList(h4[i-1],i-1+17);
152 fnSDDHistos++;
153 }
154
155 if(fkOnline) {
156 Int_t indexlast = 0;
157 Char_t *hname2[fgknSDDmodules*2] ;
158 TH1D *h5[fgknSDDmodules*2] ;
159 Int_t index1 = 0;
160 for(Int_t moduleSDD=0; moduleSDD<fgknSDDmodules; moduleSDD++){
161 if((moduleSDD >= 0 && moduleSDD < 36) || (moduleSDD >= 84 && moduleSDD < 180)) {
162 for(Int_t iside=0; iside<fgknSide; iside++){
163 //Int_t index1 = moduleSDD * 2 + iside;
164 hname2[index1] = new Char_t[50];
165 AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
166 sprintf(hname2[index1],"ProjYMap_L%d_%d_%d_%d",lay,lad,det,iside);
167
168 h5[index1] = new TH1D(hname2[index1],hname2[index1],256,-0.5,255.5);
169 Add2RawsList(h5[index1],index1+39);
170 fnSDDHistos++;
171 index1++;
172 indexlast = index1+39;
173 }
174 }
175 }
176
177 Char_t *hname3[fgknSDDmodules*8] ;
178 TH1D *h6[fgknSDDmodules*8] ;
179 Int_t indextot = 0;
180 Int_t indexlast1 = 0;
181 for(Int_t htype=0; htype<4; htype++){
182 for(Int_t moduleSDD=0; moduleSDD<fgknSDDmodules; moduleSDD++){
183 if((moduleSDD >= 0 && moduleSDD < 36) || (moduleSDD >= 84 && moduleSDD < 180)) {
184 for(Int_t iside=0; iside<fgknSide; iside++){
185 //Int_t index1 = moduleSDD*2 + iside;
186 hname3[indextot] = new Char_t[50];
187 AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
188 if(htype == 0) sprintf(hname3[indextot],"CountsVSAnode_L%d_%d_%d_%d",lay,lad,det,iside);
189 if(htype == 1) sprintf(hname3[indextot],"ChargeVSAnode_L%d_%d_%d_%d",lay,lad,det,iside);
190 if(htype == 2) sprintf(hname3[indextot],"CountsVSTbin_L%d_%d_%d_%d",lay,lad,det,iside);
191 if(htype == 3) sprintf(hname3[indextot],"ChargeVSTbin_L%d_%d_%d_%d",lay,lad,det,iside);
192 h6[indextot] = new TH1D(hname3[indextot],hname3[indextot],256,-0.5,255.5);
193 Add2RawsList(h6[indextot],indexlast + indextot);
194 fnSDDHistos++;
195 indextot++;
196 indexlast1 = indexlast + indextot;
197 }
198 }
199 }
200 }
201
202 Int_t indexlast2 = 0;
203 Char_t *hname4[fgknSDDmodules*2];
204 TH2D *h7[fgknSDDmodules*2] ;
205 index1 = 0;
206 for(Int_t moduleSDD=0; moduleSDD<fgknSDDmodules; moduleSDD++){
207 if((moduleSDD >= 0 && moduleSDD < 36) || (moduleSDD >= 84 && moduleSDD < 180)) {
208 for(Int_t iside=0; iside<fgknSide; iside++){
209 //Int_t index1 = moduleSDD * 2 + iside;
210 AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
211 hname4[index1] = new Char_t[50];
212 sprintf(hname4[index1],"Anode_vs_Charge_L%d_%d_%d_%d",lay,lad,det,iside);
213 h7[index1] = new TH2D(hname4[index1],hname4[index1],fgknSDDmodules*2,-0.5,-0.5+fgknSDDmodules*2,256,0.5,256.5);
214 Add2RawsList(h7[index1],indexlast1 + index1);
215 fnSDDHistos++;
216 index1++;
217 indexlast2 = indexlast1 + index1;
218 }
219 }
220 }
221
222 Char_t *hname[3][2 * fgknSDDmodules] ;
223 index1 = 0;
224 for(Int_t moduleSDD =0; moduleSDD<fgknSDDmodules; moduleSDD++){
225 if((moduleSDD >= 0 && moduleSDD < 36) || (moduleSDD >= 84 && moduleSDD < 180)) {
226 for(Int_t iside=0;iside<fgknSide;iside++){
227 //Int_t index1 = moduleSDD * 2 + iside ;
228 for(Int_t i=0; i<3; i++) hname[i][index1]= new Char_t[50];
229 AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
230 sprintf(hname[0][index1],"chargeMap_L%d_%d_%d_%d",lay,lad,det,iside);
231 sprintf(hname[1][index1],"TotalCharge_L%d_%d_%d_%d",lay,lad,det,iside);
232 sprintf(hname[2][index1],"hmonoDMap_L%d_%d_%d_%d",lay,lad,det,iside);
233 fModuleChargeMap[index1] = new TH2D(hname[0][index1],hname[1][index1],256,-0.5,255.5,256,-0.5,255.5);
234 Add2RawsList(fModuleChargeMap[index1],indexlast2 + index1);
235 fnSDDHistos++;
236 fmonoD[index1] = new TH1D(hname[2][index1],hname[2][index1],256,-0.5,255.5);
237 index1++;
238 }
239 }
240 }
241 }
242
243 AliDebug(1,Form("%d SDD histograms booked\n",fnSDDHistos));
244}
245
246//____________________________________________________________________________
247void AliITSQADataMakerRec::MakeRaws(AliRawReader* rawReader)
248{
249 //Fills Raw QA list of histos
9db10425 250 if(rawReader->GetType() != 7) return; // skips non physical triggers
04236e67 251 Int_t index=0;
252 if(fkOnline) {
253 for(Int_t moduleSDD =0; moduleSDD<fgknSDDmodules; moduleSDD++){
254 if((moduleSDD >= 0 && moduleSDD < 36) || (moduleSDD >= 84 && moduleSDD < 180)) {
255 for(Int_t iside=0;iside<fgknSide;iside++) {
256 if(fnSDDHistos > 39+12 * 132 + index) GetRawsData(39+12 * 132 + index)->Reset();
257 index++;
258 }
259 }
260 }
261 }
262 AliDebug(1,"entering MakeRaws\n");
9db10425 263 // rawReader->SelectEvents(7);
04236e67 264 rawReader->SelectEquipment(17,fgkeqOffset+1,fgkeqOffset + fgkDDLidRange);
265 rawReader->Reset();
266 AliITSRawStreamSDD s(rawReader);
267 Int_t lay, lad, det;
268
269 Int_t cnt = 0;
270 while(s.Next()) {
271 Int_t iddl = rawReader->GetDDLID() - fgkDDLIDshift;
272 Int_t isddmod = s.GetModuleNumber(iddl,s.GetCarlosId());
273 if(s.IsCompletedModule()) {
274 AliDebug(1,Form("IsCompletedModule == KTRUE\n"));
275 continue;
276 }
277 Int_t coord1 = s.GetCoord1();
278 Int_t coord2 = s.GetCoord2();
279 Int_t signal = s.GetSignal();
280 Int_t moduleSDD = isddmod - fgkmodoffset;
281 if(moduleSDD < 0 || moduleSDD>fgknSDDmodules+fgkmodoffset) {
282 AliDebug(1,Form( "Module SDD = %d, resetting it to 1 \n",moduleSDD));
283 moduleSDD = 1;
284 }
285 GetRawsData(0)->Fill(moduleSDD);
286
287 AliITSgeomTGeo::GetModuleId(isddmod, lay, lad, det);
288 //printf("modnumb %d, lay %d, lad %d, det %d \n",isddmod, lay, lad, det);
289 Int_t ioffset = 3;
290 Int_t iorder = 1;
291 if(lay==4) {
292 ioffset += 14;
293 iorder = 2;
294 }
295 GetRawsData(iorder)->Fill(lad);
296 GetRawsData(ioffset+lad-1)->Fill(det); //-1 because ladder# starts from 1
297
298 Short_t iside = s.GetChannel();
299 Int_t activeModule = moduleSDD;
300 if(moduleSDD > 35) activeModule -= 48;
301 Int_t index1 = activeModule * 2 + iside;
302
303 if(index1<0){
304 AliDebug(1,Form("Wrong index number %d - patched to 0\n",index1));
305 index1 = 0;
306 }
307
308 if(fkOnline) {
309 if(fnSDDHistos > 39+12 * 132 + index1) {
310 GetRawsData(39+ 2 * 132 + index1)->Fill(coord1);
311 GetRawsData(39+ 4 * 132 + index1)->Fill(coord1,signal);
312 GetRawsData(39+ 6 * 132 + index1)->Fill(coord2);
313 GetRawsData(39+ 8 * 132 + index1)->Fill(coord2,signal);
314 GetRawsData(39+10 * 132 + index1)->Fill(signal,coord1);
315 ((TH2D *)(GetRawsData(39+12 * 132 + index1)))->Fill(coord2, coord1, signal);
316 }
317 }
318 cnt++;
319 if(!(cnt%10000)) AliDebug(1,Form(" %d raw digits read",cnt));
320 }
321 AliDebug(1,Form("Event completed, %d raw digits read",cnt));
322
323 if(fkOnline) {
324 Int_t nBins = 256;
325 for(Int_t moduleSDD=0; moduleSDD<fgknSDDmodules; moduleSDD++){
326 if((moduleSDD >= 0 && moduleSDD < 36) || (moduleSDD >= 84 && moduleSDD < 180)) {
327 for(Int_t iside=0; iside<fgknSide; iside++){
328 Int_t activeModule = moduleSDD;
329 if(moduleSDD > 35) activeModule -= 48;
330 Int_t index1 = activeModule * 2 + iside;
331 if(fnSDDHistos > 39 + 2 * 132 + index1) {
332 fmonoD[index1] = ((TH2D *) (GetRawsData(39+12 * 132 + index1)))->ProjectionY();
333 for(Int_t bin=0; bin<nBins; bin++) GetRawsData(index1+39)->Fill(bin,fmonoD[index1]->GetBinContent(bin+1) );
334 }
335 }
336 }
337 }
338 for(Int_t i=0; i<fnSDDHistos; i++){
339 Int_t entries = static_cast<Int_t>(GetRawsData(i)->GetEntries());
340 if(entries != 0)
341 AliDebug(1,Form("histo %d, name %s , entries %d ",i,GetRawsData(i)->GetName(),entries));
342 }
343 }
344}
345
346
347
348//____________________________________________________________________________
349void AliITSQADataMakerRec::InitRecPoints()
350{
351 // create SDD histo of RecPoints
352
353 TH1F * h0 = new TH1F("Lay3TotCh","Layer 3 total charge",1000,-0.5, 499.5);
354 Add2RecPointsList(h0, 0);
355
356 TH1F * h1 = new TH1F("Lay4TotCh","Layer 4 total charge",1000,-0.5, 499.5);
357 Add2RecPointsList(h1, 1);
358
359
360 Char_t *hisnam[3];
361 TH1F *h2[3];
362 for(Int_t i=1; i<=3; i++){
363 hisnam[i] = new Char_t[50];
364 sprintf(hisnam[i],"Charge_L3_Strip%d",i);
365 h2[i] = new TH1F(hisnam[i],hisnam[i],1000,-0.5, 499.5);
366 Add2RecPointsList(h2[i],i+1);
367 }
368
369 Char_t *hisnam2[4] ;
370 TH1F *h3[4];
371 for(Int_t i=1; i<=4; i++){
372 hisnam2[i] = new Char_t[50];
373 sprintf(hisnam2[i],"Charge_L4_Strip%d",i);
374 h3[i] = new TH1F(hisnam2[i],hisnam2[i],1000,-0.5, 499.5);
375 Add2RecPointsList(h3[i],i+4);
376 }
377
378}
379
380
381//____________________________________________________________________________
382void AliITSQADataMakerRec::MakeRecPoints(TTree * clustersTree)
383{
384 // makes data from RecPoints
385 /*
386 TBranch *branchRecP = clustersTree->GetBranch("ITSRecPoints");
387 if (!branchRecP) {
388 AliError("can't get the branch with the ITS clusters !");
389 return;
390 }
391 TObjArray * recpoints = new TObjArray(100) ;
392 branchRecP->SetAddress(&recpoints);
393 branchRecP->GetEntry(0);
394
395 TIter next(recpoints);
396 AliITSRecPoint * rp;
397 while ( rp = dynamic_cast<AliITSRecPoint *>(next()) ) {
398 if(rp->GetLayer() ==3) GetRecPointsData(0)->Fill( rp->GetQ()) ;
399 else if(rp->GetLayer() ==4) GetRecPointsData(1)->Fill( rp->GetQ()) ;
400 }
401 recpoints->Delete();
402 delete recpoints;
403 */
404}
405
406