From 8da4327009960433242b809f2dfa8bd8ef4c02a7 Mon Sep 17 00:00:00 2001 From: rpreghen Date: Mon, 21 Mar 2011 11:39:04 +0000 Subject: [PATCH] handling of problematic channels --- .../Problematic/Run0_999999999_v0_s0.root | Bin 0 -> 5957 bytes TOF/AliTOFcalib.cxx | 79 ++++- TOF/AliTOFcalib.h | 9 +- TOF/CheckEnabledChannels.C | 36 +++ TOF/CheckProblematic.C | 56 ++++ TOF/CheckReadoutEfficiency.C | 1 + TOF/MakeCDBEntryProblematic.C | 270 ++++++++++++++++++ TOF/problematicList.example.txt | 14 + 8 files changed, 462 insertions(+), 3 deletions(-) create mode 100644 OCDB/TOF/Calib/Problematic/Run0_999999999_v0_s0.root create mode 100644 TOF/CheckEnabledChannels.C create mode 100644 TOF/CheckProblematic.C create mode 100644 TOF/MakeCDBEntryProblematic.C create mode 100644 TOF/problematicList.example.txt diff --git a/OCDB/TOF/Calib/Problematic/Run0_999999999_v0_s0.root b/OCDB/TOF/Calib/Problematic/Run0_999999999_v0_s0.root new file mode 100644 index 0000000000000000000000000000000000000000..541be5fdd2c5311928caa9e4ce9761d5137de70b GIT binary patch literal 5957 zcmeI0cTiJrm&Zfz5|9oOrHC{`m0kj&sSuGO9VtOV3st&;NJm7Pfq*mtArz4=y@_;! z5Q<0#K{`k$VbS00%>K8#GyBf$AMZ1B<~eikbI$#qGxwgk^YKI?y#auM1pokG4*;-g z001mKmwwQt5nWm*=|2wHHvj;r3m{sTC&U@#Gt7k$5d#3vo3}6T{!i9rsy~V1Re#k| z13dp`zI+-0KxU|kaDhJnJ0e}-U>g^N7t+D|&+d7t3heFaUA`sH<7 z@B>eztqa`M#v5S=e(2*SW-a%h%lfI9wU^lKKcRsC`-}jxKidE52LOsLrFUN1-x@AE zcKyF=3@P%meqw~;-+0MC^%MPxwWoo&ATI0EaP#)`|F1s4>^`L=DL@fH>_@bT6?bNW zFahR#YjvWqH=&%ukTamLc)E)xgqVjaal`>!vND$#w%_WwtO7JQzlfSRq1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z!Xnh!J%=`P6M`ISKQg(Mze`XB#Ffj0b1!1lU{jOMnG|{3*2nwo-c&E*RMZ23_CaNt z*<2iAVL0rZ==8QaBR;?YgfQVH31RIz-&i_~lAcRsce7uwi<{e(Gdyf)NY&RBe{Kl8 zyVMEYb4j@?G!fM_<^D+5_Xo!=XW8Bf>!|~3w~Xz$0~LV?wg@5Rq2SZ$0rTfXY_hud z)7|u@j8r*}cMBLb^G0g^u;wR$Ik$f>+)3!RvJ_NfqvOcOhXg66pMzKuj%dC)TYg|IAw#{7`uc^WBUp^+N0 zn{3t^5s0{J^SQJEztF;fy+|K!;s2ert$MK$H>`s0tZio*FEsqot|P={LX|yMu(%a= zHQ({@@&~SHvais_8c>uHCaW`VnBm?q+wn1>mN|zn?5kl_3Po?MUiHH}_};dGRjn3P zlvWx{2JYmbJksV7_QCyjBbZ}=FD{(E&pTW8!t8zqH37*cfwcc(J?KkEl;{g46 zq)KsEDyt;)Lf?d6m5$!;XiUz-0eR#~un{k!<)vz7gTMD>yOX-E>nd`PHdZBE%0D9i zQ5Q*An&w}0hK%YmOeO-}#Z^W+_+>~@ExSetSeed(123456789); } @@ -291,6 +295,10 @@ AliTOFcalib& AliTOFcalib::operator=(const AliTOFcalib &calib) if (fReadoutEfficiency) *fReadoutEfficiency = *calib.fReadoutEfficiency; else fReadoutEfficiency = new TH1F(*calib.fReadoutEfficiency); } + if (calib.fProblematic) { + if (fProblematic) *fProblematic = *calib.fProblematic; + else fProblematic = new TH1C(*calib.fProblematic); + } fInitFlag = calib.fInitFlag; fRemoveMeanT0 = calib.fRemoveMeanT0; fCalibrateTOFsignal = calib.fCalibrateTOFsignal; @@ -335,6 +343,7 @@ AliTOFcalib::~AliTOFcalib() if (fRunParams) delete fRunParams; if (fResponseParams) delete fResponseParams; if (fReadoutEfficiency) delete fReadoutEfficiency; + if (fProblematic) delete fProblematic; } if (fTree!=0x0) delete fTree; if (fChain!=0x0) delete fChain; @@ -2036,6 +2045,25 @@ AliTOFcalib::WriteReadoutEfficiencyOnCDB(const Char_t *sel , Int_t minrun, Int_t //---------------------------------------------------------------------------- +void +AliTOFcalib::WriteProblematicOnCDB(const Char_t *sel , Int_t minrun, Int_t maxrun) +{ + /* + * write problematic on CDB + */ + + if (!fProblematic) return; + AliCDBId id(Form("%s/Problematic", sel), minrun, maxrun); + AliCDBMetaData *md = new AliCDBMetaData(); + md->SetResponsible("Roberto Preghenella"); + AliCDBManager *man = AliCDBManager::Instance(); + man->Put(fProblematic, id, md); + AliDebug(2,Form("Problematic written on CDB with run range [%i, %i] ",minrun ,maxrun)); + delete md; +} + +//---------------------------------------------------------------------------- + Bool_t AliTOFcalib::ReadDeltaBCOffsetFromCDB(const Char_t *sel , Int_t nrun) { @@ -2151,6 +2179,29 @@ AliTOFcalib::ReadReadoutEfficiencyFromCDB(const Char_t *sel , Int_t nrun) //---------------------------------------------------------------------------- +Bool_t +AliTOFcalib::ReadProblematicFromCDB(const Char_t *sel , Int_t nrun) +{ + /* + * read problematic from CDB + */ + + AliCDBManager *man = AliCDBManager::Instance(); + AliCDBEntry *entry = man->Get(Form("%s/Problematic", sel),nrun); + if (!entry) { + AliFatal("No Problematic entry found in CDB"); + exit(0); + } + fProblematic = (TH1C *)entry->GetObject(); + if(!fProblematic){ + AliFatal("No Problematic object found in CDB entry"); + exit(0); + } + return kTRUE; +} + +//---------------------------------------------------------------------------- + Bool_t AliTOFcalib::Init(Int_t run) { @@ -2193,6 +2244,11 @@ AliTOFcalib::Init(Int_t run) AliError("cannot get \"ReadoutEfficiency\" object from OCDB"); return kFALSE; } + /* get readout efficiency obj */ + if (!ReadProblematicFromCDB("TOF/Calib", run)) { + AliError("cannot get \"Problematic\" object from OCDB"); + return kFALSE; + } /* get response params */ TFile *responseFile = TFile::Open("$ALICE_ROOT/TOF/data/AliTOFresponsePar.root"); if (!responseFile || !responseFile->IsOpen()) { @@ -2320,7 +2376,7 @@ AliTOFcalib::CalibrateESD(AliESDEvent *event) //---------------------------------------------------------------------------- Bool_t -AliTOFcalib::IsChannelEnabled(Int_t index, Bool_t checkEfficiency) +AliTOFcalib::IsChannelEnabled(Int_t index, Bool_t checkEfficiency, Bool_t checkProblematic) { /* * is channel enabled @@ -2336,6 +2392,7 @@ AliTOFcalib::IsChannelEnabled(Int_t index, Bool_t checkEfficiency) if (fStatus->GetNoiseStatus(index) == AliTOFChannelOnlineStatusArray::kTOFNoiseBad) return kFALSE; if (fStatus->GetHWStatus(index) == AliTOFChannelOnlineStatusArray::kTOFHWBad) return kFALSE; if (checkEfficiency && !IsChannelEfficient(index)) return kFALSE; + if (checkProblematic && IsChannelProblematic(index)) return kFALSE; /* good status */ return kTRUE; @@ -2364,6 +2421,26 @@ AliTOFcalib::IsChannelEfficient(Int_t index) //---------------------------------------------------------------------------- +Bool_t +AliTOFcalib::IsChannelProblematic(Int_t index) +{ + /* + * is channel problematic + */ + + if (!fInitFlag) { + AliError("class not yet initialized. Initialize it before."); + return kTRUE; + } + + /* check problematic */ + if (fProblematic->GetBinContent(index + 1) != 0) return kTRUE; + return kFALSE; + +} + +//---------------------------------------------------------------------------- + void AliTOFcalib::CalibrateTExp(AliESDEvent *event) const { diff --git a/TOF/AliTOFcalib.h b/TOF/AliTOFcalib.h index 6102e00543c..1c4142154fc 100644 --- a/TOF/AliTOFcalib.h +++ b/TOF/AliTOFcalib.h @@ -29,6 +29,7 @@ class TArrayF; class TF1; class TH1F; +class TH1C; class TObjArray; class TTree; class TChain; @@ -108,6 +109,7 @@ public: void WriteT0FillOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun); void WriteRunParamsOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun); void WriteReadoutEfficiencyOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun); + void WriteProblematicOnCDB(const Char_t *sel, Int_t minrun, Int_t maxrun); // reading Bool_t ReadSimHistoFromCDB(const Char_t *sel, Int_t nrun); @@ -147,6 +149,7 @@ public: Bool_t ReadT0FillFromCDB(const Char_t *sel, Int_t nrun); Bool_t ReadRunParamsFromCDB(const Char_t *sel, Int_t nrun); Bool_t ReadReadoutEfficiencyFromCDB(const Char_t *sel, Int_t nrun); + Bool_t ReadProblematicFromCDB(const Char_t *sel, Int_t nrun); Bool_t Init(Int_t run = -1); // init Double_t GetTimeCorrection(Int_t index, Double_t tot, Int_t deltaBC, Int_t l0l1, UInt_t timestamp); // get time correction @@ -155,8 +158,9 @@ public: void SetRemoveMeanT0(Bool_t value) {fRemoveMeanT0 = value;}; // setter void SetCalibrateTOFsignal(Bool_t value) {fCalibrateTOFsignal = value;}; // setter void SetCorrectTExp(Bool_t value) {fCorrectTExp = value;}; // setter - Bool_t IsChannelEnabled(Int_t index, Bool_t checkEfficiency = kTRUE); // is channel enabled + Bool_t IsChannelEnabled(Int_t index, Bool_t checkEfficiency = kTRUE, Bool_t checkProblematic = kTRUE); // is channel enabled Bool_t IsChannelEfficient(Int_t index); // is channel efficient + Bool_t IsChannelProblematic(Int_t index); // is channel problematic Double_t TuneForMC(AliESDEvent *event, Double_t resolution); // tune for MC private: @@ -188,13 +192,14 @@ private: AliTOFRunParams *fRunParams; // run params AliTOFResponseParams *fResponseParams; // run params TH1F *fReadoutEfficiency; // readout efficiency + TH1C *fProblematic; // problematic Bool_t fInitFlag; // init flag Bool_t fRemoveMeanT0; // remove mean T0 Bool_t fCalibrateTOFsignal; // calibrate TOF signal Bool_t fCorrectTExp; // correct expected time - ClassDef(AliTOFcalib,10); + ClassDef(AliTOFcalib,11); }; #endif // AliTOFcalib_H diff --git a/TOF/CheckEnabledChannels.C b/TOF/CheckEnabledChannels.C new file mode 100644 index 00000000000..63e0f8365e2 --- /dev/null +++ b/TOF/CheckEnabledChannels.C @@ -0,0 +1,36 @@ +CheckEnabledChannels(Int_t run, const Char_t *dbString) +{ + + /* init */ + AliCDBManager *cdb = AliCDBManager::Instance(); + cdb->SetDefaultStorage(dbString); + cdb->SetRun(run); + AliTOFcalib calib; + calib.Init(); + + TH2F *hEnabledMap = new TH2F("hEnabledMap", "Enabled channel map;sector;strip", 72, 0., 18., 91, 0., 91.); + + AliTOFcalibHisto calibhisto; + calibhisto.LoadCalibHisto(); + calibhisto.LoadCalibStat(); /* temp */ + + Int_t sector, sectorStrip, padx, fea; + Float_t hitmapx, hitmapy; + /* loop over channels */ + for (Int_t ich = 0; ich < 157248; ich++) { + if (!calib.IsChannelEnabled(ich, kTRUE, kTRUE)) continue; + sector = calibhisto.GetCalibMap(AliTOFcalibHisto::kSector, ich); + sectorStrip = calibhisto.GetCalibMap(AliTOFcalibHisto::kSectorStrip, ich); + padx = calibhisto.GetCalibMap(AliTOFcalibHisto::kPadX, ich); + fea = padx / 12; + hitmapx = sector + ((Double_t)(3 - fea) + 0.5) / 4.; + hitmapy = sectorStrip; + hEnabledMap->Fill(hitmapx, hitmapy); + } + + hEnabledMap->DrawCopy("colz"); + TFile *fileout = TFile::Open("CheckEnabledChannels.root", "RECREATE"); + hEnabledMap->Write(); + fileout->Close(); + +} diff --git a/TOF/CheckProblematic.C b/TOF/CheckProblematic.C new file mode 100644 index 00000000000..da4c95881b3 --- /dev/null +++ b/TOF/CheckProblematic.C @@ -0,0 +1,56 @@ +CheckProblematic(Int_t run, const Char_t *dbString = "raw://") +{ + + TGrid::Connect("alien"); + AliCDBManager *cdb = AliCDBManager::Instance(); + cdb->SetDefaultStorage(dbString); + cdb->SetRun(run); + AliCDBEntry *cdbe = cdb->Get("TOF/Calib/Problematic"); + CheckProblematic(cdbe); + +} + +CheckProblematic(const Char_t *fileName) +{ + + TFile *file = TFile::Open(fileName); + AliCDBEntry *cdbe = (AliCDBEntry *)file->Get("AliCDBEntry"); + CheckProblematic(cdbe); +} + +CheckProblematic(AliCDBEntry *cdbe) +{ + + if (!cdbe) { + printf("invalid CDB entry\n"); + return; + } + + TH1C *data = (TH1C *)cdbe->GetObject(); + + TH2F *hProblematicMap = new TH2F("hProblematicMap", "Problematic map;sector;strip", 72, 0., 18., 91, 0., 91.); + + AliTOFcalibHisto calib; + calib.LoadCalibHisto(); + calib.LoadCalibStat(); /* temp */ + + Int_t sector, sectorStrip, padx, fea; + Float_t efficiency, hitmapx, hitmapy; + for (Int_t i = 0; i < data->GetNbinsX(); i++) { + if (data->GetBinContent(i + 1) == 0) continue; + sector = calib.GetCalibMap(AliTOFcalibHisto::kSector, i); + sectorStrip = calib.GetCalibMap(AliTOFcalibHisto::kSectorStrip, i); + padx = calib.GetCalibMap(AliTOFcalibHisto::kPadX, i); + fea = padx / 12; + hitmapx = sector + ((Double_t)(3 - fea) + 0.5) / 4.; + hitmapy = sectorStrip; + + hProblematicMap->Fill(hitmapx, hitmapy); + } + + hProblematicMap->DrawCopy("colz"); + TFile *fout = TFile::Open("CheckProblematic.root", "RECREATE"); + hProblematicMap->Write(); + fout->Close(); + +} diff --git a/TOF/CheckReadoutEfficiency.C b/TOF/CheckReadoutEfficiency.C index 90ed4e3f434..ee2c925f3b1 100644 --- a/TOF/CheckReadoutEfficiency.C +++ b/TOF/CheckReadoutEfficiency.C @@ -48,6 +48,7 @@ CheckReadoutEfficiency(AliCDBEntry *cdbe) hEfficiencyMap->Fill(hitmapx, hitmapy, efficiency / 24.); } + hEfficiencyMap->DrawCopy("colz"); TFile *fout = TFile::Open("CheckReadoutEfficiency.root", "RECREATE"); hEfficiencyMap->Write(); fout->Close(); diff --git a/TOF/MakeCDBEntryProblematic.C b/TOF/MakeCDBEntryProblematic.C new file mode 100644 index 00000000000..632f9a4fbc1 --- /dev/null +++ b/TOF/MakeCDBEntryProblematic.C @@ -0,0 +1,270 @@ +MakeCDBEntryProblematic(Int_t startRun = 0, Int_t endRun = AliCDBRunRange::Infinity(), const Char_t *filename = NULL) +{ + + /* create object */ + TH1C *obj = new TH1C("hProblematic", "", 157248, 0., 157248.); + + /* update object */ + if (filename) { + printf("PROBLEMATIC HISTO WILL BE UPDATED ACCORDING TO INPUT LIST\n"); + printf("inputList: %s\n", filename); + UpdateProblematicHisto(obj, filename); + } + else { + printf("EMPTY PROBLEMATIC HISTO WILL BE GENERATED\n"); + } + + /* create cdb info */ + AliCDBId id("TOF/Calib/Problematic", startRun, endRun); + AliCDBMetaData *md = new AliCDBMetaData(); + md->SetResponsible("Roberto Preghenella"); + md->SetComment("Problematic"); + md->SetAliRootVersion(gSystem->Getenv("ARVERSION")); + md->SetBeamPeriod(0); + + /* put object in cdb */ + AliCDBManager *cdb = AliCDBManager::Instance(); + cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); + cdb->GetDefaultStorage()->Put(obj, id, md); + +} + +Bool_t +UpdateProblematicHisto(TH1C *histo, const Char_t *filename) +{ + /* + * this routine updates the problematic histo taking + * problematic channels from a list specified in the + * file written in ASCII format according to the + * following formats based on electronics-oriented indices: + * + * # disable single crate + * # crate[0-71] + * + * # disable single TRM + * # crate[0-71] trm[3-12] + * + * # disable single chain + * # crate[0-71] trm[3-12] chain[0-1] + * + * # disable single TDC + * # crate[0-71] trm[3-12] chain[0-1] tdc[0-14] + * + * # disable single channel + * # crate[0-71] trm[3-12] chain[0-1] tdc[0-14] channel[0-7] + * + * + * EXAMPLE: + * # this list will set as problematics: + * # - all channels of crate-39 + * # - all channels of TRM-03 crate-40 + * # - all channels of chain-A TRM-07 crate-04 + * # - all channels of TDC-04 chain-B TRM-09 crate-07 + * # - channel-03 TDC-02 chain-A TRM-04 crate-00 + * 39 + * 40 3 + * 4 7 0 + * 7 9 1 4 + * 0 4 0 2 3 + * + */ + + /* check histo */ + if (!histo) { + printf("WARNING: NULL histo, will just run in DUMMY mode\n"); + } + + /* open ASCII file */ + ifstream filein; + filein.open(filename, ifstream::in); + + /* loop over lines in file */ + char buf[1024]; + TString str; + TObjString *ostr; + TObjArray *oa; + Int_t crate, trm, chain, tdc, channel; + Int_t irequest = 0, nflagged; + printf("processing requests to flag problematic channels:\n"); + while (filein.good()) { + filein.getline(buf, 1024); + /* check whether we got to EOF */ + if (filein.eof()) break; + /* put buffer in a TString */ + str = buf; + /* check whether commented line */ + if (str.BeginsWith("#")) continue; + irequest++; + /* tokenize */ + oa = str.Tokenize(" "); + switch (oa->GetEntries()) { + case 1: + ostr = (TObjString *)oa->At(0); + crate = atoi(ostr->GetName()); + if (crate < 0 || crate > 71) { + printf("%d.) invalid crate number: %d\n", irequest, crate); + break; + } + nflagged = FlagAsProblematic(histo, crate); + printf("%d.) crate flagged as problematic (%d channels): crate-%02d\n", irequest, nflagged, crate); + break; + case 2: + ostr = (TObjString *)oa->At(0); + crate = atoi(ostr->GetName()); + if (crate < 0 || crate > 71) { + printf("%d.) invalid crate number: %d\n", irequest, crate); + break; + } + ostr = (TObjString *)oa->At(1); + trm = atoi(ostr->GetName()); + if (trm < 3 || trm > 12) { + printf("%d.) invalid TRM number: %d\n", irequest, trm); + break; + } + nflagged = FlagAsProblematic(histo, crate, trm); + printf("%d.) TRM flagged as problematic (%d channels): crate-%02d TRM-%02d\n", irequest, nflagged, crate, trm); + break; + case 3: + ostr = (TObjString *)oa->At(0); + crate = atoi(ostr->GetName()); + if (crate < 0 || crate > 71) { + printf("%d.) invalid crate number: %d\n", irequest, crate); + break; + } + ostr = (TObjString *)oa->At(1); + trm = atoi(ostr->GetName()); + if (trm < 3 || trm > 12) { + printf("%d.) invalid TRM number: %d\n", irequest, trm); + break; + } + ostr = (TObjString *)oa->At(2); + chain = atoi(ostr->GetName()); + if (chain < 0 || chain > 1) { + printf("%d.) invalid chain number: %d\n", irequest, chain); + break; + } + nflagged = FlagAsProblematic(histo, crate, trm, chain); + printf("%d.) chain flagged as problematic (%d channels): crate-%02d TRM-%02d chain-%s\n", irequest, nflagged, crate, trm, chain == 0 ? "A" : "B"); + break; + case 4: + ostr = (TObjString *)oa->At(0); + crate = atoi(ostr->GetName()); + if (crate < 0 || crate > 71) { + printf("%d.) invalid crate number: %d\n", irequest, crate); + break; + } + ostr = (TObjString *)oa->At(1); + trm = atoi(ostr->GetName()); + if (trm < 3 || trm > 12) { + printf("%d.) invalid TRM number: %d\n", irequest, trm); + break; + } + ostr = (TObjString *)oa->At(2); + chain = atoi(ostr->GetName()); + if (chain < 0 || chain > 1) { + printf("%d.) invalid chain number: %d\n", irequest, chain); + break; + } + ostr = (TObjString *)oa->At(3); + tdc = atoi(ostr->GetName()); + if (tdc < 0 || tdc > 14) { + printf("%d.) invalid chain number: %d\n", irequest, chain); + break; + } + nflagged = FlagAsProblematic(histo, crate, trm, chain, tdc); + printf("%d.) TDC flagged as problematic (%d channels): crate-%02d TRM-%02d chain-%s TDC-%02d\n", irequest, nflagged, crate, trm, chain == 0 ? "A" : "B", tdc); + break; + case 5: + ostr = (TObjString *)oa->At(0); + crate = atoi(ostr->GetName()); + if (crate < 0 || crate > 71) { + printf("%d.) invalid crate number: %d\n", irequest, crate); + break; + } + ostr = (TObjString *)oa->At(1); + trm = atoi(ostr->GetName()); + if (trm < 3 || trm > 12) { + printf("invalid TRM number: %d\n", irequest, trm); + break; + } + ostr = (TObjString *)oa->At(2); + chain = atoi(ostr->GetName()); + if (chain < 0 || chain > 1) { + printf("%d.) invalid chain number: %d\n", irequest, chain); + break; + } + ostr = (TObjString *)oa->At(3); + tdc = atoi(ostr->GetName()); + if (tdc < 0 || tdc > 14) { + printf("%d.) invalid chain number: %d\n", irequest, chain); + break; + } + ostr = (TObjString *)oa->At(4); + channel = atoi(ostr->GetName()); + if (channel < 0 || channel > 7) { + printf("%d.) invalid channel number: %d\n", irequest, channel); + break; + } + nflagged = FlagAsProblematic(histo, crate, trm, chain, tdc, channel); + printf("%d.) channel flagged as problematic (%d channels): crate-%02d TRM-%02d chain-%s TDC-%02d, channel-%d\n", irequest, nflagged, crate, trm, chain == 0 ? "A" : "B", tdc, channel); + break; + default: + printf("%d.) invalid format: %s\n", irequest, str.Data()); + break; + } + } + + /* close file */ + filein.close(); + + return kTRUE; +} + +Int_t +FlagAsProblematic(TH1C *histo, Int_t crate = -1, Int_t trm = -1, Int_t chain = -1, Int_t tdc = -1, Int_t channel = -1) +{ + + /* + * flag as problematic according to parameters + */ + + /* loop over everything checking request */ + Int_t det[5], dummy, index, nflagged = 0; + for (Int_t icrate = 0; icrate < 72; icrate++) { + if (crate != -1 && icrate != crate) continue; + for (Int_t itrm = 3; itrm <= 12; itrm++) { + if (trm != -1 && itrm != trm) continue; + for (Int_t ichain = 0; ichain < 2; ichain++) { + if (chain != -1 && ichain != chain) continue; + for (Int_t itdc = 0; itdc < 15; itdc++) { + if (tdc != -1 && itdc != tdc) continue; + for (Int_t ichannel = 0; ichannel < 8; ichannel++) { + if (channel != -1 && ichannel != channel) continue; + AliTOFRawStream::EquipmentId2VolumeId(icrate, itrm, ichain, itdc, ichannel, det); + dummy = det[4]; + det[4] = det[3]; + det[3] = dummy; + if (det[0] < 0 || det[0] > 17 || + det[1] < 0 || det[1] > 4 || + det[2] < 0 || det[2] > 18 || + det[3] < 0 || det[3] > 1 || + det[4] < 0 || det[4] > 47) { + // printf("invalid volume indices: EO = (%d %d %d %d %d), VOL = (%d %d %d %d %d)\n", icrate, itrm, ichain, itdc, ichannel, det[0], det[1], det[2], det[3], det[4]); + continue; + } + index = AliTOFGeometry::GetIndex(det); + if (index < 0 || index > 157248) { + // printf("invalid calib index: EO = (%d %d %d %d %d), VOL = (%d %d %d %d %d), CAL = %d\n", icrate, itrm, ichain, itdc, ichannel, det[0], det[1], det[2], det[3], det[4], index); + continue; + } + nflagged++; + if (!histo) continue; + histo->SetBinContent(index + 1, 0x1); + } + } + } + } + } + + return nflagged; +} diff --git a/TOF/problematicList.example.txt b/TOF/problematicList.example.txt new file mode 100644 index 00000000000..e69814371af --- /dev/null +++ b/TOF/problematicList.example.txt @@ -0,0 +1,14 @@ +# this list will set as problematics: +# - all channels of crate-39 +# - all channels of TRM-04 crate-41 +# - all channels of chain-A TRM-07 crate-04 +# - all channels of TDC-04 chain-B TRM-09 crate-07 +# - channel-03 TDC-02 chain-A TRM-04 crate-00 +39 +41 4 +4 7 0 +7 9 1 4 +0 4 0 2 3 +# invalid entries inserted on purpose +78 +54 4 0 1 5 6 -- 2.39.3