ROOT logo
CheckActiveChannels(const Char_t *);
CheckActiveChannels(Int_t nrun=-1);
CheckActiveChannelsFromCDBEntry(AliCDBEntry *);

//____________________________________________________________________

CheckActiveChannels(const Char_t *fileName)
{

  TFile *file = TFile::Open(fileName);
  AliCDBEntry *cdbe = (AliCDBEntry *)file->Get("AliCDBEntry");
  CheckActiveChannelsFromCDBEntry(cdbe);
  
}

//____________________________________________________________________

CheckActiveChannels(Int_t nrun)
{

  TGrid *alien = TGrid::Connect("alien://");
  if (!alien || !alien->IsConnected()) return;
  AliCDBManager *cdbm = AliCDBManager::Instance();
  cdbm->SetDefaultStorage("raw://");
  if (nrun==-1)
    cdbm->SetRun(80015);
  else
    cdbm->SetRun(nrun);
  AliCDBEntry *cdbe = cdbm->Get("TOF/Calib/Status");
  CheckActiveChannelsFromCDBEntry(cdbe);

}

//____________________________________________________________________

CheckActiveChannelsFromCDBEntry(AliCDBEntry *cdbe)
{

  AliTOFChannelOnlineStatusArray *array = (AliTOFChannelOnlineStatusArray *)cdbe->GetObject();
  TH1F *hStatus_hw_ok = new TH1F("hStatus_hw_ok", "HW status;index;status ok", array->GetSize(), 0., array->GetSize(););
  TH1F *hStatus_pulser_ok = new TH1F("hStatus_pulser_ok", "pulser status;index;status ok", array->GetSize(), 0., array->GetSize(););
  TH1F *hStatus_noise_ok = new TH1F("hStatus_noise_ok", "noise status;index;status ok", array->GetSize(), 0., array->GetSize(););
  TH1F *hStatus_active = new TH1F("hStatus_active", "active status;index;status ok", array->GetSize(), 0., array->GetSize(););
  Bool_t hw_ok, pulser_ok, noise_ok;
  for (Int_t i = 0; i <  array->GetSize(); i++) {
    hw_ok = array->GetHWStatus(i) & AliTOFChannelOnlineStatusArray::kTOFHWOk;
    pulser_ok = !(array->GetPulserStatus(i) & AliTOFChannelOnlineStatusArray::kTOFPulserBad);
    noise_ok = array->GetNoiseStatus(i) & AliTOFChannelOnlineStatusArray::kTOFNoiseOk;
    hStatus_hw_ok->SetBinContent(i + 1, hw_ok);
    hStatus_pulser_ok->SetBinContent(i + 1, pulser_ok);
    hStatus_noise_ok->SetBinContent(i + 1, noise_ok);
    hStatus_active->SetBinContent(i + 1, hw_ok && pulser_ok && noise_ok);
  }
  printf("%d active channels\n", hStatus_active->Integral());

  TFile *fileout = TFile::Open("ChannelStatus.root", "RECREATE");
  hStatus_hw_ok->Write();
  hStatus_pulser_ok->Write();
  hStatus_noise_ok->Write();
  hStatus_active->Write();
  fileout->Close();

}


 CheckActiveChannels.C:1
 CheckActiveChannels.C:2
 CheckActiveChannels.C:3
 CheckActiveChannels.C:4
 CheckActiveChannels.C:5
 CheckActiveChannels.C:6
 CheckActiveChannels.C:7
 CheckActiveChannels.C:8
 CheckActiveChannels.C:9
 CheckActiveChannels.C:10
 CheckActiveChannels.C:11
 CheckActiveChannels.C:12
 CheckActiveChannels.C:13
 CheckActiveChannels.C:14
 CheckActiveChannels.C:15
 CheckActiveChannels.C:16
 CheckActiveChannels.C:17
 CheckActiveChannels.C:18
 CheckActiveChannels.C:19
 CheckActiveChannels.C:20
 CheckActiveChannels.C:21
 CheckActiveChannels.C:22
 CheckActiveChannels.C:23
 CheckActiveChannels.C:24
 CheckActiveChannels.C:25
 CheckActiveChannels.C:26
 CheckActiveChannels.C:27
 CheckActiveChannels.C:28
 CheckActiveChannels.C:29
 CheckActiveChannels.C:30
 CheckActiveChannels.C:31
 CheckActiveChannels.C:32
 CheckActiveChannels.C:33
 CheckActiveChannels.C:34
 CheckActiveChannels.C:35
 CheckActiveChannels.C:36
 CheckActiveChannels.C:37
 CheckActiveChannels.C:38
 CheckActiveChannels.C:39
 CheckActiveChannels.C:40
 CheckActiveChannels.C:41
 CheckActiveChannels.C:42
 CheckActiveChannels.C:43
 CheckActiveChannels.C:44
 CheckActiveChannels.C:45
 CheckActiveChannels.C:46
 CheckActiveChannels.C:47
 CheckActiveChannels.C:48
 CheckActiveChannels.C:49
 CheckActiveChannels.C:50
 CheckActiveChannels.C:51
 CheckActiveChannels.C:52
 CheckActiveChannels.C:53
 CheckActiveChannels.C:54
 CheckActiveChannels.C:55
 CheckActiveChannels.C:56
 CheckActiveChannels.C:57
 CheckActiveChannels.C:58
 CheckActiveChannels.C:59
 CheckActiveChannels.C:60
 CheckActiveChannels.C:61
 CheckActiveChannels.C:62
 CheckActiveChannels.C:63
 CheckActiveChannels.C:64
 CheckActiveChannels.C:65
 CheckActiveChannels.C:66