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 KVIntegerList::Update() { //protected method, Mise a jour du nom de la partition (via SetName()), de sa longueur (fLength) //Le bit kHastobeComputed es mis à 0 pour indiquer que la mise à jour a été faite // KVString snom = "", stamp = ""; for (Int_t ii = fLimiteRegle; ii >= 0; ii -= 1) { Int_t contenu = fRegle->At(ii); if (contenu > 0) { //Formattage du nom de la partition stamp.Form("%d", ii); snom += stamp; if (contenu > 1) { stamp.Form("(%d)", contenu); snom += stamp; } snom += " "; } } if (snom != "") snom.Remove(snom.Length() - 1); SetName(snom.Data()); fLength = snom.Length(); SetBit(kHastobeComputed, kFALSE); }
Bool_t KVSimReader_SMF_asym::ReadHeader(){ KVString snom; Int_t res = ReadLineAndCheck(1," "); switch (res){ case 0: return kFALSE; case 1: snom.Form("%s",GetReadPar(0).Data()); snom.ReplaceAll("evt_",""); //Info("ReadHeader","lecture %d",snom.Atoi()); nv->SetValue("event_number",snom.Atoi()); break; default: return kFALSE; } res = ReadLineAndCheck(1," "); switch (res){ case 0: return kFALSE; case 1: nv->SetValue("ndes",GetIntReadPar(0)); ndes = 0; return kTRUE; default: return kFALSE; } }
const Char_t* KV_CCIN2P3_GE::GetJobName() const { //Returns name of batch job, either during submission of batch jobs or when an analysis //task is running in batch mode (access through gBatchSystem global pointer). // //In multi-job mode, the job name is generated from the base name set by SetJobName() //plus the extension "_Rxxxx-yyyy" with "xxxx" and "yyyy" the number of the first and last run //which will be analysed by the current job. // // Depending on the batch system, some sanitization of the jobname may be required // e.g. to remove "illegal" characters from the jobname. This is done by SanitizeJobName() // before the jobname is returned. if (!fAnalyser) { //stand-alone batch submission ? fCurrJobName = fJobName; } else { //replace any special symbols with their current values fCurrJobName = fAnalyser->ExpandAutoBatchName(fJobName.Data()); if (MultiJobsMode() && !fAnalyser->BatchMode()) { KVString tmp; if (fCurrJobRunList.GetNValues() > 1) tmp.Form("_R%d-%d", fCurrJobRunList.First(), fCurrJobRunList.Last()); else tmp.Form("_R%d", fCurrJobRunList.First()); fCurrJobName += tmp; } } SanitizeJobName(); return fCurrJobName.Data(); }
//________________________________________________________________ Double_t KVCaloBase::GetIngValue(KVString name) { //return the value of a name given ingredient //if it is not defined return 0 if (!nvl_ing->HasParameter(name.Data())) return 0; return nvl_ing->GetDoubleValue(name.Data()); }
void KV_CCIN2P3_GE::ChangeDefJobOpt(KVDataAnalyser* da) { // PRIVATE method called by SubmitTask() at moment of job submission. // Depending on the current environment, the default job submission options // may be changed by this method. // // This method overrides and augments KVBatchSystem::ChangeDefJobOpt (which // changes the options as a function of the type of analysis task). // Here we add the CCIN2P3-specific case where the job is launched from a directory // on the /sps/ semi-permanent storage facility, or if the data being analysed is // stored in a repository on /sps/. In this case we need to add // the option '-l u_sps_indra' to the 'qsub' command (if not already in the // default job options) // KVBatchSystem::ChangeDefJobOpt(da); KVString taskname = da->GetAnalysisTask()->GetName(); KVString rootdir = da->GetRootDirectoryOfDataToAnalyse(); Bool_t repIsSPS = rootdir.BeginsWith("/sps/"); KVString wrkdir(gSystem->WorkingDirectory()); KVString oldoptions(GetDefaultJobOptions()); if (!oldoptions.Contains("sps")) { Bool_t NeedToAddSPS = wrkdir.Contains("/sps/"); if ((NeedToAddSPS || repIsSPS)) { oldoptions += " -l sps=1"; SetDefaultJobOptions(oldoptions.Data()); Info("ChangeDefJobOpt", "Your job is being launched from /sps/... zone.\nTherefore the ressource 'sps' has been declared and the number of jobs which can be treated concurrently will be limited."); } } }
void KVSimDir::AnalyseDirectory() { // Read contents of directory given to ctor. // Each ROOT file will be analysed by AnalyseFile(). Info("AnalyseDirectory", "Analysing %s...", GetDirectory()); fSimData.Clear(); fFiltData.Clear(); //loop over files in current directory TSystemDirectory thisDir(".", GetDirectory()); TList* fileList = thisDir.GetListOfFiles(); TIter nextFile(fileList); TSystemFile* aFile = 0; while ((aFile = (TSystemFile*)nextFile())) { if (aFile->IsDirectory()) continue; KVString fileName = aFile->GetName(); if (!fileName.EndsWith(".root")) continue; /* skip non-ROOT files */ AnalyseFile(fileName); } delete fileList; }
//___________________________________________________________________________________________ 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()); } }
KVRangeYanez::KVRangeYanez() : KVIonRangeTable("RANGE", "Interface to Range dE/dx and range library (Ricardo Yanez)") { // Default constructor // Predefined materials are created based on the contents of the file(s) whose // names are given as values of the variable KVRangeYanez.PredefMaterials. // A default file is specified in the main .kvrootrc file. // If you want to add your own definitions, just put in your .kvrootrc: //+RANGE.PredefMaterials: myfile1.dat //+RANGE.PredefMaterials: myfile2.dat // If you want to override the default definitions: //RANGE.PredefMaterials: myfile1.dat //+RANGE.PredefMaterials: myfile2.dat KVString DataFilePaths = gEnv->GetValue("RANGE.PredefMaterials", ""); DataFilePaths.Begin(" "); KVString nextPath; KVString lastPath; while (!DataFilePaths.End()) { nextPath = DataFilePaths.Next(); if (nextPath == lastPath) break; //check for double occurrence of last file : TEnv bug? lastPath = nextPath; ReadPredefinedMaterials(nextPath); } }
void KV_CCIN2P3_GE::ChooseJobDisk() { KVString tmp = ""; cout << "Enter max scratch disk per job (xKB/xMB/xGB) [" << fDefJobDisk.Data() << "] : "; cout.flush(); tmp.ReadToDelim(cin); SetJobDisk(tmp.Data()); }
void KV_CCIN2P3_GE::ChooseJobMemory() { KVString tmp = ""; cout << "Enter max memory per job (xKB/xMB/xGB) [" << fDefJobMem.Data() << "] : "; cout.flush(); tmp.ReadToDelim(cin); SetJobMemory(tmp.Data()); }
//___________________________________________________________________________________________ void KVValues::init_val_base() { //protected method //Mise en correspondance du noms des differentes valeurs a calculees //et de leur position dans le tableau values // Ex: // nom_valeurs -> id_valeurs -> values[id_valeurs] KVString lname = "MIN MAX"; lname.Begin(" "); kval_base = 0; //variables de base disponibles kval_tot = 0; //nombre de variables totales disponibles while (!lname.End()) { KVString tamp = lname.Next(); SetValue(tamp.Data(), kval_tot++); } kdeb = kval_tot; //ici pos_deb=2 (par defaut) KVString smoment; for (Int_t mm = 0; mm <= kordre_mom_max; mm += 1) { //Ex: moment_max = 3 smoment.Form("SUM%d", mm); SetValue(smoment.Data(), kval_tot++); } kval_base = kval_tot; //ici nbase=6 (par defaut) values = new Double_t[knbre_val_max]; init_val(); }
void KVTGIDGrid::ReadFromAsciiFile(ifstream& gridfile) { // Read grid and parameters of LTG fit used to generate grid in gridfile. KVIDGraph::ReadFromAsciiFile(gridfile); KVString line; if (fPar->GetIntValue("HasTGID")) { line.ReadLine(gridfile); if (line.BeginsWith("++KVTGID")) fTGID = KVTGID::ReadFromAsciiFile(GetName(), gridfile); } FindAxisLimits(); }
//___________________________________________________________________________________________ Bool_t KVValues::AddFormula(KVString name, KVString expr) { TFormula* fm = new TFormula(name.Data(), expr.Data()); if (fm->GetExpFormula().IsNull()) { Warning("AddFormula", "%s considere comme nulle", expr.Data()); return kFALSE; delete fm; } kform_add->Add(fm); SetValue(name.Data(), kval_tot++); kval_add += 1; return kTRUE; }
void KV_CCIN2P3_GE::ChooseJobTime() { KVString tmp = ""; cout << "Enter max CPU time per job (ss/mn:ss/hh:mn:ss) [" << fDefJobTime << "] : "; cout.flush(); tmp.ReadToDelim(cin); if (!tmp.Length()) { SetJobTime(); return; } else SetJobTime(tmp); }
void KVINDRA::SetPinLasersForCsI() { // Sets the KVCsI::fPinLaser member of each CsI detector with the number of the // pin laser associated for the stability control of these detectors. // // We look for a file with the following format: // // CSI_0101 1 // CSI_0102 1 // CSI_0103 1 // CSI_0104 1 // etc. // // i.e. 'name of CsI detector' 'number of pin laser (1-8)' // Comment lines must begin with '#' // // The default name of this file is defined in .kvrootrc by // // INDRADB.CsIPinCorr: CsI_PILA.dat // // Dataset-specific version can be specified: // // INDRA_e999.INDRADB.CsIPinCorr: CorrCsIPin_2054.dat // // This file should be in the directory corresponding to the current dataset, // i.e. in $KVROOT/KVFiles/name_of_dataset ifstream pila_file; if (gDataSet->OpenDataSetFile(gDataSet->GetDataSetEnv("INDRADB.CsIPinCorr", ""), pila_file)) { Info("SetPinLasersForCsI", "Setting correspondance CsI-PinLaser using file %s.", gDataSet->GetDataSetEnv("INDRADB.CsIPinCorr", "")); // read file, set correspondance KVString line; line.ReadLine(pila_file); while (pila_file.good()) { if (!line.BeginsWith("#")) { line.Begin(" "); KVString detname = line.Next(kTRUE); KVCsI* det = (KVCsI*)GetDetector(detname.Data()); Int_t pila = line.Next(kTRUE).Atoi(); if (det) { det->SetPinLaser(pila); } } line.ReadLine(pila_file); } pila_file.close(); } else { Info("SetPinLasersForCsI", "File %s not found. Correspondance Csi-PinLaser is unknown.", gDataSet->GetDataSetEnv("CsIPinCorr", "")); } }
const Char_t* KVINDRAReconDataAnalyser::ExpandAutoBatchName(const Char_t* format) { //Replace any 'special' symbols in "format" with their current values // // $Date : current date and time // $System : name of system to be analysed // $User : name of user // $UserClass or $Selector : name of user's analysis class (KVSelector) // $DataSelector : name of user's data selector (KVDataSelector) static KVString tmp; tmp = KVDataAnalyser::ExpandAutoBatchName(format); tmp.ReplaceAll("$Selector", GetUserClass()); tmp.ReplaceAll("$DataSelector", GetKVDataSelector()); return tmp.Data(); }
void KVFAZIA::SetNameOfDetectors(KVEnv& env) { for (Int_t bb = fStartingBlockNumber; bb < fNblocks; bb += 1) { for (Int_t qq = 1; qq <= 4; qq += 1) { for (Int_t tt = 1; tt <= 4; tt += 1) { fDetectorLabels.Begin(","); while (!fDetectorLabels.End()) { KVString sdet = fDetectorLabels.Next(); env.SetValue( Form("BLOCK_%d_QUARTET_%d_%s-T%d", bb, qq, sdet.Data(), tt), Form("%s-T%d-Q%d-B%03d", sdet.Data(), tt, qq, bb) ); } } } } }
void KVDP2toCsIGridConvertor::ReadGammaFile(const Char_t* gammafile) { ifstream gamfile; gamfile.open(gammafile); if (!gamfile.good()) { Error(KV__ERROR(ReadGammaFile), "Problem reading file %s", gammafile); return; } KVString s; s.ReadLine(gamfile); while (gamfile.good()) { if (s == "") { s.ReadLine(gamfile); continue; } if (!s.BeginsWith('#')) { //'#' sign signals comments int ring, modu, frun, lrun; if (sscanf(s.Data(), "%d %d %d %d", &ring, &modu, &frun, &lrun) != 4) { Error(KV__ERROR(ReadGammaFile), "Problem reading file %s\nLast line read: %s", gammafile, s.Data()); return; }; //get grid for this ring,mod TString name; name. Form ("CsI R-L Grid First run=%d Last run=%d Ring min=%d Ring max=%d Mod min=%d Mod max=%d", frun, lrun, ring, ring, modu, modu); KVIDGrid* grid = (KVIDGrid*)fGrids->FindObject(name.Data()); if (!grid) { Error(KV__ERROR(ReadGammaFile), "Can't find grid %s", name.Data()); } int npoints; gamfile >> npoints; //found gamma line KVIDLine* line = 0; if (grid) { line = grid->NewLine("ok"); line->SetName("gamma_line"); line->Set(npoints); grid->Add("ok", line); } //read in points for (int i = 0; i < npoints; i++) { Double_t x, y; gamfile >> x >> y; if (grid) line->SetPoint(i, x, y); } } s.ReadLine(gamfile); }
void KVFAZIARawDataReconstructor::ExtraProcessing() { KVString label = ""; KVFAZIADetector* det = 0; KVSignal* sig = 0; KVReconstructedNucleus* recnuc = 0; while ((recnuc = recev->GetNextParticle())) { TIter next_d(recnuc->GetDetectorList()); while ((det = (KVFAZIADetector*)next_d())) { TIter next_s(det->GetListOfSignals()); while ((sig = (KVSignal*)next_s())) { if (sig->HasFPGA()) { for (Int_t ii = 0; ii < sig->GetNFPGAValues(); ii += 1) { //SI2-T3-Q1-B003.Q2.RawAmplitude=14 if (ii == 0) label = "FPGAEnergy"; if (ii == 1) label = "FPGAFastEnergy"; //only for CsI Q3 TString ene = GetEvent()->GetFPGAEnergy( det->GetBlockNumber(), det->GetQuartetNumber(), det->GetTelescopeNumber(), sig->GetType(), ii ); recnuc->GetParameters()->SetValue( Form("%s.%s.%s", det->GetName(), sig->GetName(), label.Data()), ene.Data() ); } } if (!sig->PSAHasBeenComputed()) { sig->TreateSignal(); } KVNameValueList* psa = sig->GetPSAResult(); if (psa) { *(recnuc->GetParameters()) += *psa; delete psa; } } } } }
//___________________________________________________________________________________________ void KVIntegerList::SetPartition(const Char_t* par) { //protected method, utilisée par le Streamer qui utilise le champ fName de la classe TNamed //voir également KVIntegerList::DeducePartitionFromTNamed KVString st(par); st.Begin(" "); TObjArray* toks = 0; while (!st.End()) { KVString tamp = st.Next(); Int_t val; Int_t freq; if (tamp.Contains("(")) { if (!tamp.Contains(")")) { Warning("SetPartition", "%s ->pb de coherence dans les parentheses", tamp.Data()); return; } else { toks = tamp.Tokenize("("); val = ((TObjString*)toks->At(0))->GetString().Atoi(); freq = ((TObjString*)toks->At(1))->GetString().Atoi(); delete toks; } } else { val = tamp.Atoi(); freq = 1; } Add(val, freq); } }
void KVBatchSystemManager::Init() { //Set up list of available batch systems gBatchSystem = 0; KVString list = gEnv->GetValue("BatchSystem", ""); fBatchSystems.Clear(); TObjArray* systems = list.Tokenize(" "); TIter next(systems); TObjString* batch_sys; while ((batch_sys = (TObjString*)next())) { KVBatchSystem* bs = KVBatchSystem::GetBatchSystem(batch_sys->GetString().Data()); fBatchSystems.Add(bs); } delete systems; //set default fDefault = (KVBatchSystem*)fBatchSystems.FindObjectByName(gEnv->GetValue("Default.BatchSystem", "")); }
KVNumberList KVINDRAReconDataAnalyser::PrintAvailableRuns(KVString & datatype) { //Prints list of available runs, sorted according to multiplicity //trigger, for selected dataset, data type/analysis task, and system //Returns list containing all run numbers KVNumberList all_runs= fDataSet->GetRunList(datatype.Data(), fSystem); KVINDRADBRun *dbrun; //first read list and find what triggers are available int triggers[10], n_trigs = 0; all_runs.Begin(); while ( !all_runs.End() ) { dbrun = (KVINDRADBRun *)fDataSet->GetDataBase()->GetTable("Runs")->GetRecord(all_runs.Next()); if (!KVBase:: ArrContainsValue(n_trigs, triggers, dbrun->GetTrigger())) { triggers[n_trigs++] = dbrun->GetTrigger(); } } //sort triggers in ascending order int ord_trig[10]; TMath::Sort(n_trigs, triggers, ord_trig, kFALSE); int trig = 0; while (trig < n_trigs) { cout << " ---> Trigger M>" << triggers[ord_trig[trig]] << endl; all_runs.Begin(); while ( !all_runs.End() ) { dbrun = (KVINDRADBRun *)fDataSet->GetDataBase()->GetTable("Runs")->GetRecord(all_runs.Next()); if (dbrun->GetTrigger() == triggers[ord_trig[trig]]) { cout << " " << Form("%4d", dbrun->GetNumber()); cout << Form("\t(%7d events)", dbrun->GetEvents()); cout << "\t[File written: " << dbrun->GetDatime(). AsString() << "]"; if (dbrun->GetComments()) cout << "\t" << dbrun->GetComments(); cout << endl; } } trig++; cout << endl; } return all_runs; }
void KVINDRAPulserDataTree::ReadFile(ifstream& fin) { // Read data in one file KVString line; line.ReadLine(fin); while( fin.good() ){ if( !line.BeginsWith("#") ){ line.Begin(" "); KVString br_name = line.Next(kTRUE); Int_t index = GetIndex(br_name.Data()); fVal[index] = line.Next(kTRUE).Atof(); } line.ReadLine(fin); } fin.close(); }
KVNumberList KVINDRARawDataAnalyser::PrintAvailableRuns(KVString& datatype) { //Prints list of available runs, sorted according to multiplicity //trigger, for selected dataset, data type/analysis task, and system //Returns list containing all run numbers KVNumberList all_runs = GetDataSet()->GetRunList(datatype.Data(), GetSystem()); KVINDRADBRun* dbrun; //first read list and find what triggers are available vector<int> triggers; all_runs.Begin(); while (!all_runs.End()) { dbrun = (KVINDRADBRun*)GetDataSet()->GetDataBase()->GetDBRun(all_runs.Next()); if (triggers.size() == 0 || std::find(triggers.begin(), triggers.end(), dbrun->GetTrigger()) != triggers.end()) { triggers.push_back(dbrun->GetTrigger()); } } //sort triggers in ascending order std::sort(triggers.begin(), triggers.end()); for (std::vector<int>::iterator it = triggers.begin(); it != triggers.end(); ++it) { cout << " ---> Trigger M>" << *it << endl; all_runs.Begin(); while (!all_runs.End()) { dbrun = (KVINDRADBRun*)GetDataSet()->GetDataBase()->GetDBRun(all_runs.Next()); if (dbrun->GetTrigger() == *it) { cout << " " << Form("%4d", dbrun->GetNumber()); cout << Form("\t(%7d events)", dbrun->GetEvents()); cout << "\t[File written: " << dbrun->GetDatime(). AsString() << "]"; if (dbrun->GetComments()) cout << "\t" << dbrun->GetComments(); cout << endl; } } cout << endl; } return all_runs; }
//________________________________________________________________________________________ TGraph* KVINDRA::GetPedestals(const Char_t* det_signal, const Char_t* det_type, Int_t ring_number, Int_t run_number) { //Renvoie sous forme de TGraph (en fonction du numero de module) //les piedestaux du signal (det_signal) asssocies aux detecteurs de type (det_type) //qui sont presents dans la couronne ring_number pour un numero de run donne (si run_number==-1) //on suppose que gIndra->SetParameters(xxx) a ete fait en amont //L'utilisateur doit effacer ce TGraph tout seul comme un grand apres usage //Une recherche sur l existence ou non du graph permet d eviter des boucles inutiles //Si l appel est reitere if (run_number != -1 || run_number != Int_t(GetCurrentRunNumber())) SetParameters(run_number); KVSeqCollection* sltype = 0; KVSeqCollection* slring = 0; TGraph* gr_ped = 0; KVString sgraph; sgraph.Form("KVPed_%s_%s_%d_%d", det_signal, det_type, ring_number, GetCurrentRunNumber()); if ((gr_ped = (TGraph*)gROOT->FindObject(sgraph.Data()))) return gr_ped; if ((sltype = GetDetectors()->GetSubListWithMethod(det_type, "GetType"))) { KVString sring; sring.Form("%d", ring_number); if ((slring = sltype->GetSubListWithMethod(sring, "GetRingNumber"))) { gr_ped = new TGraph(); gr_ped->SetName(sgraph.Data()); for (Int_t mm = 0; mm < slring->GetEntries(); mm += 1) { gr_ped->SetPoint(gr_ped->GetN(), ((KVINDRADetector*)slring->At(mm))->GetModuleNumber(), ((KVDetector*)slring->At(mm))->GetPedestal(det_signal)); } delete slring; return gr_ped; } delete sltype; } return 0; }
//________________________________________________________________ Double_t KVCaloBase::GetParValue(KVString name) { //return the value of a name given parameter return nvl_par->GetDoubleValue(name.Data()); }
//________________________________________________________________ Bool_t KVCaloBase::HasParameter(KVString name) { // protected method, //Check if a given parameter is defined return nvl_par->HasParameter(name.Data()); }
//________________________________________________________________ void KVCaloBase::SetIngValue(KVString name,Double_t value) { // protected method, //set the value a name given ingredient nvl_ing->SetValue(name.Data(),value); }
void KVGeoNavigator::FormatStructureName(const Char_t* type, Int_t number, KVString& name) { // If a format for naming structures of given type has been defined by a call // to SetStructureNameFormat(const Char_t *, const Char_t *), we use it to // format the name in the TString. // If no format was given, we use by default "[type]_[number]" // If SetNameCorrespondanceList(const Char_t *) was used, we use it to translate // any names resulting from this formatting to their final value. name = ""; if (fStrucNameFmt.HasParameter(type)) { KVString fmt = fStrucNameFmt.GetStringValue(type); fmt.Begin("$"); while (!fmt.End()) { KVString bit = fmt.Next(); if (bit.BeginsWith("type")) { Ssiz_t ind = bit.Index("%"); if (ind > -1) { bit.Remove(0, ind); name += Form(bit.Data(), type); } else name += type; } else if (bit.BeginsWith("number")) { Ssiz_t ind = bit.Index("%"); if (ind > -1) { bit.Remove(0, ind); name += Form(bit.Data(), number); } else name += number; } else name += bit; } } else name.Form("%s_%d", type, number); TString tmp; GetNameCorrespondance(name.Data(), tmp); name = tmp; }