void KVINDRAUpDater::SetCsIPedestals(KVDBRun* kvrun)
{
   if (!kvrun->GetKey("Pedestals"))
      return;
   if (!kvrun->GetKey("Pedestals")->GetLinks())
      return;
   if (!kvrun->GetKey("Pedestals")->GetLinks()->At(1))
      return;

   //read CsI pedestals
   ifstream file_pied_csi;
   if (!KVBase::
         SearchAndOpenKVFile(kvrun->GetKey("Pedestals")->GetLinks()->At(1)->
                             GetName(), file_pied_csi, fDataSet.Data())) {
      Error("SetPedestals", "Problem opening file %s",
            kvrun->GetKey("Pedestals")->GetLinks()->At(1)->GetName());
      return;
   }
   cout << "--> Setting Pedestals" << endl;
   cout << "    CsI            : " << kvrun->GetKey("Pedestals")->
        GetLinks()->At(1)->GetName() << endl;

   int cou, mod, type, n_phys, n_gene;
   float ave_phys, sig_phys, ave_gene, sig_gene;
   TString line;

   //skip first 5 lines - header
   for (int i = 5; i; i--) {
      line.ReadLine(file_pied_csi);
   }

   while (file_pied_csi.good()) {

      file_pied_csi >> cou >> mod >> type >> n_phys >> ave_phys >> sig_phys
                    >> n_gene >> ave_gene >> sig_gene;

      KVDetector* det = GetINDRA()->GetDetectorByType(cou, mod, type);
      if (det) {
         switch (type) {

            case CsI_R:

               det->SetPedestal("R", ave_gene);
               break;

            case CsI_L:

               det->SetPedestal("L", ave_gene);
               break;

            default:

               break;
         }
      }
   }
   file_pied_csi.close();
}
void KVINDRAUpDater_e475s::SetPedestals(KVDBRun* kvrun)
{
   
	KVRList *param_list = kvrun->GetLinks("Pedestals");

   if (!param_list)
      return;
   if (!param_list->GetSize())
      return;

   KVDetector *det;
   KVDBParameterSet *kvps;
   TIter next_ps(param_list);
   KVString str;
	Double_t pied_value;
	
   // Setting all pedestal values available
   while ((kvps = (KVDBParameterSet *) next_ps())) {    // boucle sur les parametres
      str = kvps->GetName();
		if ( (det = gIndra->GetDetector(str.Data())) ){
		   pied_value = kvps->GetParameter(1);
			det->SetPedestal(kvps->GetTitle(),pied_value);
		}                      //detector found
   }   	                     //boucle sur les parameters

}
void KVINDRAUpDater::SetChIoSiPedestals(KVDBRun* kvrun)
{
   //read Chio-Si-Etalons pedestals

   if (!kvrun->GetKey("Pedestals"))
      return;
   if (!kvrun->GetKey("Pedestals")->GetLinks())
      return;
   if (!kvrun->GetKey("Pedestals")->GetLinks()->At(0))
      return;

   ifstream file_pied_chiosi;
   if (!KVBase::
         SearchAndOpenKVFile(kvrun->GetKey("Pedestals")->GetLinks()->At(0)->
                             GetName(), file_pied_chiosi, fDataSet.Data())) {
      Error("SetPedestals", "Problem opening file %s",
            kvrun->GetKey("Pedestals")->GetLinks()->At(0)->GetName());
      return;
   }
   cout << "--> Setting Pedestals" << endl;
   cout << "    ChIo/Si/Etalons: " << kvrun->GetKey("Pedestals")->
        GetLinks()->At(0)->GetName() << endl;

   //skip first 5 lines - header
   TString line;
   for (int i = 5; i; i--) {
      line.ReadLine(file_pied_chiosi);
   }

   int cou, mod, type, n_phys, n_gene;
   float ave_phys, sig_phys, ave_gene, sig_gene;

   while (file_pied_chiosi.good()) {

      file_pied_chiosi >> cou >> mod >> type >> n_phys >> ave_phys >>
                       sig_phys >> n_gene >> ave_gene >> sig_gene;

      KVDetector* det = GetINDRA()->GetDetectorByType(cou, mod, type);
      if (det) {
         switch (type) {

            case ChIo_GG:

               det->SetPedestal("GG", ave_gene);
               break;

            case ChIo_PG:

               det->SetPedestal("PG", ave_gene);
               break;

            case Si_GG:

               det->SetPedestal("GG", ave_gene);
               break;

            case Si_PG:

               det->SetPedestal("PG", ave_gene);
               break;

            case SiLi_GG:

               det->SetPedestal("GG", ave_gene);
               break;

            case SiLi_PG:

               det->SetPedestal("PG", ave_gene);
               break;

            case Si75_GG:

               det->SetPedestal("GG", ave_gene);
               break;

            case Si75_PG:

               det->SetPedestal("PG", ave_gene);
               break;

            default:

               break;
         }
      }
   }
   file_pied_chiosi.close();
}