void MyFunctions::BuildGradeNormMap() { // This function build the gradeNormMap if it isn't already filled if (gradeNormMap.size() > 0) return; // Already filled // This is build from the Students root file. Maybe this should be from a course file instead? TFile* f = new TFile("Students.root"); TTree* studentTree = (TTree*)f->Get("Students"); Student* student = 0; studentTree->SetBranchAddress("student", &student); Long64_t nentries = studentTree->GetEntriesFast(); for (Long64_t jentry = 0; jentry < nentries; jentry++) { studentTree->GetEntry(jentry); //Loop over all terms for this student and accumulate grade distribution info for (auto const& grade : student->Grades()) { // Only look at Fall and Spring Terms int term = grade.term; if (!regularSemester(term)) continue; if (!ValidGrade(grade.grade)) continue; auto thisKey = std::make_pair(grade.course, 0); auto thisKeyAll = std::make_pair("AllCourses", 0); MyFunctions::gradeNormMap[thisKey].AddGrade(grade.grade); // Will automatically create entry in map if it doesn't exist MyFunctions::gradeNormMap[thisKeyAll].AddGrade(grade.grade); auto termKey = std::make_pair(grade.course, term); auto termKeyAll = std::make_pair("AllCourses", term); MyFunctions::gradeNormMap[termKey].AddGrade(grade.grade); MyFunctions::gradeNormMap[termKeyAll].AddGrade(grade.grade); } } f->Close(); }