#include #include #include #include #include #include #include #include #include void hits_function_thita() { // Open the root file TFile *file = new TFile("data22_13p6TeV_00436422_physics.root"); TH1F *hist = new TH1F("hist","mmOnTrackNStrips",100,0,60); // If the file doesn't exist or couldn't be opened, exit the program if (!file || file->IsZombie()) { printf("Unable to open file.\n"); return; } // List the objects in the file file->ls(); TTree* tree = dynamic_cast(file->Get("BasicTesterTree")); tree->SetBranchStatus("*", false); tree->SetBranchStatus("mmOnTrackNStrips", true); std::vector* mmOnTrackNStrips = 0; // Set the addresses of the branches to the variables tree->SetBranchAddress("mmOnTrackNStrips",&mmOnTrackNStrips); //tree->Print(); // Loop over the entries in the tree and print the values of cout << tree->GetEntries() <size() <GetEntries(); i++) { tree->GetEntry(i); if (!(mmOnTrackNStrips && mmOnTrackNStrips->size() > 0)) continue; // just a precaution for (unsigned j = 0; j < mmOnTrackNStrips->size(); j++) hist->Fill(mmOnTrackNStrips->at(j)); hist->Fill((*mmOnTrackNStrips)[0]); } hist->Draw(); }