]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDCalibViewer.cxx
Possiblilty update or not update OCDB Time Delay entry for runs taken with new DA...
[u/mrichter/AliRoot.git] / TRD / AliTRDCalibViewer.cxx
CommitLineData
9bf458e3 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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: AliTRDCalibViewer.cxx 40390 2010-04-14 09:43:23Z cblume $ */
17
18///////////////////////////////////////////////////////////////////////////////
19// //
20// Class which implements AliBaseCalibViewer for the TRD //
21// used for the calibration monitor //
22// //
23// Authors: Marian Ivanov (Marian.Ivanov@cern.ch) //
24// Jens Wiechula (Jens.Wiechula@cern.ch) //
25// Ionut Arsene (iarsene@cern.ch) //
26// //
27///////////////////////////////////////////////////////////////////////////////
28
29#include <iostream>
30#include <fstream>
31#include <TString.h>
32#include <TRandom.h>
33#include <TLegend.h>
34#include <TLine.h>
35#include <TCanvas.h>
36#include <TROOT.h>
37#include <TStyle.h>
38#include <TH1.h>
39#include <TH1F.h>
40#include <TMath.h>
41#include <TVectorD.h>
42#include <THashTable.h>
43#include <TObjString.h>
44#include <TTimeStamp.h>
45#include <TObjString.h>
46#include <TTreeStream.h>
47#include <TFile.h>
48#include <TKey.h>
49#include <TGraph.h>
50#include <TDirectory.h>
51#include <TFriendElement.h>
52#include <TGrid.h>
53#include <TGeoManager.h>
54#include "AliTRDCalDet.h"
55#include "AliTRDCalPad.h"
56#include "AliTRDCalROC.h"
57#include "AliTRDCalChamberStatus.h"
58#include "AliTRDCalSingleChamberStatus.h"
59#include "AliTRDCalPadStatus.h"
d6a1ec13 60#include "AliTRDCalDCSv2.h"
61#include "AliTRDCalDCSFEEv2.h"
9bf458e3 62#include "AliTRDcalibDB.h"
63#include "AliCDBManager.h"
64#include "AliCDBStorage.h"
65#include "AliCDBEntry.h"
66#include "AliGRPObject.h"
67#include "AliTRDalignment.h"
68#include "AliTRDgeometry.h"
69#include "AliTRDpadPlane.h"
70
71#include "AliTRDCalibViewer.h"
72
73
74using namespace std;
75
76ClassImp(AliTRDCalibViewer)
77
78//_____________________________________________________________________________
79AliTRDCalibViewer::AliTRDCalibViewer()
80 :AliBaseCalibViewer()
81{
82 //
83 // Default constructor (just call base class constructor)
84 //
85}
86
87//_____________________________________________________________________________
88AliTRDCalibViewer::AliTRDCalibViewer(const AliTRDCalibViewer &c)
89 :AliBaseCalibViewer(c)
90{
91 //
92 // copy constructor (just call base class copy constructor)
93 //
94}
95
96//_____________________________________________________________________________
97AliTRDCalibViewer::AliTRDCalibViewer(TTree* tree)
98 :AliBaseCalibViewer(tree)
99{
100 //
101 // Constructor (just call the corresponding base constructor)
102 //
103}
104
105//_____________________________________________________________________________
106AliTRDCalibViewer::AliTRDCalibViewer(const char* fileName, const char* treeName)
107 :AliBaseCalibViewer(fileName, treeName)
108{
109 //
110 // Constructor (just call the corresponding base constructor)
111 //
112}
113
114//_____________________________________________________________________________
115AliTRDCalibViewer& AliTRDCalibViewer::operator=(const AliTRDCalibViewer& param) {
116 //
117 // assignment operator
118 //
119 fTree = param.fTree;
120 fTreeMustBeDeleted = param.fTreeMustBeDeleted;
121 fListOfObjectsToBeDeleted = param.fListOfObjectsToBeDeleted;
122 fAbbreviation = param.fAbbreviation;
123 fAppendString = param.fAppendString;
124 return(*this);
125}
126
127//_____________________________________________________________________________
128AliTRDCalibViewer::~AliTRDCalibViewer()
129{
130 //
131 // AliTRDCalibViewer destructor
132 // do nothing, the base class destructor will do the job
133}
134
135/*
136//_____________________________________________________________________________
137void AliTRDCalibViewer::GetTimeInfoOCDB(const Char_t* runList, const Char_t* outFile,
138 Int_t firstRun, Int_t lastRun, UInt_t infoFlags,
139 const Char_t* ocdbStorage) {
140//
141// Get time information from OCDB by calling the DumpOCDBtoTree.C macro
142//
143 DumpOCDBtoTree(runList, outFile, firstRun, lastRun,
144 TESTBIT(infoFlags,1), TESTBIT(infoFlags,2),
145 TESTBIT(infoFlags,3), TESTBIT(infoFlags,4),
146 ocdbStorage);
147}
148*/
149
150//_____________________________________________________________________________
151const char* AliTRDCalibViewer::AddAbbreviations(char* c, Bool_t printDrawCommand){
152 // Replace all "<variable>" with "<variable><fAbbreviation>" (Adds forgotten "~")
153 // but take care on the statistical information, like "CEQmean_Mean"
154 // and also take care on correct given variables, like "CEQmean~"
155 //
156 // For each variable out of "listOfVariables":
157 // - 'Save' correct items:
158 // - form <replaceString>, take <variable>'s first char, add <removeString>, add rest of <variable>, e.g. "C!#EQmean" (<removeString> = "!#")
159 // - For each statistical information in "listOfNormalizationVariables":
160 // - ReplaceAll <variable><statistical_Information> with <replaceString><statistical_Information>
161 // - ReplaceAll <variable><abbreviation> with <replaceString><abbreviation>, e.g. "CEQmean~" -> "C!#EQmean~"
162 // - ReplaceAll <variable><appendStr> with <replaceString><appendStr>, e.g. "CEQmean.fElements" -> "C!#EQmean.fElements"
163 //
164 // - Do actual replacing:
165 // - ReplaceAll <variable> with <variable><fAbbreviation>, e.g. "CEQmean" -> "CEQmean~"
166 //
167 // - Undo saving:
168 // - For each statistical information in "listOfNormalizationVariables":
169 // - ReplaceAll <replaceString><statistical_Information> with <variable><statistical_Information>
170 // - ReplaceAll <replaceString><abbreviation> with <variable><abbreviation>, e.g. "C!#EQmean~" -> "CEQmean~"
171 // - ReplaceAll <replaceString><appendStr> with <variable><appendStr>, e.g. "C!#EQmean.fElements" -> "CEQmean.fElements"
172 //
173 // Now all the missing "~" should be added.
174
175 TString str(c);
176 TString removeString = "!#"; // very unprobable combination of chars
177 TString replaceString = "";
178 TString searchString = "";
179 TString normString = "";
180 TObjArray *listOfVariables = GetListOfVariables();
181 // variables used for mapping the pads, mcms, ...
182 listOfVariables->Add(new TObjString("SuperModule"));
183 listOfVariables->Add(new TObjString("Layer"));
184 listOfVariables->Add(new TObjString("Stack"));
185 listOfVariables->Add(new TObjString("Channel"));
186 listOfVariables->Add(new TObjString("Row"));
187 listOfVariables->Add(new TObjString("Column"));
188 listOfVariables->Add(new TObjString("Chamber"));
189 listOfVariables->Add(new TObjString("PadSuperRow"));
190 listOfVariables->Add(new TObjString("PadSuperColumn"));
191 listOfVariables->Add(new TObjString("MCMSuperRow"));
192 listOfVariables->Add(new TObjString("MCMSuperColumn"));
193 listOfVariables->Add(new TObjString("ROB"));
194 listOfVariables->Add(new TObjString("MCM"));
195 TObjArray *listOfNormalizationVariables = GetListOfNormalizationVariables();
196 Int_t nVariables = listOfVariables->GetEntriesFast();
197 Int_t nNorm = listOfNormalizationVariables->GetEntriesFast();
198
950337d0 199 Int_t *varLengths = new Int_t[nVariables];
9bf458e3 200 for (Int_t i = 0; i < nVariables; i++) {
201 varLengths[i] = ((TObjString*)listOfVariables->At(i))->String().Length();
202 }
950337d0 203 Int_t *normLengths = new Int_t[nNorm];
9bf458e3 204 for (Int_t i = 0; i < nNorm; i++) {
205 normLengths[i] = ((TObjString*)listOfNormalizationVariables->At(i))->String().Length();
206 }
4e5939c4 207 Int_t *varSort = new Int_t[nVariables+1];
9bf458e3 208 TMath::Sort(nVariables, varLengths, varSort, kTRUE);
4e5939c4 209 Int_t *normSort = new Int_t[nNorm+1];
9bf458e3 210 TMath::Sort(nNorm, normLengths, normSort, kTRUE);
211
212 for (Int_t ivar = 0; ivar < nVariables; ivar++) {
213 // ***** save correct tokens *****
214 // first get the next variable:
215 searchString = ((TObjString*)listOfVariables->At(varSort[ivar]))->String();
216 // form replaceString:
217 replaceString = "";
218 for (Int_t i = 0; i < searchString.Length(); i++) {
219 replaceString.Append(searchString[i]);
220 if (i == 0) replaceString.Append(removeString);
221 }
222 // go through normalization:
223 for (Int_t inorm = 0; inorm < nNorm; inorm++) {
224 normString = ((TObjString*)listOfNormalizationVariables->At(normSort[inorm]))->String();
225 str.ReplaceAll(searchString + normString, replaceString + normString);
226 // like: str.ReplaceAll("CEQmean_Mean", "C!EQmean_Mean");
227 }
228 str.ReplaceAll(searchString + fAbbreviation, replaceString + fAbbreviation);
229 // like: str.ReplaceAll("CEQmean~", "C!EQmean~");
230 str.ReplaceAll(searchString + fAppendString, replaceString + fAppendString);
231 // like: str.ReplaceAll("CEQmean.fElements", "C!EQmean.fElements");
232
233 // ***** add missing extensions *****
234 str.ReplaceAll(searchString, replaceString + fAbbreviation);
235 // like: str.ReplaceAll("CEQmean", "C!EQmean~");
236 }
237
238 // ***** undo saving *****
239 str.ReplaceAll(removeString, "");
240
241 if (printDrawCommand) std::cout << "The string looks now like: " << str.Data() << std::endl;
b5ed6afb 242 delete [] varSort;
243 delete [] normSort;
9bf458e3 244 return str.Data();
245}
246
247//_____________________________________________________________________________
248TObjArray* AliTRDCalibViewer::GetListOfVariables(Bool_t printList) {
249 //
250 // scan the tree - produces a list of available variables in the tree
251 // printList: print the list to the screen, after the scan is done
252 //
253 TObjArray* arr = new TObjArray();
254 TObjString* str = 0;
255 if (!fTree) {
256 return 0;
257 }
258 Int_t nentries = fTree->GetListOfBranches()->GetEntries();
259 for (Int_t i = 0; i < nentries; i++) {
260 str = new TObjString(fTree->GetListOfBranches()->At(i)->GetName());
261 str->String().ReplaceAll("_Mean", "");
262 str->String().ReplaceAll("_RMS", "");
263 str->String().ReplaceAll("_Median", "");
264 str->String().ReplaceAll(".", "");
265 str->String().ReplaceAll("_Run", "");
266 str->String().ReplaceAll("_SuperModule", "");
267 str->String().ReplaceAll("_Chamber", "");
268 // add all the variables in the tree to a list
269 // exception make variables which are used for mapping, specified in AddAbbreviations()
270 // These two functions should be kept synchronized with respect to the mapping variables
271 if (!arr->FindObject(str) &&
272 !(str->String() == "run" ||
273 str->String() == "SuperModule" || str->String() == "Layer" || str->String() == "Stack" ||
274 str->String() == "Chamber" ||
275 str->String() == "Channel" || str->String() == "Row" || str->String() == "Column" ||
276 str->String() == "PadSuperRow" || str->String() == "PadSuperColumn" || str->String() == "MCMSuperRow"
277 || str->String() == "MCMSuperColumn" || str->String() == "MCM" || str->String() == "ROB")) {
278 arr->Add(str);
279 }
280 }
281
282 // loop over all friends (if there are some) and add them to the list
283 if (fTree->GetListOfFriends()) {
284 for (Int_t ifriend = 0; ifriend < fTree->GetListOfFriends()->GetEntries(); ifriend++){
285 // printf("iterating through friendlist, currently at %i\n", ifriend);
286 // printf("working with %s\n", fTree->GetListOfFriends()->At(ifriend)->ClassName());
287 if (TString(fTree->GetListOfFriends()->At(ifriend)->ClassName()) != "TFriendElement") continue; // no friendElement found
288 TFriendElement *friendElement = (TFriendElement*)fTree->GetListOfFriends()->At(ifriend);
289 if (friendElement->GetTree() == 0) continue; // no tree found in friendElement
290 // printf("friend found \n");
291 for (Int_t i = 0; i < friendElement->GetTree()->GetListOfBranches()->GetEntries(); i++) {
292 // printf("iterating through friendelement entries, currently at %i\n", i);
293 str = new TObjString(friendElement->GetTree()->GetListOfBranches()->At(i)->GetName());
294 str->String().ReplaceAll("_Mean", "");
295 str->String().ReplaceAll("_RMS", "");
296 str->String().ReplaceAll("_Median", "");
297 str->String().ReplaceAll(".", "");
298 str->String().ReplaceAll("_Run", "");
299 str->String().ReplaceAll("_SuperModule", "");
300 str->String().ReplaceAll("_Chamber", "");
301 if (!(str->String() == "run" ||
302 str->String() == "SuperModule" || str->String() == "Layer" || str->String() == "Stack" ||
303 str->String() == "Chamber" ||
304 str->String() == "Channel" || str->String() == "Row" || str->String() == "Column" ||
305 str->String() == "PadSuperRow" || str->String() == "PadSuperColumn" || str->String() == "MCMSuperRow"
306 || str->String() == "MCMSuperColumn" || str->String() == "MCM" || str->String() == "ROB")){
307 // insert "<friendName>." at the beginning: (<friendName> is per default "R")
308 str->String().Insert(0, ".");
309 str->String().Insert(0, friendElement->GetName());
310 if (!arr->FindObject(str)) {
311 arr->Add(str);
312 }
313 // printf("added string %s \n", str->String().Data());
314 }
315 }
316 }
317 } // if (fTree->GetListOfFriends())
318
319 arr->Sort();
320
321 if (printList) {
322 TIterator* iter = arr->MakeIterator();
323 iter->Reset();
324 TObjString* currentStr = 0;
325 while ( (currentStr = (TObjString*)(iter->Next())) ) {
326 std::cout << currentStr->GetString().Data() << std::endl;
327 }
328 delete iter;
329 }
330 return arr;
331}
332
333TObjArray* AliTRDCalibViewer::GetListOfNormalizationVariables(Bool_t printList) const{
334 //
335 // produces a list of available variables for normalization in the tree
336 // printList: print the list to the screen, after the scan is done
337 //
338 TObjArray* arr = new TObjArray();
339 arr->Add(new TObjString("_Mean_Run"));
340 arr->Add(new TObjString("_Mean_SuperModule"));
341 arr->Add(new TObjString("_Mean_Chamber"));
342 arr->Add(new TObjString("_Median_Run"));
343 arr->Add(new TObjString("_Median_SuperModule"));
344 arr->Add(new TObjString("_Median_Chamber"));
345
346 if (printList) {
347 TIterator* iter = arr->MakeIterator();
348 iter->Reset();
349 TObjString* currentStr = 0;
350 while ((currentStr = (TObjString*)(iter->Next()))) {
351 std::cout << currentStr->GetString().Data() << std::endl;
352 }
353 delete iter;
354 }
355 return arr;
356}
357
358void AliTRDCalibViewer::GetLayerSectorStack(TString trdString, Int_t& layerNo, Int_t& sectorNo, Int_t& stackNo) const {
359 // Get the layer, sector and stack numbers out of a string
360 // encoded with the following format:
361 // Layer%dSector%dStack%d
362
4e5939c4 363 //sscanf(trdString.Data(), "Layer%1dSector%02dStack%1d", &layerNo, &sectorNo, &stackNo);
364
365 // Coverity compliant solution (bit more cumbersome, but works) CBL
366 TString cName = trdString.Data();
367 Char_t cLayer[2];
368 Char_t cSector[3];
369 Char_t cStack[2];
370
371 cLayer[0] = cName[5];
372 cLayer[1] = 0;
373 cSector[0] = cName[12];
374 cSector[1] = cName[13];
375 cSector[2] = 0;
376 cStack[0] = cName[19];
377 cStack[1] = 0;
378
379 layerNo = atoi(cLayer);
380 sectorNo = atoi(cSector);
381 stackNo = atoi(cStack);
9bf458e3 382
383 return;
384}
385
386//_____________________________________________________________________________
387Int_t AliTRDCalibViewer::EasyDraw(const char* drawCommand, const char* sector, const char* cuts, const char* drawOptions, Bool_t writeDrawCommand) const {
388 //
389 // easy drawing of data, use '~' for abbreviation of '.fElements'
390 // example: EasyDraw("CETmean~-CETmean_mean", "A", "(CETmean~-CETmean_mean)>0")
391 // sector: sector-number - only the specified sector will be drwawn
392 // 'A'/'C' or 'a'/'c' - side A/C will be drawn
393 // 'ALL' - whole TPC will be drawn, projected on one side
394 // cuts: specifies cuts
395 // drawOptions: draw options like 'same'
396 // writeDrawCommand: write the command, that is passed to TTree::Draw
397 //
398
399 TString drawStr(drawCommand);
400
401 TString sectorStr(sector);
402 Int_t layerNo = -1;
403 Int_t sectorNo = -1;
404 Int_t stackNo = -1;
405 GetLayerSectorStack(sectorStr, layerNo, sectorNo, stackNo);
406 if(layerNo==-1) {
407 Warning("EasyDraw", "The sector string must always contain the Layer number!");
408 return -1;
409 }
410 if(layerNo<0 || layerNo>5) {
411 Warning("EasyDraw", "The Layer number must be in the range [0,5] !");
412 return -1;
413 }
414 if(sectorNo!=-1 && (sectorNo<0 || sectorNo>17)) {
415 Warning("EasyDraw", "The SuperModule number must be in the range [0,17] !");
416 return -1;
417 }
418 if(stackNo!=-1 && (stackNo<0 || stackNo>4)) {
419 Warning("EasyDraw", "The Stack number must be in the range [0,4] !");
420 return -1;
421 }
422
423 TString cutStr("");
424
425 Bool_t dangerousToDraw = drawStr.Contains(":") || drawStr.Contains(">>");
426 if (dangerousToDraw) {
427 Warning("EasyDraw", "The draw string must not contain ':' or '>>'. Using only first variable for drawing!");
428 drawStr.Resize(drawStr.First(":"));
429 }
430
431 TString drawOptionsStr("");
432 TRandom rnd(0);
433 Int_t rndNumber = rnd.Integer(10000);
434
435 if (drawOptions && strcmp(drawOptions, "") != 0)
436 drawOptionsStr += drawOptions;
437 else
438 drawOptionsStr += "profcolz";
439
440 const Int_t gkNRows[ 5] = {16, 16, 12, 16, 16}; // number of pad rows in the chambers from each of the 5 stacks
441
442 // draw calibration stuff
443 if(drawStr.Contains("Status") || drawStr.Contains("Gain") || drawStr.Contains("Noise") ||
444 drawStr.Contains("Vdrift") || drawStr.Contains("T0") ||
445 drawStr.Contains("gain") || drawStr.Contains("chiSquare")) {
446 if(sectorNo==-1 && stackNo==-1) { // plot the entire layer
447 drawStr += Form(":PadSuperColumn%s:PadSuperRow%s>>prof", fAppendString.Data(), fAppendString.Data());
448 drawStr += rndNumber;
449 drawStr += "(76,-0.5,75.5,2592,-0.5,2591.5)";
450 cutStr += Form("Layer==%d", layerNo);
451 }
452 else if(sectorNo!=-1 && stackNo==-1) { // plot a sector from a layer
453 drawStr += Form(":Column%s:PadSuperRow%s>>prof", fAppendString.Data(), fAppendString.Data());
454 drawStr += rndNumber;
455 drawStr += "(76,-0.5,75.5,144,-0.5,143.5)";
456 cutStr += Form("Layer==%d && SuperModule==%d", layerNo, sectorNo);
457 }
458 else if(sectorNo==-1 && stackNo!=-1) { // plot a stack from a layer
459 drawStr += Form(":PadSuperColumn%s:Row%s>>prof", fAppendString.Data(), fAppendString.Data());
460 drawStr += rndNumber;
461 drawStr += Form("(%d,-0.5,%d-0.5,2592,-0.5,2591.5)", gkNRows[stackNo], gkNRows[stackNo]);
462 cutStr += Form("Layer==%d && Stack==%d", layerNo, stackNo);
463 }
464 else { // the layer, sector and stack are determined -> so plot a chamber
465 drawStr += Form(":Column%s:Row%s>>prof", fAppendString.Data(), fAppendString.Data());
466 drawStr += rndNumber;
467 drawStr += Form("(%d,-0.5,%d-0.5,144,-0.5,143.5)", gkNRows[stackNo], gkNRows[stackNo]);
468 cutStr += Form("Layer==%d && SuperModule==%d && Stack==%d", layerNo, sectorNo, stackNo);
469 }
470 }
471 // draw FEE stuff
472 else if(drawStr.Contains("SORandEOR") ||
473 drawStr.Contains("gsmSOR") || drawStr.Contains("gsmDelta") ||
474 drawStr.Contains("nimSOR") || drawStr.Contains("nimDelta") ||
475 drawStr.Contains("nevSOR") || drawStr.Contains("nevDelta") ||
476 drawStr.Contains("nptSOR") || drawStr.Contains("nptDelta")) {
477 if(sectorNo==-1 && stackNo==-1) { // plot the entire layer
478 drawStr += Form(":MCMSuperColumn%s:MCMSuperRow%s>>prof", fAppendString.Data(), fAppendString.Data());
479 drawStr += rndNumber;
480 drawStr += "(76,-0.5,75.5,144,-0.5,143.5)";
481 cutStr += Form("Layer==%d", layerNo);
482 }
483 else if(sectorNo!=-1 && stackNo==-1) { // plot a sector from a layer
484 drawStr += Form(":MCMSuperColumn%s:MCMSuperRow%s>>prof", fAppendString.Data(), fAppendString.Data());
485 drawStr += rndNumber;
486 drawStr += "(76,-0.5,75.5,144,-0.5,143.5)";
487 cutStr += Form("Layer==%d && SuperModule==%d", layerNo, sectorNo);
488 }
489 else if(sectorNo==-1 && stackNo!=-1) { // plot a stack from a layer
490 drawStr += Form(":MCMSuperColumn%s:MCMSuperRow%s>>prof", fAppendString.Data(), fAppendString.Data());
491 drawStr += rndNumber;
492 // drawStr += Form("(%d,-0.5,%d-0.5,2592,-0.5,2591.5)", gkNRows[stackNo], gkNRows[stackNo]);
493 drawStr += "(76,-0.5,75.5,144,-0.5,143.5)";
494 cutStr += Form("Layer==%d && Stack==%d", layerNo, stackNo);
495 }
496 else { // the layer, sector and stack are determined -> so plot a chamber
497 drawStr += Form(":ROB%s:MCM%s>>prof", fAppendString.Data(), fAppendString.Data());
498 drawStr += rndNumber;
499 drawStr += Form("(16,-0.5,15.5,%d,-0.5,%d-0.5)", gkNRows[stackNo]/2, gkNRows[stackNo]/2);
500 cutStr += Form("Layer==%d && SuperModule==%d && Stack==%d", layerNo, sectorNo, stackNo);
501 }
502 }
503 // draw alignment stuff
504 else if(drawStr.Contains("Align")) {
505 if(sectorNo==-1 && stackNo==-1) { // plot the entire layer
506 drawStr += ":SuperModule:Stack>>prof";
507 drawStr += rndNumber;
508 drawStr += "(5,-0.5,4.5,18,-0.5,17.5)";
509 cutStr += Form("Layer==%d", layerNo);
510 }
511 else if(sectorNo!=-1 && stackNo==-1) { // plot a sector from a layer
512 drawStr += ":SuperModule:Stack>>prof";
513 drawStr += rndNumber;
514 drawStr += Form("(5,-0.5,4.5,1,%f,%f)", sectorNo-0.5, sectorNo+0.5);
515 cutStr += Form("Layer==%d && SuperModule==%d", layerNo, sectorNo);
516 }
517 else if(sectorNo==-1 && stackNo!=-1) { // plot a stack from a layer
518 drawStr += ":SuperModule:Stack>>prof";
519 drawStr += rndNumber;
520 drawStr += Form("(1,%f,%f,18,-0.5,17.5)", stackNo-0.5, stackNo+0.5);
521 cutStr += Form("Layer==%d && Stack==%d", layerNo, stackNo);
522 }
523 else { // the layer, sector and stack are determined -> so plot a chamber
524 drawStr += ":SuperModule:Stack>>prof";
525 drawStr += rndNumber;
526 drawStr += Form("(1,%f,%f,1,%f,%f)", stackNo-0.5, stackNo+0.5, sectorNo-0.5, sectorNo+0.5);
527 cutStr += Form("Layer==%d && SuperModule==%d && Stack==%d", layerNo, sectorNo, stackNo);
528 }
529 }
530
531
532 if (cuts && cuts[0] != 0) {
533 if (cutStr.Length() != 0) cutStr += "&& ";
534 cutStr += "(";
535 cutStr += cuts;
536 cutStr += ")";
537 }
538 drawStr.ReplaceAll(fAbbreviation, fAppendString);
539 cutStr.ReplaceAll(fAbbreviation, fAppendString);
540 if (writeDrawCommand) std::cout << "fTree->Draw(\"" << drawStr << "\", \"" << cutStr << "\", \"" << drawOptionsStr << "\");" << std::endl;
541 Int_t returnValue = fTree->Draw(drawStr.Data(), cutStr.Data(), drawOptionsStr.Data());
542 TString profName("prof");
543 profName += rndNumber;
544 TObject *obj = gDirectory->Get(profName.Data());
545 // set the names of the axes
546 TH1 *histObj = (TH1*)obj;
547 if(drawStr.Contains("Status") || drawStr.Contains("Gain") || drawStr.Contains("Noise") ||
548 drawStr.Contains("Vdrift") || drawStr.Contains("T0") ||
549 drawStr.Contains("gain") || drawStr.Contains("chiSquare")) {
550 histObj->GetXaxis()->SetTitle("Row");
551 histObj->GetYaxis()->SetTitle("Column");
552 }
553 else if(drawStr.Contains("SORandEOR") ||
554 drawStr.Contains("gsmSOR") || drawStr.Contains("gsmDelta") ||
555 drawStr.Contains("nimSOR") || drawStr.Contains("nimDelta") ||
556 drawStr.Contains("nevSOR") || drawStr.Contains("nevDelta") ||
557 drawStr.Contains("nptSOR") || drawStr.Contains("nptDelta")) {
558 histObj->GetXaxis()->SetTitle("MCM Row");
559 histObj->GetYaxis()->SetTitle("MCM Column");
560 }
561 else if(drawStr.Contains("Align")) {
562 histObj->GetXaxis()->SetTitle("Stack");
563 histObj->GetYaxis()->SetTitle("Sector");
564 }
565
566 if (obj && obj->InheritsFrom("TH1")) FormatHistoLabels((TH1*)obj);
567 return returnValue;
568}
569
570//_____________________________________________________________________________
571Int_t AliTRDCalibViewer::EasyDraw1D(const char* drawCommand, const char* sector, const char* cuts, const char* drawOptions, Bool_t writeDrawCommand) const {
572 //
573 // easy drawing of data, use '~' for abbreviation of '.fElements'
574 // example: EasyDraw("CETmean~-CETmean_mean", "A", "(CETmean~-CETmean_mean)>0")
575 // sector: sector-number - the specified sector will be drwawn
576 // 'A'/'C' or 'a'/'c' - side A/C will be drawn
577 // 'ALL' - whole TPC will be drawn, projected on one side
578 // cuts: specifies cuts
579 // drawOptions: draw options like 'same'
580 // writeDrawCommand: write the command, that is passed to TTree::Draw
581 //
582
583 TString drawStr(drawCommand);
584
585 TString sectorStr(sector);
586 Int_t layerNo = -1;
587 Int_t sectorNo = -1;
588 Int_t stackNo = -1;
589 GetLayerSectorStack(sectorStr, layerNo, sectorNo, stackNo);
590 if(layerNo==-1) {
591 Warning("EasyDraw", "The sector string must always contain the Layer number!");
592 return -1;
593 }
594 if(layerNo<0 || layerNo>5) {
595 Warning("EasyDraw", "The Layer number must be in the range [0,5] !");
596 return -1;
597 }
598 if(sectorNo!=-1 && (sectorNo<0 || sectorNo>17)) {
599 Warning("EasyDraw", "The Sector number must be in the range [0,17] !");
600 return -1;
601 }
602 if(stackNo!=-1 && (stackNo<0 || stackNo>4)) {
603 Warning("EasyDraw", "The Stack number must be in the range [0,4] !");
604 return -1;
605 }
606
607 TString drawOptionsStr(drawOptions);
608 TString cutStr("");
609
610 if(sectorNo==-1 && stackNo==-1) // plot the entire layer
611 cutStr += Form("Layer==%d", layerNo);
612 else if(sectorNo!=-1 && stackNo==-1) // plot a sector from a layer
613 cutStr += Form("Layer==%d && SuperModule==%d", layerNo, sectorNo);
614 else if(sectorNo==-1 && stackNo!=-1) // plot a stack from a layer
615 cutStr += Form("Layer==%d && Stack==%d", layerNo, stackNo);
616 else // the layer, sector and stack are determined -> so plot a chamber
617 cutStr += Form("Layer==%d && SuperModule==%d && Stack==%d", layerNo, sectorNo, stackNo);
618
619 if(cuts && cuts[0] != 0) {
620 if (cutStr.Length() != 0) cutStr += "&& ";
621 cutStr += "(";
622 cutStr += cuts;
623 cutStr += ")";
624 }
625
626 drawStr.ReplaceAll(fAbbreviation, fAppendString);
627 cutStr.ReplaceAll(fAbbreviation, fAppendString);
628 if (writeDrawCommand) std::cout << "fTree->Draw(\"" << drawStr << "\", \"" << cutStr << "\", \"" << drawOptionsStr << "\");" << std::endl;
629 Int_t returnValue = fTree->Draw(drawStr.Data(), cutStr.Data(), drawOptionsStr.Data());
630 if (returnValue == -1) return -1;
631
632 TObject *obj = (gPad) ? gPad->GetPrimitive("htemp") : 0;
633 if (!obj) obj = (TH1F*)gDirectory->Get("htemp");
634 if (!obj) obj = gPad->GetPrimitive("tempHist");
635 if (!obj) obj = (TH1F*)gDirectory->Get("tempHist");
636 if (!obj) obj = gPad->GetPrimitive("Graph");
637 if (!obj) obj = (TH1F*)gDirectory->Get("Graph");
638 if (obj && obj->InheritsFrom("TH1")) FormatHistoLabels((TH1*)obj);
639 return returnValue;
640}
641
642//_____________________________________________________________________________
643Int_t AliTRDCalibViewer::EasyDraw(const char* drawCommand, Int_t chamber, const char* cuts, const char* drawOptions, Bool_t writeDrawCommand) const {
644 //
645 // easy drawing of data, use '~' for abbreviation of '.fElements'
646 // example: EasyDraw("CETmean~-CETmean_mean", 34, "(CETmean~-CETmean_mean)>0")
647 // sector: sector-number - only the specified sector will be drwawn
648 // cuts: specifies cuts
649 // drawOptions: draw options like 'same'
650 // writeDrawCommand: write the command, that is passed to TTree::Draw
651 //
652 if(chamber >= 0 && chamber < 540) {
653 Int_t superModuleNo = chamber/30;
654 Int_t stackNo = (chamber%30)/6;
655 Int_t layerNo = (chamber%30)%6;
656 char sectorChr[22];
a987273c 657 snprintf(sectorChr,22, "Layer%iSector%iStack%i", layerNo, superModuleNo, stackNo);
9bf458e3 658 return EasyDraw(drawCommand, sectorChr, cuts, drawOptions, writeDrawCommand);
659 }
660 Error("EasyDraw","The TRD contains only chamber from 0 to 539");
661 return -1;
662}
663
664//_____________________________________________________________________________
665Int_t AliTRDCalibViewer::EasyDraw1D(const char* drawCommand, Int_t chamber, const char* cuts, const char* drawOptions, Bool_t writeDrawCommand) const {
666 //
667 // easy drawing of data, use '~' for abbreviation of '.fElements'
668 // example: EasyDraw("CETmean~-CETmean_mean", 34, "(CETmean~-CETmean_mean)>0")
669 // sector: sector-number - the specified sector will be drwawn
670 // cuts: specifies cuts
671 // drawOptions: draw options like 'same'
672 // writeDrawCommand: write the command, that is passed to TTree::Draw
673 //
674
675 if (chamber >= 0 && chamber < 539) {
676 Int_t superModuleNo = chamber/30;
677 Int_t stackNo = (chamber%30)/6;
678 Int_t layerNo = (chamber%30)%6;
679 char sectorChr[22];
a987273c 680 snprintf(sectorChr,22, "Layer%iSector%iStack%i", layerNo, superModuleNo, stackNo);
9bf458e3 681 return EasyDraw1D(drawCommand, sectorChr, cuts, drawOptions, writeDrawCommand);
682 }
683 Error("EasyDraw1D","The TRD contains only chambers from 0 to 539");
684 return -1;
685}
686
687//_____________________________________________________________________________
688Bool_t AliTRDCalibViewer::DumpOCDBtoTreeDetails(const Char_t* runListFilename,
689 const Char_t* outFilename,
690 Int_t firstRun, Int_t lastRun,
691 const Char_t* storage,
692 Int_t version,
693 Int_t subVersion,
694 Bool_t getCalibs,
695 Bool_t getDCS,
696 Bool_t getAlign) {
697 //
698 // Retrieve TRD OCDB information for a given run list/range
699 //
700
701 if(runListFilename[0]!='\0' && firstRun==-1 && lastRun==-1) {
702 cout << "AliTRDCalibViewer::DumpOCDBtoTreeDetails(): You must provide at least a run range or an ascii filename with run numbers"
703 << endl;
704 return kFALSE;
705 }
706 // initialize the OCDB manager
707 TString storageString = storage;
708 if(storageString.Contains("alien://")) {
709 TGrid::Connect("alien://");
710 }
711 AliCDBManager *manager = AliCDBManager::Instance();
712 if(storage[0]!='\0') {
713 manager->SetDefaultStorage(storage);
714 }
715 else {
716 if(!manager->IsDefaultStorageSet()) {
717 cout << "AliTRDCalibViewer::DumpOCDBtoTreeDetails(): Default OCDB storage not set!!" << endl;
718 return kFALSE;
719 }
720 }
721 manager->SetRun(1);
722
723 // open the ascii file
724 ifstream in;
725 if(runListFilename[0]!='\0')
726 in.open(runListFilename);
727
728 // initialize the tree streamer
729 if(outFilename[0]=='\0') outFilename = "trdDetails.root";
730 TString calibFilename = outFilename;
731
732 TTreeSRedirector *treeStreamer = new TTreeSRedirector(calibFilename.Data());
733
734 Int_t currRun;
735 if(runListFilename[0]=='\0' && firstRun!=-1 && lastRun!=-1)
736 currRun = firstRun;
737
738 TVectorD runs;
739
740 // loop over runs
741 while(1) {
742 if(runListFilename[0]!='\0') {
743 if(!(in>>currRun)) continue;
744 if(currRun < (firstRun==-1 ? 0 : firstRun) ||
745 currRun > (lastRun==-1 ? 999999999 : lastRun))
746 continue;
747 }
748 else {
749 if(currRun>lastRun) break;
750 }
751 cout << "run = " << currRun << endl;
752 manager->SetRun(currRun);
753
754 // Get GRP data. If there is no proper GRP object for this run than
755 // this run is aborted
756 AliCDBEntry *entry = manager->Get("GRP/GRP/Data");
757 AliGRPObject* grpObject = 0;
758 if(entry) {
759 entry->SetOwner(kFALSE);
760 grpObject = dynamic_cast<AliGRPObject*>(entry->GetObject());
761 }
762 else {
763 currRun++;
764 // continue;
765 // return kFALSE;
766 }
767 if(!grpObject)
768 cout << "No GRP info available for this run " << endl;
769
770 time_t startTimeGRP = 0;
771 TObjString runType("");
772 if(grpObject) {
773 startTimeGRP = grpObject->GetTimeStart();
774 TTimeStamp start(grpObject->GetTimeStart());
775 TTimeStamp end(grpObject->GetTimeEnd());
776 cout << "Start time: " << start.GetDate()/10000 << "/"
777 << (start.GetDate()/100)-(start.GetDate()/10000)*100 << "/"
778 << start.GetDate()%100 << " "
779 << start.GetTime()/10000 << ":"
780 << (start.GetTime()/100)-(start.GetTime()/10000)*100 << ":"
781 << start.GetTime()%100 << endl;
782 cout << "End time: " << end.GetDate()/10000 << "/"
783 << (end.GetDate()/100)-(end.GetDate()/10000)*100 << "/"
784 << end.GetDate()%100 << " "
785 << end.GetTime()/10000 << ":"
786 << (end.GetTime()/100)-(end.GetTime()/10000)*100 << ":"
787 << end.GetTime()%100 << endl;
788 cout << "Run type = " << grpObject->GetRunType().Data() << endl;
789 runType = grpObject->GetRunType().Data();
790 }
791
792 // gain
793 AliTRDCalDet *chamberGainFactor = 0;
794 if(getCalibs) {
795 entry = manager->Get("TRD/Calib/ChamberGainFactor", currRun, version, subVersion);
796 if(entry) {
797 entry->SetOwner(kFALSE);
798 chamberGainFactor = (AliTRDCalDet*)entry->GetObject();
799 }
800 }
801 AliTRDCalPad *padGainFactor = 0;
802 if(getCalibs) {
803 entry = manager->Get("TRD/Calib/LocalGainFactor", currRun, version, subVersion);
804 if(entry) {
805 entry->SetOwner(kFALSE);
806 padGainFactor = (AliTRDCalPad*)entry->GetObject();
807 }
808 }
809 Double_t runMeanGain, runRMSGain;
810 TVectorD chamberMeanGain(AliTRDcalibDB::kNdet);
811 TVectorD chamberRMSGain(AliTRDcalibDB::kNdet);
812 TVectorD smMeanGain(AliTRDcalibDB::kNsector);
813 TVectorD smRMSGain(AliTRDcalibDB::kNsector);
814 for(Int_t iNdet=0; iNdet<AliTRDcalibDB::kNdet; iNdet++) {chamberMeanGain[iNdet] = 0.0; chamberRMSGain[iNdet] = 0.0;}
815 for(Int_t iSm=0; iSm<AliTRDcalibDB::kNsector; iSm++) {smMeanGain[iSm] = 0.0; smRMSGain[iSm] = 0.0;}
816 TString parName("Gain");
817 if(getCalibs)
818 ProcessTRDCalibArray(chamberGainFactor, padGainFactor,
819 parName,
820 runMeanGain, runRMSGain,
821 chamberMeanGain, chamberRMSGain,
822 smMeanGain, smRMSGain);
823
824 // noise/pedestals
825 AliTRDCalDet *chamberNoise = 0;
826 if(getCalibs) {
827 entry = manager->Get("TRD/Calib/DetNoise", currRun, version, subVersion);
828 if(entry) {
829 entry->SetOwner(kFALSE);
830 chamberNoise = (AliTRDCalDet*)entry->GetObject();
831 }
832 }
833 AliTRDCalPad *padNoise = 0;
834 if(getCalibs) {
835 entry = manager->Get("TRD/Calib/PadNoise", currRun, version, subVersion);
836 if(entry) {
837 entry->SetOwner(kFALSE);
838 padNoise = (AliTRDCalPad*)entry->GetObject();
839 }
840 }
841 Double_t runMeanNoise, runRMSNoise;
842 TVectorD chamberMeanNoise(AliTRDcalibDB::kNdet);
843 TVectorD chamberRMSNoise(AliTRDcalibDB::kNdet);
844 TVectorD smMeanNoise(AliTRDcalibDB::kNsector);
845 TVectorD smRMSNoise(AliTRDcalibDB::kNsector);
846 for(Int_t iNdet=0; iNdet<AliTRDcalibDB::kNdet; iNdet++) {chamberMeanNoise[iNdet] = 0.0; chamberRMSNoise[iNdet] = 0.0;}
847 for(Int_t iSm=0; iSm<AliTRDcalibDB::kNsector; iSm++) {smMeanNoise[iSm] = 0.0; smRMSNoise[iSm] = 0.0;}
848 parName = "Noise";
849 if(getCalibs)
850 ProcessTRDCalibArray(chamberNoise, padNoise,
851 parName,
852 runMeanNoise, runRMSNoise,
853 chamberMeanNoise, chamberRMSNoise,
854 smMeanNoise, smRMSNoise);
855
856 // vdrift
857 AliTRDCalDet *chamberVdrift = 0;
858 if(getCalibs) {
859 entry = manager->Get("TRD/Calib/ChamberVdrift", currRun, version, subVersion);
860 if(entry) {
861 entry->SetOwner(kFALSE);
862 chamberVdrift = (AliTRDCalDet*)entry->GetObject();
863 }
864 }
865 AliTRDCalPad *padVdrift = 0;
866 if(getCalibs) {
867 entry = manager->Get("TRD/Calib/LocalVdrift", currRun, version, subVersion);
868 if(entry) {
869 entry->SetOwner(kFALSE);
870 padVdrift = (AliTRDCalPad*)entry->GetObject();
871 }
872 }
873 Double_t runMeanVdrift, runRMSVdrift;
874 TVectorD chamberMeanVdrift(AliTRDcalibDB::kNdet);
875 TVectorD chamberRMSVdrift(AliTRDcalibDB::kNdet);
876 TVectorD smMeanVdrift(AliTRDcalibDB::kNsector);
877 TVectorD smRMSVdrift(AliTRDcalibDB::kNsector);
878 for(Int_t iNdet=0; iNdet<AliTRDcalibDB::kNdet; iNdet++) {chamberMeanVdrift[iNdet] = 0.0; chamberRMSVdrift[iNdet] = 0.0;}
879 for(Int_t iSm=0; iSm<AliTRDcalibDB::kNsector; iSm++) {smMeanVdrift[iSm] = 0.0; smRMSVdrift[iSm] = 0.0;}
880 parName = "Vdrift";
881 if(getCalibs)
882 ProcessTRDCalibArray(chamberVdrift, padVdrift,
883 parName,
884 runMeanVdrift, runRMSVdrift,
885 chamberMeanVdrift, chamberRMSVdrift,
886 smMeanVdrift, smRMSVdrift);
887
888 // T0
889 AliTRDCalDet *chamberT0 = 0;
890 if(getCalibs) {
891 entry = manager->Get("TRD/Calib/ChamberT0", currRun, version, subVersion);
892 if(entry) {
893 entry->SetOwner(kFALSE);
894 chamberT0 = (AliTRDCalDet*)entry->GetObject();
895 }
896 }
897 AliTRDCalPad *padT0 = 0;
898 if(getCalibs) {
899 entry = manager->Get("TRD/Calib/LocalT0", currRun, version, subVersion);
900 if(entry) {
901 entry->SetOwner(kFALSE);
902 padT0 = (AliTRDCalPad*)entry->GetObject();
903 }
904 }
905 Double_t runMeanT0, runRMST0;
906 TVectorD chamberMeanT0(AliTRDcalibDB::kNdet);
907 TVectorD chamberRMST0(AliTRDcalibDB::kNdet);
908 TVectorD smMeanT0(AliTRDcalibDB::kNsector);
909 TVectorD smRMST0(AliTRDcalibDB::kNsector);
910 for(Int_t iNdet=0; iNdet<AliTRDcalibDB::kNdet; iNdet++) {chamberMeanT0[iNdet] = 0.0; chamberRMST0[iNdet] = 0.0;}
911 for(Int_t iSm=0; iSm<AliTRDcalibDB::kNsector; iSm++) {smMeanT0[iSm] = 0.0; smRMST0[iSm] = 0.0;}
912 parName = "T0";
913 if(getCalibs)
914 ProcessTRDCalibArray(chamberT0, padT0,
915 parName,
916 runMeanT0, runRMST0,
917 chamberMeanT0, chamberRMST0,
918 smMeanT0, smRMST0);
919
920 // status
921 AliTRDCalChamberStatus* chamberStatus = 0;
922 if(getCalibs) {
923 entry = manager->Get("TRD/Calib/ChamberStatus", currRun, version, subVersion);
924 if(entry) {
925 entry->SetOwner(kFALSE);
926 chamberStatus = (AliTRDCalChamberStatus*)entry->GetObject();
927 }
928 }
929 AliTRDCalPadStatus *padStatus = 0;
930 if(getCalibs) {
931 entry = manager->Get("TRD/Calib/PadStatus", currRun, version, subVersion);
932 if(entry) {
933 entry->SetOwner(kFALSE);
934 padStatus = (AliTRDCalPadStatus*)entry->GetObject();
935 }
936 }
937
938 // DCS FEE information
939 TObjArray *dcsArray = 0;
940 if(getDCS) {
5f481838 941 entry = manager->Get("TRD/Calib/DCS");
9bf458e3 942 if(entry) {
943 entry->SetOwner(kTRUE);
944 dcsArray = (TObjArray*)entry->GetObject();
945 }
946 }
d6a1ec13 947 AliTRDCalDCSv2 *dcsSOR = 0;
948 AliTRDCalDCSv2 *dcsEOR = 0;
9bf458e3 949 if(getDCS && dcsArray) {
d6a1ec13 950 dcsSOR = (AliTRDCalDCSv2*)dcsArray->At(0);
951 dcsEOR = (AliTRDCalDCSv2*)dcsArray->At(1);
9bf458e3 952 }
953
954 // Alignment information
955 // get the geometry from OCDB
956 TGeoManager *geoMan = 0x0;
957 if(getAlign) {
958 entry=manager->Get("GRP/Geometry/Data");
959 if(entry)
960 geoMan=(TGeoManager*)entry->GetObject();
961 else
962 cout << "Cannot get an entry for the geometry storage" << endl;
963 }
964 // get the alignment from OCDB
965 AliTRDalignment *alignMan=0;
966 if(getAlign && geoMan) {
967 entry=manager->Get("TRD/Align/Data", currRun, version, subVersion);
968 if(entry) {
969 alignMan = new AliTRDalignment();
970 cout << "storage for alignment = " << manager->GetDefaultStorage()->GetURI().Data() << endl;
971 alignMan->ReadDB(manager->GetDefaultStorage()->GetURI().Data(), "TRD/Align/Data", currRun, version, subVersion);
972 }
973 else {
974 cout << "Cannot get an entry for the alignment info" << endl;
975 }
976 }
977
978 Int_t kSuperModuleStatus[18] = {1, 1, 0, 0, 0, 0, // super module status (1- installed, 0- not installed)
979 0, 1, 1, 1, 1, 0,
980 0, 0, 0, 0, 0, 1};
981 Int_t kNRows[ 5] = {16, 16, 12, 16, 16}; // number of pad rows in the chambers from each of the 5 stacks
982 Int_t kNCols = 144; // number of pad columns in the chambers from each of the 18 supermodules
983 Int_t kROB[5] = {8, 8, 6, 8, 8}; // number of read out boards(ROB) per chamber (6 in stack 2 and 8 in the rest)
984 Int_t kMCM = 16; // number of MCMs per ROB
985 for(Short_t iLayer=0; iLayer<AliTRDgeometry::kNlayer; iLayer++) { // loop over layers
986 for(Short_t iSector=0; iSector<AliTRDgeometry::kNsector; iSector++) { // loop over supermodules
987 if(kSuperModuleStatus[iSector]==0)
988 continue;
989 Double_t alignSMPars[6];
990 for(Int_t ipar=0; ipar<6; ipar++) alignSMPars[ipar]=0.0;
991 if(getAlign && alignMan)
992 alignMan->GetSm(iSector, alignSMPars);
993 for(Short_t iStack=0; iStack<AliTRDgeometry::kNstack; iStack++) { // loop over stacks
994 Short_t chamberNo = AliTRDgeometry::GetDetector(iLayer, iStack, iSector);
995 AliTRDCalROC *gainROC = 0;
996 if(padGainFactor) gainROC = padGainFactor->GetCalROC(chamberNo);
997 AliTRDCalROC *noiseROC = 0;
998 if(padNoise) noiseROC = padNoise->GetCalROC(chamberNo);
999 AliTRDCalROC *vdriftROC = 0;
1000 if(padVdrift) vdriftROC = padVdrift->GetCalROC(chamberNo);
1001 AliTRDCalROC *t0ROC = 0;
1002 if(t0ROC) t0ROC = padT0->GetCalROC(chamberNo);
1003 AliTRDCalSingleChamberStatus *statusROC = 0;
1004 if(padStatus) statusROC = padStatus->GetCalROC(chamberNo);
1005 TVectorD channelVector(kNRows[iStack]*kNCols);
1006 TVectorD rowVector(kNRows[iStack]*kNCols);
1007 TVectorD colVector(kNRows[iStack]*kNCols);
1008 TVectorD statusVector(kNRows[iStack]*kNCols);
1009 TVectorD gainVector(kNRows[iStack]*kNCols);
1010 TVectorD noiseVector(kNRows[iStack]*kNCols);
1011 TVectorD vdriftVector(kNRows[iStack]*kNCols);
1012 TVectorD t0Vector(kNRows[iStack]*kNCols);
1013 TVectorD padSuperRowVector(kNRows[iStack]*kNCols);
1014 TVectorD padSuperColumnVector(kNRows[iStack]*kNCols);
1015 for(Int_t ipar=0; ipar<kNRows[iStack]*kNCols; ipar++) {
1016 channelVector[ipar] = 0; rowVector[ipar] = 0; colVector[ipar] = 0;
1017 statusVector[ipar] = 0; gainVector[ipar] = 0; noiseVector[ipar] = 0;
1018 vdriftVector[ipar] = 0; t0Vector[ipar] = 0; padSuperRowVector[ipar] = 0;
1019 padSuperColumnVector[ipar] = 0;
1020 }
1021 Int_t index = 0;
1022 if(getCalibs) {
1023 for(Short_t iRow=0; iRow<kNRows[iStack]; iRow++) { // loop over pad rows
1024 for(Short_t iCol=0; iCol<kNCols; iCol++) { // loop over pad columns
1025 Short_t padSuperRow = iRow;
1026 for(Int_t i=0; i<iStack; i++) padSuperRow = padSuperRow + kNRows[i];
1027 padSuperRowVector[index] = padSuperRow;
1028 Short_t padSuperColumn = iCol;
1029 for(Int_t i=0; i<iSector; i++) padSuperColumn = padSuperColumn + kNCols;
1030 padSuperColumnVector[index] = padSuperColumn;
1031 Short_t channelNo = -1;
1032 Float_t gain = -99.;
1033 if(gainROC && chamberGainFactor) {
1034 channelNo = gainROC->GetChannel(iCol, iRow);
1035 gain = chamberGainFactor->GetValue(chamberNo) * gainROC->GetValue(iCol, iRow);
1036 }
1037 Float_t noise = -99.;
1038 if(noiseROC && chamberNoise)
1039 noise = chamberNoise->GetValue(chamberNo) * noiseROC->GetValue(iCol, iRow);
1040 Float_t vdrift = -99.;
1041 if(vdriftROC && chamberVdrift)
1042 vdrift = chamberVdrift->GetValue(chamberNo) * vdriftROC->GetValue(iCol, iRow);
1043 Float_t t0 = -99.;
1044 if(t0ROC && chamberT0)
1045 t0 = chamberT0->GetValue(chamberNo) + t0ROC->GetValue(iCol, iRow);
1046 Int_t status = -99;
1047 if(statusROC)
1048 status = statusROC->GetStatus(iCol, iRow);
1049 channelVector[index] = channelNo;
1050 rowVector[index] = iRow;
1051 colVector[index] = iCol;
1052 statusVector[index] = status;
1053 gainVector[index] = gain;
1054 noiseVector[index] = noise;
1055 vdriftVector[index] = vdrift;
1056 t0Vector[index] = t0;
1057 index++;
1058 } // end loop over pad columns
1059 } // end loop over pad rows
1060 } // end if(getCalibs)
1061
1062 // get the dcs information
d6a1ec13 1063 AliTRDCalDCSFEEv2 *dcsfeeSOR = 0;
1064 AliTRDCalDCSFEEv2 *dcsfeeEOR = 0;
9bf458e3 1065 if(getDCS) {
1066 if(dcsSOR) dcsfeeSOR = dcsSOR->GetCalDCSFEEObj(chamberNo);
1067 if(dcsEOR) dcsfeeEOR = dcsEOR->GetCalDCSFEEObj(chamberNo);
1068 }
1069
1070 Bool_t sorAndEor = kFALSE;
1071 if(getDCS && dcsfeeSOR && dcsfeeEOR) sorAndEor = kTRUE;
1072 if(getDCS && !dcsfeeSOR && dcsfeeEOR) dcsfeeSOR = dcsfeeEOR;
1073 TVectorD robVector(kROB[iStack]*kMCM);
1074 TVectorD mcmVector(kROB[iStack]*kMCM);
1075 TVectorD sorandeorVector(kROB[iStack]*kMCM);
1076 TVectorD gsmSorVector(kROB[iStack]*kMCM);
1077 TVectorD gsmDeltaVector(kROB[iStack]*kMCM);
1078 TVectorD nimSorVector(kROB[iStack]*kMCM);
1079 TVectorD nimDeltaVector(kROB[iStack]*kMCM);
1080 TVectorD nevSorVector(kROB[iStack]*kMCM);
1081 TVectorD nevDeltaVector(kROB[iStack]*kMCM);
1082 TVectorD nptSorVector(kROB[iStack]*kMCM);
1083 TVectorD nptDeltaVector(kROB[iStack]*kMCM);
1084 TVectorD mcmSuperRowVector(kROB[iStack]*kMCM);
1085 TVectorD mcmSuperColumnVector(kROB[iStack]*kMCM);
1086 for(Int_t ipar=0; ipar<kROB[iStack]*kMCM; ipar++) {
1087 robVector[ipar] = 0; mcmVector[ipar] = 0; sorandeorVector[ipar] = 0;
1088 gsmSorVector[ipar] = 0; gsmDeltaVector[ipar] = 0; nimSorVector[ipar] = 0;
1089 nimDeltaVector[ipar] = 0; nevSorVector[ipar] = 0; nevDeltaVector[ipar] = 0;
1090 nptSorVector[ipar] = 0; nptDeltaVector[ipar] = 0; mcmSuperRowVector[ipar] = 0;
1091 mcmSuperColumnVector[ipar] = 0;
1092 }
1093
1094 Int_t robsRowDirection = kNRows[iStack]/4; // 4 or 3 ROBs per chamber in row direction
1095 Int_t index1 = 0;
1096 if(getDCS && (dcsfeeSOR || dcsfeeEOR) && dcsfeeSOR->GetStatusBit()==0) {
1097 for(Int_t iROB=0; iROB<kROB[iStack]; iROB++) { // loop over ROBs
1098 for(Int_t iMCM=0; iMCM<kMCM; iMCM++) { // loop over MCMs
1099 Short_t superRowMCM = iMCM%4; // 4 MCMs per ROB in row direction
1100 superRowMCM += 4*(iROB%robsRowDirection); // now we have the row of this MCM inside one chamber
1101 for(Int_t kk=0; kk<iStack; kk++) superRowMCM += kNRows[kk]; // add number of rows in previous stacks
1102 Short_t superColumnMCM = iMCM/4; // 4 MCMs per ROB in column direction
1103 superColumnMCM += 4*(iROB/robsRowDirection); // should yield 0 or 1 (2 ROBs per chamber in col direction)
1104 superColumnMCM += iSector*8;
1105 mcmSuperRowVector[index1] = superRowMCM;
1106 mcmSuperColumnVector[index1] = superColumnMCM;
1107 Int_t gsm = dcsfeeSOR->GetMCMGlobalState(iROB, iMCM);
1108 Int_t nim = dcsfeeSOR->GetMCMStateNI(iROB, iMCM);
1109 Int_t nev = dcsfeeSOR->GetMCMEventCnt(iROB, iMCM);
1110 Int_t npt = dcsfeeSOR->GetMCMPtCnt(iROB, iMCM);
1111 Int_t dgsm = -100000;
1112 Int_t dnim = -100000;
1113 Int_t dnev = -100000;
1114 Int_t dnpt = -100000;
1115 if(sorAndEor) {
1116 dgsm = gsm - dcsfeeEOR->GetMCMGlobalState(iROB, iMCM);
1117 dnim = nim - dcsfeeEOR->GetMCMStateNI(iROB, iMCM);
1118 dnev = nev - dcsfeeEOR->GetMCMEventCnt(iROB, iMCM);
1119 dnpt = npt - dcsfeeEOR->GetMCMPtCnt(iROB, iMCM);
1120 if(gsm==-1 && dgsm==0) dgsm = -100000;
1121 if(nim==-1 && dnim==0) dnim = -100000;
1122 if(nev==-1 && dnev==0) dnev = -100000;
1123 if(npt==-1 && dnpt==0) dnpt = -100000;
1124 }
1125 robVector[index1] = iROB;
1126 mcmVector[index1] = iMCM;
1127 sorandeorVector[index1] = sorAndEor;
1128 gsmSorVector[index1] = gsm;
1129 gsmDeltaVector[index1] = dgsm;
1130 nimSorVector[index1] = nim;
1131 nimDeltaVector[index1] = dnim;
1132 nevSorVector[index1] = nev;
1133 nevDeltaVector[index1] = dnev;
1134 nptSorVector[index1] = npt;
1135 nptDeltaVector[index1] = dnpt;
1136 index1++;
1137 } // end loop over MCMs
1138 } // end loop over ROBs
1139 } // end if(getDCS ...)
1140
1141 Double_t alignChamberPars[6];
1142 for(Int_t ipar=0; ipar<6; ipar++) alignChamberPars[ipar]=0;
1143 if(getAlign && alignMan)
1144 alignMan->GetCh(chamberNo, alignChamberPars);
1145
1146 (*treeStreamer)<< "TRDcalibDetails"
1147 << "run=" << currRun
1148 << "SuperModule=" << iSector
1149 << "Stack=" << iStack
1150 << "Layer=" << iLayer
1151 << "Chamber=" << chamberNo;
1152 if(getAlign)
1153 (*treeStreamer)<< "TRDcalibDetails"
1154 << "Align_SM_ShiftRphi=" << alignSMPars[0]
1155 << "Align_SM_ShiftZ=" << alignSMPars[1]
1156 << "Align_SM_ShiftR=" << alignSMPars[2]
1157 << "Align_SM_RotRphi=" << alignSMPars[3]
1158 << "Align_SM_RotZ=" << alignSMPars[4]
1159 << "Align_SM_RotR=" << alignSMPars[5]
1160 << "Align_Ch_ShiftRphi=" << alignChamberPars[0]
1161 << "Align_Ch_ShiftZ=" << alignChamberPars[1]
1162 << "Align_Ch_ShiftR=" << alignChamberPars[2]
1163 << "Align_Ch_RotRphi=" << alignChamberPars[3]
1164 << "Align_Ch_RotZ=" << alignChamberPars[4]
1165 << "Align_Ch_RotR=" << alignChamberPars[5];
1166 if(getCalibs)
1167 (*treeStreamer)<< "TRDcalibDetails"
1168 << "Gain_Mean_Run=" << runMeanGain
1169 << "Gain_RMS_Run=" << runRMSGain
1170 << "Gain_Mean_SuperModule=" << smMeanGain[iSector]
1171 << "Gain_RMS_SuperModule=" << smRMSGain[iSector]
1172 << "Gain_Mean_Chamber=" << chamberMeanGain[chamberNo]
1173 << "Gain_RMS_Chamber=" << chamberRMSGain[chamberNo]
1174 << "Noise_Mean_Run=" << runMeanNoise
1175 << "Noise_RMS_Run=" << runRMSNoise
1176 << "Noise_Mean_SuperModule=" << smMeanNoise[iSector]
1177 << "Noise_RMS_SuperModule=" << smRMSNoise[iSector]
1178 << "Noise_Mean_Chamber=" << chamberMeanNoise[chamberNo]
1179 << "Noise_RMS_Chamber=" << chamberRMSNoise[chamberNo]
1180 << "Vdrift_Mean_Run=" << runMeanVdrift
1181 << "Vdrift_RMS_Run=" << runRMSVdrift
1182 << "Vdrift_Mean_SuperModule=" << smMeanVdrift[iSector]
1183 << "Vdrift_RMS_SuperModule=" << smRMSVdrift[iSector]
1184 << "Vdrift_Mean_Chamber=" << chamberMeanVdrift[chamberNo]
1185 << "Vdrift_RMS_Chamber=" << chamberRMSVdrift[chamberNo]
1186 << "T0_Mean_Run=" << runMeanT0
1187 << "T0_RMS_Run=" << runRMST0
1188 << "T0_Mean_SuperModule=" << smMeanT0[iSector]
1189 << "T0_RMS_SuperModule=" << smRMST0[iSector]
1190 << "T0_Mean_Chamber=" << chamberMeanT0[chamberNo]
1191 << "T0_RMS_Chamber=" << chamberRMST0[chamberNo]
1192 << "Channel.=" << &channelVector
1193 << "Row.=" << &rowVector
1194 << "Column.=" << &colVector
1195 << "PadSuperRow.=" << &padSuperRowVector
1196 << "PadSuperColumn.=" << &padSuperColumnVector
1197 << "Status.=" << &statusVector
1198 << "Gain.=" << &gainVector
1199 << "Noise.=" << &noiseVector
1200 << "Vdrift.=" << &vdriftVector
1201 << "T0.=" << &t0Vector;
1202 if(getDCS)
1203 (*treeStreamer)<< "TRDcalibDetails"
1204 << "ROB.=" << &robVector
1205 << "MCM.=" << &mcmVector
1206 << "MCMSuperRow.=" << &mcmSuperRowVector
1207 << "MCMSuperColumn.=" << &mcmSuperColumnVector
1208 << "SORandEOR.=" << &sorandeorVector
1209 << "gsmSOR.=" << &gsmSorVector
1210 << "gsmDelta.=" << &gsmDeltaVector
1211 << "nimSOR.=" << &nimSorVector
1212 << "nimDelta.=" << &nimDeltaVector
1213 << "nevSOR.=" << &nevSorVector
1214 << "nevDelta.=" << &nevDeltaVector
1215 << "nptSOR.=" << &nptSorVector
1216 << "nptDelta.=" << &nptDeltaVector;
1217 (*treeStreamer)<< "TRDcalibDetails"
1218 << "\n";
1219 } // end loop over stacks
1220 } // end loop over supermodules
1221 } // end loop over layers
1222
1223 // add the run number to the list of runs
1224 runs.ResizeTo(runs.GetNoElements()+1);
1225 runs[runs.GetNoElements()-1] = currRun;
1226
1227 // do cleaning
1228 if(chamberGainFactor) delete chamberGainFactor;
1229 if(padGainFactor) delete padGainFactor;
1230 if(chamberNoise) delete chamberNoise;
1231 if(padNoise) delete padNoise;
1232 if(chamberVdrift) delete chamberVdrift;
1233 if(padVdrift) delete padVdrift;
1234 if(chamberT0) delete chamberT0;
1235 if(padT0) delete padT0;
1236 if(chamberStatus) delete chamberStatus;
1237 if(padStatus) delete padStatus;
1238
1239 // check if we still have run numbers in the file or provided range
1240 if(runListFilename[0]=='\0' && firstRun!=-1 && lastRun!=-1) {
1241 currRun++;
1242 if(currRun>lastRun) break;
1243 }
1244 if(runListFilename[0]!='\0' && in.eof())
1245 break;
1246 } // end loop over runs
1247
1248 treeStreamer->GetFile()->cd();
1249 runs.Write("runs");
1250 delete treeStreamer;
1251 return kTRUE;
1252 // delete treeStreamerDCS;
1253}
1254
1255//_________________________________________________________________________
1256void AliTRDCalibViewer::DumpCalibToTree(const Char_t* inFilename, const Char_t* outFilename)
1257{
1258 //
1259 // extract info from CalPad objects and dump them into a tree to be viewed
1260 //
1261 TTreeSRedirector *treeStreamer = new TTreeSRedirector(outFilename);
1262 //open file and retrieve list of calPad objects
1263 TFile f(inFilename);
1264 TList *l=(TList*)f.GetListOfKeys();
1265
1266 TObjArray arrCalPads;
1267 TObjArray arrSMmean;
1268 TObjArray arrSMrms;
1269 arrCalPads.SetOwner();
1270 arrSMmean.SetOwner();
1271 arrSMrms.SetOwner();
1272
1273 TIter next(l);
1274 TKey *k=0x0;
1275 while ( (k=(TKey*)next()) ){
1276 AliTRDCalPad *pad=dynamic_cast<AliTRDCalPad*>(k->ReadObj());
1277 if (!pad) continue;
1278 arrCalPads.Add(pad);
1279
1280 TVectorD *smMean=new TVectorD(AliTRDcalibDB::kNsector);
1281 TVectorD *smRMS=new TVectorD(AliTRDcalibDB::kNsector);
1282
1283 arrSMmean.Add(smMean);
1284 arrSMrms.Add(smRMS);
1285
1286 ProcessTRDCalibArray(pad, *smMean, *smRMS);
1287 }
1288
1289 Int_t kSuperModuleStatus[18] = {1, 1, 0, 0, 0, 0, // super module status (1- installed, 0- not installed)
1290 0, 1, 1, 1, 1, 0,
1291 0, 0, 0, 0, 0, 1};
1292
1293 AliTRDgeometry trdGeom;
1294 Int_t kNRows[5] = {16, 16, 12, 16, 16}; // number of pad rows in the chambers from each of the 5 stacks
1295
1296 for(Short_t iLayer=0; iLayer<AliTRDgeometry::kNlayer; iLayer++) { // loop over layers
1297 for(Short_t iSM=0; iSM<AliTRDgeometry::kNsector; iSM++) { // loop over supermodules
1298 if(kSuperModuleStatus[iSM]==0)
1299 continue;
1300
1301 for(Short_t iStack=0; iStack<AliTRDgeometry::kNstack; iStack++) { // loop over stacks
1302 AliTRDpadPlane &plane=*trdGeom.GetPadPlane(iLayer, iStack);
1303
1304 Short_t chamberNo = AliTRDgeometry::GetDetector(iLayer, iStack, iSM);
1305 const Int_t nrows=plane.GetNrows();
1306 const Int_t ncols=plane.GetNcols();
1307 const Int_t nchannels=nrows*ncols;
1308// printf("chamberNo: %d (%03d-%03d-%03d)\n", chamberNo,nrows,ncols,nchannels);
1309
1310 TVectorD channelVector(nchannels);
1311 TVectorD rowVector(nchannels);
1312 TVectorD colVector(nchannels);
1313
1314 TVectorD gxVector(nchannels);
1315 TVectorD gyVector(nchannels);
1316 TVectorD gzVector(nchannels);
1317
1318 TVectorD padSuperRowVector(nchannels);
1319 TVectorD padSuperColumnVector(nchannels);
1320
1321 Int_t index = 0;
1322 for(Short_t iRow=0; iRow<nrows; iRow++) { // loop over pad rows
1323 for(Short_t iCol=0; iCol<ncols; iCol++) { // loop over pad columns
1324 Short_t padSuperRow = iRow;
1325 for(Int_t i=0; i<iStack; i++) padSuperRow = padSuperRow + kNRows[i];
1326 padSuperRowVector.GetMatrixArray()[index] = padSuperRow;
1327
1328 Short_t padSuperColumn = iCol;
1329 for(Int_t i=0; i<iSM; i++) padSuperColumn = padSuperColumn + ncols;
1330 padSuperColumnVector.GetMatrixArray()[index] = padSuperColumn;
1331
1332 rowVector.GetMatrixArray()[index] = iRow;
1333 colVector.GetMatrixArray()[index] = iCol;
1334
1335 index++;
1336 } // end loop over pad columns
1337 } // end loop over pad rows
1338
1339 (*treeStreamer)<< "TRDcalibDetails"
1340 << "SuperModule=" << iSM
1341 << "Stack=" << iStack
1342 << "Layer=" << iLayer
1343 << "Chamber=" << chamberNo
1344 //geographical information
1345 << "Channel.=" << &channelVector
1346 << "Row.=" << &rowVector
1347 << "Column.=" << &colVector
1348 << "PadSuperRow.=" << &padSuperRowVector
1349 << "PadSuperColumn.=" << &padSuperColumnVector;
1350// << "gx.=" << &gxVector
1351// << "gy.=" << &gyVector
1352// << "gz.=" << &gzVector;
1353
1354 //
1355 // pad calibrations
1356 //
1357 TObjArray arrTrash;
1358 arrTrash.SetOwner();
1359 Int_t ncalib=arrCalPads.GetEntriesFast();
1360 for (Int_t iCalib=0; iCalib<ncalib; ++iCalib){
1361 AliTRDCalPad *pad=(AliTRDCalPad*)arrCalPads.UncheckedAt(iCalib);
1362 AliTRDCalROC *calROC=pad->GetCalROC(chamberNo);
1363
1364 TVectorD &smMean=*((TVectorD*)arrSMmean.UncheckedAt(iCalib));
1365 TVectorD &smRMS=*((TVectorD*)arrSMrms.UncheckedAt(iCalib));
1366
1367 TString calibName=pad->GetName();
1368
1369 TVectorD *valueVector=new TVectorD(nchannels);
1370 arrTrash.Add(valueVector);
1371
1372 Double_t rocMean=0;
1373 Double_t rocRMS=0;
1374 Double_t rocMedian=0;
1375
1376 if (calROC){
fc2125de 1377 Int_t index2 = 0;
9bf458e3 1378 for(Short_t iRow=0; iRow<nrows; iRow++) {
1379 for(Short_t iCol=0; iCol<ncols; iCol++) {
fc2125de 1380 valueVector->GetMatrixArray()[index2] = calROC->GetValue(iCol,iRow);
1381 index2++;
9bf458e3 1382 }
1383 }
1384 rocMean = calROC->GetMean();
1385 rocRMS = calROC->GetRMS();
1386 rocMedian = calROC->GetMedian();
1387 //check for NaN
1388 if ( !(rocMean<1e30) ) rocMean=0;
1389 if ( !(rocRMS<1e30) ) rocRMS=0;
1390
1391// printf("mean: %f\n",rocMean);
1392// printf("rms: %f\n",rocRMS);
1393// printf("median: %f\n",rocMedian);
1394 }
1395
1396 (*treeStreamer)<< "TRDcalibDetails"
1397 // statistical information
1398 << (Char_t*)((calibName+"_Mean_SuperModule=").Data()) << smMean[iSM]
1399 << (Char_t*)((calibName+"_RMS_SuperModule=").Data()) << smRMS[iSM]
1400 << (Char_t*)((calibName+"_Mean_Chamber=").Data()) << rocMean
1401 << (Char_t*)((calibName+"_RMS_Chamber=").Data()) << rocRMS
1402 << (Char_t*)((calibName+"_Median_Chamber=").Data()) << rocMedian
1403 //pad by pad information
1404 << (Char_t*)((calibName+".=").Data()) << valueVector;
1405
1406 } // end loop over calib objects
1407
1408 (*treeStreamer)<< "TRDcalibDetails"
1409 << "\n";
1410 arrTrash.Delete();
1411 } // end loop over stacks
1412 } // end loop over supermodules
1413 } // end loop over layers
1414 delete treeStreamer;
1415}
1416
1417//_____________________________________________________________________________
1418void AliTRDCalibViewer::ProcessTRDCalibArray(AliTRDCalDet* chamberCalib, AliTRDCalPad *padCalib,
1419 TString parName,
1420 Double_t &runValue, Double_t &runRMS,
1421 TVectorD &chamberValues, TVectorD &chamberValuesRMS,
1422 TVectorD &superModuleValues, TVectorD &superModuleValuesRMS) {
1423 // Process the calibrations for a given run.
1424 // Calculates the run and chamber wise averages
1425 //
1426 if(!chamberCalib) return;
1427 if(!padCalib) return;
1428 Int_t kSuperModuleStatus[18] = {1, 1, 0, 0, 0, 0, // super module status (1- installed, 0- not installed)
1429 0, 1, 1, 1, 1, 0,
1430 0, 0, 0, 0, 0, 1};
1431
1432 // initialize the histograms used for extracting the mean and RMS
1433 TH1F *runWiseHisto = new TH1F("runHisto", "runHisto", 200, -10.0, 10.0);
1434 TH1F *superModuleWiseHisto = new TH1F("smHisto", "smHisto", 200, -10.0, 10.0);
1435 TH1F *chamberWiseHisto = new TH1F("chamberHisto", "chamberHisto", 200, -10.0, 10.0);
1436
1437 // check if the calibration parameter is multiplicative or additive
1438 Bool_t multiplicative = kTRUE;
1439 if(!parName.CompareTo("T0")) multiplicative = kFALSE;
1440
1441 // first iteration (calculate all averages and RMS without discrimination on the SM average)
1442 runWiseHisto->Reset();
1443 for(Int_t iSM = 0; iSM<AliTRDcalibDB::kNsector; iSM++) { // loop over supermodules
1444 // reset the super module histogram
1445 superModuleWiseHisto->Reset();
1446 // check if SM is installed
1447 if(!kSuperModuleStatus[iSM]) continue;
1448 for(Int_t iChamber=iSM*AliTRDcalibDB::kNstack*AliTRDcalibDB::kNlayer;
1449 iChamber < (iSM+1)*AliTRDcalibDB::kNstack*AliTRDcalibDB::kNlayer;
1450 iChamber++) { // loop over chambers in this supermodule
1451 // get the chamber value
1452 Float_t chamberValue = chamberCalib->GetValue(iChamber);
1453 // get the ROC object
1454 AliTRDCalROC *chamberROC = padCalib->GetCalROC(iChamber);
1455 if(!chamberROC)
1456 continue;
1457 chamberWiseHisto->Reset();
1458 for(Int_t iChannel = 0; iChannel < chamberROC->GetNchannels(); iChannel++){ // loop over channels
1459 // calculate the calibration parameter for this pad
1460 Float_t padValue;
1461 if(multiplicative)
1462 padValue = chamberValue * chamberROC->GetValue(iChannel);
1463 else
1464 padValue = chamberValue + chamberROC->GetValue(iChannel);
1465 // fill the run, SM and chamber wise histograms
1466 chamberWiseHisto->Fill(padValue);
1467 // if the parameter is Noise then check if the pad value is not a default one
1468 // Default value is now 1.2!!!! Check with Raphaelle for more informations
1469 if(parName.Contains("Noise") &&
1470 TMath::Abs(padValue-1.2)<0.00001) continue;
1471 superModuleWiseHisto->Fill(padValue);
1472 runWiseHisto->Fill(padValue);
1473 } // end loop over channels
1474 // get the chamber wise mean and RMS
1475 chamberValues[iChamber] = chamberWiseHisto->GetMean();
1476 chamberValuesRMS[iChamber] = chamberWiseHisto->GetRMS();
1477 } // end loop over chambers
1478 // SM wise mean and RMS
1479 superModuleValues[iSM] = superModuleWiseHisto->GetMean();
1480 superModuleValuesRMS[iSM] = superModuleWiseHisto->GetRMS();
1481 } // end loop over supermodules
1482 // run wise mean and RMS
1483 runValue = runWiseHisto->GetMean();
1484 runRMS = runWiseHisto->GetRMS();
1485
1486 // Noise and Gain are finished processing
1487 if(parName.Contains("Noise") || parName.Contains("Gain"))
1488 return;
1489 // second iteration (calculate SM and run wise averages and RMS for Vdrift and T0)
1490 // The pads with calib parameter equal to the SM average are discarded (default value)
1491 runWiseHisto->Reset();
1492 for(Int_t iSM = 0; iSM<AliTRDcalibDB::kNsector; iSM++) { // loop over supermodules
1493 superModuleWiseHisto->Reset();
1494 // eliminate the uninstalled super modules
1495 if(!kSuperModuleStatus[iSM]) continue;
1496 for(Int_t iChamber=iSM*AliTRDcalibDB::kNstack*AliTRDcalibDB::kNlayer;
1497 iChamber < (iSM+1)*AliTRDcalibDB::kNstack*AliTRDcalibDB::kNlayer;
1498 iChamber++) { // loop over chambers
1499 // the chamber value
1500 Float_t chamberValue = chamberCalib->GetValue(iChamber);
1501 AliTRDCalROC *chamberROC = padCalib->GetCalROC(iChamber);
1502 if(!chamberROC)
1503 continue;
1504
1505 for(Int_t iChannel = 0; iChannel < chamberROC->GetNchannels(); iChannel++){ // loop over channels in a chamber
1506 // get the pad value
1507 Float_t padValue;
1508 if(multiplicative)
1509 padValue = chamberValue * chamberROC->GetValue(iChannel);
1510 else
1511 padValue = chamberValue + chamberROC->GetValue(iChannel);
1512 // eliminate from the average and RMS calculation all pads which
1513 // have the calib parameter equal with the SM average
1514 if((parName.Contains("Vdrift") || parName.Contains("T0")) &&
1515 TMath::Abs(padValue-superModuleValues[iSM])<0.00001) continue;
1516 superModuleWiseHisto->Fill(padValue);
1517 runWiseHisto->Fill(padValue);
1518 } // end loop over channels
1519 } // end loop over chambers
1520
1521 superModuleValues[iSM] = superModuleWiseHisto->GetMean();
1522 superModuleValuesRMS[iSM] = superModuleWiseHisto->GetRMS();
1523 } // end loop over super modules
1524 runValue = runWiseHisto->GetMean();
1525 runRMS = runWiseHisto->GetRMS();
1526
1527 delete chamberWiseHisto;
1528 delete superModuleWiseHisto;
1529 delete runWiseHisto;
1530
1531 return;
1532}
1533
1534
1535//_____________________________________________________________________________
1536void AliTRDCalibViewer::ProcessTRDCalibArray(AliTRDCalPad *padCalib,
1537 TVectorD &superModuleValues, TVectorD &superModuleValuesRMS)
1538{
1539// Process the calibrations for a given run.
1540// Calculates the run and chamber wise averages
1541
1542 if(!padCalib) return;
1543 Int_t kSuperModuleStatus[18] = {1, 1, 0, 0, 0, 0, // super module status (1- installed, 0- not installed)
1544 0, 1, 1, 1, 1, 0,
1545 0, 0, 0, 0, 0, 1};
1546
1547 for(Int_t iSM = 0; iSM<AliTRDcalibDB::kNsector; iSM++) { // loop over supermodules
1548 Double_t mean=0;
1549 Double_t rms=0;
1550 Double_t count=0;
1551 if(!kSuperModuleStatus[iSM]) continue;
1552
1553 // loop over chambers in this supermodule
1554 const Int_t nchambers=AliTRDcalibDB::kNstack*AliTRDcalibDB::kNlayer;
1555 for(Int_t iChamber=iSM*nchambers; iChamber < (iSM+1)*nchambers; iChamber++) {
1556 AliTRDCalROC *chamberROC = padCalib->GetCalROC(iChamber);
1557 if(!chamberROC)
1558 continue;
1559
1560 // loop over channels
1561 for(Int_t iChannel = 0; iChannel < chamberROC->GetNchannels(); iChannel++){
1562 mean+=chamberROC->GetValue(iChannel);
1563 rms+=chamberROC->GetValue(iChannel)*chamberROC->GetValue(iChannel);
1564 ++count;
1565 } // end loop over channels
1566 } // end loop over chambers
1567
1568 //calculate mean and rms
1569 if (count>0){
1570 mean/=count;
1571 rms/=count;
1572 rms=TMath::Sqrt(TMath::Abs(mean*mean-rms));
1573 }
1574 // SM wise mean and RMS
1575 superModuleValues[iSM] = mean;
1576 superModuleValuesRMS[iSM] = rms;
1577 } // end loop over supermodules
1578}