static int DaoDataFrame_MakeSlice( DaoxDataFrame *self, DaoProcess *proc, DaoValue *idx[], int N, DArray *slices ) { daoint *dims = self->dims; daoint i, D = 3, S = 1; DaoxDataFrame_MakeFullSlice( self, slices ); if( N > D ){ DaoProcess_RaiseException( proc, DAO_WARNING, "too many indices" ); N = D; } for(i=0; i<N; ++i) MakeSlice( proc, idx[i], dims[i], slices->items.pVector[i] ); for(i=0; i<D; ++i) S *= slices->items.pVector[i]->data.daoints[1]; return S; }
//_______________________________________________________________________________ // Main constructor Analysis::TreeCategory::TreeCategory( std::string name, TTree *itree, std::string cuts ) : fCuts( cuts ), fName( name ), fTree( itree ) { // Initializes the tree indices as an enumeration size_t n = 0; fTreeEntries = std::vector<size_t>( fTree -> GetEntries() ); std::generate( fTreeEntries.begin(), fTreeEntries.end(), [ & ] { return n++; } ); // If a set of cuts is providen it calculates the associated indices if ( cuts.size() ) fTreeEntries = MakeSlice( fCuts ); // Displays the information of the tree category std::cout << "*** Created new tree category < " << name << " > ***" << std::endl; std::cout << " - Directory:\t" << fTree -> GetDirectory() -> GetName() << std::endl; std::cout << " - Input tree:\t" << fTree -> GetName() << std::endl; if ( fCuts.size() ) std::cout << " - Cuts:\t" << fCuts << std::endl; std::cout << " - Entries:\t" << fTreeEntries.size() << std::endl; }
// Note: ignore parallel paramter, only applies to other IScorers ScoreResult Tree::Score(const bkp::MaskedVector<const HiggsCsvRow>& data, bool parallel) { int data_size = static_cast<int>(data.size()); std::vector<double> s_scores(data_size, std::numeric_limits<double>::quiet_NaN()); std::vector<double> b_scores(data_size, std::numeric_limits<double>::quiet_NaN()); bkp::MaskedVector<int> return_indices( std::vector<int>( boost::counting_iterator<int>(0), boost::counting_iterator<int>(data_size) ) ); // construct filter such that filter[i] is true iff data has no NaN values in any of // our target_feature columns (don't care about NaNs in other columns) std::vector<bool> filter = HasNan(data, *target_features_); filter.flip(); // use local std::vectors as backing stores for some MaskingVectors. ScoreHelper // will then populate our vectors by populating the MaskingVector and their // MaskingVector::Slices (implicitly ignoring rows with NaN's, which will be // handled by other trees). // // Normally it would be dangerous to create a shared_ptr to a local variable like // this. Either the shared_ptr will go out of scope and try to delete the // local variable (crash and/or UB) or the local variable will go out of scope with the // shared_ptr still pointing to it (dangling ptr). In this case we can see that // the local variable will outlive the shared_ptrs (they will both live until the // end of this method, although the contents of the local vectors will be std::moved // to a value-returned Score object at the end of the method). So, all we need to do // is remove the shared_ptr's deleter (done in ShareLocal) and we're good to go. auto filtered_return_indices = return_indices.Filter(filter); ScoreHelper(data, filtered_return_indices.MakeSlice(), s_scores, b_scores); return hrf::ScoreResult(std::move(s_scores), std::move(b_scores)); }
void DrawEtaPhi(Double_t pmin = 2.){ TFile *in = TFile::Open("HFEtaskTRD2.root"); TList *res = (TList *)in->Get("TRD_HFE_Results2"); // Container with tracks AliHFEcontainer *hfecont = (AliHFEcontainer *)res->FindObject("trackContainer"); AliCFContainer *cont = hfecont->GetCFContainer("recTrackContReco"); // Container with number of events for normalization AliCFContainer *evc = (AliCFContainer *)res->FindObject("eventContainer"); TH1 *h1 = (TH1 *)evc->Project(4, 0); Int_t nEvents = h1->GetEntries(); cout << "Number of events: " << nEvents << endl; // For plotting Double_t rm = 0.2; Double_t ts = 0.045; Int_t steps = cont->GetNStep() - 1; TH2 *htpr = 0; TCanvas *plotall = new TCanvas("plot", "Eta-phi maps for different cut steps (all charge)", 1000, 600); plotall->Divide(steps/2, 2); AliCFContainer *scall= MakeSlice(cont, pmin, 0); for(Int_t istep = 1; istep < cont->GetNStep(); istep++){ plotall->cd(istep); gPad->SetRightMargin(rm); hptr = (TH2 *)scall->Project(istep, 0,1); hptr->Scale(1e5/static_cast<Double_t>(nEvents)); hptr->SetStats(0); hptr->SetName(Form("%sall", cont->GetStepTitle(istep))); hptr->SetTitle(Form("Step %s", cont->GetStepTitle(istep))); hptr->GetXaxis()->SetTitle("#eta"); hptr->GetYaxis()->SetTitle("#phi"); hptr->GetZaxis()->SetTitle("Tracks / 100000 Events"); hptr->GetZaxis()->SetTitleOffset(1.2); hptr->GetXaxis()->SetTitleSize(ts); hptr->GetYaxis()->SetTitleSize(ts); hptr->GetZaxis()->SetTitleSize(ts); hptr->GetZaxis()->SetRangeUser(0, 2.2); hptr->Draw("colz"); } plotall->cd(); TCanvas *plotpos = new TCanvas("plotpos", "Eta-phi maps for different cut steps (pos charge)", 1000, 600); plotpos->Divide(steps/2, 2); AliCFContainer *scpos = MakeSlice(cont, pmin, 1); for(Int_t istep = 1; istep < cont->GetNStep(); istep++){ plotpos->cd(istep); gPad->SetRightMargin(rm); hptr = (TH2 *)scpos->Project(istep, 0,1); hptr->Scale(1e5/static_cast<Double_t>(nEvents)); hptr->SetStats(0); hptr->SetTitle(Form("Step %s", cont->GetStepTitle(istep))); hptr->SetName(Form("%spos", cont->GetStepTitle(istep))); hptr->GetXaxis()->SetTitle("#eta"); hptr->GetYaxis()->SetTitle("#phi"); hptr->GetZaxis()->SetTitle("Tracks / 100000 Events"); hptr->GetZaxis()->SetTitleOffset(1.2); hptr->GetXaxis()->SetTitleSize(ts); hptr->GetYaxis()->SetTitleSize(ts); hptr->GetZaxis()->SetTitleSize(ts); hptr->GetZaxis()->SetRangeUser(0, 1.1); hptr->Draw("colz"); } plotpos->cd(); TCanvas *plotneg = new TCanvas("plotneg", "Eta-phi maps for different cut steps (neg charge)", 1000, 600); plotneg->Divide(steps/2, 2); AliCFContainer *scneg = MakeSlice(cont, pmin, -1); for(Int_t istep = 1; istep < cont->GetNStep(); istep++){ plotneg->cd(istep); gPad->SetRightMargin(rm); hptr = (TH2 *)scneg->Project(istep, 0,1); hptr->Scale(1e5/static_cast<Double_t>(nEvents)); hptr->SetStats(0); hptr->SetName(Form("%sneg", cont->GetStepTitle(istep))); hptr->SetTitle(Form("Step %s", cont->GetStepTitle(istep))); hptr->GetXaxis()->SetTitle("#eta"); hptr->GetYaxis()->SetTitle("#phi"); hptr->GetZaxis()->SetTitle("Tracks / 100000 Events"); hptr->GetZaxis()->SetTitleOffset(1.2); hptr->GetXaxis()->SetTitleSize(ts); hptr->GetYaxis()->SetTitleSize(ts); hptr->GetZaxis()->SetTitleSize(ts); hptr->GetZaxis()->SetRangeUser(0, 1.1); hptr->Draw("colz"); } plotneg->cd(); }