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