UInt_t GetListOfJobs( TFile* file, TList& jobdirs) { // get a list of all jobs in all method directories // based on ideas by Peter and Joerg found in macro deviations.C TIter next(file->GetListOfKeys()); TKey *key(0); while ((key = (TKey*)next())) { if (TString(key->GetName()).BeginsWith("Method_")) { if (gROOT->GetClass(key->GetClassName())->InheritsFrom("TDirectory")) { TDirectory* mDir = (TDirectory*)key->ReadObj(); TIter keyIt(mDir->GetListOfKeys()); TKey *jobkey; while ((jobkey = (TKey*)keyIt())) { if (!gROOT->GetClass(jobkey->GetClassName())->InheritsFrom("TDirectory")) continue; TDirectory *jobDir = (TDirectory *)jobkey->ReadObj(); cout << "jobdir name " << jobDir->GetName() << endl; jobdirs.Add(jobDir); } } } } return jobdirs.GetSize(); }
void TextStage::filterAndScore(BSONObj key, DiskLoc loc) { // Locate score within possibly compound key: {prefix,term,score,suffix}. BSONObjIterator keyIt(key); for (unsigned i = 0; i < _params.spec.numExtraBefore(); i++) { keyIt.next(); } keyIt.next(); // Skip past 'term'. BSONElement scoreElement = keyIt.next(); double documentTermScore = scoreElement.number(); double& documentAggregateScore = _scores[loc]; // Handle filtering. if (documentAggregateScore < 0) { // We have already rejected this document. return; } if (documentAggregateScore == 0 && _filter) { // We have not seen this document before and need to apply a filter. Record* rec_p = loc.rec(); BSONObj doc = BSONObj::make(rec_p); // TODO: Covered index matching logic here. if (!_filter->matchesBSON(doc)) { documentAggregateScore = -1; return; } } // Aggregate relevance score, term keys. documentAggregateScore += documentTermScore; }
inline bool operator()(TUInt key,int x,int y){ TFRG_map<TUInt,int>::const_iterator keyIt(m_nodeKeysSet.find(key)); if (keyIt==m_nodeKeysSet.end()) return false; if (((TUInt32)x%kFrg_ClipWidth==0)&&((TUInt32)y%kFrg_ClipHeight==0)&&(keyIt->second==1)){//self node return false; } m_matchMap.insert(TColorMatch::TMatchMap::value_type((TUInt32)key,packMatchXY(x, y))); return false; }
void DrawNetworkMovie( TFile* file, const TString& methodType, const TString& methodTitle ) { TString dirname = methodType + "/" + methodTitle + "/" + "EpochMonitoring"; TDirectory *epochDir = (TDirectory*)file->Get( dirname ); if (!epochDir) { cout << "Big troubles: could not find directory \"" << dirname << "\"" << endl; exit(1); } epochDir->cd(); // loop over all epoch-wise monitoring histograms TIter keyIt(epochDir->GetListOfKeys()); TKey *key; vector<TString> epochList; Int_t ic = 0; while ((key = (TKey*)keyIt())) { if (!gROOT->GetClass(key->GetClassName())->InheritsFrom("TH2F")) continue; TString name = key->GetName(); if (!name.BeginsWith("epochmonitoring___")) continue; // extract epoch TObjArray* tokens = name.Tokenize("_"); TString es = ((TObjString*)tokens->At(2))->GetString(); // check if done already Bool_t isOld = kFALSE; for (vector<TString>::const_iterator it = epochList.begin(); it < epochList.end(); it++) { if (*it == es) isOld = kTRUE; } if (isOld) continue; epochList.push_back( es ); // create bulk file name TString bulkname = Form( "epochmonitoring___epoch_%s_weights_hist", es.Data() ); // draw the network if (ic <= 60) draw_network( file, epochDir, bulkname, kTRUE, es ); ic++; } }
void TextStage::addTerm(const BSONObj& key, const DiskLoc& loc, ScoreMap* curMap) { double *documentAggregateScore = &(*curMap)[loc]; if (curMap != &_negativeScores) ++_specificStats.keysExamined; // Locate score within possibly compound key: {prefix,term,score,suffix}. BSONObjIterator keyIt(key); for (unsigned i = 0; i < _params.spec.numExtraBefore(); i++) { keyIt.next(); } keyIt.next(); // Skip past 'term'. BSONElement scoreElement = keyIt.next(); double documentTermScore = scoreElement.number(); // Handle filtering. if (*documentAggregateScore < 0) { // We have already rejected this document. return; } if (*documentAggregateScore == 0) { if (_filter) { // We have not seen this document before and need to apply a filter. bool fetched = false; TextMatchableDocument tdoc(_params.index->keyPattern(), key, loc, _params.index->getCollection(), &fetched); if (!_filter->matches(&tdoc)) { // We had to fetch but we're not going to return it. if (fetched && curMap != &_negativeScores) { ++_specificStats.fetches; } *documentAggregateScore = -1; return; } } else { // If we're here, we're going to return the doc, and we do a fetch later. if (curMap != &_negativeScores) ++_specificStats.fetches; } } // Aggregate relevance score, term keys. *documentAggregateScore += documentTermScore; }
bool KPrDeclarations::saveOdf(KoPASavingContext &paContext) const { /* <presentation:header-decl presentation:name="hdr1">header</presentation:header-decl> <presentation:footer-decl presentation:name="ftr1">Footer for the slide</presentation:footer-decl> <presentation:footer-decl presentation:name="ftr2">footer</presentation:footer-decl> <presentation:date-time-decl presentation:name="dtd1" presentation:source="current-date" style:data-style-name="D3"/> */ KoXmlWriter &writer(paContext.xmlWriter()); QHash<Type, QHash<QString, QVariant> >::const_iterator typeIt(m_declarations.constBegin()); for (; typeIt != m_declarations.constEnd(); ++typeIt) { QHash<QString, QVariant>::const_iterator keyIt(typeIt.value().begin()); for (; keyIt != typeIt.value().constEnd(); ++keyIt) { switch (typeIt.key()) { case Footer: writer.startElement("presentation:footer-decl"); break; case Header: writer.startElement("presentation:header-decl"); break; case DateTime: writer.startElement("presentation:date-time-decl"); break; } writer.addAttribute("presentation:name", keyIt.key()); if (typeIt.key() == DateTime) { //TODO } else { writer.addTextNode(keyIt.value().value<QString>()); } writer.endElement(); } } return true; }
// input: - Input file (result from TMVA) // - use of TMVA plotting TStyle void mvas( TString fin = "TMVA.root", HistType htype = MVAType, Bool_t useTMVAStyle = kTRUE ) { // set style and remove existing canvas' TMVAGlob::Initialize( useTMVAStyle ); // switches const Bool_t Save_Images = kTRUE; // checks if file with name "fin" is already open, and if not opens one TFile* file = TMVAGlob::OpenFile( fin ); // define Canvas layout here! Int_t xPad = 1; // no of plots in x Int_t yPad = 1; // no of plots in y Int_t noPad = xPad * yPad ; const Int_t width = 600; // size of canvas // this defines how many canvases we need TCanvas *c = 0; // counter variables Int_t countCanvas = 0; // search for the right histograms in full list of keys TIter next(file->GetListOfKeys()); TKey *key(0); while ((key = (TKey*)next())) { if (!TString(key->GetName()).BeginsWith("Method_")) continue; if( ! gROOT->GetClass(key->GetClassName())->InheritsFrom("TDirectory") ) continue; TString methodName; TMVAGlob::GetMethodName(methodName,key); TDirectory* mDir = (TDirectory*)key->ReadObj(); TIter keyIt(mDir->GetListOfKeys()); TKey *titkey; while ((titkey = (TKey*)keyIt())) { if (!gROOT->GetClass(titkey->GetClassName())->InheritsFrom("TDirectory")) continue; TDirectory *titDir = (TDirectory *)titkey->ReadObj(); TString methodTitle; TMVAGlob::GetMethodTitle(methodTitle,titDir); cout << "--- Found directory for method: " << methodName << "::" << methodTitle << flush; TString hname = "MVA_" + methodTitle; if (htype == ProbaType ) hname += "_Proba"; else if (htype == RarityType ) hname += "_Rarity"; TH1* sig = dynamic_cast<TH1*>(titDir->Get( hname + "_S" )); TH1* bgd = dynamic_cast<TH1*>(titDir->Get( hname + "_B" )); if (sig==0 || bgd==0) { if (htype == MVAType) cout << "mva distribution not available (this is normal for Cut classifier)" << endl; else if(htype == ProbaType) cout << "probability distribution not available (this is normal for Cut classifier)" << endl; else if(htype == RarityType) cout << "rarity distribution not available (this is normal for Cut classifier)" << endl; else if(htype == CompareType) cout << "overtraining check not available (this is normal for Cut classifier)" << endl; else cout << endl; } else { cout << endl; // chop off useless stuff sig->SetTitle( Form("TMVA response for classifier: %s", methodTitle.Data()) ); if (htype == ProbaType) sig->SetTitle( Form("TMVA probability for classifier: %s", methodTitle.Data()) ); else if (htype == RarityType) sig->SetTitle( Form("TMVA Rarity for classifier: %s", methodTitle.Data()) ); else if (htype == CompareType) sig->SetTitle( Form("TMVA overtraining check for classifier: %s", methodTitle.Data()) ); // create new canvas TString ctitle = ((htype == MVAType) ? Form("TMVA response %s",methodTitle.Data()) : (htype == ProbaType) ? Form("TMVA probability %s",methodTitle.Data()) : (htype == CompareType) ? Form("TMVA comparison %s",methodTitle.Data()) : Form("TMVA Rarity %s",methodTitle.Data())); TString cname = ((htype == MVAType) ? Form("output_%s",methodTitle.Data()) : (htype == ProbaType) ? Form("probability_%s",methodTitle.Data()) : (htype == CompareType) ? Form("comparison_%s",methodTitle.Data()) : Form("rarity_%s",methodTitle.Data())); c = new TCanvas( Form("canvas%d", countCanvas+1), ctitle, countCanvas*50+200, countCanvas*20, width, (Int_t)width*0.78 ); // set the histogram style TMVAGlob::SetSignalAndBackgroundStyle( sig, bgd ); // normalise both signal and background TMVAGlob::NormalizeHists( sig, bgd ); // frame limits (choose judicuous x range) Float_t nrms = 4; cout << "--- Mean and RMS (S): " << sig->GetMean() << ", " << sig->GetRMS() << endl; cout << "--- Mean and RMS (B): " << bgd->GetMean() << ", " << bgd->GetRMS() << endl; Float_t xmin = TMath::Max( TMath::Min(sig->GetMean() - nrms*sig->GetRMS(), bgd->GetMean() - nrms*bgd->GetRMS() ), sig->GetXaxis()->GetXmin() ); Float_t xmax = TMath::Min( TMath::Max(sig->GetMean() + nrms*sig->GetRMS(), bgd->GetMean() + nrms*bgd->GetRMS() ), sig->GetXaxis()->GetXmax() ); Float_t ymin = 0; Float_t maxMult = (htype == CompareType) ? 1.3 : 1.2; Float_t ymax = TMath::Max( sig->GetMaximum(), bgd->GetMaximum() )*maxMult; // build a frame Int_t nb = 500; TString hFrameName(TString("frame") + methodTitle); TObject *o = gROOT->FindObject(hFrameName); if(o) delete o; TH2F* frame = new TH2F( hFrameName, sig->GetTitle(), nb, xmin, xmax, nb, ymin, ymax ); frame->GetXaxis()->SetTitle( methodTitle + ((htype == MVAType || htype == CompareType) ? " response" : "") ); if (htype == ProbaType ) frame->GetXaxis()->SetTitle( "Signal probability" ); else if (htype == RarityType ) frame->GetXaxis()->SetTitle( "Signal rarity" ); frame->GetYaxis()->SetTitle("Normalized"); TMVAGlob::SetFrameStyle( frame ); // eventually: draw the frame frame->Draw(); c->GetPad(0)->SetLeftMargin( 0.105 ); frame->GetYaxis()->SetTitleOffset( 1.2 ); // Draw legend TLegend *legend= new TLegend( c->GetLeftMargin(), 1 - c->GetTopMargin() - 0.12, c->GetLeftMargin() + (htype == CompareType ? 0.40 : 0.3), 1 - c->GetTopMargin() ); legend->SetFillStyle( 1 ); legend->AddEntry(sig,TString("Signal") + ((htype == CompareType) ? " (test sample)" : ""), "F"); legend->AddEntry(bgd,TString("Background") + ((htype == CompareType) ? " (test sample)" : ""), "F"); legend->SetBorderSize(1); legend->SetMargin( (htype == CompareType ? 0.2 : 0.3) ); legend->Draw("same"); // overlay signal and background histograms sig->Draw("samehist"); bgd->Draw("samehist"); if (htype == CompareType) { // if overtraining check, load additional histograms TH1* sigOv = 0; TH1* bgdOv = 0; TString ovname = hname += "_Train"; sigOv = dynamic_cast<TH1*>(titDir->Get( ovname + "_S" )); bgdOv = dynamic_cast<TH1*>(titDir->Get( ovname + "_B" )); if (sigOv == 0 || bgdOv == 0) { cout << "+++ Problem in \"mvas.C\": overtraining check histograms do not exist" << endl; } else { cout << "--- Found comparison histograms for overtraining check" << endl; TLegend *legend2= new TLegend( 1 - c->GetRightMargin() - 0.42, 1 - c->GetTopMargin() - 0.12, 1 - c->GetRightMargin(), 1 - c->GetTopMargin() ); legend2->SetFillStyle( 1 ); legend2->SetBorderSize(1); legend2->AddEntry(sigOv,"Signal (training sample)","P"); legend2->AddEntry(bgdOv,"Background (training sample)","P"); legend2->SetMargin( 0.1 ); legend2->Draw("same"); } Int_t col = sig->GetLineColor(); sigOv->SetMarkerColor( col ); sigOv->SetMarkerSize( 0.7 ); sigOv->SetMarkerStyle( 20 ); sigOv->SetLineWidth( 1 ); sigOv->SetLineColor( col ); sigOv->Draw("e1same"); col = bgd->GetLineColor(); bgdOv->SetMarkerColor( col ); bgdOv->SetMarkerSize( 0.7 ); bgdOv->SetMarkerStyle( 20 ); bgdOv->SetLineWidth( 1 ); bgdOv->SetLineColor( col ); bgdOv->Draw("e1same"); ymax = TMath::Max( ymax, TMath::Max( sigOv->GetMaximum(), bgdOv->GetMaximum() )*maxMult ); frame->GetYaxis()->SetLimits( 0, ymax ); // for better visibility, plot thinner lines sig->SetLineWidth( 1 ); bgd->SetLineWidth( 1 ); // perform K-S test cout << "--- Perform Kolmogorov-Smirnov tests" << endl; Double_t kolS = sig->KolmogorovTest( sigOv ); Double_t kolB = bgd->KolmogorovTest( bgdOv ); cout << "--- Goodness of signal (background) consistency: " << kolS << " (" << kolB << ")" << endl; TString probatext = Form( "Kolmogorov-Smirnov test: signal (background) probability = %5.3g (%5.3g)", kolS, kolB ); TText* tt = new TText( 0.12, 0.74, probatext ); tt->SetNDC(); tt->SetTextSize( 0.032 ); tt->AppendPad(); } // redraw axes frame->Draw("sameaxis"); // text for overflows Int_t nbin = sig->GetNbinsX(); Double_t dxu = sig->GetBinWidth(0); Double_t dxo = sig->GetBinWidth(nbin+1); TString uoflow = Form( "U/O-flow (S,B): (%.1f, %.1f)%% / (%.1f, %.1f)%%", sig->GetBinContent(0)*dxu*100, bgd->GetBinContent(0)*dxu*100, sig->GetBinContent(nbin+1)*dxo*100, bgd->GetBinContent(nbin+1)*dxo*100 ); TText* t = new TText( 0.975, 0.115, uoflow ); t->SetNDC(); t->SetTextSize( 0.030 ); t->SetTextAngle( 90 ); t->AppendPad(); // update canvas c->Update(); // save canvas to file TMVAGlob::plot_logo(1.058); if (Save_Images) { if (htype == MVAType) TMVAGlob::imgconv( c, Form("plots/mva_%s", methodTitle.Data()) ); else if (htype == ProbaType) TMVAGlob::imgconv( c, Form("plots/proba_%s", methodTitle.Data()) ); else if (htype == CompareType) TMVAGlob::imgconv( c, Form("plots/overtrain_%s", methodTitle.Data()) ); else TMVAGlob::imgconv( c, Form("plots/rarity_%s", methodTitle.Data()) ); } countCanvas++; } } } }
IndexBoundsChecker::KeyState IndexBoundsChecker::checkKey(const BSONObj& key, int* keyEltsToUse, bool* movePastKeyElts, vector<const BSONElement*>* out, vector<bool>* incOut) { verify(_curInterval.size() > 0); verify(out->size() == _curInterval.size()); verify(incOut->size() == _curInterval.size()); // It's useful later to go from a field number to the value for that field. Store these. // TODO: on optimization pass, populate the vector as-needed and keep the vector around as a // member variable vector<BSONElement> keyValues; BSONObjIterator keyIt(key); while (keyIt.more()) { keyValues.push_back(keyIt.next()); } verify(keyValues.size() == _curInterval.size()); size_t firstNonContainedField; Location orientation; if (!findLeftmostProblem(keyValues, &firstNonContainedField, &orientation)) { // All fields in the index are within the current interval. Caller can use the key. return VALID; } // Field number 'firstNonContainedField' of the index key is before its current interval. // Tell the caller to move forward to the start of the current interval. if (BEHIND == orientation) { *keyEltsToUse = firstNonContainedField; *movePastKeyElts = false; for (size_t j = firstNonContainedField; j < _curInterval.size(); ++j) { const OrderedIntervalList& oil = _bounds->fields[j]; (*out)[j] = &oil.intervals[_curInterval[j]].start; (*incOut)[j] = oil.intervals[_curInterval[j]].startInclusive; } return MUST_ADVANCE; } verify(AHEAD == orientation); // Field number 'firstNonContainedField' of the index key is after interval we think it's // in. Fields 0 through 'firstNonContained-1' are within their current intervals and we can // ignore them. while (firstNonContainedField < _curInterval.size()) { // Find the interval that contains our field. size_t newIntervalForField; Location where = findIntervalForField(keyValues[firstNonContainedField], _bounds->fields[firstNonContainedField], _expectedDirection[firstNonContainedField], &newIntervalForField); if (WITHIN == where) { // Found a new interval for field firstNonContainedField. Move our internal choice // of interval to that. _curInterval[firstNonContainedField] = newIntervalForField; // Let's find valid intervals for fields to the right. ++firstNonContainedField; } else if (BEHIND == where) { // firstNonContained field is between the intervals (newIntervalForField-1) and // newIntervalForField. We have to tell the caller to move forward until he at // least hits our new current interval. _curInterval[firstNonContainedField] = newIntervalForField; // All other fields to the right start at their first interval. for (size_t i = firstNonContainedField + 1; i < _curInterval.size(); ++i) { _curInterval[i] = 0; } *keyEltsToUse = firstNonContainedField; *movePastKeyElts = false; for (size_t i = firstNonContainedField; i < _curInterval.size(); ++i) { const OrderedIntervalList& oil = _bounds->fields[i]; (*out)[i] = &oil.intervals[_curInterval[i]].start; (*incOut)[i] = oil.intervals[_curInterval[i]].startInclusive; } return MUST_ADVANCE; } else { verify (AHEAD == where); // Field number 'firstNonContainedField' cannot possibly be placed into an interval, // as it is already past its last possible interval. The caller must move forward // to a key with a greater value for the previous field. // If all fields to the left have hit the end of their intervals, we can't ask them // to move forward and we should stop iterating. if (!spaceLeftToAdvance(firstNonContainedField, keyValues)) { return DONE; } *keyEltsToUse = firstNonContainedField; *movePastKeyElts = true; for (size_t i = firstNonContainedField; i < _curInterval.size(); ++i) { _curInterval[i] = 0; } // If movePastKeyElts is true, we don't examine any fields after the keyEltsToUse // fields of the key. As such we don't populate the out/incOut. return MUST_ADVANCE; } } verify(firstNonContainedField == _curInterval.size()); return VALID; }
Status S2IndexCursor::seek(const BSONObj &position) { vector<GeoQuery> regions; bool isNearQuery = false; NearQuery nearQuery; // Go through the fields that we index, and for each geo one, make // a GeoQuery object for the S2*Cursor class to do intersection // testing/cover generating with. BSONObjIterator keyIt(_descriptor->keyPattern()); while (keyIt.more()) { BSONElement keyElt = keyIt.next(); if (keyElt.type() != String || IndexNames::GEO_2DSPHERE != keyElt.valuestr()) { continue; } BSONElement e = position.getFieldDotted(keyElt.fieldName()); if (e.eoo()) { continue; } if (!e.isABSONObj()) { continue; } BSONObj obj = e.Obj(); if (nearQuery.parseFrom(obj, _params.radius)) { if (isNearQuery) { return Status(ErrorCodes::BadValue, "Only one $near clause allowed: " + position.toString(), 16685); } isNearQuery = true; nearQuery.field = keyElt.fieldName(); continue; } GeoQuery geoQueryField(keyElt.fieldName()); if (!geoQueryField.parseFrom(obj)) { return Status(ErrorCodes::BadValue, "can't parse query (2dsphere): " + obj.toString(), 16535); } if (!geoQueryField.hasS2Region()) { return Status(ErrorCodes::BadValue, "Geometry unsupported: " + obj.toString(), 16684); } regions.push_back(geoQueryField); } // Remove all the indexed geo regions from the query. The s2*cursor will // instead create a covering for that key to speed up the search. // // One thing to note is that we create coverings for indexed geo keys during // a near search to speed it up further. BSONObjBuilder geoFieldsToNuke; if (isNearQuery) { geoFieldsToNuke.append(nearQuery.field, ""); } for (size_t i = 0; i < regions.size(); ++i) { geoFieldsToNuke.append(regions[i].getField(), ""); } // false means we want to filter OUT geoFieldsToNuke, not filter to include only that. BSONObj filteredQuery = position.filterFieldsUndotted(geoFieldsToNuke.obj(), false); if (isNearQuery) { S2NearIndexCursor* nearCursor = new S2NearIndexCursor(_descriptor, _params); _underlyingCursor.reset(nearCursor); nearCursor->seek(filteredQuery, nearQuery, regions); } else { S2SimpleCursor* simpleCursor = new S2SimpleCursor(_descriptor, _params); _underlyingCursor.reset(simpleCursor); simpleCursor->seek(filteredQuery, regions); } return Status::OK(); }
void plPageOptimizer::Optimize() { fResMgr->AddSinglePage(fPagePath); // Get the location of the page we're optimizing IFindLoc(); bool loaded = true; // Get the key for the scene node, we'll load it to force a load on all the objects plKey snKey = plKeyFinder::Instance().FindSceneNodeKey(fLoc); if (snKey) { // Load all the keys fPageNode = fResMgr->FindPage(fLoc); fResMgr->LoadPageKeys(fPageNode); // Put all the keys in a vector, so they won't get unreffed class plVecKeyCollector : public plRegistryKeyIterator { public: KeyVec& fKeys; plVecKeyCollector(KeyVec& keys) : fKeys(keys) {} virtual bool EatKey(const plKey& key) { fKeys.push_back(key); return true; } }; plVecKeyCollector keyIt(fAllKeys); fResMgr->IterateKeys(&keyIt); // Set our load proc, which will track the order that objects are loaded fResMgr->SetProgressBarProc(KeyedObjectProc); // Load the page snKey->VerifyLoaded(); // Unload everything snKey->RefObject(); snKey->UnRefObject(); snKey = nil; } else { loaded = false; } if (loaded) IRewritePage(); uint64_t oldSize = plFileInfo(fPagePath).FileSize(); uint64_t newSize = plFileInfo(fTempPagePath).FileSize(); if (!loaded) { puts("no scene node."); } else if (fOptimized) { plFileSystem::Unlink(fTempPagePath); puts("already optimized."); } else if (oldSize == newSize) { plFileSystem::Unlink(fPagePath); plFileSystem::Move(fTempPagePath, fPagePath); puts("complete"); } else { plFileSystem::Unlink(fTempPagePath); puts("failed. File sizes different"); } }
// input: - Input file (result from TMVA) // - use of TMVA plotting TStyle void deviations( TString fin = "TMVAReg.root", HistType htype = MVAType, Bool_t showTarget, Bool_t useTMVAStyle = kTRUE ) { // set style and remove existing canvas' TMVAGlob::Initialize( useTMVAStyle ); gStyle->SetNumberContours(999); // switches const Bool_t Save_Images = kTRUE; // checks if file with name "fin" is already open, and if not opens one TFile* file = TMVAGlob::OpenFile( fin ); // define Canvas layout here! Int_t xPad = 1; // no of plots in x Int_t yPad = 1; // no of plots in y Int_t noPad = xPad * yPad ; const Int_t width = 650; // size of canvas // this defines how many canvases we need TCanvas* c[100]; // counter variables Int_t countCanvas = 0; // search for the right histograms in full list of keys // TList* methods = new TMap(); TIter next(file->GetListOfKeys()); TKey *key(0); while ((key = (TKey*)next())) { if (!TString(key->GetName()).BeginsWith("Method_")) continue; if (!gROOT->GetClass(key->GetClassName())->InheritsFrom("TDirectory")) continue; TString methodName; TMVAGlob::GetMethodName(methodName,key); cout << "--- Plotting deviation for method: " << methodName << endl; TObjString *mN = new TObjString( methodName ); TDirectory* mDir = (TDirectory*)key->ReadObj(); TList* jobNames = new TList(); TIter keyIt(mDir->GetListOfKeys()); TKey *titkey; while ((titkey = (TKey*)keyIt())) { if (!gROOT->GetClass(titkey->GetClassName())->InheritsFrom("TDirectory")) continue; TDirectory *titDir = (TDirectory *)titkey->ReadObj(); TObjString *jN = new TObjString( titDir->GetName() ); if (!jobNames->Contains( jN )) jobNames->Add( jN ); else delete jN; TString methodTitle; TMVAGlob::GetMethodTitle(methodTitle,titDir); TString hname = "MVA_" + methodTitle; TIter dirKeyIt( titDir->GetListOfKeys() ); TKey* dirKey; Int_t countPlots = 0; while ((dirKey = (TKey*)dirKeyIt())){ if (dirKey->ReadObj()->InheritsFrom("TH2F")) { TString s(dirKey->ReadObj()->GetName()); if (s.Contains("_reg_") && ( (showTarget && s.Contains("_tgt")) || (!showTarget && !s.Contains("_tgt")) ) && s.Contains( (htype == CompareType ? "train" : "test" ))) { c[countCanvas] = new TCanvas( Form("canvas%d", countCanvas+1), Form( "Regression output deviation versus %s for method: %s", (showTarget ? "target" : "input variables"), methodName.Data() ), countCanvas*50+100, (countCanvas+1)*20, width, (Int_t)width*0.72 ); c[countCanvas]->SetRightMargin(0.10); // leave space for border TH1* h = (TH1*)dirKey->ReadObj(); h->SetTitle( Form("Output deviation for method: %s (%s sample)", hname.Data(), (htype == CompareType ? "training" : "test" )) ); // methodName.Data(), (htype == CompareType ? "training" : "test" )) ); h->Draw("colz"); TLine* l = new TLine( h->GetXaxis()->GetXmin(), 0, h->GetXaxis()->GetXmax(), 0 ); l->SetLineStyle(2); l->Draw(); // update and print cout << "plotting logo" << endl; TMVAGlob::plot_logo(1.058); c[countCanvas]->Update(); TString fname = Form( "plots/deviation_%s_%s_%s_c%i", methodName.Data(), (showTarget ? "target" : "vars"), (htype == CompareType ? "training" : "test" ), countPlots ); TMVAGlob::imgconv( c[countCanvas], fname ); countPlots++; countCanvas++; } } } } } }
void ctkQtMobilityServiceRuntime::processPlugin(QSharedPointer<ctkPlugin> plugin) { QHash<QString, QString> headers = plugin->getHeaders(); QHash<QString, QString>::const_iterator it = headers.find(ctkQtMobilityServiceConstants::SERVICE_DESCRIPTOR); ctkLogService* log = ctkQtMobilityServiceActivator::getLogService(); CTK_DEBUG(log) << "Process header " << ctkQtMobilityServiceConstants::SERVICE_DESCRIPTOR << " for plugin #" << plugin->getPluginId() << ": " << (it != headers.end() ? it.value() : "[missing]"); if (it != headers.end()) { QString sd = it.value(); if (sd.isEmpty()) { QString msg = QString("Header ") + ctkQtMobilityServiceConstants::SERVICE_DESCRIPTOR + " empty."; ctkQtMobilityServiceActivator::logError(plugin->getPluginContext(), msg); return; } QByteArray serviceDescription = plugin->getResource(sd); QBuffer serviceBuffer(&serviceDescription); qServiceManager.addService(&serviceBuffer); QServiceManager::Error error = qServiceManager.error(); if (!(error == QServiceManager::NoError || error == QServiceManager::ServiceAlreadyExists)) { QString msg = QString("Registering the QtMobility service descriptor failed: ") + getQServiceManagerErrorString(error); ctkQtMobilityServiceActivator::logError(plugin->getPluginContext(), msg); return; } QString serviceName = plugin->getSymbolicName() + "_" + plugin->getVersion().toString(); QList<QServiceInterfaceDescriptor> descriptors = qServiceManager.findInterfaces(serviceName); if (descriptors.isEmpty()) { QString msg = QString("No interfaces found for service name ") + serviceName; ctkQtMobilityServiceActivator::logWarning(plugin->getPluginContext(), msg); return; } QListIterator<QServiceInterfaceDescriptor> it(descriptors); while (it.hasNext()) { QServiceInterfaceDescriptor descr = it.next(); CTK_DEBUG(ctkQtMobilityServiceActivator::getLogService()) << "Registering:" << descr.interfaceName(); QStringList classes; ctkDictionary props; QStringList customKeys = descr.customAttributes(); QStringListIterator keyIt(customKeys); bool classAttrFound = false; while (keyIt.hasNext()) { QString key = keyIt.next(); if (key == ctkPluginConstants::OBJECTCLASS) { classAttrFound = true; classes << descr.customAttribute(key); } else { props.insert(key, descr.customAttribute(key)); } } if (!classAttrFound) { QString msg = QString("The custom attribute \"") + ctkPluginConstants::OBJECTCLASS + "\" is missing in the interface description of \"" + descr.interfaceName(); ctkQtMobilityServiceActivator::logError(plugin->getPluginContext(), msg); continue; } ctkQtMobilityServiceFactory* serviceObject = new ctkQtMobilityServiceFactory(descr, this, plugin); ctkServiceRegistration serviceReg = plugin->getPluginContext()->registerService(classes, serviceObject, props); if (serviceReg) { mapPluginToServiceFactory.insert(plugin, serviceObject); mapPluginToServiceRegistration.insert(plugin, serviceReg); } else { QString msg = QString("Could not register QtMobility service ") + descr.serviceName() + " " + descr.interfaceName(); ctkQtMobilityServiceActivator::logError(plugin->getPluginContext(), msg); continue; } } } }