]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSQASDDDataMakerRec.cxx
Evaluation of the combinatorial background is now performed automatically in one...
[u/mrichter/AliRoot.git] / ITS / AliITSQASDDDataMakerRec.cxx
CommitLineData
ebdd0606 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 + P. Cerello Feb 2008
8b7e858c 24// M.Siciliano Aug 2008 QA RecPoints
ebdd0606 25// INFN Torino
26
27// --- ROOT system ---
ad300de9 28
ebdd0606 29#include <TProfile2D.h>
30#include <TH2D.h>
31#include <TBranch.h>
32#include <TTree.h>
33#include <TGaxis.h>
34#include <TMath.h>
8b7e858c 35#include <TF1.h>
ebdd0606 36#include <TDirectory.h>
e41192d7 37#include <TSystem.h>
ebdd0606 38// --- Standard library ---
39
40// --- AliRoot header files ---
41#include "AliITSQASDDDataMakerRec.h"
42#include "AliLog.h"
4e25ac79 43#include "AliQAv1.h"
ebdd0606 44#include "AliQAChecker.h"
45#include "AliRawReader.h"
e41192d7 46#include "AliITSRawStream.h"
ebdd0606 47#include "AliITSRawStreamSDD.h"
e41192d7 48#include "AliITSRawStreamSDDCompressed.h"
49#include "AliITSDetTypeRec.h"
5192f264 50#include "AliITSdigit.h"
ebdd0606 51#include "AliITSRecPoint.h"
52#include "AliITSgeomTGeo.h"
ebdd0606 53#include "AliCDBManager.h"
54#include "AliCDBStorage.h"
55#include "AliCDBEntry.h"
ad300de9 56#include "Riostream.h"
fc89f88c 57#include "AliITSdigitSDD.h"
58#include "AliITS.h"
59#include "AliRunLoader.h"
60#include "AliITSLoader.h"
61#include "AliITSDetTypeRec.h"
62
63
ebdd0606 64
65ClassImp(AliITSQASDDDataMakerRec)
66
67//____________________________________________________________________________
68AliITSQASDDDataMakerRec::AliITSQASDDDataMakerRec(AliITSQADataMakerRec *aliITSQADataMakerRec, Bool_t kMode, Short_t ldc) :
69TObject(),
70fAliITSQADataMakerRec(aliITSQADataMakerRec),
71fkOnline(kMode),
72fLDC(ldc),
ad300de9 73fSDDhRawsTask(0),
44ed7a66 74fSDDhDigitsTask(0),
ad300de9 75fSDDhRecPointsTask(0),
ad300de9 76fGenRawsOffset(0),
44ed7a66 77fGenDigitsOffset(0),
ad300de9 78fGenRecPointsOffset(0),
ebdd0606 79fTimeBinSize(1),
e41192d7 80fDDLModuleMap(0),
8b7e858c 81fGoodAnodes(0),
82fBadAnodes(0),
83fGoodAnodesCurrent(0),
84fBadAnodesCurrent(0)
ebdd0606 85{
86 //ctor used to discriminate OnLine-Offline analysis
8b7e858c 87 if(fLDC < 0 || fLDC > 6) {
ebdd0606 88 AliError("Error: LDC number out of range; return\n");
89 }
8b7e858c 90 fGenRawsOffset = new Int_t[AliRecoParam::kNSpecies];
91 fGenRecPointsOffset = new Int_t[AliRecoParam::kNSpecies];
4a903927 92 fGenDigitsOffset = new Int_t[AliRecoParam::kNSpecies];
8b7e858c 93 for(Int_t i=0; i<AliRecoParam::kNSpecies; i++) {
94 fGenRawsOffset[i] = 0;
95 fGenRecPointsOffset[i] = 0;
4a903927 96 fGenDigitsOffset[i]=0;
8b7e858c 97 }
ebdd0606 98}
99
100//____________________________________________________________________________
101AliITSQASDDDataMakerRec::AliITSQASDDDataMakerRec(const AliITSQASDDDataMakerRec& qadm) :
102TObject(),
103fAliITSQADataMakerRec(qadm.fAliITSQADataMakerRec),
104fkOnline(qadm.fkOnline),
105fLDC(qadm.fLDC),
ad300de9 106fSDDhRawsTask(qadm.fSDDhRawsTask),
44ed7a66 107fSDDhDigitsTask(qadm.fSDDhDigitsTask),
ad300de9 108fSDDhRecPointsTask(qadm.fSDDhRecPointsTask),
ad300de9 109fGenRawsOffset(qadm.fGenRawsOffset),
44ed7a66 110fGenDigitsOffset(qadm.fGenDigitsOffset),
ad300de9 111fGenRecPointsOffset(qadm.fGenRecPointsOffset),
ebdd0606 112fTimeBinSize(1),
e41192d7 113fDDLModuleMap(0),
8b7e858c 114fGoodAnodes(qadm.fGoodAnodes),
115fBadAnodes(qadm.fBadAnodes),
116fGoodAnodesCurrent(qadm.fGoodAnodesCurrent),
117fBadAnodesCurrent(qadm.fBadAnodesCurrent){
ebdd0606 118 //copy ctor
119 fAliITSQADataMakerRec->SetName((const char*)qadm.fAliITSQADataMakerRec->GetName()) ;
120 fAliITSQADataMakerRec->SetTitle((const char*)qadm.fAliITSQADataMakerRec->GetTitle());
121 fDDLModuleMap=NULL;
122}
123
124//____________________________________________________________________________
125AliITSQASDDDataMakerRec::~AliITSQASDDDataMakerRec(){
126 // destructor
127 // if(fDDLModuleMap) delete fDDLModuleMap;
128}
129//__________________________________________________________________
130AliITSQASDDDataMakerRec& AliITSQASDDDataMakerRec::operator = (const AliITSQASDDDataMakerRec& qac )
131{
7a0e5776 132 // Equal operator.
ebdd0606 133 this->~AliITSQASDDDataMakerRec();
134 new(this) AliITSQASDDDataMakerRec(qac);
135 return *this;
136}
137
138//____________________________________________________________________________
139void AliITSQASDDDataMakerRec::StartOfDetectorCycle()
140{
141 //Detector specific actions at start of cycle
5379c4a3 142 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM::Start of SDD Cycle\n");
ebdd0606 143}
144
145//____________________________________________________________________________
4e25ac79 146void AliITSQASDDDataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t /*task*/, TObjArray* /*list*/)
ebdd0606 147{
f867e0d8 148
ebdd0606 149 // launch the QA checking
8b7e858c 150 if(fkOnline) {
151 AnalyseBNG(); // Analyse Baseline, Noise, Gain
152 AnalyseINJ(); // Analyse Injectors
153 }
f867e0d8 154
8b7e858c 155 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSDM instantiates checker with Run(AliQAv1::kITS, task, list)\n");
ebdd0606 156}
157
158//____________________________________________________________________________
eca4fa66 159Int_t AliITSQASDDDataMakerRec::InitRaws()
ebdd0606 160{
161 // Initialization for RAW data - SDD -
7d297381 162 const Bool_t expert = kTRUE ;
163 const Bool_t saveCorr = kTRUE ;
164 const Bool_t image = kTRUE ;
eca4fa66 165 Int_t rv = 0 ;
ebdd0606 166 AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD");
167 Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
e41192d7 168 if(!ddlMapSDD)
169 {
170 AliError("Calibration object retrieval failed! SDD will not be processed");
171 fDDLModuleMap = NULL;
eca4fa66 172 return rv;
e41192d7 173 }
ebdd0606 174 fDDLModuleMap = (AliITSDDLModuleMapSDD*)ddlMapSDD->GetObject();
175 if(!cacheStatus)ddlMapSDD->SetObject(NULL);
176 ddlMapSDD->SetOwner(kTRUE);
e41192d7 177 if(!cacheStatus)
178 {
179 delete ddlMapSDD;
180 }
8b7e858c 181
ebdd0606 182 Int_t lay, lad, det;
ebdd0606 183 Int_t indexlast = 0;
184 Int_t index1 = 0;
185
7a0e5776 186 if(fkOnline)
187 {
188 AliInfo("Book Online Histograms for SDD\n");
189 }
190 else
191 {
192 AliInfo("Book Offline Histograms for SDD\n ");
193 }
194 TH1D *h0 = new TH1D("SDDModPattern","HW Modules pattern",fgknSDDmodules,239.5,499.5); //0
ebdd0606 195 h0->GetXaxis()->SetTitle("Module Number");
196 h0->GetYaxis()->SetTitle("Counts");
8b7e858c 197 rv = fAliITSQADataMakerRec->Add2RawsList((new TH1D(*h0)),0+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
ebdd0606 198 delete h0;
ad300de9 199 fSDDhRawsTask++;
7a0e5776 200
201 //zPhi distribution using ladder and modules numbers
202 TH2D *hphil3 = new TH2D("SDDphizL3","SDD #varphiz Layer3 ",6,0.5,6.5,14,0.5,14.5);
203 hphil3->GetXaxis()->SetTitle("z[#Module L3 ]");
204 hphil3->GetYaxis()->SetTitle("#varphi[#Ladder L3]");
f867e0d8 205 rv = fAliITSQADataMakerRec->Add2RawsList((new TH2D(*hphil3)),1+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image, saveCorr);
7a0e5776 206 delete hphil3;
207 fSDDhRawsTask++;
208
209 TH2D *hphil4 = new TH2D("SDDphizL4","SDD #varphiz Layer4 ",8,0.5,8.5,22,0.5,22.5);
210 hphil4->GetXaxis()->SetTitle("z[#Module L4]");
211 hphil4->GetYaxis()->SetTitle("#varphi[#Ladder L4]");
f867e0d8 212 rv = fAliITSQADataMakerRec->Add2RawsList((new TH2D(*hphil4)),2+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image, saveCorr);
7a0e5776 213 delete hphil4;
214 fSDDhRawsTask++;
215
ebdd0606 216
7a0e5776 217 if(fkOnline)
218 {
219
220 //DDL Pattern
221 TH2D *hddl = new TH2D("SDDDDLPattern","SDD DDL Pattern ",24,-0.5,23.5,24,-0.5,23.5);
ad300de9 222 hddl->GetXaxis()->SetTitle("Channel");
223 hddl->GetYaxis()->SetTitle("#DDL");
8b7e858c 224 rv = fAliITSQADataMakerRec->Add2RawsList((new TH2D(*hddl)),3+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
ad300de9 225 delete hddl;
226 fSDDhRawsTask++;
7a0e5776 227 Int_t indexlast1 = 0;
228
229 fTimeBinSize = 4;
230 indexlast = 0;
231 index1 = 0;
232 indexlast1 = fSDDhRawsTask;
233 char *hname[3];
234 for(Int_t i=0; i<3; i++) hname[i]= new char[50];
235 for(Int_t moduleSDD =0; moduleSDD<fgknSDDmodules; moduleSDD++){
236 for(Int_t iside=0;iside<fgknSide;iside++){
237 AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
238 sprintf(hname[0],"SDDchargeMapFSE_L%d_%d_%d_%d",lay,lad,det,iside);
239 sprintf(hname[1],"SDDChargeMapForSingleEvent_L%d_%d_%d_%d",lay,lad,det,iside);
fc89f88c 240 // sprintf(hname[2],"SDDhmonoDMap_L%d_%d_%d_%d",lay,lad,det,iside);
7a0e5776 241 TProfile2D *fModuleChargeMapFSE = new TProfile2D(hname[0],hname[1],256/fTimeBinSize,-0.5,255.5,256,-0.5,255.5);
242 fModuleChargeMapFSE->GetXaxis()->SetTitle("Time Bin");
243 fModuleChargeMapFSE->GetYaxis()->SetTitle("Anode");
8b7e858c 244 rv = fAliITSQADataMakerRec->Add2RawsList((new TProfile2D(*fModuleChargeMapFSE)),indexlast1 + index1 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
7a0e5776 245 delete fModuleChargeMapFSE;
246
247 fSDDhRawsTask++;
248 index1++;
ebdd0606 249 }
7a0e5776 250 }
251
252 for(Int_t moduleSDD =0; moduleSDD<fgknSDDmodules; moduleSDD++){
253 for(Int_t iside=0;iside<fgknSide;iside++){
254 AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
255 sprintf(hname[0],"SDDchargeMap_L%d_%d_%d_%d",lay,lad,det,iside);
256 sprintf(hname[1],"SDDChargeMap_L%d_%d_%d_%d",lay,lad,det,iside);
257 TProfile2D *fModuleChargeMap = new TProfile2D(hname[0],hname[1],256/fTimeBinSize,-0.5,255.5,256,-0.5,255.5);
258 fModuleChargeMap->GetXaxis()->SetTitle("Time Bin");
259 fModuleChargeMap->GetYaxis()->SetTitle("Anode");
8b7e858c 260 rv = fAliITSQADataMakerRec->Add2RawsList((new TProfile2D(*fModuleChargeMap)),indexlast1 + index1 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
7a0e5776 261 delete fModuleChargeMap;
262
263 fSDDhRawsTask++;
264 index1++;
ebdd0606 265 }
7a0e5776 266 }
267
8b7e858c 268
7a0e5776 269 } // kONLINE
ebdd0606 270
5379c4a3 271 AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SDD Raws histograms booked\n",fSDDhRawsTask));
eca4fa66 272 return rv ;
ebdd0606 273}
274
275
276//____________________________________________________________________________
eca4fa66 277Int_t AliITSQASDDDataMakerRec::MakeRaws(AliRawReader* rawReader)
ebdd0606 278{
279 // Fill QA for RAW - SDD -
8b7e858c 280 Int_t rv = 0;
7555afef 281 // Check id histograms already created for this Event Specie
7555afef 282
ebdd0606 283 if(!fDDLModuleMap){
284 AliError("SDD DDL module map not available - skipping SDD QA");
eca4fa66 285 return rv;
ebdd0606 286 }
eca4fa66 287 if(rawReader->GetType() != 7) return rv; // skips non physical triggers
5379c4a3 288 AliDebug(AliQAv1::GetQADebugLevel(),"entering MakeRaws\n");
e41192d7 289 rawReader->Reset();
8b7e858c 290 AliITSRawStream *stream=AliITSRawStreamSDD::CreateRawStreamSDD(rawReader);
291 stream->SetDDLModuleMap(fDDLModuleMap);
e41192d7 292
ebdd0606 293 Int_t lay, lad, det;
7a0e5776 294
ebdd0606 295 Int_t index=0;
296 if(fkOnline) {
297 for(Int_t moduleSDD =0; moduleSDD<fgknSDDmodules; moduleSDD++){
7a0e5776 298 for(Int_t iside=0;iside<fgknSide;iside++) {
8b7e858c 299 if(fSDDhRawsTask > 4 + index) fAliITSQADataMakerRec->GetRawsData(4 + index +fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
7a0e5776 300 // 4 because the 2D histos for single events start after the fourth position
301 index++;
302 }
ebdd0606 303 }
304 }
e41192d7 305
ebdd0606 306 Int_t cnt = 0;
307 Int_t ildcID = -1;
308 Int_t iddl = -1;
309 Int_t isddmod = -1;
7a0e5776 310 Int_t coord1, coord2, signal, moduleSDD, activeModule, index1;
e41192d7 311
312 while(stream->Next()) {
ebdd0606 313 ildcID = rawReader->GetLDCId();
314 iddl = rawReader->GetDDLID() - fgkDDLIDshift;
7a0e5776 315
e41192d7 316 isddmod = fDDLModuleMap->GetModuleNumber(iddl,stream->GetCarlosId());
ebdd0606 317 if(isddmod==-1){
5379c4a3 318 AliDebug(AliQAv1::GetQADebugLevel(),Form("Found module with iddl: %d, stream->GetCarlosId: %d \n",iddl,stream->GetCarlosId()));
ebdd0606 319 continue;
320 }
e41192d7 321 if(stream->IsCompletedModule()) {
5379c4a3 322 AliDebug(AliQAv1::GetQADebugLevel(),Form("IsCompletedModule == KTRUE\n"));
ebdd0606 323 continue;
324 }
de075dae 325 if(stream->IsCompletedDDL()) {
5379c4a3 326 AliDebug(AliQAv1::GetQADebugLevel(),Form("IsCompletedDDL == KTRUE\n"));
de075dae 327 continue;
328 }
ebdd0606 329
e41192d7 330 coord1 = stream->GetCoord1();
331 coord2 = stream->GetCoord2();
332 signal = stream->GetSignal();
ebdd0606 333
7a0e5776 334 moduleSDD = isddmod - fgkmodoffset;
335
b62d7123 336 if(isddmod <fgkmodoffset|| isddmod>fgknSDDmodules+fgkmodoffset-1) {
5379c4a3 337 AliDebug(AliQAv1::GetQADebugLevel(),Form( "Module SDD = %d, resetting it to 1 \n",isddmod));
b62d7123 338 isddmod = 1;
ebdd0606 339 }
7a0e5776 340
ebdd0606 341 AliITSgeomTGeo::GetModuleId(isddmod, lay, lad, det);
8b7e858c 342 fAliITSQADataMakerRec->GetRawsData( 0 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()] )->Fill(isddmod);
343 if(lay==3) fAliITSQADataMakerRec->GetRawsData(1+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(det,lad);
ebdd0606 344 if(lay==4) {
8b7e858c 345 fAliITSQADataMakerRec->GetRawsData(2+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(det,lad);}
7a0e5776 346
e41192d7 347 Short_t iside = stream->GetChannel();
ebdd0606 348
fc89f88c 349
7a0e5776 350
ad300de9 351
ebdd0606 352 if(fkOnline) {
7a0e5776 353
8b7e858c 354 fAliITSQADataMakerRec->GetRawsData(3+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(2*(stream->GetCarlosId())+iside,iddl);
fc89f88c 355
7a0e5776 356 activeModule = moduleSDD;
357 index1 = activeModule * 2 + iside;
358
359 if(index1<0){
5379c4a3 360 AliDebug(AliQAv1::GetQADebugLevel(),Form("Wrong index number %d - patched to 0\n",index1));
7a0e5776 361 index1 = 0;
362 }
8b7e858c 363 fAliITSQADataMakerRec->GetRawsData(3+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(2*(stream->GetCarlosId())+iside,iddl);
7a0e5776 364 if(fSDDhRawsTask > 4 + index1) {
8b7e858c 365 ((TProfile2D *)(fAliITSQADataMakerRec->GetRawsData(4 + index1 +fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])))->Fill(coord2, coord1, signal);
366 ((TProfile2D *)(fAliITSQADataMakerRec->GetRawsData(4 + index1 + 260*2 +fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])))->Fill(coord2, coord1, signal);
ebdd0606 367 }
368 }
7a0e5776 369 cnt++;
5379c4a3 370 if(!(cnt%10000)) AliDebug(AliQAv1::GetQADebugLevel(),Form(" %d raw digits read",cnt));
ebdd0606 371 }
5379c4a3 372 AliDebug(AliQAv1::GetQADebugLevel(),Form("Event completed, %d raw digits read",cnt));
e41192d7 373 delete stream;
374 stream = NULL;
8b7e858c 375
376// if(fkOnline) {
377// AnalyseBNG(); // Analyse Baseline, Noise, Gain
378// AnalyseINJ(); // Analyse Injectors
379// }
380
381
eca4fa66 382 return rv ;
7a0e5776 383}
ebdd0606 384
44ed7a66 385//____________________________________________________________________________
eca4fa66 386Int_t AliITSQASDDDataMakerRec::InitDigits()
44ed7a66 387{
fc89f88c 388
7555afef 389
44ed7a66 390 // Initialization for DIGIT data - SDD -
391 const Bool_t expert = kTRUE ;
392 const Bool_t image = kTRUE ;
eca4fa66 393 Int_t rv = 0 ;
394// fGenDigitsOffset = (fAliITSQADataMakerRec->fDigitsQAList[AliRecoParam::kDefault])->GetEntries();
44ed7a66 395 //fSDDhTask must be incremented by one unit every time a histogram is ADDED to the QA List
396 TH1F* h0=new TH1F("SDD DIGITS Module Pattern","SDD DIGITS Module Pattern",260,239.5,499.5); //hmod
397 h0->GetXaxis()->SetTitle("SDD Module Number");
398 h0->GetYaxis()->SetTitle("# DIGITS");
4a903927 399 rv = fAliITSQADataMakerRec->Add2DigitsList(h0,fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
44ed7a66 400 fSDDhDigitsTask ++;
4a903927 401 // printf("Add %s \t the task offset is %i\n",fAliITSQADataMakerRec->GetDigitsData(fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetName() , fSDDhDigitsTask );
44ed7a66 402 TH1F* h1=new TH1F("SDD Anode Distribution","DIGITS Anode Distribution",512,-0.5,511.5); //hanocc
403 h1->GetXaxis()->SetTitle("Anode Number");
404 h1->GetYaxis()->SetTitle("# DIGITS");
4a903927 405 rv = fAliITSQADataMakerRec->Add2DigitsList(h1,1+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
44ed7a66 406 fSDDhDigitsTask ++;
4a903927 407 //printf("Add %s \t the task offset is %i\n",fAliITSQADataMakerRec->GetDigitsData(1+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetName() , fSDDhDigitsTask );
44ed7a66 408 TH1F* h2=new TH1F("SDD Tbin Distribution","DIGITS Tbin Distribution",256,-0.5,255.5); //htbocc
409 h2->GetXaxis()->SetTitle("Tbin Number");
410 h2->GetYaxis()->SetTitle("# DIGITS");
4a903927 411 rv = fAliITSQADataMakerRec->Add2DigitsList(h2,2+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
44ed7a66 412 fSDDhDigitsTask ++;
4a903927 413 //printf("Add %s \t the task offset is %i\n",fAliITSQADataMakerRec->GetDigitsData(2+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetName() , fSDDhDigitsTask );
44ed7a66 414 TH1F* h3=new TH1F("SDD ADC Counts Distribution","DIGITS ADC Counts Distribution",200,0.,1024.); //hsig
415 h3->GetXaxis()->SetTitle("ADC Value");
416 h3->GetYaxis()->SetTitle("# DIGITS");
4a903927 417 rv = fAliITSQADataMakerRec->Add2DigitsList(h3,3+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
44ed7a66 418 fSDDhDigitsTask ++;
4a903927 419 //printf("Add %s \t the task offset is %i\n",fAliITSQADataMakerRec->GetDigitsData(3+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetName() , fSDDhDigitsTask );
44ed7a66 420 AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SDD Digits histograms booked\n",fSDDhDigitsTask));
eca4fa66 421 return rv ;
44ed7a66 422}
423
424//____________________________________________________________________________
eca4fa66 425Int_t AliITSQASDDDataMakerRec::MakeDigits(TTree * digits)
44ed7a66 426{
7555afef 427
44ed7a66 428 // Fill QA for DIGIT - SDD -
fc89f88c 429 //AliITS *fITS = (AliITS*)gAlice->GetModule("ITS");
430 //fITS->SetTreeAddress();
431 //TClonesArray *iITSdigits = fITS->DigitsAddress(1);
432
433
eca4fa66 434 Int_t rv = 0 ;
435
fc89f88c 436 TBranch *branchD = digits->GetBranch("ITSDigitsSDD");
437
438 if (!branchD) {
439 AliError("can't get the branch with the ITS SDD digits !");
eca4fa66 440 return rv ;
44ed7a66 441 }
eca4fa66 442 // Check id histograms already created for this Event Specie
8b7e858c 443// if ( ! fAliITSQADataMakerRec->GetDigitsData(fGenDigitsOffset) )
444// rv = InitDigits() ;
eca4fa66 445
fc89f88c 446 static TClonesArray statDigits("AliITSdigitSDD");
44ed7a66 447 TClonesArray *iITSdigits = &statDigits;
448 branchD->SetAddress(&iITSdigits);
fc89f88c 449
44ed7a66 450 for(Int_t i=0; i<260; i++){
451 Int_t nmod=i+240;
452 digits->GetEvent(nmod);
453 Int_t ndigits = iITSdigits->GetEntries();
4a903927 454 fAliITSQADataMakerRec->GetDigitsData(fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(nmod,ndigits);
7555afef 455
44ed7a66 456 for (Int_t idig=0; idig<ndigits; idig++) {
457 AliITSdigit *dig=(AliITSdigit*)iITSdigits->UncheckedAt(idig);
458 Int_t iz=dig->GetCoord1(); // cell number z
459 Int_t ix=dig->GetCoord2(); // cell number x
460 Int_t sig=dig->GetSignal();
4a903927 461 fAliITSQADataMakerRec->GetDigitsData(1+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(iz);
462 fAliITSQADataMakerRec->GetDigitsData(2+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(ix);
463 fAliITSQADataMakerRec->GetDigitsData(3+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(sig);
44ed7a66 464 }
465 }
eca4fa66 466 return rv ;
44ed7a66 467}
468
ebdd0606 469//____________________________________________________________________________
eca4fa66 470Int_t AliITSQASDDDataMakerRec::InitRecPoints()
ebdd0606 471{
7555afef 472
8b7e858c 473 //AliInfo("Initialize SDD recpoints histos\n");
ebdd0606 474 // Initialization for RECPOINTS - SDD -
7d297381 475 const Bool_t expert = kTRUE ;
476 const Bool_t image = kTRUE ;
eca4fa66 477 Int_t rv = 0 ;
478// fGenRecPointsOffset = (fAliITSQADataMakerRec->fRecPointsQAList[AliRecoParam::kDefault])->GetEntries();
ad300de9 479
ebdd0606 480 Int_t nOnline=1;
481 Int_t nOnline2=1;
482 Int_t nOnline3=1;
483 Int_t nOnline4=1;
484 if(fkOnline)
485 {
ebdd0606 486 nOnline=4;
487 nOnline2=28;
488 nOnline3=64;
489 nOnline4=14;
490 }
491
8b7e858c 492 //AliInfo(Form("fAliITSQADataMakerRec->GetEventSpecie() %d\n",fAliITSQADataMakerRec->GetEventSpecie()));
493 //AliInfo(Form("fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] %d\n",fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]));
ebdd0606 494 TH1F *h0 = new TH1F("SDDLay3TotCh","Layer 3 total charge",1000/nOnline,-0.5, 499.5); //position number 0
495 h0->GetXaxis()->SetTitle("ADC value");
496 h0->GetYaxis()->SetTitle("Entries");
8b7e858c 497 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h0)), 0 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
498 //delete h0;
ad300de9 499 fSDDhRecPointsTask++;
ebdd0606 500
501 TH1F *h1 = new TH1F("SDDLay4TotCh","Layer 4 total charge",1000/nOnline,-0.5, 499.5);//position number 1
502 h1->GetXaxis()->SetTitle("ADC value");
503 h1->GetYaxis()->SetTitle("Entries");
8b7e858c 504 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h1)), 1 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
ebdd0606 505 delete h1;
ad300de9 506 fSDDhRecPointsTask++;
ebdd0606 507
508 char hisnam[50];
509 TH2F *h2 = new TH2F("SDDGlobalCoordDistribYX","YX Global Coord Distrib",5600/nOnline2,-28,28,5600/nOnline2,-28,28);//position number 2
510 h2->GetYaxis()->SetTitle("Y[cm]");
511 h2->GetXaxis()->SetTitle("X[cm]");
8b7e858c 512 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h2)),2+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, !image);
ebdd0606 513 delete h2;
ad300de9 514 fSDDhRecPointsTask++;
ebdd0606 515
516 TH2F *h3 = new TH2F("SDDGlobalCoordDistribRZ","RZ Global Coord Distrib",6400/nOnline3,-32,32,1400/nOnline4,12,26);//position number 3
517 h3->GetYaxis()->SetTitle("R[cm]");
518 h3->GetXaxis()->SetTitle("Z[cm]");
8b7e858c 519 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h3)),3+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, !image);
ebdd0606 520 delete h3;
ad300de9 521 fSDDhRecPointsTask++;
ebdd0606 522
523 TH2F *h4 = new TH2F("SDDGlobalCoordDistribL3PHIZ","#varphi Z Global Coord Distrib L3",6400/nOnline3,-32,32,360/nOnline,-TMath::Pi(),TMath::Pi());//position number 4
524 h4->GetYaxis()->SetTitle("#phi[rad]");
525 h4->GetXaxis()->SetTitle("Z[cm]");
8b7e858c 526 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h4)),4+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
ebdd0606 527 delete h4;
ad300de9 528 fSDDhRecPointsTask++;
ebdd0606 529
530 TH2F *h5 = new TH2F("SDDGlobalCoordDistribL4PHIZ","#varphi Z Global Coord Distrib L4",6400/nOnline3,-32,32,360/nOnline,-TMath::Pi(),TMath::Pi());//position number 5
531 h5->GetYaxis()->SetTitle("#phi[rad]");
532 h5->GetXaxis()->SetTitle("Z[cm]");
8b7e858c 533 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h5)),5+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
ebdd0606 534 delete h5;
ad300de9 535 fSDDhRecPointsTask++;
ebdd0606 536
537 TH1F *h6 = new TH1F("SDDModPatternRP","Modules pattern RP",fgknSDDmodules,239.5,499.5); //position number 6
538 h6->GetXaxis()->SetTitle("Module number"); //spd offset = 240
539 h6->GetYaxis()->SetTitle("Entries");
8b7e858c 540 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h6)),6 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
ebdd0606 541 delete h6;
ad300de9 542 fSDDhRecPointsTask++;
ebdd0606 543 TH1F *h7 = new TH1F("SDDLadPatternL3RP","Ladder pattern L3 RP",14,0.5,14.5); //position number 7
544 h7->GetXaxis()->SetTitle("Ladder #, Layer 3");
545 h7->GetYaxis()->SetTitle("Entries");
8b7e858c 546 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h7)),7 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
ebdd0606 547 delete h7;
ad300de9 548 fSDDhRecPointsTask++;
ebdd0606 549 TH1F *h8 = new TH1F("SDDLadPatternL4RP","Ladder pattern L4 RP",22,0.5,22.5); //position number 8
550 h8->GetXaxis()->SetTitle("Ladder #, Layer 4");
551 h8->GetYaxis()->SetTitle("Entries");
8b7e858c 552 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h8)),8 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
ebdd0606 553 delete h8;
ad300de9 554 fSDDhRecPointsTask++;
ebdd0606 555 TH2F *h9 = new TH2F("SDDLocalCoordDistrib","Local Coord Distrib",1000/nOnline,-4,4,1000/nOnline,-4,4);//position number 9
556 h9->GetXaxis()->SetTitle("X local coord, drift, cm");
557 h9->GetYaxis()->SetTitle("Z local coord, anode, cm");
8b7e858c 558 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h9)),9 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
ebdd0606 559 delete h9;
ad300de9 560 fSDDhRecPointsTask++;
ebdd0606 561
8b7e858c 562 //AliInfo("Create SDD recpoints histos\n");
ebdd0606 563
564 TH1F *h10 = new TH1F("SDDrdistrib_Layer3" ,"SDD r distribution Layer3" ,100,14.,18.);//position number 10 (L3)
565 h10->GetXaxis()->SetTitle("r[cm]");
566 h10->GetXaxis()->CenterTitle();
567 h10->GetYaxis()->SetTitle("Entries");
8b7e858c 568 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h10)),10 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
ebdd0606 569 delete h10;
ad300de9 570 fSDDhRecPointsTask++;
ebdd0606 571
572 TH1F *h11 = new TH1F("SDDrdistrib_Layer4" ,"SDD r distribution Layer4" ,100,22.,26.);// and position number 11 (L4)
573 h11->GetXaxis()->SetTitle("r[cm]");
574 h11->GetXaxis()->CenterTitle();
575 h11->GetYaxis()->SetTitle("Entries");
8b7e858c 576 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h11)),11 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
ebdd0606 577 delete h11;
ad300de9 578 fSDDhRecPointsTask++;
ebdd0606 579
580 for(Int_t iLay=0; iLay<=1; iLay++){
581 sprintf(hisnam,"SDDphidistrib_Layer%d",iLay+3);
582 TH1F *h12 = new TH1F(hisnam,hisnam,180,-TMath::Pi(),TMath::Pi());//position number 12 (L3) and position number 13 (L4)
583 h12->GetXaxis()->SetTitle("#varphi[rad]");
584 h12->GetXaxis()->CenterTitle();
585 h12->GetYaxis()->SetTitle("Entries");
8b7e858c 586 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h12)),iLay+12+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
ebdd0606 587 delete h12;
ad300de9 588 fSDDhRecPointsTask++;
ebdd0606 589 }
590
591 if(fkOnline)
592 {
593 TH2F *h14 = new TH2F("SDDGlobalCoordDistribYXFSE","YX Global Coord Distrib FSE",5600/nOnline2,-28,28,5600/nOnline2,-28,28);//position number 14
594 h14->GetYaxis()->SetTitle("Y[cm]");
595 h14->GetXaxis()->SetTitle("X[cm]");
8b7e858c 596 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h14)),14+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
ebdd0606 597 delete h14;
ad300de9 598 fSDDhRecPointsTask++;
ebdd0606 599
600 TH2F *h15 = new TH2F("SDDGlobalCoordDistribRZFSE","RZ Global Coord Distrib FSE",Int_t(6400/nOnline3),-32,32,1400/nOnline4,12,26);//position number 15
601 h15->GetYaxis()->SetTitle("R[cm]");
602 h15->GetXaxis()->SetTitle("Z[cm]");
8b7e858c 603 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h15)),15+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
ebdd0606 604 delete h15;
ad300de9 605 fSDDhRecPointsTask++;
ebdd0606 606
ebdd0606 607 }//online
608
5379c4a3 609 AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SDD Recs histograms booked\n",fSDDhRecPointsTask));
ebdd0606 610
eca4fa66 611 return rv ;
ebdd0606 612}
613
614//____________________________________________________________________________
eca4fa66 615Int_t AliITSQASDDDataMakerRec::MakeRecPoints(TTree * clustersTree)
7a0e5776 616{
ebdd0606 617 // Fill QA for RecPoints - SDD -
eca4fa66 618 Int_t rv = 0 ;
7555afef 619
8b7e858c 620 //AliInfo(Form("fAliITSQADataMakerRec->GetEventSpecie() %d\n",fAliITSQADataMakerRec->GetEventSpecie()));
621 //AliInfo(Form("fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] %d\n",fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]));
7555afef 622 // Check id histograms already created for this Event Specie
8b7e858c 623// if ( ! fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]) )
624// rv = InitRecPoints() ;
ebdd0606 625 Int_t lay, lad, det;
8b7e858c 626 //AliInfo("get the branch with the ITS clusters !\n");
ebdd0606 627 TBranch *branchRecP = clustersTree->GetBranch("ITSRecPoints");
628 if (!branchRecP) {
629 AliError("can't get the branch with the ITS clusters !");
eca4fa66 630 return rv ;
ebdd0606 631 }
632
633 static TClonesArray statRecpoints("AliITSRecPoint") ;
634 TClonesArray *recpoints = &statRecpoints;
635 branchRecP->SetAddress(&recpoints);
636 Int_t npoints = 0;
637 Float_t cluglo[3]={0.,0.,0.};
638 if(fkOnline)
639 {
640 for(Int_t i=14;i<16;i++)
641 {
8b7e858c 642 fAliITSQADataMakerRec->GetRecPointsData(i+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
ebdd0606 643 }
644 }
8b7e858c 645 for(Int_t module=0; module<clustersTree->GetEntries();module++){
646 //AliInfo(Form("Module %d\n",module));
647 branchRecP->GetEvent(module);
648 npoints += recpoints->GetEntries();
649 //AliInfo(Form("modnumb %d, npoints %d, total points %d\n",module, recpoints->GetEntries(),npoints));
650 AliITSgeomTGeo::GetModuleId(module, lay, lad, det);
651 //AliInfo(Form("modnumb %d, lay %d, lad %d, det %d \n",module, lay, lad, det));
652 Bool_t kSDD = kFALSE;
653 if(lay == 3 || lay == 4) kSDD = kTRUE;
654 if(!kSDD) continue;
655 //AliInfo(Form("modnumb %d, entries %d\n",module, recpoints->GetEntries()));
656 for(Int_t j=0;j<recpoints->GetEntries();j++){
657 //AliInfo(Form("modnumb %d, entry %d \n",module, j));
658 AliITSRecPoint *recp = (AliITSRecPoint*)recpoints->At(j);
659 fAliITSQADataMakerRec->GetRecPointsData(6 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(module);//modpatternrp
660 recp->GetGlobalXYZ(cluglo);
661 Float_t rad=TMath::Sqrt(cluglo[0]*cluglo[0]+cluglo[1]*cluglo[1]);
662 Float_t phi=TMath::ATan2(cluglo[1],cluglo[0]);
663 fAliITSQADataMakerRec->GetRecPointsData(9 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(recp->GetDetLocalX(),recp->GetDetLocalZ());//local distribution
664 fAliITSQADataMakerRec->GetRecPointsData(2 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[0],cluglo[1]);//global distribution YX
665 fAliITSQADataMakerRec->GetRecPointsData(3 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],rad);//global distribution rz
666 if(fkOnline) {
667 fAliITSQADataMakerRec->GetRecPointsData(14 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[0],cluglo[1]);//global distribution YX FSE
668 fAliITSQADataMakerRec->GetRecPointsData(15 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],rad);//global distribution rz FSE
669 }
670 if(recp->GetLayer() == 2) {
671 fAliITSQADataMakerRec->GetRecPointsData(0 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(recp->GetQ()) ;//total charge of layer 3
672 fAliITSQADataMakerRec->GetRecPointsData(7 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(lad);//lad pattern layer 3
673 fAliITSQADataMakerRec->GetRecPointsData(10 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(rad);//r distribution layer 3
674 fAliITSQADataMakerRec->GetRecPointsData(12 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(phi);// phi distribution layer 3
675 fAliITSQADataMakerRec->GetRecPointsData(4 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],phi);// phi distribution layer 3
676 } else if(recp->GetLayer() == 3) {
677 fAliITSQADataMakerRec->GetRecPointsData(1 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(recp->GetQ()) ;//total charge layer 4
678 fAliITSQADataMakerRec->GetRecPointsData(8 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(lad);//ladpatternlayer4
679 fAliITSQADataMakerRec->GetRecPointsData(11 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(rad);//r distribution
680 fAliITSQADataMakerRec->GetRecPointsData(13 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(phi);//phi distribution
681 fAliITSQADataMakerRec->GetRecPointsData(5 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],phi);// phi distribution layer 4
682 }
683 }
ebdd0606 684 }
8b7e858c 685 statRecpoints.Clear();
686 return rv ;
ebdd0606 687}
688
ad300de9 689//_______________________________________________________________
690
4e25ac79 691Int_t AliITSQASDDDataMakerRec::GetOffset(AliQAv1::TASKINDEX_t task)
7a0e5776 692{
ad300de9 693 Int_t offset=0;
4e25ac79 694 if( task == AliQAv1::kRAWS )
7a0e5776 695 {
8b7e858c 696 offset=fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()];
7a0e5776 697 }
eca4fa66 698 else if(task == AliQAv1::kDIGITSR )
699 {
4a903927 700 offset=fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()];
eca4fa66 701 }
702 else if( task == AliQAv1::kRECPOINTS )
703 {
8b7e858c 704 offset=fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()];
eca4fa66 705 }
ad300de9 706 return offset;
707}
708
709//_______________________________________________________________
710
8b7e858c 711void AliITSQASDDDataMakerRec::SetOffset(AliQAv1::TASKINDEX_t task, Int_t offset, Int_t specie) {
eca4fa66 712 // Returns offset number according to the specified task
713 if( task == AliQAv1::kRAWS ) {
8b7e858c 714 fGenRawsOffset[specie]=offset;
eca4fa66 715 }
716 else if( task == AliQAv1::kDIGITSR ) {
4a903927 717 fGenDigitsOffset[specie]=offset;
eca4fa66 718 }
719 else if( task == AliQAv1::kRECPOINTS ) {
8b7e858c 720 fGenRecPointsOffset[specie]=offset;
eca4fa66 721 }
722}
723
724//_______________________________________________________________
725
4e25ac79 726Int_t AliITSQASDDDataMakerRec::GetTaskHisto(AliQAv1::TASKINDEX_t task)
7a0e5776 727{
ad300de9 728
7a0e5776 729 Int_t histotot=0;
ad300de9 730
4e25ac79 731 if( task == AliQAv1::kRAWS )
7a0e5776 732 {
733 histotot=fSDDhRawsTask ;
734 }
eca4fa66 735 else if(task == AliQAv1::kDIGITSR)
736 {
737 histotot=fSDDhDigitsTask;
738 }
739 else if( task == AliQAv1::kRECPOINTS )
740 {
741 histotot=fSDDhRecPointsTask;
742 }
8b7e858c 743 else {
744 AliInfo("No task has been selected. TaskHisto set to zero.\n");
745 }
ad300de9 746 return histotot;
e41192d7 747}
8b7e858c 748
749//_______________________________________________________________
750
751void AliITSQASDDDataMakerRec::AnalyseBNG()
752{
753
754// get file time for Previous test
755 AliInfo("AnalyseBNG\n");
756 static Int_t bngtimePrevious[6];
757 FILE *fpinPrevious = fopen( "SDDgainHistos.time", "r" );
758 if(fpinPrevious) {
759 for(Int_t i=0; i<6; i++) fscanf(fpinPrevious,"%d",&bngtimePrevious[i]);
760 fclose (fpinPrevious);
761 } else
762 for(Int_t i=0; i<6; i++) bngtimePrevious[i] = 0;
763 Int_t bngtimeCurrent[6] = { 0 };
764 gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]' SDDgainHistos1.root > SDDgainHistos.time");
765 gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]' SDDgainHistos2.root >> SDDgainHistos.time");
766 gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]' SDDgainHistos3.root >> SDDgainHistos.time");
767 gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]' SDDgainHistos4.root >> SDDgainHistos.time");
768 gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]' SDDgainHistos5.root >> SDDgainHistos.time");
769 gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]' SDDgainHistos6.root >> SDDgainHistos.time");
770 FILE *fpin = fopen( "SDDgainHistos.time", "r" );
771 for(Int_t i=0; i<6; i++) {
772 fscanf(fpin,"%d",&bngtimeCurrent[i]);
773// AliInfo(Form("bngtimeCurrent[%d] %d, bngtimePrevious[%d] %d\n",i,bngtimeCurrent[i],i,bngtimePrevious[i]));
774 }
775 Bool_t kAnalyse = kTRUE;
776 for(Int_t i=0; i<6; i++) if(bngtimeCurrent[i] <= bngtimePrevious[i]) kAnalyse = kFALSE;
777 if(kAnalyse) {
778 // new bng file found
779 for(Int_t i=0; i<6; i++) bngtimePrevious[i] = bngtimeCurrent[i];
780 Bool_t kFilesExist = kTRUE;
781 char *hname = new char[50];
782 for(Int_t i=0; i<6; i++) {
783 sprintf(hname,"SDDgainHistos%d.root",i+1);
784 TFile gainFile(hname);
785 if(gainFile.IsZombie()) kFilesExist = kFALSE;
786 }
787 if(kFilesExist) {
788 AnodeStatus();
789 AnalyseHistos(1); // Baseline
790 AnalyseHistos(2); // Uncorrected Noise
791 AnalyseHistos(3); // Common Mode Noise
792 AnalyseHistos(4); // Corrected Noise
793 AnalyseHistos(5); // Gain
794 gSystem->Exec("cp SDDgainHistos1.root SDDgainHistosPrevious1.root");
795 gSystem->Exec("cp SDDgainHistos2.root SDDgainHistosPrevious2.root");
796 gSystem->Exec("cp SDDgainHistos3.root SDDgainHistosPrevious3.root");
797 gSystem->Exec("cp SDDgainHistos4.root SDDgainHistosPrevious4.root");
798 gSystem->Exec("cp SDDgainHistos5.root SDDgainHistosPrevious5.root");
799 gSystem->Exec("cp SDDgainHistos6.root SDDgainHistosPrevious6.root");
800 } else {
801 AliInfo("file(s) SDDgainHistos .root not found \n");
802 }
803 }
804 fclose (fpin);
805// delete fpin;
806
807}
808
809//_______________________________________________________________
810
811void AliITSQASDDDataMakerRec::AnalyseINJ()
812{
813// get file time for last test
814
815 AliInfo("AnalyseINJ\n");
816 static Int_t injtimePrevious[6];
817 FILE *fpinPrevious = fopen( "SDDinjectHistos.time", "r" );
818 if(fpinPrevious) {
819 for(Int_t i=0; i<6; i++) fscanf(fpinPrevious,"%d",&injtimePrevious[i]);
820 fclose (fpinPrevious);
821 } else
822 for(Int_t i=0; i<6; i++) injtimePrevious[i] = 0;
823 Int_t injtimeCurrent[6] = { 0 };
824 gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]' SDDinjectHistos1.root > SDDinjectHistos.time");
825 gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]' SDDinjectHistos2.root >> SDDinjectHistos.time");
826 gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]' SDDinjectHistos3.root >> SDDinjectHistos.time");
827 gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]' SDDinjectHistos4.root >> SDDinjectHistos.time");
828 gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]' SDDinjectHistos5.root >> SDDinjectHistos.time");
829 gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]' SDDinjectHistos6.root >> SDDinjectHistos.time");
830 FILE *fpin = fopen( "SDDinjectHistos.time", "r" );
831 for(Int_t i=0; i<6; i++) {
832 fscanf(fpin,"%d",&injtimeCurrent[i]);
833// AliInfo(Form("injtimeCurrent[%d] %d, injtimePrevious[%d] %d\n",i,injtimeCurrent[i],i,injtimePrevious[i]));
834 }
835 Bool_t kAnalyse = kTRUE;
836 for(Int_t i=0; i<6; i++) if(injtimeCurrent[i] <= injtimePrevious[i]) kAnalyse = kFALSE;
837 if(kAnalyse) {
838 // new inj file found
839 for(Int_t i=0; i<6; i++) injtimePrevious[i] = injtimeCurrent[i];
840 Bool_t kFilesExist = kTRUE;
841 char *hname = new char[50];
842 for(Int_t i=0; i<6; i++) {
843 sprintf(hname,"SDDinjectHistos%d.root",i+1);
844 TFile gainFile(hname);
845 if(gainFile.IsZombie()) kFilesExist = kFALSE;
846 }
847 if(kFilesExist) {
848 AnalyseHistos(6); // Drift Speed
849 gSystem->Exec("cp SDDinjectHistos1.root SDDinjectHistosPrevious1.root");
850 gSystem->Exec("cp SDDinjectHistos2.root SDDinjectHistosPrevious2.root");
851 gSystem->Exec("cp SDDinjectHistos3.root SDDinjectHistosPrevious3.root");
852 gSystem->Exec("cp SDDinjectHistos4.root SDDinjectHistosPrevious4.root");
853 gSystem->Exec("cp SDDinjectHistos5.root SDDinjectHistosPrevious5.root");
854 gSystem->Exec("cp SDDinjectHistos6.root SDDinjectHistosPrevious6.root");
855 } else {
856 AliInfo("file(s) SDDinjectHistos .root not found \n");
857 }
858 }
859 fclose (fpin);
860/*
861 static Int_t injtimeLast = 0;
862 FILE *fpinlast = fopen( "SDDinjectHistos.time", "r" );
863 if(fpinlast) {
864 fscanf(fpinlast,"%d",&injtimeLast);
865 fclose (fpinlast);
866 } else
867 injtimeLast = 0;
868 Int_t injtimeCurrent = 0;
869 gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]' SDDinjectHistos.root > SDDinjectHistos.time");
870 FILE *fpin = fopen( "SDDinjectHistos.time", "r" );
871 fscanf(fpin,"%d",&injtimeCurrent);
872 if(injtimeCurrent > injtimeLast) {
873 // new gain file found
874 injtimeLast = injtimeCurrent;
875
876 TFile injectFile("SDDinjectHistos.root");
877 if(!injectFile.IsZombie()) {
878 AnalyseHistos(6); // Drift Speed
879 gSystem->Exec("cp SDDinjectHistos.root SDDinjectHistosLast.root");
880 } else {
881 AliInfo("file SDDinjectHistos.root not found \n");
882 }
883
884 }
885 fclose (fpin);
886*/
887// delete fpin;
888}
889
890//_______________________________________________________________
891
892void AliITSQASDDDataMakerRec::AnodeStatus()
893{
894 char *hnamePrevious = new char[50];
895 char *fnamePrevious = new char[50];
896 fGoodAnodes = 0;
897
898 for(Int_t k=0;k<6;k++) {
899 sprintf(fnamePrevious,"SDDgainHistosPrevious%d.root",k+1);
900 TFile gainFilePrevious(fnamePrevious);
901 if(gainFilePrevious.IsZombie()) continue;
902 for(Int_t ddl =0; ddl<fDDLModuleMap->GetNDDLs(); ddl++){
903 for(Int_t crx =0; crx<fDDLModuleMap->GetNModPerDDL(); crx++){
904 for(Int_t iside=0;iside<fgknSide;iside++){
905 Int_t moduleSDD = fDDLModuleMap->GetModuleNumber(ddl,crx);
906 //AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
907 sprintf(hnamePrevious,"hgood%02dc%02ds%d",ddl,crx,iside);
908 //AliInfo(Form("get histo %s\n",hnamePrevious));
909 TH1F *hgood = (TH1F *) gainFilePrevious.Get(hnamePrevious);
910 if(!hgood) continue;
911 for(Int_t i=0; i<hgood->GetNbinsX();i++) {
912 fAnodeMap[moduleSDD-fgkmodoffset][iside][i] = hgood->GetBinContent(i);
913 if(fAnodeMap[moduleSDD-fgkmodoffset][iside][i]) fGoodAnodes++;
914 }
915 delete hgood;
916 }
917 }
918 }
919 gainFilePrevious.Close();
920 }
921
922 fGoodAnodesCurrent = 0;
923 fBadAnodesCurrent = 0;
924 char *hname = new char[50];
925 Int_t nChangedStatus = 0;
926 Bool_t CurrentAnodeMap[fgknSDDmodules][fgknSide][fgknAnode];
927 for(Int_t k=0;k<6;k++) {
928 sprintf(fnamePrevious,"SDDgainHistos%d.root",k+1);
929 TFile gainFile(fnamePrevious);
930 if(gainFile.IsZombie()) continue;
931 for(Int_t ddl =0; ddl<fDDLModuleMap->GetNDDLs(); ddl++){
932 for(Int_t crx =0; crx<fDDLModuleMap->GetNModPerDDL(); crx++){
933 for(Int_t iside=0;iside<fgknSide;iside++){
934 Int_t moduleSDD = fDDLModuleMap->GetModuleNumber(ddl,crx);
935 //AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
936 sprintf(hname,"hgood%02dc%02ds%d",ddl,crx,iside);
937 //AliInfo(Form("get histo %s\n",hname));
938 TH1F *hgood = (TH1F *) gainFile.Get(hname);
939 if(!hgood) continue;
940 for(Int_t i=0; i<hgood->GetNbinsX();i++) {
941 CurrentAnodeMap[moduleSDD-fgkmodoffset][iside][i] = hgood->GetBinContent(i);
942 if(CurrentAnodeMap[moduleSDD-fgkmodoffset][iside][i]) fGoodAnodesCurrent++;
943 else fBadAnodesCurrent++;
944 if(CurrentAnodeMap[moduleSDD-fgkmodoffset][iside][i] != fAnodeMap[moduleSDD-fgkmodoffset][iside][i]) {
945 fAnodeMap[moduleSDD-fgkmodoffset][iside][i] = CurrentAnodeMap[moduleSDD-fgkmodoffset][iside][i];
946 nChangedStatus++;
947 AliWarning(Form("DDL %d, CRX %d, Side %d, Anode %d changed status to %d \n",ddl,crx,iside,i,fAnodeMap[moduleSDD-fgkmodoffset][iside][i]));
948 }
949 }
950 delete hgood;
951 }
952 }
953 }
954 gainFile.Close();
955 }
956
957 AliWarning(Form("Number of good anodes changed from %d to %d, that is %f %%\n",fGoodAnodes,fGoodAnodesCurrent,((Float_t) TMath::Abs(fGoodAnodes-fGoodAnodesCurrent))/(fBadAnodesCurrent+fGoodAnodesCurrent)));
958 if(fGoodAnodesCurrent != fGoodAnodes) {
959 fGoodAnodes = fGoodAnodesCurrent;
960 }
961 AliWarning(Form("Number of bad anodes changed from %d to %d, that is %f %%\n",fBadAnodes,fBadAnodesCurrent,((Float_t) TMath::Abs(fBadAnodes-fBadAnodesCurrent))/(fBadAnodesCurrent+fGoodAnodesCurrent)));
962 if(fBadAnodesCurrent != fBadAnodes) {
963 fBadAnodes = fBadAnodesCurrent;
964 }
965// delete hname;
966}
967
968//_______________________________________________________________
969
970void AliITSQASDDDataMakerRec::AnalyseHistos(Int_t type)
971{
972
973 if(type < 1 || type > 6) AliWarning(Form("Wrong type (%d), must be between 1 and 6\n",type));
974
975 Double_t Current[fgknSDDmodules][fgknSide][fgknAnode];
976 char *hnamePrevious = new char[50];
977 char *fnamePrevious = new char[50];
978
979 for(Int_t k=0; k<6; k++) {
980 if(type < 6) sprintf(fnamePrevious,"SDDgainHistosPrevious%d.root",k+1);
981 else sprintf(fnamePrevious,"SDDinjectHistosPrevious%d.root",k+1);
982 TFile *gainFilePrevious = new TFile(fnamePrevious);
983 if(gainFilePrevious->IsZombie()) continue;
984
985 for(Int_t ddl =0; ddl<fDDLModuleMap->GetNDDLs(); ddl++){
986 for(Int_t crx =0; crx<fDDLModuleMap->GetNModPerDDL(); crx++){
987 for(Int_t iside=0;iside<fgknSide;iside++){
988 Int_t moduleSDD = fDDLModuleMap->GetModuleNumber(ddl,crx);
989 //AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
990 if(type == 1) sprintf(hnamePrevious,"hbase%02dc%02ds%d",ddl,crx,iside);
991 else if(type == 2) sprintf(hnamePrevious,"hnois%02dc%02ds%d",ddl,crx,iside);
992 else if(type == 3) sprintf(hnamePrevious,"hcmn%02dc%02ds%d",ddl,crx,iside);
993 else if(type == 4) sprintf(hnamePrevious,"hcorn%02dc%02ds%d",ddl,crx,iside);
994 else if(type == 5) sprintf(hnamePrevious,"hgain%02dc%02ds%d",ddl,crx,iside);
995 else if(type == 6) sprintf(hnamePrevious,"hdrsp%02dc%02ds%d",ddl,crx,iside);
996 //AliInfo(Form("get histo %s\n",hnamePrevious));
997 TH1F *hhist = (TH1F *) gainFilePrevious->Get(hnamePrevious);
998 if(!hhist) continue;
999 for(Int_t i=0; i<hhist->GetNbinsX();i++) {
1000 Current[moduleSDD-fgkmodoffset][iside][i] = hhist->GetBinContent(i);
1001 }
1002 delete hhist;
1003 }
1004 }
1005 }
1006 gainFilePrevious->Close();
1007 delete gainFilePrevious;
1008 }
1009
1010 Float_t xmin = 0.;
1011 Float_t xmax = 0;
1012 Int_t nbins = 1;
1013 TH1F *hDist = 0;
1014 TH1F *hDistDiff = 0;
1015 if(type == 1) {
1016 xmin = 0.;
1017 xmax = 500.;
1018 nbins = (Int_t)(xmax-xmin);
1019 hDist = new TH1F("hBaseline","Baseline",nbins,xmin,xmax);
1020 hDistDiff = new TH1F("hBaselineDiff","Baseline Difference",200,-100.,100.);
1021 } else if(type == 2) {
1022 xmin = 0.;
1023 xmax = 10.;
1024 nbins = (Int_t) (100.*(xmax-xmin));
1025 hDist = new TH1F("hNoiseUnc","Noise (before correction)",nbins,xmin,xmax);
1026 hDistDiff = new TH1F("hNoiseUncDiff","Noise (before correction) Difference",200,-10.,10.);
1027 } else if(type == 3) {
1028 xmin = 0.;
1029 xmax = 10.;
1030 nbins = (Int_t)( 100.*(xmax-xmin));
1031 hDist = new TH1F("hNoiseCMN","Noise (common mode)",nbins,xmin,xmax);
1032 hDistDiff = new TH1F("hNoiseCMNDiff","Noise (common mode) Difference",200,-10.,10.);
1033 } else if(type == 4) {
1034 xmin = 0.;
1035 xmax = 10.;
1036 nbins = (Int_t)(100.*(xmax-xmin));
1037 hDist = new TH1F("hNoiseCor","Noise (after correction)",nbins,xmin,xmax);
1038 hDistDiff = new TH1F("hNoiseCorDiff","Noise (after correction) Difference",200,-10.,10.);
1039 } else if(type == 5) {
1040 xmin = 0.;
1041 xmax = 5.;
1042 nbins = (Int_t)(100.*(xmax-xmin));
1043 hDist = new TH1F("hGain","Gain",nbins,xmin,xmax);
1044 hDistDiff = new TH1F("hGainDiff","Gain Difference",200,-10.,10.);
1045 } else if(type == 6) {
1046 xmin = 0.;
1047 xmax = 10.;
1048 nbins = (Int_t)(100.*(xmax-xmin));
1049 hDist = new TH1F("hDriftSpeed","Drift Speed",nbins,xmin,xmax);
1050 hDistDiff = new TH1F("hDriftSpeedDiff","Drift Speed Difference",200,-10.,10.);
1051 }
1052
1053 Float_t binw = (xmax-xmin)/nbins;
1054
1055 for(Int_t k=0; k<6; k++) {
1056 if(type < 6) sprintf(fnamePrevious,"SDDgainHistos%d.root",k+1);
1057 else sprintf(fnamePrevious,"SDDinjectHistos%d.root",k+1);
1058 TFile *gainFile = new TFile(fnamePrevious);
1059 if(gainFile->IsZombie()) continue;
1060
1061 for(Int_t ddl =0; ddl<fDDLModuleMap->GetNDDLs(); ddl++){
1062 for(Int_t crx =0; crx<fDDLModuleMap->GetNModPerDDL(); crx++){
1063 for(Int_t iside=0;iside<fgknSide;iside++){
1064 Int_t moduleSDD = fDDLModuleMap->GetModuleNumber(ddl,crx);
1065 //AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
1066 if(type == 1) sprintf(hnamePrevious,"hbase%02dc%02ds%d",ddl,crx,iside);
1067 else if(type == 2) sprintf(hnamePrevious,"hnois%02dc%02ds%d",ddl,crx,iside);
1068 else if(type == 3) sprintf(hnamePrevious,"hcmn%02dc%02ds%d",ddl,crx,iside);
1069 else if(type == 4) sprintf(hnamePrevious,"hcorn%02dc%02ds%d",ddl,crx,iside);
1070 else if(type == 5) sprintf(hnamePrevious,"hgain%02dc%02ds%d",ddl,crx,iside);
1071 else if(type == 6) sprintf(hnamePrevious,"hdrsp%02dc%02ds%d",ddl,crx,iside);
1072 //AliInfo(Form("get histo %s\n",hname));
1073 TH1F *hhist = (TH1F *) gainFile->Get(hnamePrevious);
1074 if(!hhist) continue;
1075 for(Int_t i=0; i<hhist->GetNbinsX();i++) {
1076 if(!fAnodeMap[moduleSDD-fgkmodoffset][iside][i]) continue;
1077 hDist->Fill(hhist->GetBinContent(i));
1078 hDistDiff->Fill(hhist->GetBinContent(i)-Current[moduleSDD-fgkmodoffset][iside][i]);
1079 }
1080 delete hhist;
1081 }
1082 }
1083 }
1084 gainFile->Close();
1085 delete gainFile;
1086
1087 }
1088
1089 TF1 ff("ff", "gaus", xmin+0.1, xmax-0.1);
1090 hDist->Fit("ff","NWR");
1091// hDist->Fit("gaus","","",xmin+0.1, xmax-0.1);
1092// Float_t ChiSquared = (Float_t) ff.GetChisquare();
1093// Int_t NDF = ff.GetNumberFitPoints() - ff.GetNpar();
1094 Float_t average = (Float_t) ff.GetParameter(1);
1095 Float_t sigma = (Float_t) ff.GetParameter(2);
1096// Float_t mean = hDist->GetMean();
1097// Float_t rms = hDist->GetRMS();
1098 Int_t badB = 0;
1099 for(Int_t i=0; i<hDist->GetNbinsX();i++) {
1100// if(type < 6)
1101 if(TMath::Abs(i*binw-average) > 4.*sigma) badB += (Int_t)hDist->GetBinContent(i);
1102// else
1103// if(TMath::Abs(i-mean) > 4*rms) badB += hDist->GetBinContent(i);
1104 }
1105 if(type == 1) {
1106 AliInfo(Form("Number of anodes with baseline out of 4*sigma from average: %d, %f%%\n",badB,100.*((Float_t) badB)/hDist->GetEntries()));
1107 } else if(type == 2) {
1108 AliInfo(Form("Number of anodes with uncorrected noise out of 4*sigma from average: %d, %f%%\n",badB,100.*((Float_t) badB)/hDist->GetEntries()));
1109 } else if(type == 3) {
1110 AliInfo(Form("Number of anodes with common mode noise out of 4*sigma from average: %d, %f%%\n",badB,100.*((Float_t) badB)/hDist->GetEntries()));
1111 } else if(type == 4) {
1112 AliInfo(Form("Number of anodes with corrected noise out of 4*sigma from average: %d, %f%%\n",badB,100.*((Float_t) badB)/hDist->GetEntries()));
1113 } else if(type == 5) {
1114 AliInfo(Form("Number of anodes with gain out of 4*sigma from average: %d, %f%%\n",badB,100.*((Float_t) badB)/hDist->GetEntries()));
1115 } else if(type == 6) {
1116 Int_t badspeed = (Int_t)hDist->GetBinContent(1);
1117 AliInfo(Form("Number of anodes with drift speed equal to 0: %d\n",badspeed));
1118 AliInfo(Form("Number of anodes with drift speed out of 4*sigma from average: %d, %f%%\n",badB-badspeed,100.*((Float_t) (badB-badspeed))/(hDist->GetEntries()-badspeed)));
1119 }
1120
1121 TH1F *hDistHistoryCurrent = NULL;
1122 TH1F *hDistHistoryPrevious = NULL;
1123
1124 TFile *gainHistoryFile;
1125 if(type < 6)
1126 gainHistoryFile = new TFile("SDDgainHistory.root","UPDATE");
1127 else
1128 gainHistoryFile = new TFile("SDDinjectHistory.root","UPDATE");
1129 hDist->Write();
1130 hDistDiff->Write();
1131 //AliInfo("SDDgainHistory.root file opened\n");
1132 if(!gainHistoryFile->IsZombie()) {
1133 if(type == 1) hDistHistoryPrevious = (TH1F *) gainHistoryFile->Get("hBaselineHistory");
1134 else if(type == 2) hDistHistoryPrevious = (TH1F *) gainHistoryFile->Get("hNoiseUncHistory");
1135 else if(type == 3) hDistHistoryPrevious = (TH1F *) gainHistoryFile->Get("hNoiseCMNHistory");
1136 else if(type == 4) hDistHistoryPrevious = (TH1F *) gainHistoryFile->Get("hNoiseCorHistory");
1137 else if(type == 5) hDistHistoryPrevious = (TH1F *) gainHistoryFile->Get("hGainHistory");
1138 else if(type == 6) hDistHistoryPrevious = (TH1F *) gainHistoryFile->Get("hDriftSpeedHistory");
1139 //AliInfo(Form("hDistHistoryPrevious %x\n",hDistHistoryPrevious));
1140
1141 if(!hDistHistoryPrevious) {
1142 if(type == 1) hDistHistoryCurrent = new TH1F("hBaselineHistory","Average Baseline History",1,0,1);
1143 else if(type == 2) hDistHistoryCurrent = new TH1F("hNoiseUncHistory","Average Uncorrected Noise History",1,0,1);
1144 else if(type == 3) hDistHistoryCurrent = new TH1F("hNoiseCMNHistory","Average Common Mode Noise History",1,0,1);
1145 else if(type == 4) hDistHistoryCurrent = new TH1F("hNoiseCorHistory","Average Corrected Noise History",1,0,1);
1146 else if(type == 5) hDistHistoryCurrent = new TH1F("hGainHistory","Average Gain History",1,0,1);
1147 else if(type == 6) hDistHistoryCurrent = new TH1F("hDriftSpeedHistory","Average Drift Speed History",1,0,1);
1148 //AliInfo(Form("hDistHistoryCurrent 1 %x\n",hDistHistoryCurrent));
1149// if(type < 6) {
1150 hDistHistoryCurrent->SetBinContent(1,average);
1151 hDistHistoryCurrent->SetBinError(1,sigma);
1152/*
1153 } else {
1154 hDistHistoryCurrent->SetBinContent(1,mean);
1155 hDistHistoryCurrent->SetBinError(1,rms);
1156 }
1157*/
1158 } else {
1159 if(type == 1) hDistHistoryCurrent = new TH1F("hBaselineHistory","Average Baseline History",hDistHistoryPrevious->GetNbinsX()+1,0,hDistHistoryPrevious->GetNbinsX()+1);
1160 else if(type == 2) hDistHistoryCurrent = new TH1F("hNoiseUncHistory","Average Uncorrected Noise History",hDistHistoryPrevious->GetNbinsX()+1,0,hDistHistoryPrevious->GetNbinsX()+1);
1161 else if(type == 3) hDistHistoryCurrent = new TH1F("hNoiseCMNHistory","Average Common Mode Noise History",hDistHistoryPrevious->GetNbinsX()+1,0,hDistHistoryPrevious->GetNbinsX()+1);
1162 else if(type == 4) hDistHistoryCurrent = new TH1F("hNoiseCorHistory","Average Corrected Noise History",hDistHistoryPrevious->GetNbinsX()+1,0,hDistHistoryPrevious->GetNbinsX()+1);
1163 else if(type == 5) hDistHistoryCurrent = new TH1F("hGainHistory","Average Gain History",hDistHistoryPrevious->GetNbinsX()+1,0,hDistHistoryPrevious->GetNbinsX()+1);
1164 else if(type == 6) hDistHistoryCurrent = new TH1F("hDriftSpeedHistory","Average Drift Speed History",hDistHistoryPrevious->GetNbinsX()+1,0,hDistHistoryPrevious->GetNbinsX()+1);
1165 //AliInfo(Form("hBaselineHistory 2 %x\n",hDistHistory));
1166 for(Int_t i=0;i<hDistHistoryPrevious->GetNbinsX();i++) {
1167 hDistHistoryCurrent->SetBinContent(i,hDistHistoryPrevious->GetBinContent(i));
1168 hDistHistoryCurrent->SetBinError(i,hDistHistoryPrevious->GetBinError(i));
1169 }
1170 hDistHistoryCurrent->SetBinContent(hDistHistoryPrevious->GetNbinsX(),average);
1171 hDistHistoryCurrent->SetBinError(hDistHistoryPrevious->GetNbinsX(),sigma);
1172 }
1173 }
1174 hDistHistoryCurrent->Write();
1175 gainHistoryFile->Close();
1176 delete gainHistoryFile;
1177// delete hname;
1178 delete hDist;
1179 delete hDistDiff;
1180}//_______________________________________________________________
1181