void KVINDRAPulserDataTree::CreateTree() { // Create new TTree with // 1 branch 'Run' with run number // 1 branch for each acquisition parameter of every detector (except time markers) // 2 branches for each 'PILA_...' or 'SI_PIN...' parameter, suffixed with '_laser' and '_gene' // // NB if multidetector has not been built, it will be built by this method fArb = new TTree("PulserData", "Created by KVINDRAPulserDataTree"); fArb->SetDirectory(0); fArb->Branch("Run", &fRun, "Run/I"); if (!gIndra) KVMultiDetArray::MakeMultiDetector(gDataSet->GetName()); KVSeqCollection* acq_pars = gIndra->GetACQParams(); fTab_siz = acq_pars->GetEntries() + 20; fVal = new Float_t[fTab_siz]; fIndex = new THashTable(20, 5); fIndex->SetOwner(kTRUE); TIter nxtACQ(acq_pars); KVACQParam* ap = 0; Int_t ap_num = 0; KVBase* iob; while ((ap = (KVACQParam*)nxtACQ())) { TString ap_name(ap->GetName()); TString ap_type(ap->GetType()); if (ap_name.BeginsWith("PILA") || ap_name.BeginsWith("SI_PIN")) { ap_name += "_laser"; iob = new KVBase(ap_name.Data()); iob->SetNumber(ap_num); fIndex->Add(iob); fArb->Branch(ap_name.Data(), &fVal[ap_num++] , Form("%s/F", ap_name.Data())); ap_name.Form("%s%s", ap->GetName(), "_gene"); iob = new KVBase(ap_name.Data()); iob->SetNumber(ap_num); fIndex->Add(iob); fArb->Branch(ap_name.Data(), &fVal[ap_num++] , Form("%s/F", ap_name.Data())); } else if (ap_type != "T") { iob = new KVBase(ap_name.Data()); iob->SetNumber(ap_num); fIndex->Add(iob); fArb->Branch(ap_name.Data(), &fVal[ap_num++] , Form("%s/F", ap_name.Data())); } if (ap_num > fTab_siz - 2) { Error("CreateTree", "Number of branches to create is greater than estimated (%d). Not all parameters can be treated.", fTab_siz); return; } } //keep number of used 'slots' in array fTab_siz = ap_num; }
void KVLVContainer::OpenContextMenu(TGFrame* f, Int_t but, Int_t x, Int_t y) { // Open context menu when user right-clicks an object in the list. // Calling AllowContextMenu(kFALSE) will disable this. // We also fill the list fPickOrderedObjects with the selected objects // in the order of clicking // // if fUseObjLabelAsRealClass=kTRUE (and if objects inherit from KVBase) // then the context menu opened will be that of the class given by // KVBase::GetLabel. The object's KVBase::GetObject() method must // return the real object to use. if (but == kButton1) { TGLVEntry* el = (TGLVEntry*)f; TObject* ob = (TObject*)el->GetUserData(); if (!fControlClick || !GetMultipleSelection()) fPickOrderedObjects->Clear(); if (ob) { Bool_t in_list = fPickOrderedObjects->FindObject(ob); if (in_list) fPickOrderedObjects->Remove(ob); else fPickOrderedObjects->AddLast(ob); } return; } // context menus globally disabled and no exceptions defined if (!fAllowContextMenu && !fContextMenuClassExceptions) return; if (but == kButton3) { // Error("OpenContextMenu","x=%d y=%d",x,y); // fContextMenu->Popup(x,y,this); return; TGLVEntry* el = (TGLVEntry*)f; TObject* ob = (TObject*)el->GetUserData(); if (ob) { TObject* CMob = ob; TString CMobClass = ob->ClassName(); if (fUseObjLabelAsRealClass && ob->TestBit(KVBase::kIsKaliVedaObject)) { KVBase* bob = dynamic_cast<KVBase*>(ob); CMobClass = bob->GetLabel(); CMob = bob->GetObject(); } // check class context menu status if (fContextMenuClassExceptions) { if ((!fAllowContextMenu && fContextMenuClassExceptions->FindObject(CMobClass)) || (fAllowContextMenu && !fContextMenuClassExceptions->FindObject(CMobClass))) fContextMenu->Popup(x, y, CMob); } else if (fAllowContextMenu) fContextMenu->Popup(x, y, CMob); } } }
//_______________________________________________________________________________ KVBase *KVRList::FindObjectByLabel(const Char_t * type) const { // // Find an object in this list using its label. Requires a sequential // scan till the object has been found. Returns 0 if object with specified // label is not found. // if (type) { if (GetSize()) //make sure list contains some objects { for (Int_t i = 0; i < GetSize(); i++) { KVBase *obj = (KVBase *) At(i); if (obj->GetLabel() && !strcmp(type, obj->GetLabel())) return obj; } } } // Warning("GetObjectByType",KVRLIST_NOT_WITH_THIS_TYPE,type); return 0; }
//_______________________________________________________________________________ KVBase *KVRList::FindObject(const Char_t * name, const Char_t * type) const { // // Find an object in this list using its type and name. Requires a sequential // scan till the object has been found. Returns 0 if object with specified // name is not found. // if (type && name) { if (GetSize()) //make sure list contains some objects { for (Int_t i = 0; i < GetSize(); i++) { KVBase *obj = (KVBase *) At(i); if (!strcmp(type, obj->GetType()) && !strcmp(name, obj->GetName())) return obj; } } } // Warning("GetObject",KVRLIST_NOT_WITH_THIS_NAME_AND_TYPE,name,type); return 0; }
void KVAvailableRunsFile::Update(Bool_t no_existing_file) { // Examine the contents of the repository directory corresponding to this datatype // for parent dataset fDataSet. // For each file found which was not already in the list of available runs and // which corresponds to a run in the database gDataBase, // we add an entry to the available runlist file: // [run number]|[date of modification]|[name of file] // For "old" runs we keep the existing informations (including KV version & username) // // When no_existing_file=kTRUE we are making an available runs file // for the first time. There is no pre-existing file. TString runlist; AssignAndDelete(runlist, gSystem->ConcatFileName(GetFilePath(), GetFileName())); if(!no_existing_file){ // read all existing informations ReadFile(); //use "lockfile" to make sure nobody else tries to modify available_runs file //while we are working on it if(!runlist_lock.Lock(runlist.Data())) return; } //open temporary file TString tmp_file_path(GetFileName()); ofstream tmp_file; KVBase::OpenTempFile(tmp_file_path, tmp_file); KVDataRepository *repository = fDataSet->GetRepository(); cout << endl << "Updating runlist : " << flush; //get directory listing from repository KVUniqueNameList *dir_list = repository->GetDirectoryListing(fDataSet, GetDataType()); if (!dir_list) return; TIter next(dir_list); KVBase *objs; //progress bar Int_t ntot = dir_list->GetSize(); Int_t n5pc = TMath::Max(ntot / 20, 1); Int_t ndone = 0; KVDBTable *run_table = 0; KVDataBase* db = fDataSet->GetDataBase(); if (!db){ db = new KVDataBase(); db->AddTable("Runs","List of Runs"); } run_table = db->GetTable("Runs"); while ((objs = (KVBase *) next())) { // loop over all entries in directory Int_t run_num; //is this the correct name of a run in the repository ? Info("Update","%s %d",objs->GetName(),IsRunFileName(objs->GetName())); if ((run_num = IsRunFileName(objs->GetName()))) { KVDBRun *run = (KVDBRun *) run_table->GetRecord(run_num); if (run) { FileStat_t fs; //get file modification date if (repository-> GetFileInfo(fDataSet, GetDataType(), objs->GetName(), fs)) { //runfile exists in repository TDatime modt(fs.fMtime); if(!no_existing_file){ // was there already an entry for exactly the same file in the previous file ? Int_t occIdx=0; KVNameValueList* prevEntry = RunHasFileWithDateAndName(run->GetNumber(), objs->GetName(), modt, occIdx); if(prevEntry){ // copy infos of previous entry tmp_file << run->GetNumber() << '|' << modt.AsSQLString() << '|' << objs->GetName(); if(prevEntry->HasParameter(Form("KVVersion[%d]",occIdx))){ tmp_file <<"|"<< prevEntry->GetStringValue(Form("KVVersion[%d]",occIdx)) <<"|"<<prevEntry->GetStringValue(Form("Username[%d]",occIdx)); } tmp_file << endl; } else { // New Entry - write in temporary runlist file '[run number]|[date of modification]|[name of file] tmp_file << run->GetNumber() << '|' << modt.AsSQLString() << '|' << objs->GetName() << endl; } } else // no previous existing file { // New Entry in a new file - write in temporary runlist file '[run number]|[date of modification]|[name of file] tmp_file << run->GetNumber() << '|' << modt.AsSQLString() << '|' << objs->GetName() << endl; } } } else{ Info("Update","the current run [%s] is not in database",objs->GetName()); FileStat_t fs; if (repository->GetFileInfo(fDataSet, GetDataType(),objs->GetName(), fs)) { TDatime modt(fs.fMtime); // New Entry in a new file - write in temporary runlist file '[run number]|[date of modification]|[name of file] tmp_file << run_num << '|' << modt.AsSQLString() << '|' << objs->GetName() << endl; } else{ Warning("Update","%s GetFileInfo return kFALSE",objs->GetName()); } } } ndone++; if (!(ndone % n5pc)) cout << '>' << flush; } cout << " DONE" << endl; delete dir_list; //close temp file tmp_file.close(); if(no_existing_file){ //use "lockfile" to make sure nobody else tries to modify available_runs file //while we are working on it if(!runlist_lock.Lock(runlist.Data())) return; } //copy temporary file to KVFiles directory, overwrite previous gSystem->CopyFile(tmp_file_path, runlist, kTRUE); //set access permissions to 664 gSystem->Chmod(runlist.Data(), CHMODE(6,6,4)); //remove lockfile runlist_lock.Release(); //delete temp file gSystem->Unlink(tmp_file_path); }
void KVRTGIDManager::BuildGridForAllTGID(const Char_t *idtype, Double_t xmin, Double_t xmax, Int_t ID_min, Int_t ID_max, Int_t npoints, Bool_t logscale){ // Build a grid (KVTGIDGrid) for all the identification functions // of the global list. The new grids are automatically loaded in // gIDGridManager and are visible in the Grid Manager GUI. // If a function is already associated to a grid then a new grid // is not built. No grid is built for copies of KVTGID's made in // the method ReadAsciiFile(...). // // Inputs: idtype - type of the identification for which the // grids will be built (CI-SI, SI-CSI, CI-CSI, // SI75-SILI, ...). By default, all grids are // built // xmin // xmax // ID_min // ID_max // npoints // logscale - see KVTGIDGrid::Generate(...) if( !fIDGlobalList ) return; // First make a sublist of TGID found in object inheriting // from KVTGIDGrid in gIDGridManager TList tgid_list; GetTGIDfromIDGridManager(&tgid_list); KVIDGridManager *gm = gIDGridManager; KVList *grid_list = NULL; if(gm){ grid_list = gm->GetGrids(); grid_list->Disconnect("Modified()",gm,"Modified()"); } // If the TGID of the global list is not in the sublist then // build grid TIter next(fIDGlobalList); Bool_t IDtypeOK = strcmp(idtype,""); KVTGID *tgid = NULL; while( (tgid = (KVTGID *)next()) ){ if(tgid_list.FindObject(tgid)) continue; if(IDtypeOK){ KVBase *idt = NULL; TSeqCollection *idt_list = (TSeqCollection* )GetIDTelescopesForTGID(tgid); if(!idt_list) continue; if( !(idt = (KVBase *)idt_list->First()) ) continue; SafeDelete(idt_list); if( strcmp(idtype,idt->GetLabel()) ) continue; } // Not built grid for a KVTGID copy TString tmp = tgid->GetTitle(); if(tmp.Contains("COPY")){ tmp.Remove(0, tmp.Index("0x")); KVTGID *tmp_tgid = reinterpret_cast<KVTGID *>((Int_t)tmp.Atof()); Warning("KVRTGIDManager::BuildGridForAllTGID","No grid built for %s (%s, %p) because it is a copy of %s (%s, %p)" , tgid->GetName(), tgid->ClassName(), tgid , tmp_tgid->GetName(), tmp_tgid->ClassName(), tmp_tgid); continue; } KVTGIDGrid *grid = new KVTGIDGrid(tgid); grid->SetOnlyZId((Bool_t)tgid->GetZorA()); if(tgid->GetZorA()) grid->SetMassFormula(tgid->GetMassFormula()); grid->Generate(xmax, xmin, ID_min, ID_max, npoints, logscale); Info("KVRTGIDManager::BuildGridForAllTGID","grid built from its TGID function %s (%s, %p)" , tgid->GetName(), tgid->ClassName(), tgid); } if( grid_list ) grid_list->Connect("Modified()","KVIDGridManager",gm,"Modified()"); gm->Modified(); }