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 : ////////////////////////////////////////////////////////////////////////////
17 : // //
18 : // AliTRDCalibChamberStatus: to determine which half chambers are off //
19 : // Produce a AliTRDCalChamberStatus calibration object //
20 : // Check with the AliTRDCalDCSFEEv2 info //
21 : // //
22 : // //
23 : // Authors: //
24 : // J. Book (jbook@ikf.uni-frankfurt.de) //
25 : // R. Bailhache (rbailhache@ikf.uni-frankfurt.de) //
26 : // //
27 : ////////////////////////////////////////////////////////////////////////////
28 :
29 :
30 : //Root includes
31 : #include <THnSparse.h>
32 :
33 : #include <TDirectory.h>
34 : #include <TFile.h>
35 : #include <TAxis.h>
36 : #include <TH2F.h>
37 : #include <TStyle.h>
38 : #include <TCanvas.h>
39 :
40 : //AliRoot includes
41 : #include "AliRawReader.h"
42 :
43 : //header file
44 : #include "AliLog.h"
45 : #include "AliTRDCalibChamberStatus.h"
46 : #include "AliTRDgeometry.h"
47 : #include "AliTRDfeeParam.h"
48 : #include "AliTRDdigitsManager.h"
49 : #include "AliTRDSignalIndex.h"
50 : #include "AliTRDpadPlane.h"
51 : #include "AliTRDCalChamberStatus.h"
52 : #include "AliTRDCalDCSv2.h"
53 : #include "AliTRDCalDCSFEEv2.h"
54 :
55 : #include "AliTRDrawStream.h"
56 : #include "AliTRDseedV1.h"
57 : #include "AliTRDcluster.h"
58 :
59 : #ifdef ALI_DATE
60 : #include "event.h"
61 : #endif
62 :
63 48 : ClassImp(AliTRDCalibChamberStatus) /*FOLD00*/
64 :
65 : //_____________________________________________________________________
66 : AliTRDCalibChamberStatus::AliTRDCalibChamberStatus() : /*FOLD00*/
67 0 : TObject(),
68 0 : fDetector(-1),
69 0 : fNumberOfTimeBins(0),
70 0 : fCounterEventNotEmpty(0),
71 0 : fCalChamberStatus(0x0),
72 0 : fHnSparseI(0x0),
73 0 : fHnSparseHCM(0x0),
74 0 : fHnSparseEvtDet(0x0),
75 0 : fHnSparseDebug(0x0),
76 0 : fHnSparseMCM(0x0),
77 0 : fC1(0x0),
78 0 : fDebugLevel(0)
79 0 : {
80 : //
81 : // default constructor
82 : //
83 :
84 0 : }
85 : //_____________________________________________________________________
86 : AliTRDCalibChamberStatus::AliTRDCalibChamberStatus(const AliTRDCalibChamberStatus &ped) : /*FOLD00*/
87 0 : TObject(ped),
88 0 : fDetector(ped.fDetector),
89 0 : fNumberOfTimeBins(ped.fNumberOfTimeBins),
90 0 : fCounterEventNotEmpty(ped.fCounterEventNotEmpty),
91 0 : fCalChamberStatus(ped.fCalChamberStatus),
92 0 : fHnSparseI(ped.fHnSparseI),
93 0 : fHnSparseHCM(ped.fHnSparseHCM),
94 0 : fHnSparseEvtDet(ped.fHnSparseEvtDet),
95 0 : fHnSparseDebug(ped.fHnSparseDebug),
96 0 : fHnSparseMCM(ped.fHnSparseMCM),
97 0 : fC1(ped.fC1),
98 0 : fDebugLevel(ped.fDebugLevel)
99 0 : {
100 : //
101 : // copy constructor
102 : //
103 :
104 0 : }
105 : //_____________________________________________________________________
106 : AliTRDCalibChamberStatus& AliTRDCalibChamberStatus::operator = (const AliTRDCalibChamberStatus &source)
107 : {
108 : //
109 : // assignment operator
110 : //
111 0 : if (&source == this) return *this;
112 0 : new (this) AliTRDCalibChamberStatus(source);
113 :
114 0 : return *this;
115 0 : }
116 : //_____________________________________________________________________
117 : AliTRDCalibChamberStatus::~AliTRDCalibChamberStatus() /*FOLD00*/
118 0 : {
119 : //
120 : // destructor
121 : //
122 0 : if(fCalChamberStatus){
123 0 : delete fCalChamberStatus;
124 : }
125 0 : if(fHnSparseI) {
126 0 : delete fHnSparseI;
127 : }
128 0 : if(fHnSparseHCM) {
129 0 : delete fHnSparseHCM;
130 : }
131 0 : if(fHnSparseEvtDet) {
132 0 : delete fHnSparseEvtDet;
133 : }
134 0 : if(fHnSparseDebug) {
135 0 : delete fHnSparseDebug;
136 : }
137 0 : if(fHnSparseMCM) {
138 0 : delete fHnSparseMCM;
139 : }
140 0 : if(fC1) {
141 0 : delete fC1;
142 : }
143 0 : }
144 :
145 : //_____________________________________________________________________
146 : void AliTRDCalibChamberStatus::Init()
147 : {
148 : //
149 : // Init the different THnSparse
150 : //
151 : //
152 :
153 : //
154 : // Init the fHnSparseI
155 : //
156 :
157 : //create the map
158 0 : Int_t thnDimEvt[4]; // sm, layer, stack, halfchamber
159 0 : thnDimEvt[0] = 18;
160 0 : thnDimEvt[1] = 6;
161 0 : thnDimEvt[2] = 5;
162 0 : thnDimEvt[3] = 2;
163 : //arrays for lower bounds :
164 0 : Double_t* binEdgesEvt[4];
165 0 : for(Int_t ivar = 0; ivar < 4; ivar++)
166 0 : binEdgesEvt[ivar] = new Double_t[thnDimEvt[ivar] + 1];
167 : //values for bin lower bounds
168 0 : for(Int_t i=0; i<=thnDimEvt[0]; i++) binEdgesEvt[0][i]= 0.0 + (18.0)/thnDimEvt[0]*(Double_t)i;
169 0 : for(Int_t i=0; i<=thnDimEvt[1]; i++) binEdgesEvt[1][i]= 0.0 + (6.0)/thnDimEvt[1]*(Double_t)i;
170 0 : for(Int_t i=0; i<=thnDimEvt[2]; i++) binEdgesEvt[2][i]= 0.0 + (5.0)/thnDimEvt[2]*(Double_t)i;
171 0 : for(Int_t i=0; i<=thnDimEvt[3]; i++) binEdgesEvt[3][i]= 0.0 + (2.0)/thnDimEvt[3]*(Double_t)i;
172 :
173 : //create the THnSparse
174 0 : fHnSparseI = new THnSparseI("NumberOfEntries","NumberOfEntries",4,thnDimEvt);
175 0 : for (int k=0; k<4; k++) {
176 0 : fHnSparseI->SetBinEdges(k,binEdgesEvt[k]);
177 : }
178 0 : fHnSparseI->Sumw2();
179 :
180 : //
181 : // Init the fHnSparseHCM (THnSparseI)
182 : //
183 :
184 : //create the THnSparse
185 0 : fHnSparseHCM = new THnSparseI("HCMerrors","HCMerrors",4,thnDimEvt);
186 0 : for (int k=0; k<4; k++) {
187 0 : fHnSparseHCM->SetBinEdges(k,binEdgesEvt[k]);
188 : }
189 0 : fHnSparseHCM->Sumw2();
190 :
191 :
192 : //---------//
193 : // Debug //
194 0 : if(fDebugLevel > 0) {
195 :
196 : //
197 : // Init the fHnSparseEvtDet (THnSparseI)
198 : //
199 :
200 : //create the map
201 0 : Int_t thnDimEvts[3]; // event, detector, halfchamber
202 0 : thnDimEvts[0] = 10000;
203 0 : thnDimEvts[1] = 540;
204 0 : thnDimEvts[2] = 2;
205 : //arrays for lower bounds :
206 0 : Double_t* binEdgesEvts[3];
207 0 : for(Int_t ivar = 0; ivar < 3; ivar++)
208 0 : binEdgesEvts[ivar] = new Double_t[thnDimEvts[ivar] + 1];
209 : //values for bin lower bounds
210 0 : for(Int_t i=0; i<=thnDimEvts[0]; i++) binEdgesEvts[0][i]= 0.0 + (10000.0)/thnDimEvts[0]*(Double_t)i;
211 0 : for(Int_t i=0; i<=thnDimEvts[1]; i++) binEdgesEvts[1][i]= 0.0 + (540.0)/thnDimEvts[1]*(Double_t)i;
212 0 : for(Int_t i=0; i<=thnDimEvts[2]; i++) binEdgesEvts[2][i]= 0.0 + (2.0)/thnDimEvts[2]*(Double_t)i;
213 :
214 : //create the THnSparse
215 0 : fHnSparseEvtDet = new THnSparseI("NumberOfEntriesPerEvent","NumberOfEntriesPerEvent",3,thnDimEvts);
216 0 : for (int k=0; k<3; k++) {
217 0 : fHnSparseEvtDet->SetBinEdges(k,binEdgesEvts[k]);
218 : }
219 0 : fHnSparseEvtDet->Sumw2();
220 :
221 : //
222 : // Init the fHnSparseDebug (THnSparseI)
223 : //
224 :
225 : //create the THnSparse
226 0 : fHnSparseDebug = new THnSparseI("NumberOfDifferentDecisions","NumberOfDifferentDecisions",4,thnDimEvt);
227 0 : for (int k=0; k<4; k++) {
228 0 : fHnSparseDebug->SetBinEdges(k,binEdgesEvt[k]);
229 : }
230 0 : fHnSparseDebug->Sumw2();
231 :
232 : //
233 : // Init the fHnSparseMCM (THnSparseI)
234 : //
235 :
236 : //create the map
237 0 : Int_t thnDimEvtt[6]; // sm, layer, stack, ROB, MCM
238 0 : thnDimEvtt[0] = 18;
239 0 : thnDimEvtt[1] = 6;
240 0 : thnDimEvtt[2] = 5;
241 0 : thnDimEvtt[3] = 8;
242 0 : thnDimEvtt[4] = 18;
243 0 : thnDimEvtt[5] = 18;
244 : //arrays for lower bounds :
245 0 : Double_t* binEdgesEvtt[6];
246 0 : for(Int_t ivar = 0; ivar < 6; ivar++)
247 0 : binEdgesEvtt[ivar] = new Double_t[thnDimEvtt[ivar] + 1];
248 : //values for bin lower bounds
249 0 : for(Int_t i=0; i<=thnDimEvtt[0]; i++) binEdgesEvtt[0][i]= 0.0 + (18.0)/thnDimEvtt[0]*(Double_t)i;
250 0 : for(Int_t i=0; i<=thnDimEvtt[1]; i++) binEdgesEvtt[1][i]= 0.0 + (6.0)/thnDimEvtt[1]*(Double_t)i;
251 0 : for(Int_t i=0; i<=thnDimEvtt[2]; i++) binEdgesEvtt[2][i]= 0.0 + (5.0)/thnDimEvtt[2]*(Double_t)i;
252 0 : for(Int_t i=0; i<=thnDimEvtt[3]; i++) binEdgesEvtt[3][i]= 0.0 + (8.0)/thnDimEvtt[3]*(Double_t)i;
253 0 : for(Int_t i=0; i<=thnDimEvtt[4]; i++) binEdgesEvtt[4][i]= 0.0 + (18.0)/thnDimEvtt[4]*(Double_t)i;
254 0 : for(Int_t i=0; i<=thnDimEvtt[5]; i++) binEdgesEvtt[5][i]= 0.0 + (18.0)/thnDimEvtt[5]*(Double_t)i;
255 :
256 : //create the THnSparse
257 0 : fHnSparseMCM = new THnSparseI("MCMerrorDCS","MCMerrorDCS",6,thnDimEvtt);
258 0 : for (int k=0; k<6; k++) {
259 0 : fHnSparseMCM->SetBinEdges(k,binEdgesEvtt[k]);
260 : }
261 0 : fHnSparseMCM->Sumw2();
262 :
263 0 : }
264 : // Debug //
265 : //---------//
266 :
267 0 : }
268 : //_____________________________________________________________________
269 : void AliTRDCalibChamberStatus::ProcessTrack(const AliTRDtrackV1 * trdTrack)
270 : {
271 : //
272 : // Track Processing to get half chamber status
273 : //
274 : //
275 :
276 :
277 : const AliTRDseedV1 *tracklet = 0x0;
278 : AliTRDcluster *cluster;
279 : //////////////////////////////////////
280 : // Loop tracklets
281 : /////////////////////////////////////
282 0 : for(Int_t itr = 0; itr < 6; ++itr){
283 :
284 0 : if(!(tracklet = trdTrack->GetTracklet(itr))) continue;
285 0 : if(!tracklet->IsOK()) continue;
286 :
287 : // Loop on clusters
288 0 : for(int ic=0; ic<AliTRDseedV1::kNtb; ++ic){
289 0 : if((cluster = tracklet->GetClusters(ic))) {
290 : //printf("ic %d\n",ic);
291 0 : break;
292 : }
293 : }
294 0 : if(!cluster) continue;
295 :
296 0 : Int_t det = cluster->GetDetector();
297 0 : Int_t layer = AliTRDgeometry::GetLayer(det);
298 0 : Int_t sm = AliTRDgeometry::GetSector(det);
299 0 : Int_t stac = AliTRDgeometry::GetStack(det);
300 :
301 0 : Int_t col = cluster->GetPadCol();
302 0 : Int_t iMcm = (Int_t)(col/18); // current group of 18 col pads
303 : Double_t rphi = 0.5;
304 0 : if(iMcm > 3) rphi = 1.5;
305 :
306 0 : Double_t val[4] = {static_cast<Double_t>(sm),static_cast<Double_t>(layer),static_cast<Double_t>(stac),static_cast<Double_t>(rphi)};
307 0 : if(fHnSparseI->GetBinContent((const Int_t*)val)<2147483646) fHnSparseI->Fill(&val[0]);
308 0 : }
309 :
310 0 : }
311 : //_____________________________________________________________________
312 : void AliTRDCalibChamberStatus::ProcessEvent(AliRawReader * rawReader, Int_t nevents_physics)
313 : {
314 : //
315 : // Event Processing loop with AliTRDrawStream
316 : //
317 : //
318 :
319 : Bool_t notEmpty = kFALSE;
320 :
321 0 : AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager(kTRUE);
322 0 : digitsManager->CreateArrays();
323 :
324 0 : AliTRDrawStream *rawStream = new AliTRDrawStream(rawReader);
325 0 : rawStream->SetDigitsManager(digitsManager);
326 : // rawStream->SetNoErrorWarning();
327 : // rawStream->SetSharedPadReadout(kFALSE);
328 :
329 :
330 : Int_t det = 0;
331 0 : while ((det = rawStream->NextChamber(digitsManager, NULL, NULL)) >= 0) {
332 :
333 : //nextchamber loop
334 :
335 : // do the QA analysis
336 0 : if (digitsManager->GetIndexes(det)->HasEntry()) {//QA
337 : // printf("there is ADC data on this chamber!\n");
338 :
339 0 : AliTRDSignalIndex *indexes = digitsManager->GetIndexes(det);
340 0 : if (indexes->IsAllocated() == kFALSE) {
341 : // AliError("Indexes do not exist!");
342 0 : break;
343 : }
344 :
345 0 : Int_t iRow = 0;
346 0 : Int_t iCol = 0;
347 0 : indexes->ResetCounters();
348 :
349 0 : while (indexes->NextRCIndex(iRow, iCol)){
350 0 : Int_t iMcm = (Int_t)(iCol/18); // current group of 18 col pads
351 :
352 0 : Int_t layer = AliTRDgeometry::GetLayer(det);
353 0 : Int_t sm = AliTRDgeometry::GetSector(det);
354 0 : Int_t stac = AliTRDgeometry::GetStack(det);
355 : Double_t rphi = 0.5;
356 0 : if(iMcm > 3) rphi = 1.5;
357 :
358 0 : Double_t val[4] = {static_cast<Double_t>(sm),static_cast<Double_t>(layer),static_cast<Double_t>(stac),static_cast<Double_t>(rphi)};
359 0 : fHnSparseI->Fill(&val[0]);
360 : notEmpty = kTRUE;
361 :
362 : //---------//
363 : // Debug //
364 0 : if(fDebugLevel > 0) {
365 0 : Int_t detector = AliTRDgeometry::GetDetector(layer,stac,sm);
366 0 : Double_t valu[3] = {static_cast<Double_t>(nevents_physics),static_cast<Double_t>(detector),rphi};
367 0 : fHnSparseEvtDet->Fill(&valu[0]);
368 0 : }
369 : // Debug //
370 : //---------//
371 0 : }
372 :
373 0 : }
374 0 : digitsManager->ClearArrays(det);
375 : }
376 :
377 0 : if(notEmpty) fCounterEventNotEmpty++;
378 :
379 0 : delete digitsManager;
380 0 : delete rawStream;
381 :
382 0 : }
383 : //_____________________________________________________________________
384 : Bool_t AliTRDCalibChamberStatus::TestEventHisto(Int_t nevent) /*FOLD00*/
385 : {
386 : //
387 : // Test event loop
388 : // fill the fHnSparseI with entries
389 : //
390 :
391 0 : AliTRDgeometry geo;
392 :
393 :
394 0 : for(Int_t ievent=0; ievent<nevent; ievent++){
395 0 : for (Int_t ism=0; ism<18; ism++){
396 0 : for (Int_t istack=0; istack<5; istack++){
397 0 : for (Int_t ipl=0; ipl<6; ipl++){
398 0 : for (Int_t icol=0; icol<geo.GetColMax(ipl); icol++){
399 : Int_t side = 0;
400 0 : if(icol > 72) side = 1;
401 0 : Double_t val[4] = {static_cast<Double_t>(ism),static_cast<Double_t>(ipl),static_cast<Double_t>(istack),static_cast<Double_t>(side)};
402 0 : fHnSparseI->Fill(&val[0]);
403 0 : }
404 : }
405 : }
406 : }
407 : }
408 :
409 : return kTRUE;
410 :
411 0 : }
412 : //_____________________________________________________________________
413 : void AliTRDCalibChamberStatus::AnalyseHisto(Int_t limit, Double_t chamberlimit) /*FOLD00*/
414 : {
415 : //
416 : // Create the AliTRDCalChamberStatus according to the fHnSparseI
417 : //
418 :
419 0 : if(fCalChamberStatus) delete fCalChamberStatus;
420 0 : fCalChamberStatus = new AliTRDCalChamberStatus();
421 :
422 : //printf("test0\n");
423 :
424 : // Check if enough events/tracklets per halfchamber to say something
425 : Double_t mean=0.0; //number of tracklets per HCS
426 0 : Int_t coord2[4];
427 0 : for(Int_t bin = 0; bin < fHnSparseI->GetNbins(); bin++) {
428 : //if(fHnSparseI->GetBinContent(bin,coord2)==0.0) printf(" bin shouldnt be empty!!\n");
429 0 : mean+=fHnSparseI->GetBinContent(bin,coord2);
430 : }
431 0 : if(fHnSparseI->GetNbins() > 0.0) mean/=fHnSparseI->GetNbins();
432 : //printf(" mean tracklets per halfchamber %.3e \n",mean);
433 0 : if((fCounterEventNotEmpty < limit) && (mean < limit)) {
434 : // Say all good
435 0 : for (Int_t idet=0; idet<540; idet++) {
436 0 : fCalChamberStatus->SetStatus(idet,AliTRDCalChamberStatus::kGood);
437 : }
438 0 : return;
439 : }
440 :
441 : //printf("test1\n");
442 :
443 : // set all chambers to NoData
444 0 : for (Int_t idet=0; idet<540; idet++) {
445 0 : fCalChamberStatus->SetStatus(idet,AliTRDCalChamberStatus::kNoData);
446 : }
447 :
448 : // set status according to fHnSparseI
449 0 : Int_t coord[4];
450 0 : for(Int_t bin = 0; bin < fHnSparseI->GetNbins(); bin++) {
451 :
452 0 : Double_t content = fHnSparseI->GetBinContent(bin,coord);
453 :
454 : // layer, stack, sector
455 0 : Int_t detector = AliTRDgeometry::GetDetector(coord[1]-1,coord[2]-1,coord[0]-1);
456 :
457 0 : if(content<chamberlimit*mean) {
458 : //printf("Number of entries for detector %03d-%s: %.3e -> %.3f \n",detector,(coord[3]-1==0?"A":"B"),content,content/mean);
459 0 : continue;
460 : }
461 : //
462 : // Check which halfchamber side corresponds to the bin number (0=A, 1=B)
463 : // Change the status accordingly
464 : //
465 0 : if(coord[3]-1==0) { // HCS-A
466 0 : fCalChamberStatus->SetStatus(detector,AliTRDCalChamberStatus::kGood);
467 0 : fCalChamberStatus->UnsetStatusBit(detector,AliTRDCalChamberStatus::kNoDataHalfChamberSideA); // A has data
468 : //fCalChamberStatus->UnsetStatusBit(detector,AliTRDCalChamberStatus::kNoData);
469 0 : }
470 : else { //HCS-B
471 : fCalChamberStatus->SetStatus(detector,AliTRDCalChamberStatus::kGood);
472 0 : fCalChamberStatus->UnsetStatusBit(detector,AliTRDCalChamberStatus::kNoDataHalfChamberSideB); // B has data
473 : //fCalChamberStatus->UnsetStatusBit(detector,AliTRDCalChamberStatus::kNoData);
474 : }
475 0 : }
476 :
477 : // printf
478 : //for (Int_t idet=0; idet<540; idet++) {
479 : // if(fCalChamberStatus->IsNoData(idet)) printf("No Data: chamber %d\n",idet);
480 : //}
481 :
482 :
483 0 : }
484 : //_____________________________________________________________________
485 : void AliTRDCalibChamberStatus::CheckEORStatus(const AliTRDCalDCSv2 *calDCS) /*FOLD00*/
486 : {
487 : //
488 : // Correct the AliTRDCalChamberStatus according to the AliTRDCalDCSv2
489 : // Using globale state of the HalfChamberMerger (HCM)
490 : //
491 0 : for(Int_t det = 0; det < 540; det++) {
492 0 : AliTRDCalDCSFEEv2* calDCSFEEEOR = calDCS->GetCalDCSFEEObj(det);
493 :
494 0 : if(!calDCSFEEEOR) continue;
495 :
496 : // MCM Global State Machine State Definitions
497 : // low_power = 0,
498 : // test = 1,
499 : // wait_pre = 3,
500 : // preproc = 7,
501 : // zero_sp = 8,
502 : // full_rd = 9,
503 : // clear_st = 11,
504 : // wait_L1 = 12,
505 : // tr_send = 14,
506 : // tr_proc = 15
507 :
508 0 : Int_t sm = AliTRDgeometry::GetSector(det);
509 0 : Int_t lay = AliTRDgeometry::GetLayer(det);
510 0 : Int_t stac = AliTRDgeometry::GetStack(det);
511 :
512 : Int_t stateA = 0; // 0=bad, 1=good state
513 : Int_t stateB = 0;
514 :
515 : // loop over all mcm to define DCS-HCS
516 0 : for(Int_t ii = 0; ii < 8; ii++) { //ROB loop
517 0 : for(Int_t i = 0; i < 18; i++) { //MCM loop
518 :
519 0 : Int_t side = ii%2; // 0=sideA, 1=sideB
520 0 : Int_t cstate = calDCSFEEEOR->GetMCMGlobalState(ii,i); //current mcm state
521 :
522 0 : if(cstate==3) {
523 0 : switch(side) {
524 0 : case 0: stateA=1; break;
525 0 : case 1: stateB=1; break;
526 : }
527 : }
528 : }
529 : }
530 :
531 : //---------//
532 : // Debug //
533 0 : if(fDebugLevel > 0) {
534 0 : if( ((fCalChamberStatus->GetStatus(det) <= 1) && (stateA==0 || stateB==0)) ||
535 0 : ((fCalChamberStatus->GetStatus(det) == 2) && (stateA==1 || stateB==1)) ||
536 0 : ((fCalChamberStatus->GetStatus(det) == 3) && (stateA==1 || stateB==0)) ||
537 0 : ((fCalChamberStatus->GetStatus(det) == 4) && (stateB==0 || stateB==1)) )
538 : {
539 : //printf(" Different half chamber status in DCS and DATA!!\n");
540 0 : Double_t val[4] = {static_cast<Double_t>(sm),static_cast<Double_t>(lay),static_cast<Double_t>(stac),1};
541 0 : fHnSparseDebug->Fill(&val[0]);
542 :
543 : // Fill MCM status map
544 0 : for(Int_t ii = 0; ii < 8; ii++) { //ROB loop
545 0 : for(Int_t i = 0; i < 18; i++) { //MCM loop
546 0 : Double_t valss[6] = {static_cast<Double_t>(sm),static_cast<Double_t>(lay),static_cast<Double_t>(stac),static_cast<Double_t>(ii),static_cast<Double_t>(i)
547 0 : ,static_cast<Double_t>(calDCSFEEEOR->GetMCMGlobalState(ii,i))};
548 0 : fHnSparseMCM->Fill(&valss[0]);
549 :
550 0 : }
551 : }
552 0 : }
553 : }
554 : //---------//
555 : // Debug //
556 :
557 : //---------------------------------------
558 : // Change the status according to DCS
559 : //---------------------------------------
560 0 : Int_t statusData = fCalChamberStatus->GetStatus(det);
561 0 : switch(statusData)
562 : {
563 : case 1:
564 0 : if(stateA==0 && stateB==0) fCalChamberStatus->SetStatus(det,2); // completely masked from DCS
565 0 : if(stateA==1 && stateB==0) fCalChamberStatus->SetStatus(det,4); // Only B side masked from DCS
566 0 : if(stateA==0 && stateB==1) fCalChamberStatus->SetStatus(det,3); // Only A side masked from DCS
567 0 : if(stateA==1 && stateB==1) fCalChamberStatus->SetStatus(det,1);
568 : break;
569 : case 2: // completely masked from DATA
570 0 : if(stateA==0 && stateB==0) fCalChamberStatus->SetStatus(det,2); // completely masked from DCS
571 : break;
572 : case 3: // Only A side masked from DATA
573 0 : if(stateA==0 && stateB==0) fCalChamberStatus->SetStatus(det,2); // completely masked from DCS
574 0 : if(stateA==1 && stateB==0) fCalChamberStatus->SetStatus(det,2); // Only B side masked from DCS
575 0 : if(stateA==0 && stateB==1) fCalChamberStatus->SetStatus(det,3); // Only A side masked from DCS
576 0 : if(stateA==1 && stateB==1) fCalChamberStatus->SetStatus(det,3);
577 : break;
578 : case 4: // Only B side masked from DATA
579 0 : if(stateA==0 && stateB==0) fCalChamberStatus->SetStatus(det,2); // completely masked from DCS
580 0 : if(stateA==1 && stateB==0) fCalChamberStatus->SetStatus(det,4); // Only B side masked from DCS
581 0 : if(stateA==0 && stateB==1) fCalChamberStatus->SetStatus(det,2); // Only A side masked from DCS
582 0 : if(stateA==1 && stateB==1) fCalChamberStatus->SetStatus(det,4);
583 : break;
584 : }
585 :
586 0 : }
587 :
588 0 : }
589 :
590 : //_____________________________________________________________________________________
591 : void AliTRDCalibChamberStatus::Add(const AliTRDCalibChamberStatus *calibChamberStatus) /*FOLD00*/
592 : {
593 : //
594 : // Add the THnSparseI of this calibChamberStatus
595 : //
596 :
597 0 : fCounterEventNotEmpty += calibChamberStatus->GetNumberEventNotEmpty();
598 :
599 0 : THnSparseI *hnSparseI = calibChamberStatus->GetSparseI();
600 0 : if(!hnSparseI) return;
601 :
602 0 : if(!fHnSparseI) {
603 0 : fHnSparseI = (THnSparseI *) hnSparseI->Clone();
604 0 : }
605 : else {
606 0 : fHnSparseI->Add(hnSparseI);
607 : }
608 :
609 :
610 0 : }
611 : //_____________________________________________________________________
612 : void AliTRDCalibChamberStatus::DumpToFile(const Char_t *filename, const Char_t *dir, Bool_t append) /*FOLD00*/
613 : {
614 : //
615 : // Write class to file
616 : //
617 :
618 0 : TString sDir(dir);
619 0 : TString option;
620 :
621 0 : if ( append )
622 0 : option = "update";
623 : else
624 0 : option = "recreate";
625 :
626 0 : TDirectory *backup = gDirectory;
627 0 : TFile f(filename,option.Data());
628 0 : f.cd();
629 0 : if ( !sDir.IsNull() ){
630 0 : f.mkdir(sDir.Data());
631 0 : f.cd(sDir);
632 : }
633 0 : this->Write();
634 0 : f.Close();
635 :
636 0 : if ( backup ) backup->cd();
637 0 : }
638 : //_____________________________________________________________________________
639 : TH2D* AliTRDCalibChamberStatus::PlotSparseI(Int_t sm,Int_t side)
640 : {
641 : //
642 : // Plot number of entries for supermodule sm
643 : // as a function of layer and stack
644 : //
645 :
646 0 : if(!fHnSparseI) return 0x0;
647 :
648 0 : fHnSparseI->GetAxis(0)->SetRange(sm+1,sm+1);
649 0 : fHnSparseI->GetAxis(3)->SetRange(side+1,side+1);
650 0 : TH2D *h2 = fHnSparseI->Projection(1,2);
651 :
652 :
653 : return h2;
654 :
655 0 : }
656 : //_____________________________________________________________________
657 : TH2F *AliTRDCalibChamberStatus::MakeHisto2DSmPlEORStatus(const AliTRDCalDCSv2 *calDCS, Int_t sm, Int_t pl) /*FOLD00*/
658 : {
659 : //
660 : // Plot globale state of the HalfChamberMerger (HCM)
661 : //
662 0 : AliTRDfeeParam *paramfee = AliTRDfeeParam::Instance();
663 :
664 0 : AliTRDgeometry *trdGeo = new AliTRDgeometry();
665 0 : AliTRDpadPlane *padPlane0 = trdGeo->GetPadPlane(pl,0); // layer,stack
666 0 : Double_t row0 = padPlane0->GetRow0();
667 0 : Double_t col0 = padPlane0->GetCol0();
668 :
669 0 : char name[1000];
670 0 : snprintf(name,1000,"%s DCS status sm %d pl %d",GetTitle(),sm,pl);
671 0 : TH2F * his = new TH2F( name, name, 88,-TMath::Abs(row0),TMath::Abs(row0)
672 0 : ,148,-TMath::Abs(col0),TMath::Abs(col0));
673 :
674 :
675 : // Where we begin
676 0 : Int_t offsetsmpl = 30*sm+pl;
677 : Int_t nstack = 5;
678 : Int_t ncols = 144;
679 :
680 0 : for (Int_t k = 0; k < nstack; k++){
681 0 : Int_t det = offsetsmpl+k*6;
682 0 : Int_t stac = AliTRDgeometry::GetStack(det);
683 0 : AliTRDCalDCSFEEv2* calDCSFEEEOR = calDCS->GetCalDCSFEEObj(det);
684 0 : if(!calDCSFEEEOR) { continue;}
685 0 : for (Int_t icol=0; icol<ncols; icol++){
686 : Int_t nrows = 16;
687 0 : if(stac==2) nrows = 12;
688 0 : for (Int_t irow=0; irow<nrows; irow++){
689 : Int_t binz = 0;
690 0 : Int_t kb = 5-1-k;
691 0 : Int_t krow = nrows-1-irow;
692 0 : Int_t kcol = ncols-1-icol;
693 0 : if(kb > 2) binz = 16*(kb-1)+12+krow+1+2*(kb+1);
694 0 : else binz = 16*kb+krow+1+2*(kb+1);
695 0 : Int_t biny = kcol+1+2;
696 : // Take the value
697 0 : Int_t mcm = paramfee->GetMCMfromPad(irow,icol);
698 0 : Int_t rob = paramfee->GetROBfromPad(irow,icol);
699 0 : if(mcm < 0) AliWarning("Problem with mcm number");
700 0 : Int_t state = calDCSFEEEOR->GetMCMGlobalState(rob,TMath::Abs(mcm));
701 0 : his->SetBinContent(binz,biny,state);
702 : }
703 : }
704 0 : for(Int_t icol = 1; icol < 147; icol++){
705 0 : for(Int_t l = 0; l < 2; l++){
706 : Int_t binz = 0;
707 0 : Int_t kb = 5-1-k;
708 0 : if(kb > 2) binz = 16*(kb-1)+12+1+2*(kb+1)-(l+1);
709 0 : else binz = 16*kb+1+2*(kb+1)-(l+1);
710 0 : his->SetBinContent(binz,icol,16.0);
711 : }
712 : }
713 0 : }
714 :
715 0 : for(Int_t icol = 1; icol < 147; icol++){
716 0 : his->SetBinContent(88,icol,16.0);
717 0 : his->SetBinContent(87,icol,16.0);
718 : }
719 0 : for(Int_t irow = 1; irow < 89; irow++){
720 0 : his->SetBinContent(irow,1,16.0);
721 0 : his->SetBinContent(irow,2,16.0);
722 0 : his->SetBinContent(irow,147,16.0);
723 0 : his->SetBinContent(irow,148,16.0);
724 : }
725 :
726 0 : his->SetXTitle("z (cm)");
727 0 : his->SetYTitle("y (cm)");
728 0 : his->SetMaximum(12);
729 0 : his->SetMinimum(0.0);
730 0 : his->SetStats(0);
731 :
732 0 : return his;
733 :
734 0 : }
735 : //_____________________________________________________________________________
736 : TCanvas* AliTRDCalibChamberStatus::PlotHistos2DSmEORStatus(AliTRDCalDCSv2 *calDCS, Int_t sm, const Char_t *name)
737 : {
738 : //
739 : // Make 2D graph
740 : //
741 :
742 0 : gStyle->SetPalette(1);
743 0 : fC1 = new TCanvas(name,name,50,50,600,800);
744 0 : fC1->Divide(3,2);
745 0 : fC1->cd(1);
746 0 : MakeHisto2DSmPlEORStatus(calDCS,sm,0)->Draw("colz");
747 0 : fC1->cd(2);
748 0 : MakeHisto2DSmPlEORStatus(calDCS,sm,1)->Draw("colz");
749 0 : fC1->cd(3);
750 0 : MakeHisto2DSmPlEORStatus(calDCS,sm,2)->Draw("colz");
751 0 : fC1->cd(4);
752 0 : MakeHisto2DSmPlEORStatus(calDCS,sm,3)->Draw("colz");
753 0 : fC1->cd(5);
754 0 : MakeHisto2DSmPlEORStatus(calDCS,sm,4)->Draw("colz");
755 0 : fC1->cd(6);
756 0 : MakeHisto2DSmPlEORStatus(calDCS,sm,5)->Draw("colz");
757 :
758 0 : return fC1;
759 :
760 0 : }
761 :
762 :
763 :
|