Ejemplo n.º 1
0
//___________________________________________________________________________________________
void KVValues::DefineAdditionalValue(KVString name, KVString expr)
{

   if (HasParameter(name.Data())) {
      Warning("DefineAdditionalValue", "le nom de variable %s est deja utilise", name.Data());
      return;
   }

   KVString expr2 = expr;
   KVNumberList* nl = TransformExpression(expr2);

   if (nl) {
      if (nl->IsEmpty()) {
         Warning("DefineAdditionalValue", "la KVNumberList est vide #%s#", nl->GetList());
      }
      else {
         if (AddFormula(name, expr2)) {
            LinkParameters(nl);
            ComputeAdditionalValues(kval_add - 1, kval_add);
         }
      }
   }
   else {
      Error("DefineAdditionalValue", "La traduction de l'expression %s a echouee", expr.Data());
   }
}
Ejemplo n.º 2
0
KVINDRATelescope* KVINDRA::BuildTelescope(const Char_t* prefix, Int_t module)
{
   // Build telescope from infos in file "$KVROOT/KVFiles/data/indra-struct.[dataset].env"

   //Info("BuildTelescope", "Building telescope %s",name);
   KVINDRATelescope* kvt = new KVINDRATelescope;
   KVString telescopes = fStrucInfos.GetValue(Form("%s.Telescope", prefix), "");
   telescopes.Begin(" ");
   KVString name;
   while (!telescopes.End()) {
      name = telescopes.Next();
      KVNumberList mods = fStrucInfos.GetValue(Form("%s.Telescope.%s.Modules", prefix, name.Data()), "1-100");
      if (mods.Contains(module)) break;
   }

   KVString detectors = fStrucInfos.GetValue(Form("INDRA.Telescope.%s.Detectors", name.Data()), "");
   Double_t aziwidth = fStrucInfos.GetValue(Form("INDRA.Telescope.%s.AziWidth", name.Data()), 1.0);
   Double_t dist = fStrucInfos.GetValue(Form("%s.Dist", prefix), 0.0);
   kvt->SetDistance(dist);
   detectors.Begin(" ");
   Int_t idet = 1;
   while (!detectors.End()) {
      KVString detector = detectors.Next();
      detector.Begin("()");
      KVString dettype = detector.Next();
      Double_t detthick = detector.Next().Atof();
      KVDetector* det = KVDetector::MakeDetector(Form("%s.%s", fDataSet.Data(), dettype.Data()), detthick);
      kvt->Add(det);
      Double_t depth = fStrucInfos.GetValue(Form("INDRA.Telescope.%s.Depth.%s", name.Data(), dettype.Data()), 0.);
      kvt->SetDepth(idet, depth);
      idet++;
   }
   kvt->SetAzimuthalWidth(aziwidth);
   return kvt;
}
Ejemplo n.º 3
0
void KVLVContainer::ActivateItemsWithColumnData(const Char_t* colname, KVNumberList data, Bool_t activ)
{
    KVLVColumnData* CD = fColData[((KVListView*)GetListView())->GetColumnNumber(colname)];
    TGFrameElement* el;
    TIter next(fList);
    TGLVEntry* f = 0;
    Long_t val;
    data.Begin();
    while (!data.End()) {
        Int_t nd = data.Next();
        //printf("nd=%d\n",nd);
        next.Reset();
        Bool_t find = kFALSE;
        while ((el = (TGFrameElement*) next()) && !find) {
            f = (TGLVEntry*) el->fFrame;
            CD->GetData((TObject*)f->GetUserData(), val);
            if (val == nd) {
                find = kTRUE;
                if (activ) ActivateItemFromSelectAll(el);
                else DeActivateItem(el);
            }
        }
    }
    fClient->NeedRedraw(this);
}
Ejemplo n.º 4
0
void CsICalib::InitTelescope(Int_t si_num ,Int_t csi_num)
{
    
    Char_t si_name [128] = "null";
    Char_t csi_name [128] = "null";

    sprintf(si_name, "SIE_%02i", si_num+1); 
    sprintf(csi_name, "CSI%02i", csi_num+1);

    Char_t tel_name [128] = "null";
    sprintf(tel_name, "SIE_%02i_CSI%02i", si_num+1, csi_num+1);

    list = 0;        
//    KVList *grid_list = 0;
    kvid = 0;
    KVNumberList runList = 0;

    list = (KVList*) gIDGridManager->GetGrids();
		
    if(list != 0){
	
		Int_t entries = (Int_t) list->GetEntries();
//		Int_t kHasGrids = 0;

		KVIDGrid *tmpGrid = 0;
//		Int_t nGridsForRun = 0;

		for(Int_t i=0; i<entries; i++){
    			tmpGrid = (KVIDGrid*) list->At(i);
    			if(tmpGrid != 0){
        			runList = (KVNumberList) tmpGrid->GetRuns();
        			runList.Begin();
        			while( !runList.End() ){
            				UInt_t next_val = (UInt_t) runList.Next();
            				if(next_val == gIndra->GetCurrentRunNumber()){
						if(strcmp(tmpGrid->GetName(),tel_name)==0){
							kvid = tmpGrid;
							}
						}
					
        				}
    				}
			} 
			
			      				
		if(kvid != 0){

        }else{  
	    /*printf("Error: 'kvid' assignment failed\n");
	    cout<<"si_num : "<<si_num<<" csi_num : "<<csi_num<<endl; 
	    cout<<"name : "<<tel_name<<endl;*/ 	    
        }
    }else{
        //printf("Error: 'list' assignment failed\n");   
    }

}
Ejemplo n.º 5
0
void KVAvailableRunsFile::RemoveDuplicateLines(KVNumberList lines_to_be_removed)
{
   // Remove from available runs file all lines whose numbers are in the list

   //does runlist exist ?
   if (!OpenAvailableRunsFile()) {
      Error("Remove", "Error opening available runs file");
      return;
   }
   //open temporary file
   TString tmp_file_path(GetFileName());
   ofstream tmp_file;
   KVBase::OpenTempFile(tmp_file_path, tmp_file);

   //loop over lines in fRunlist file
   //all lines which are not in list are directly copied to temp file
   TString line;
   Int_t line_number=1;
   line.ReadLine(fRunlist);

   lines_to_be_removed.Begin();
   Int_t next_line_to_remove = 0;
   if(!lines_to_be_removed.End()) next_line_to_remove = lines_to_be_removed.Next();

   while (fRunlist.good()) {

       if(line_number!=next_line_to_remove)
           tmp_file << line.Data() << endl;
       else {
           if(!lines_to_be_removed.End()) next_line_to_remove = lines_to_be_removed.Next();
       }
       line_number++;
       line.ReadLine(fRunlist);

   }

   CloseAvailableRunsFile();
   TString fRunlist_path;
   AssignAndDelete(fRunlist_path,
                   gSystem->ConcatFileName(GetFilePath(),
                                           GetFileName()));
   //keep lock on runsfile
   if( !runlist_lock.Lock( fRunlist_path.Data() ) ) return;

   //close temp file
   tmp_file.close();

   //copy temporary file to KVFiles directory, overwrite previous
   gSystem->CopyFile(tmp_file_path, fRunlist_path, kTRUE);
   //set access permissions to 664
   gSystem->Chmod(fRunlist_path.Data(), CHMODE(6,6,4));
   //delete temp file
   gSystem->Unlink(tmp_file_path);
   //unlock runsfile
   runlist_lock.Release();
}
Ejemplo n.º 6
0
KVNumberList KVAvailableRunsFile::CheckMultiRunfiles()
{
   //Returns a list with all runs which occur more than once in the available runs file.

//    //does runlist exist ?
//    if (!OpenAvailableRunsFile()) {
//       Error("CheckMultiRunfiles", "Cannot open available runs file");
//       return 0;
//    }
// 
//    TString fLine;
//    TList *run_list = new TList;
//    fLine.ReadLine(fRunlist);
// 
//    KVNumberList multiruns;
// 
//    Int_t fRunNumber;
//    KVDBTable *runs_table = fDataSet->GetDataBase()->GetTable("Runs");
// 
//    while (fRunlist.good()) {
// 
//       TObjArray *toks = fLine.Tokenize('|');    // split into fields
//       KVString kvs(((TObjString *) toks->At(0))->GetString());
//       fRunNumber = kvs.Atoi();
//       delete toks;
// 
//       KVDBRun *a_run = (KVDBRun *) runs_table->GetRecord(fRunNumber);
// 
//       if (!run_list->Contains(a_run)) {
//          //first time that run appears
//          run_list->Add(a_run);
//       } else {
//          //run appears >1 times
//          multiruns.Add(fRunNumber);
//       }
// 
//       fLine.ReadLine(fRunlist);
//    }
//    delete run_list;
//    CloseAvailableRunsFile();
// 
//    return multiruns;
   ReadFile();
   KVNumberList multiruns;
   TIter next(fAvailableRuns);
   KVNameValueList* run;
   while( (run = (KVNameValueList*)next()) ){
      
      if(run->GetIntValue("Occurs")>1) multiruns.Add(run->GetName());
      
   }
   return multiruns;
}
Ejemplo n.º 7
0
KVNumberList KVAvailableRunsFile::GetRunList(const KVDBSystem * sys)
{
   //Returns list of available run numbers for this data type.
   //If 'sys' gives the address of a valid database reaction system, only runs
   //corresponding to the system will be included.

   KVNumberList runs;

   //does runlist exist ?
   if (!OpenAvailableRunsFile()) {
      Error("GetRunList", "Cannot open available runs file");
      return runs;
   }

   TString fLine;
   fLine.ReadLine(fRunlist);

   Int_t fRunNumber;
   KVDBTable *runs_table = 0;
   KVDataBase* db = fDataSet->GetDataBase();
   if (!db){
   	db = new KVDataBase();
   	db->AddTable("Runs","List of Runs");
   }
   runs_table = db->GetTable("Runs");
   
   //KVDBTable *runs_table = fDataSet->GetDataBase()->GetTable("Runs");

   while (fRunlist.good()) {

      TObjArray *toks = fLine.Tokenize('|');    // split into fields
      KVString kvs(((TObjString *) toks->At(0))->GetString());
      fRunNumber = kvs.Atoi();
      delete toks;

      if (sys) {
         // check run is from right system
         KVDBRun *a_run = (KVDBRun *) runs_table->GetRecord(fRunNumber);
         if (a_run) {
            if (a_run->GetSystem() == sys)
               runs.Add(fRunNumber);
         }
      } else {
         // add all runs to list
         runs.Add(fRunNumber);
      }

      fLine.ReadLine(fRunlist);
   }

   CloseAvailableRunsFile();
   return runs;
}
Ejemplo n.º 8
0
void CsICalib::InitTelescopeSiTof(Int_t si_num)
{

    Char_t tel_name [128] = "null";
    sprintf(tel_name, "SIE%i_TOF",si_num+1);	
	
    list_sitof = 0;        
//    KVList *grid_list = 0;
    kvid_sitof = 0;
    KVNumberList runList = 0;

    list_sitof = (KVList*) gIDGridManager->GetGrids();
		
    if(list_sitof != 0){
		Int_t entries = (Int_t) list_sitof->GetEntries();
//		Int_t kHasGrids = 0;

		KVIDGrid *tmpGrid = 0;
//		Int_t nGridsForRun = 0;

		for(Int_t i=0; i<entries; i++){
    			tmpGrid = (KVIDGrid*) list_sitof->At(i);
    			if(tmpGrid != 0){				
				runList = (KVNumberList) tmpGrid->GetRuns();
        			runList.Begin();
        			while( !runList.End() ){
            				UInt_t next_val = (UInt_t) runList.Next();
            				if(next_val == gIndra->GetCurrentRunNumber()){
						if(strcmp(tmpGrid->GetName(),tel_name)==0){
							kvid_sitof = tmpGrid;
							}
						}
					
        				}
    				}
			} 
			
			      				
		if(kvid_chiosi != 0){

        }else{  
	    printf("Error: 'kvid_sitof' assignment failed\n");
	    cout<<"name : "<<tel_name<<endl; 	    
        }
    }else{
        //printf("Error: 'list' assignment failed\n");   
    }

return;
}
Ejemplo n.º 9
0
void KVINDRA::BuildLayer(const Char_t* name)
{
   // Build layer 'name' with infos in file "$KVROOT/KVFiles/data/indra-struct.[dataset].env"

   KVLayer* layer = new KVLayer;
   Int_t number = fStrucInfos.GetValue(Form("INDRA.Layer.%s.Number", name), 0);
   layer->SetName(name);
   layer->SetNumber(number);
   Add(layer);
   Info("BuildLayer", "Building layer %d:%s", number, name);
   KVNumberList rings = fStrucInfos.GetValue(Form("INDRA.Layer.%s.Rings", name), "");
   rings.Begin();
   while (!rings.End()) {
      Int_t ring_num = rings.Next();
      TString prefix = Form("INDRA.Layer.%s.Ring.%d", name, ring_num);
      KVRing* ring = BuildRing(ring_num, prefix);
      layer->Add(ring);
   }
}
Ejemplo n.º 10
0
KVRing* KVINDRA::BuildRing(Int_t number, const Char_t* prefix)
{
   // Build ring with infos in file "$KVROOT/KVFiles/data/indra-struct.[dataset].env"

   KVRing* ring = new KVRing;
   Info("BuildRing", "Building ring %d (%s)", number, prefix);

   Double_t thmin = fStrucInfos.GetValue(Form("%s.ThMin", prefix), 0.0);
   Double_t thmax = fStrucInfos.GetValue(Form("%s.ThMax", prefix), 0.0);
   Double_t phi_0 = fStrucInfos.GetValue(Form("%s.Phi0", prefix), 0.0);
   Int_t ntel = fStrucInfos.GetValue(Form("%s.Ntel", prefix), 0);
   Int_t step = fStrucInfos.GetValue(Form("%s.Step", prefix), 1);
   Int_t num_first = fStrucInfos.GetValue(Form("%s.Nfirst", prefix), 1);
   Double_t dphi = fStrucInfos.GetValue(Form("%s.Dphi", prefix), -1.0);
   KVNumberList absent = fStrucInfos.GetValue(Form("%s.Absent", prefix), "");

   ring->SetPolarMinMax(thmin, thmax);
   KVINDRATelescope* kvt = BuildTelescope(prefix, num_first);
   Double_t phi_min = phi_0 - 0.5 * (kvt->GetAzimuthalWidth());
   phi_min = (phi_min < 0. ? phi_min + 360. : phi_min);
   dphi = (dphi < 0. ? 360. / ntel : dphi);
   Double_t phi_max =
      phi_0 + ((ntel - 1.0) * dphi) + 0.5 * (kvt->GetAzimuthalWidth());
   phi_max = (phi_max > 360. ? phi_max - 360. : phi_max);
   ring->SetAzimuthalMinMax(phi_min, phi_max);
   ring->SetNumber(number);

   Double_t phi = phi_0;
   UInt_t counter = num_first;
   for (int i = 0; i < ntel; i++) {
      kvt->SetPolarMinMax(thmin, thmax);
      kvt->SetPhi(phi);
      phi = (phi + dphi > 360. ? (phi + dphi - 360.) : (phi + dphi));
      kvt->SetNumber(counter);
      if (!absent.Contains(counter)) ring->Add(kvt);
      else delete kvt;
      counter += step;
      if (i + 1 < ntel) kvt = BuildTelescope(prefix, counter);
   }
   ring->SetName(Form("RING_%d", number));
   return ring;
}
Ejemplo n.º 11
0
//___________________________________________________________________________________________
void KVValues::ComputeAdditionalValues(Int_t min, Int_t max)
{

   if (min < 0)   min = 0;
   if (max == -1) max = kval_add;

   KVNumberList* nl = 0;
   TFormula* fm = 0;

   for (Int_t ff = min; ff < max; ff += 1) {
      nl = (KVNumberList*)kpar_add->At(ff);
      fm = (TFormula*)kform_add->At(ff);
      nl->Begin();
      while (!nl->End()) {
         Int_t nn = nl->Next();
         fm->SetParameter(nn, values[nn]);
      }
      values[kval_tot - kval_add + ff] = fm->Eval(0);
   }
}
Ejemplo n.º 12
0
KVIonRangeTableMaterial* KVRangeYanez::MakeNaturallyOccuringElementMixture(Int_t z)
{
   // create a material containing the naturally occuring isotopes of the given element,
   // weighted according to their abundance.

   if (!gNDTManager) {
      Error("MakeNaturallyOccuringElementMixture",
            "Nuclear data tables have not been initialised");
      return NULL;
   }
   KVElementDensity* ed = (KVElementDensity*)gNDTManager->GetData(z, z, "ElementDensity");
   if (!ed) {
      Error("AddElementalMaterial",
            "No element found in ElementDensity NDT-table with Z=%d", z);
      return 0x0;
   }
   TString state = "solid";
   if (ed->IsGas()) state = "gas";
   KVRangeYanezMaterial* mat =
      new KVRangeYanezMaterial(this,
                               ed->GetElementName(),
                               ed->GetElementSymbol(),
                               state, ed->GetValue());
   KVNucleus nuc(z);
   KVNumberList isotopes = nuc.GetKnownARange();
   isotopes.Begin();
   while (!isotopes.End()) {

      nuc.SetA(isotopes.Next());
      Double_t abundance = nuc.GetAbundance() / 100.;
      if (abundance > 0.) mat->AddMixtureElement(z, nuc.GetA(), 1, abundance);

   }
   mat->Initialize();
   return (KVIonRangeTableMaterial*)mat;
}
Ejemplo n.º 13
0
//_____________________________________________________________________________________________________//
KVIDGrid* KVIDTelescope::CalculateDeltaE_EGrid(TH2* haa_zz, Bool_t Zonly, Int_t npoints)
{
   //Genere une grille dE-E (perte d'energie - energie residuelle)
   //Le calcul est fait pour chaque couple comptant de charge (Z) et masse (A)
   //au moins un coup dans l'histogramme haa_zz definit :
   // Axe X -> Z
   // Axe Y -> A
   //
   //- Si Zonly=kTRUE (kFALSE par defaut), pour un Z donne, le A choisi est la valeur entiere la
   //plus proche de la valeur moyenne <A>
   //- Si Zonly=kFALSE et que pour un Z donne il n'y a qu'un seul A associe, les lignes correspondants
   //a A-1 et A+1 sont ajoutes
   //- Si a un Z donne, il n'y a aucun A, pas de ligne tracee
   //un noyau de A et Z donne n'est considere que s'il retourne KVNucleus::IsKnown() = kTRUE
   //
   // Warning : the grid is not added to the list of the telescope and MUST BE DELETED by the user !

   if (GetSize() <= 1) return 0;

   TClass* cl = new TClass(GetDefaultIDGridClass());
   KVIDGrid* idgrid = (KVIDGrid*)cl->New();
   delete cl;

   idgrid->AddIDTelescope(this);
   idgrid->SetOnlyZId(Zonly);

   KVDetector* det_de = GetDetector(1);
   if (!det_de)      return 0;
   KVDetector* det_eres = GetDetector(2);
   if (!det_eres)    return 0;

   KVNucleus part;
   Info("CalculateDeltaE_EGrid",
        "Calculating dE-E grid: dE detector = %s, E detector = %s",
        det_de->GetName(), det_eres->GetName());

   KVIDCutLine* B_line = (KVIDCutLine*)idgrid->Add("OK", "KVIDCutLine");
   Int_t npoi_bragg = 0;
   B_line->SetName("Bragg_line");
   B_line->SetAcceptedDirection("right");

   Double_t SeuilE = 0.1;

   for (Int_t nx = 1; nx <= haa_zz->GetNbinsX(); nx += 1) {

      Int_t zz = TMath::Nint(haa_zz->GetXaxis()->GetBinCenter(nx));
      KVNumberList nlA;
      Double_t sumA = 0, sum = 0;
      for (Int_t ny = 1; ny <= haa_zz->GetNbinsY(); ny += 1) {
         Double_t stat = haa_zz->GetBinContent(nx, ny);
         if (stat > 0) {
            Double_t val = haa_zz->GetYaxis()->GetBinCenter(ny);
            nlA.Add(TMath::Nint(val));
            sumA += val * stat;
            sum  += stat;
         }
      }
      sumA /= sum;
      Int_t nA = nlA.GetNValues();
      if (nA == 0) {
         Warning("CalculateDeltaE_EGrid", "no count for Z=%d", zz);
      } else {
         if (Zonly) {
            nlA.Clear();
            nlA.Add(TMath::Nint(sumA));
         } else {
            if (nA == 1) {
               Int_t aref = nlA.Last();
               nlA.Add(aref - 1);
               nlA.Add(aref + 1);
            }
         }
         part.SetZ(zz);
//            printf("zz=%d\n",zz);
         nlA.Begin();
         while (!nlA.End()) {
            Int_t aa = nlA.Next();
            part.SetA(aa);
//                printf("+ aa=%d known=%d\n",aa,part.IsKnown());
            if (part.IsKnown()) {

               //loop over energy
               //first find :
               //  ****E1 = energy at which particle passes 1st detector and starts to enter in the 2nd one****
               //      E2 = energy at which particle passes the 2nd detector
               //then perform npoints calculations between these two energies and use these
               //to construct a KVIDZALine

               Double_t E1, E2;
               //find E1
               //go from SeuilE MeV to det_de->GetEIncOfMaxDeltaE(part.GetZ(),part.GetA()))
               Double_t E1min = SeuilE, E1max = det_de->GetEIncOfMaxDeltaE(zz, aa);
               E1 = (E1min + E1max) / 2.;

               while ((E1max - E1min) > SeuilE) {

                  part.SetEnergy(E1);
                  det_de->Clear();
                  det_eres->Clear();

                  det_de->DetectParticle(&part);
                  det_eres->DetectParticle(&part);
                  if (det_eres->GetEnergy() > SeuilE) {
                     //particle got through - decrease energy
                     E1max = E1;
                     E1 = (E1max + E1min) / 2.;
                  } else {
                     //particle stopped - increase energy
                     E1min = E1;
                     E1 = (E1max + E1min) / 2.;
                  }
               }

               //add point to Bragg line
               Double_t dE_B = det_de->GetMaxDeltaE(zz, aa);
               Double_t E_B = det_de->GetEIncOfMaxDeltaE(zz, aa);
               Double_t Eres_B = det_de->GetERes(zz, aa, E_B);
               B_line->SetPoint(npoi_bragg++, Eres_B, dE_B);

               //find E2
               //go from E1 MeV to maximum value where the energy loss formula is valid
               Double_t E2min = E1, E2max = det_eres->GetEmaxValid(part.GetZ(), part.GetA());
               E2 = (E2min + E2max) / 2.;

               while ((E2max - E2min > SeuilE)) {

                  part.SetEnergy(E2);
                  det_de->Clear();
                  det_eres->Clear();

                  det_de->DetectParticle(&part);
                  det_eres->DetectParticle(&part);
                  if (part.GetEnergy() > SeuilE) {
                     //particle got through - decrease energy
                     E2max = E2;
                     E2 = (E2max + E2min) / 2.;
                  } else {
                     //particle stopped - increase energy
                     E2min = E2;
                     E2 = (E2max + E2min) / 2.;
                  }
               }

//                    printf("z=%d a=%d E1=%lf E2=%lf\n",zz,aa,E1,E2);
               KVIDZALine* line = (KVIDZALine*)idgrid->Add("ID", "KVIDZALine");
               if (TMath::Even(zz)) line->SetLineColor(4);
               line->SetAandZ(aa, zz);

               Double_t logE1 = TMath::Log(E1);
               Double_t logE2 = TMath::Log(E2);
               Double_t dLog = (logE2 - logE1) / (npoints - 1.);

               for (Int_t i = 0; i < npoints; i++) {
                  Double_t E = TMath::Exp(logE1 + i * dLog);
                  Double_t Eres = 0.;
                  Int_t niter = 0;
                  while (Eres < SeuilE && niter <= 20) {
                     det_de->Clear();
                     det_eres->Clear();

                     part.SetEnergy(E);

                     det_de->DetectParticle(&part);
                     det_eres->DetectParticle(&part);

                     Eres = det_eres->GetEnergy();
                     E += SeuilE;

                     niter += 1;
                  }
                  if (!(niter > 20)) {
                     Double_t dE = det_de->GetEnergy();
                     Double_t gEres, gdE;
                     line->GetPoint(i - 1, gEres, gdE);
                     line->SetPoint(i, Eres, dE);
                  }
               }

            }
         }

      }

   }

   return idgrid;

}
Ejemplo n.º 14
0
//___________________________________________________________________________________________
KVNumberList* KVValues::TransformExpression(KVString& expr)
{

   KVNumberList* nl = new KVNumberList();

   const char* O = "[";
   const char* F = "]";

   KVString clone;
   clone.Form("%s", expr.Data());
   const char* expression = clone.Data();

   Int_t nouvert = 0, nferme = 0;
   Int_t posouvert = 0, posferme = 0;
   Int_t nvar = 0;

   Int_t nsize = clone.Length();
   for (Int_t ii = 0; ii <= nsize; ii += 1) {
      if (expression[ii] == O[0]) {
         nouvert += 1;
         posouvert = ii;
      }
      else if (expression[ii] == F[0]) {
         nferme += 1;
         posferme = ii;
         KVString st(clone(posouvert + 1, posferme - posouvert - 1));
         if (st.IsDigit()) {
            Int_t idx = st.Atoi();
            if (0 <= idx && idx < kval_tot) {
               nl->Add(idx);
               nvar += 1;
            }
            else {
               delete nl;
               return 0;
            }
         }
         else {

            Int_t idx = GetValuePosition(st.Data());
            if (idx == -1) {
               delete nl;
               return 0;
            }
            nl->Add(idx);
            nvar += 1;
            KVString s1;
            s1.Form("[%s]", st.Data());
            KVString s2;
            s2.Form("[%d]", idx);
            expr.ReplaceAll(s1, s2);
         }
      }
      else {}
   }

   if (nouvert != nferme || nvar != nouvert) {
      Error("TransformExpr", "nombre [ : %d - nombre de ] : %d - nombre de variables %d", nouvert, nferme, nvar);
   }

   return nl;

}
Ejemplo n.º 15
0
void KV_CCIN2P3_GE::Run()
{
   //Processes the job requests for the batch system.
   //In normal mode, this submits one job for the data analyser fAnalyser
   //In multijobs mode, this submits one job for each run in the runlist associated to fAnalyser

   if (!CheckJobParameters()) return;

   if (MultiJobsMode()) {
      if (fAnalyser->InheritsFrom("KVDataSetAnalyser")) {
         //submit jobs for every GetRunsPerJob() runs in runlist
         KVDataSetAnalyser* ana = dynamic_cast<KVDataSetAnalyser*>(fAnalyser);
         KVNumberList runs = ana->GetRunList();
         runs.Begin();
         Int_t remaining_runs = runs.GetNValues();
         fCurrJobRunList.Clear();
         while (remaining_runs && !runs.End()) {
            Int_t run = runs.Next();
            remaining_runs--;
            fCurrJobRunList.Add(run);
            if ((fCurrJobRunList.GetNValues() == GetRunsPerJob()) || runs.End()) {
               // submit job for GetRunsPerJob() runs (or less if we have reached end of runlist 'runs')
               ana->SetRuns(fCurrJobRunList, kFALSE);
               ana->SetFullRunList(runs);
               SubmitJob();
               fCurrJobRunList.Clear();
            }
         }
         ana->SetRuns(runs, kFALSE);
      }
      else if (fAnalyser->InheritsFrom("KVSimDirAnalyser")) {
         // here we understand "run" to mean "file"
         KVSimDirAnalyser* ana = dynamic_cast<KVSimDirAnalyser*>(fAnalyser);
         TList* file_list = ana->GetFileList();
         Int_t remaining_runs = ana->GetNumberOfFilesToAnalyse();
         fCurrJobRunList.Clear();
         TList cur_file_list;
         TObject* of;
         TIter it(file_list);
         Int_t file_no = 1;
         while ((of = it())) {
            cur_file_list.Add(of);
            fCurrJobRunList.Add(file_no);
            remaining_runs--;
            file_no++;
            if ((fCurrJobRunList.GetNValues() == GetRunsPerJob()) || (remaining_runs == 0)) {
               // submit job for GetRunsPerJob() files (or less if we have reached end of list)
               ana->SetFileList(&cur_file_list);
               SubmitJob();
               fCurrJobRunList.Clear();
               cur_file_list.Clear();
            }
         }
         ana->SetFileList(file_list);
      }
   }
   else {
      SubmitJob();
   }

}
Ejemplo n.º 16
0
void CsICalib::InitTelescopeChioSi(Int_t ci_num, Int_t si_num)
{
    
    Char_t si_name [128] = "null";
    Char_t ci_name [128] = "null";

    sprintf(si_name, "SIE_%02i", si_num+1); 
    sprintf(ci_name, "CI_%02i", ci_num);

    Char_t tel_name [128] = "null";
    //sprintf(tel_name, "CI_%02i_SIE_%02i", ci_num, si_num+1);
    sprintf(tel_name, "CI_01_SIE_18");	//Similar grids (using energies) for all Chio-Si combinaisons
    //cout<<"tel_name 1: "<<tel_name<<endl; 	
	
    list_chiosi = 0;        
//    KVList *grid_list = 0;
    kvid_chiosi = 0;
    KVNumberList runList = 0;

    list_chiosi = (KVList*) gIDGridManager->GetGrids();
		
    if(list_chiosi != 0){
		//cout<<"list_chiosi!=0"<<endl;
		Int_t entries = (Int_t) list_chiosi->GetEntries();
//		Int_t kHasGrids = 0;

		KVIDGrid *tmpGrid = 0;
//		Int_t nGridsForRun = 0;

		for(Int_t i=0; i<entries; i++){
    			tmpGrid = (KVIDGrid*) list_chiosi->At(i);
    			if(tmpGrid != 0){
				//cout<<"tmpGrid!=0"<<endl;				
				runList = (KVNumberList) tmpGrid->GetRuns();
        			runList.Begin();
        			while( !runList.End() ){
            				UInt_t next_val = (UInt_t) runList.Next();
            				if(next_val == gIndra->GetCurrentRunNumber()){
						//cout<<"next_val : "<<next_val<<endl;
						//L->Log<<"name : "<<tmpGrid->GetName()<<endl;
						if(strcmp(tmpGrid->GetName(),tel_name)==0){
							//L->Log<<"tel_name 2 : "<<tmpGrid->GetName()<<endl;
							//cout<<"tel_name 2: "<<tel_name<<endl;
							kvid_chiosi = tmpGrid;
							}
						}
					
        				}
    				}
			} 
			
			      				
		if(kvid_chiosi != 0){

        }else{  
	    printf("Error: 'kvid_chiosi' assignment failed\n");
	    cout<<"ci_num : "<<ci_num<<" si_num : "<<si_num+1<<endl; 
	    cout<<"name : "<<tel_name<<endl; 	    
        }
    }else{
        //printf("Error: 'list' assignment failed\n");   
    }

return;
}