//This code creates 5 histograms, two seperate histograms using input object (helicity, etc.) and input variable(fadc_a)(h0, h1), one for the subtraction of these 2 (h2), one for addition of the two (h3), then final one divividing them (h4). void hsad() { // Creates 2 histograms TH1F* h0 = new TH1F("h0", "fadc_a, h0", 1000, 0, 25000); //Adjust "fadc_a" to any variable in tree TH1F* h1 = new TH1F("h1", "fadc_a, h1", 1000, 0, 25000); // Fills histograms with different helicity (can also test differences in objects other than helicity) T->Draw("fadc_a>>h0", "helicity==0"); T->Draw("fadc_a>>h1", "helicity==1"); // Subtracts h0 - h1 and writes to new histogram "h2" TH1F* h2 = (TH1F*)h0->Clone("h2"); h2->Add(h1, -1); // Reinitializes h0 h0->Reset(); T->Draw("fadc_a>>h0", "helicity==0"); // Adds h0 + h1 and fills new histogram "h3" TH1F* h3 = (TH1F*)h0->Clone("h3"); h3->SetName("fadc_a, +"); h3->SetTitle("fadc_a, +;x-axis;y-axis"); //OPTIONAL- set name and axis for addition histogram h3->Add(h1, 1); // Divides h2 / h3 and fills new histogram "h4" TH1F* h4 = (TH1F*)h2->Clone("h4"); h4->SetName("fadc_a"); //Var h4->SetTitle("fadc_a;x-axis;y-axis"); //Set name of final histogram and set x and y axis names h4->Divide(h3); // Reinitializes h0 and h2 h0->Reset(); T->Draw("fadc_a>>h0", "helicity==0"); h2->Reset(); h2->Add(h1, -1); h2->SetName("fadc_a, -"); h2->SetTitle("fadc_a, -;x-axis;y-axis"); //OPTIONAL- set name and axis for subtraction histogram h0->Reset(); T->Draw("fadc_a>>h0", "helicity==0"); //gPad->SetLogx(); // Draw final result h4->Draw(); //Change "h4" to desired histogram }