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(); }
//___________________________________________________________________________________________ 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(); }
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; } }
//________________________________________________________________________________________ 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; }
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; }
//________________________________________________________________ void KVVAMOSDetector::SetFiredBitmask(KVString& lpar_dummy) { // Set bitmask used to determine which acquisition parameters are // taken into account by KVVAMOSDetector::Fired based on the environment variables // [dataset].KVACQParam.[par name].Working: NO // [dataset].KVDetector.Fired.ACQParameterList.[type]: Q,T,T_HF,E,X,Y // The first allows to define certain acquisition parameters as not functioning; // they will not be taken into account. // The second allows to "fine-tune" what is meant by "all" or "any" acquisition parameters // (i.e. when using Fired("all"), Fired("any"), Fired("Pall", etc.). // For each detector type, give a comma-separated list of the acquisition // parameter types to be taken into account in the KVDetector::Fired method. // Only those parameters which appear in the list will be considered: // then "all" means => for each type in the list at least one acquisition // parameter has to be fired // and "any" means => at least for one type of the list an acquisition parameter // has to be fired // These lists are read during construction of VAMOS (KVVAMOS::Build), // the method KVVAMOS::SetACQParams uses them to define a mask for each detector // of the spectrometer. // X, Y and Z types that we can set in a list are not associated to acquisition // parameters. In the bitmask, the 3 first bits are kept for these coordinates. // If one of these 3 bits is 1 then the methode GetRawPosition(Double_t *) // is called and the returned values is compared to these 3 bits. // If no variable [dataset].KVDetector.Fired.ACQParameterList.[type] exists, // we set a bitmask authorizing all acquisition parameters of the detector, e.g. // if the detector has 3 types of acquisition parameters which are fired byt // no position type then the bitmask will be "111000" UNUSED(lpar_dummy); // lpar is determined below fFiredMask.Set(""); KVString inst; //inst.Form("KVVAMOSDetector.Fired.ACQParameterList.%s", GetType()); inst.Form(GetFiredACQParameterListFormatString(), GetType()); KVString lpar = gDataSet->GetDataSetEnv(inst); TObjArray* toks = lpar.Tokenize(","); if (!toks->GetEntries()) { fFiredMask.Set("11111111"); delete toks; return; } // 3 first bits for XYZ positions UChar_t idx; const Char_t* pos[3] = {"X", "Y", "Z"}; for (Int_t i = 0; i < 3; i++) { idx = GetPositionTypeIdx(pos[i]) ; if ((idx < 9) && (toks->FindObject(pos[i]))) fFiredMask.SetBit(i); } UChar_t Nbits = 3; // other bits for Acquisition parameters UChar_t idx_max = 0; Bool_t found = kFALSE; TIter next(toks); TObject* obj = NULL; while ((obj = next())) { idx = GetACQParamTypeIdx(obj->GetName()); if (idx < 9) { found = kTRUE; fFiredMask.SetBit(idx + Nbits); if (idx > idx_max) idx_max = idx; } } delete toks; if (found) Nbits += idx_max + 1; fFiredMask.SetNBits(Nbits); }
//___________________________________________________________________________________________ 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; }
void KVEventListMaker::Process(){ if (!IsReady()) return; //open file where tree is stored TFile *file = new TFile(GetFileName().Data(),"update"); KVList *kevtlist = new KVList(); TTree *tt = NULL; //just count the number of branches KVString lname = GetBranchName(); Int_t nbre=0; lname.Begin(" "); while (!lname.End()) {KVString stamp=lname.Next(); nbre+=1;} if (nbre==0) return; Int_t *variable = new Int_t[nbre]; KVString evtname; Bool_t ok=kFALSE; //check if the tree are there if ( (tt = (TTree *)file->Get(GetTreeName().Data())) ){ Int_t nentries = tt->GetEntries(); printf("nbre d entree %d\n",nentries); TBranch* bb = NULL; nbre=0; lname.Begin(" "); //loop on branche names validity, if there is one wrong name //the program will exit while (!lname.End()) { KVString stamp = lname.Next(); if ( (bb = tt->GetBranch(stamp.Data())) ){ tt->SetBranchAddress(stamp.Data(),&variable[nbre]); nbre+=1; ok=kTRUE; } } if (!ok) return; TEventList *el = NULL; //loop on tree entries for (Int_t kk=0;kk<nentries;kk+=1){ if (kk%10000==0) printf("%d evts lus\n",kk); tt->GetEntry(kk); evtname=""; nbre=0; lname.Begin(" "); //compute the name of the TEventList //using branch name and branch value while (!lname.End()) { KVString stamp = lname.Next(); if ( (bb = tt->GetBranch(stamp.Data())) ){ KVString val; val.Form("%s_%d_",stamp.Data(),variable[nbre]); evtname+=val; nbre+=1; } } if ( !(el = (TEventList *)kevtlist->FindObject(evtname.Data())) ){ printf("creation de %s \n",evtname.Data()); kevtlist->Add(new TEventList(evtname.Data())); el = (TEventList *)kevtlist->Last(); } el->Enter(kk); } //write TEventList created if (ktag_tree){ for (Int_t nn=0;nn<kevtlist->GetEntries();nn+=1){ KVString tampname; tampname.Form("%s_%s",GetTreeName().Data(),kevtlist->At(nn)->GetName()); ((TEventList*) kevtlist->At(nn))->SetName(tampname.Data()); kevtlist->At(nn)->Write(); } } else { kevtlist->Write(); } } else printf("%s n existe pas\n",GetTreeName().Data()); delete [] variable; //close the file file->Close(); }