1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 /// \file MUONStatusMap.C
20 /// \brief Macro to check/test pad status and pad status map makers
22 /// \author Laurent Aphecetche
24 #if !defined(__CINT__) || defined(__MAKECINT__)
25 #include "AliCDBManager.h"
26 #include "AliCDBEntry.h"
29 #include "AliMpDEManager.h"
30 #include "AliMUONCDB.h"
31 #include "AliMUONCalibrationData.h"
32 #include "AliMUONPadStatusMaker.h"
33 #include "AliMUONPadStatusMapMaker.h"
34 #include "AliMUONRecoParam.h"
35 #include "AliMUONVCalibParam.h"
36 #include "AliMUONVStore.h"
37 #include "AliMpConstants.h"
38 #include "AliMpDDLStore.h"
39 #include "AliMpDetElement.h"
40 #include "AliMpManuIterator.h"
41 #include "Riostream.h"
56 Int_t NTOTALNUMBEROFPADS(1064008);
59 //______________________________________________________________________________
60 void ReadIntegers(const char* filename, std::vector<int>& integers)
62 /// Read integers from filename, where integers are either
63 /// separated by "," or by return carriage
64 ifstream in(gSystem->ExpandPathName(filename));
69 in.getline(line,10000,'\n');
73 if (sline.Contains(","))
75 TObjArray* a = sline.Tokenize(",");
78 while ( ( s = static_cast<TObjString*>(next()) ) )
80 integers.push_back(s->String().Atoi());
85 integers.push_back(sline.Atoi());
89 integers.push_back(i);
93 std::sort(integers.begin(),integers.end());
97 //______________________________________________________________________________
98 void MUONStatusMap(AliMUONVStore*& vstatus,
99 AliMUONVStore*& vstatusMap,
100 const char* cdbStorage = "alien://folder=/alice/data/2011/OCDB",
101 Int_t runNumber=145292)
104 AliCDBManager::Instance()->SetDefaultStorage(cdbStorage);
105 AliCDBManager::Instance()->SetRun(runNumber);
107 AliMUONCDB::LoadMapping();
109 AliMUONRecoParam* recoParam = AliMUONCDB::LoadRecoParam();
111 AliMUONCalibrationData cd(runNumber);
113 AliMUONPadStatusMaker statusMaker(cd);
115 statusMaker.SetLimits(*recoParam);
117 UInt_t mask = recoParam->PadGoodnessMask();
119 statusMaker.Report(mask);
121 vstatus = static_cast<AliMUONVStore*>(statusMaker.StatusStore()->Clone());
123 const Bool_t deferredInitialization = kFALSE;
125 AliMUONPadStatusMapMaker statusMapMaker(cd,mask,deferredInitialization);
127 vstatusMap = static_cast<AliMUONVStore*>(statusMapMaker.StatusMap()->Clone());
130 //______________________________________________________________________________
131 Int_t GetBadChannels(Int_t runNumber,
140 if (!AliCDBManager::Instance()->IsDefaultStorageSet())
142 // AliCDBManager::Instance()->SetDefaultStorage("alien://folder=/alice/data/2011/OCDB?cacheFold=/local/cdb");
143 AliCDBManager::Instance()->SetDefaultStorage("raw://");
146 AliCDBManager::Instance()->SetRun(runNumber);
148 AliMpCDB::LoadDDLStore();
150 AliMUONCalibrationData cd(runNumber,true);
152 AliMUONPadStatusMaker statusMaker(cd);
154 AliMUONRecoParam* recoParam = AliMUONCDB::LoadRecoParam();
156 statusMaker.SetLimits(*recoParam);
158 AliMpManuIterator it;
159 Int_t detElemId, manuId;
162 AliMUONPadStatusMaker::kPedMeanZero |
163 AliMUONPadStatusMaker::kPedMeanTooLow |
164 AliMUONPadStatusMaker::kPedMeanTooHigh |
165 AliMUONPadStatusMaker::kPedSigmaTooLow |
166 AliMUONPadStatusMaker::kPedSigmaTooHigh );
169 AliMUONPadStatusMaker::kHVError |
170 AliMUONPadStatusMaker::kHVTooLow |
171 AliMUONPadStatusMaker::kHVTooHigh |
172 AliMUONPadStatusMaker::kHVChannelOFF |
173 AliMUONPadStatusMaker::kHVSwitchOFF );
177 AliMUONPadStatusMaker::kManuOccupancyTooHigh
189 while ( it.Next(detElemId,manuId) )
191 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
193 if ( chamber >= 0 && AliMpDEManager::GetChamberId(detElemId) != chamber ) continue;
195 for ( Int_t manuChannel = 0; manuChannel < AliMpConstants::ManuNofChannels(); ++manuChannel )
197 if ( de->IsConnectedChannel(manuId,manuChannel) )
201 UInt_t status = statusMaker.PadStatus(detElemId, manuId, manuChannel);
203 if (!status) continue;
207 if ( status & AliMUONPadStatusMaker::BuildStatus(pedCheck,0,0,0) )
213 if ( status & AliMUONPadStatusMaker::BuildStatus(0,hvCheck,0,0) )
219 if ( status & AliMUONPadStatusMaker::BuildStatus(0,0,0,occCheck) )
225 if ( status & recoParam->PadGoodnessMask() )
230 if ( status & AliMUONPadStatusMaker::BuildStatus(AliMUONPadStatusMaker::kMissing,0,0,AliMUONPadStatusMaker::kMissing) )
241 if ( chamber<0 && ntotal!=NTOTALNUMBEROFPADS)
243 cerr << Form("ERROR ! NOT THE EXPECTED NUMBER OF CHANNELS (%d vs 1064008) FOR RUN %09d",
244 ntotal,runNumber) << endl;
248 cout << Form("Chamber %d - %d channels",chamber,ntotal) << endl;
249 cout << Form("nbadped %5d nbadhv %5d nbadgain %5d nbadocc %5d nmissing %5d nreco %5d",
250 nbadped,nbadhv,nbadgain,nbadocc,nmissing,nreco) << endl;
253 AliCDBManager::Instance()->ClearCache();
258 //______________________________________________________________________________
259 void Draw(TFile* f, const char* gname, TLegend* l, Bool_t normalized)
263 TGraph* g = static_cast<TGraph*>(f->Get(gname));
269 g = static_cast<TGraph*>(g->Clone());
270 for ( Int_t i = 0; i < g->GetN(); ++i )
272 Double_t y = g->GetY()[i];
273 g->SetPoint(i,g->GetX()[i],y/NTOTALNUMBEROFPADS);
278 g->GetXaxis()->SetNdivisions(505);
279 g->GetXaxis()->SetNoExponent();
281 if (l) l->AddEntry(g,gname,"LP");
284 //______________________________________________________________________________
285 void DrawPeriod(double run1, double run2, double ymin, double ymax, const char* label)
287 TBox* b = new TBox(run1,ymin,run2,ymax);
290 TText* text = new TText((run1+run2)/2.0,ymax*0.6,label);
291 text->SetTextSize(0.05);
295 //______________________________________________________________________________
296 void DrawEvolution(const char* file, bool normalized=true)
299 TFile* f = TFile::Open(file);
303 TCanvas* c = new TCanvas("mch-status-evolution","mch-status-evolution");
310 TLegend* l = new TLegend(0.1,0.7,0.3,0.95,"ch evolution");
312 TGraph* g = static_cast<TGraph*>(f->Get("nbad"));
315 int runmin = TMath::Nint(g->GetX()[0]);
316 int runmax = TMath::Nint(g->GetX()[g->GetN()-1]);
320 TH2* h = new TH2F("hframe","hframe;Run number;Fraction of dead channels",100,runmin-200,runmax+200,100,0,ymax);
322 gStyle->SetOptStat(kFALSE);
324 h->GetXaxis()->SetNoExponent();
325 h->GetXaxis()->SetNdivisions(505);
327 gStyle->SetOptTitle(kFALSE);
329 DrawPeriod(115881,117222,0,ymax,"10b");
331 DrawPeriod(119159,120824,0,ymax,"10c");
333 DrawPeriod(122374,126424,0,ymax,"10d");
335 DrawPeriod(127724,130850,0,ymax,"10e");
337 DrawPeriod(133005,134929,0,ymax,"10f");
339 DrawPeriod(135658,136376,0,ymax,"10g");
341 DrawPeriod(137133,139513,0,ymax,"10h");
343 DrawPeriod(143856,146860,0,ymax,"11a");
345 DrawPeriod(148370,150702,0,ymax,"11b");
347 DrawPeriod(151566,154583,0,ymax,"11c");
349 DrawPeriod(158084,159606,0,ymax,"11d");
351 DrawPeriod(160677,162717,0,ymax,"11e");
353 DrawPeriod(167703,170207,0,ymax,"11h");
355 Draw(f,"nbad",l,normalized);
356 Draw(f,"nbadped",l,normalized);
357 Draw(f,"nbadocc",l,normalized);
358 Draw(f,"nbadhv",l,normalized);
359 Draw(f,"nmissing",l,normalized);
360 Draw(f,"nreco",l,normalized);
369 //______________________________________________________________________________
370 void MUONStatusMapEvolution(const char* runlist, const char* outfile)
372 // Compute the number of bad pads (because of bad ped, bad hv, bad occupancy
373 // or missing in configuration)
375 // output a root file with the different graphs.
377 // output can be then plotted using the DrawEvolution function
379 // Note that the output of different runlists can then be merged simply using
380 // the hadd program, and so then the DrawEvolution can be used over
381 // a huge period, e.g. a full year, while this method is better restricted
382 // to a period or even less (depending on your success of accessing the OCDB)
385 std::vector<int> runs;
387 ReadIntegers(runlist,runs);
391 cout << "No runs to process..." << endl;
397 if ( runs[0] <= 139699 ) year=2010;
399 AliCDBManager::Instance()->SetDefaultStorage(Form("alien://folder=/alice/data/%d/OCDB?cacheFold=/local/cdb",year));
403 glist.SetOwner(kTRUE);
405 TGraph* gnbad = new TGraph(runs.size());
406 gnbad->SetName("nbad");
409 TGraph* gnbadped = new TGraph(runs.size());
410 gnbadped->SetName("nbadped");
413 TGraph* gnbadocc = new TGraph(runs.size());
414 gnbadocc->SetName("nbadocc");
417 TGraph* gnbadhv = new TGraph(runs.size());
418 gnbadhv->SetName("nbadhv");
421 TGraph* gnmissing = new TGraph(runs.size());
422 gnmissing->SetName("nmissing");
423 glist.Add(gnmissing);
425 TGraph* gnreco = new TGraph(runs.size());
426 gnreco->SetName("nreco");
429 for ( std::vector<int>::size_type i = 0; i < runs.size(); ++i )
431 Int_t runNumber = runs[i];
439 Int_t nbad = GetBadChannels(runNumber,nbadped,nbadhv,nbadgain,nbadocc,nmissing,nreco);
441 gnbad->SetPoint(i,runNumber,nbad);
442 gnbadped->SetPoint(i,runNumber,nbadped);
443 gnbadhv->SetPoint(i,runNumber,nbadhv);
444 gnbadocc->SetPoint(i,runNumber,nbadocc);
445 gnmissing->SetPoint(i,runNumber,nmissing);
446 gnreco->SetPoint(i,runNumber,nreco);
453 TFile f(outfile,"recreate");
454 Int_t color[] = { 1 , 2 , 3 , 4, 6, 8 };
455 Int_t marker[] = { 28 , 24 , 23 , 26, 30, 5 };
457 while ( ( g = static_cast<TGraph*>(next() ) ) )
459 g->GetXaxis()->SetNdivisions(505);
460 g->GetXaxis()->SetNoExponent();
462 g->GetYaxis()->SetNoExponent();
463 g->SetLineColor(color[index]);
464 g->SetMarkerStyle(marker[index]);
465 g->SetMarkerColor(color[index]);
466 g->SetMarkerSize(1.0);