// Reads the points from a file and produces a simple graph. int macro2(){ auto c=new TCanvas();c->SetGrid(); TGraphErrors graph_expected("./macro2_input_expected.txt", "%lg %lg %lg"); graph_expected.SetTitle( "Measurement XYZ and Expectation;" "lenght [cm];" "Arb.Units"); graph_expected.SetFillColor(kYellow); graph_expected.DrawClone("E3AL"); // E3 draws the band TGraphErrors graph("./macro2_input.txt","%lg %lg %lg"); graph.SetMarkerStyle(kCircle); graph.SetFillColor(0); graph.DrawClone("PESame"); // Draw the Legend TLegend leg(.1,.7,.3,.9,"Lab. Lesson 2"); leg.SetFillColor(0); leg.AddEntry(&graph_expected,"Expected Points"); leg.AddEntry(&graph,"Measured Points"); leg.DrawClone("Same"); graph.Print(); return 0; }
int main(int argc, char * argv[]) { UnivariatePolynomial<double> a({1,2,3,4,5,6}); LegendrePolynomials<double> leg(10); assert((leg.getPoly(leg.project(a))-a).coeffs().norm() < 1e-10); return 0; }
int main() { Legendre leg(-1., 1., 8); DArray darr; leg.FindPolynomial(darr); cerr << "Polynomial:"; PrintArray(darr); return 0; }
int main(int argc, char *argv[]) { dsFunctions fn; double x[4] = {0.00}, y[4] = {0.00}; // Center of gravity double z[4] = { 0.05, 0.50, 1.50, 2.55}; double m[4] = {10.00, 2.00, 2.00, 2.00}; // mass double anchor_x[4] = {0.00}, anchor_y[4] = {0.00};// anchors of joints double anchor_z[4] = { 0.00, 0.10, 1.00, 2.00}; double axis_x[4] = { 0.00, 0.00, 0.00, 0.00}; // axises of joints double axis_y[4] = { 0.00, 0.00, 1.00, 1.00}; double axis_z[4] = { 1.00, 1.00, 0.00, 0.00}; fn.version = DS_VERSION; fn.start = &init; fn.step = &simLoop; fn.command = &command; fn.path_to_textures = "drawstuff_texture"; dInitODE(); // Initialize ODE world = dWorldCreate(); // Create a world dWorldSetGravity(world, 0, 0, -9.8); bool isDrawingEnabled = true; Leg leg(world); LegDraw legDraw(&leg); /* for (int i = 0; i < NUM; i++) { dMass mass; link[i] = dBodyCreate(world); dBodySetPosition(link[i], x[i], y[i], z[i]); // Set a position dMassSetZero(&mass); // Set mass parameter to zero dMassSetCapsuleTotal(&mass,m[i],3,r[i],l[i]); // Calculate mass parameter dBodySetMass(link[i], &mass); // Set mass } joint[0] = dJointCreateFixed(world, 0); // A fixed joint dJointAttach(joint[0], link[0], 0); // Attach the joint between the ground and the base dJointSetFixed(joint[0]); // Set the fixed joint for (int j = 1; j < NUM; j++) { joint[j] = dJointCreateHinge(world, 0); // Create a hinge joint dJointAttach(joint[j], link[j-1], link[j]); // Attach the joint dJointSetHingeAnchor(joint[j], anchor_x[j], anchor_y[j],anchor_z[j]); dJointSetHingeAxis(joint[j], axis_x[j], axis_y[j], axis_z[j]); }*/ dsSimulationLoop(argc, argv, 640, 480, &fn); // Simulation loop dCloseODE(); return 0; }
void compareHistos( char *Current, char *Reference=0 ) { TText* te = new TText(); te->SetTextSize(0.1); TFile * curfile = new TFile( TString(Current)+".root" ); TFile * reffile = curfile; if (Reference) reffile = new TFile(TString(Reference)+".root"); char * prefix="DQMData/MixingV/Mixing"; //1-Dimension Histogram TDirectory * refDir=reffile->GetDirectory(prefix); TDirectory * curDir=curfile->GetDirectory(prefix); TList* list = refDir->GetListOfKeys(); TObject* object = list->First(); int iHisto = 0; char title[50]; while (object) { // find histo objects std::cout << " object :" << object->GetName() << std::endl; TProfile * h1 = dynamic_cast<TProfile*>( refDir->Get(object->GetName())); TProfile * h2 = dynamic_cast<TProfile*>( curDir->Get(object->GetName())); bool isHisto = (refDir->Get(object->GetName()))->InheritsFrom("TProfile"); std::cout << " isHisto = " << isHisto << std::endl; if (isHisto && h1 && h2 && *h1->GetName()== *h2->GetName()) { iHisto++; char title[50]; // draw and compare std::cout << " Start draw and compare" << std::endl; TCanvas c1; TProfile htemp2; h2->Copy(htemp2);// to keep 2 distinct histos h1->SetLineColor(2); htemp2.SetLineColor(3); h1->SetLineStyle(3); h1->SetMarkerColor(3); htemp2.SetLineStyle(5); htemp2.SetMarkerColor(5); TLegend leg(0.1, 0.15, 0.2, 0.25); leg.AddEntry(h1, "Reference", "l"); leg.AddEntry(&htemp2, "New ", "l"); h1->Draw(); htemp2.Draw("Same"); leg.Draw(); sprintf(title,"%s%s", object->GetName(),".gif"); c1.Print(title); } // go to next object object = list->After(object); } }
void macro1(){ // The values and the errors on the Y axis const int n_points=10; double x_vals[n_points]= {1,2,3,4,5,6,7,8,9,10}; double y_vals[n_points]= {6,12,14,20,22,24,35,45,44,53}; double y_errs[n_points]= {5,5,4.7,4.5,4.2,5.1,2.9,4.1,4.8,5.43}; // Instance of the graph TGraphErrors graph(n_points,x_vals,y_vals,nullptr,y_errs); graph.SetTitle("Measurement XYZ;lenght [cm];Arb.Units"); // Make the plot estetically better graph.SetMarkerStyle(kOpenCircle); graph.SetMarkerColor(kBlue); graph.SetLineColor(kBlue); // The canvas on which we'll draw the graph auto mycanvas = new TCanvas(); // Draw the graph ! graph.DrawClone("APE"); // Define a linear function TF1 f("Linear law","[0]+x*[1]",.5,10.5); // Let's make the funcion line nicer f.SetLineColor(kRed); f.SetLineStyle(2); // Fit it to the graph and draw it graph.Fit(&f); f.DrawClone("Same"); // Build and Draw a legend TLegend leg(.1,.7,.3,.9,"Lab. Lesson 1"); leg.SetFillColor(0); graph.SetFillColor(0); leg.AddEntry(&graph,"Exp. Points"); leg.AddEntry(&f,"Th. Law"); leg.DrawClone("Same"); // Draw an arrow on the canvas TArrow arrow(8,8,6.2,23,0.02,"|>"); arrow.SetLineWidth(2); arrow.DrawClone(); // Add some text to the plot TLatex text(8.2,7.5,"#splitline{Maximum}{Deviation}"); text.DrawClone(); mycanvas->Print("graph_with_law.pdf"); }
void gerrors() { TCanvas *mycanvas = new TCanvas("mycanvs","A Simple Graph with error bars",200,10,700,500); // mycanvas->SetFillColor(42); mycanvas->SetGrid(); // mycanvas->GetFrame()->SetFillColor(21); // mycanvas->GetFrame()->SetBorderSize(12); const int n_points =10; #double x_vals [ n_points]= {1,2,3,4,5,6,7,8,9,10}; double y_vals [ n_points]= {6 ,12 ,14 ,20 ,22 ,24 ,35 ,45 ,44 ,53}; double y_errs [ n_points]= {5 ,5 ,4.7 ,4.5 ,4.2 ,5.1,2.9,4.1,4.8,5.43}; TGraphErrors *gr = new TGraphErrors(n_points,x_vals,y_vals,NULL,y_errs); // TGraphErrors graph(n_points,x_vals,y_vals,NULL,y_errs); gROOT -> SetStyle("Plain"); gr->SetTitle("TGraphErrors Example; lengtht [cm];Arb. Units"); gr->SetMarkerColor(kBlue); gr->SetMarkerStyle(kOpenCircle); gr->SetLineColor ( kBlue ) ; gr->Draw("ALP"); //Define a linear function TF1 f("Linear law" ,"[0]+x*[1]" ,.5 ,10.5) ; // Let's make the funcion line nicer f.SetLineColor(kRed); f.SetLineStyle(2); // Fit it to the graph and draw it gr->Fit(&f); f.DrawClone("Same"); // Build and Draw a legend TLegend leg(.1 ,.7 ,.3 ,.9 ,"Lab. Lesson 1"); leg.SetFillColor (0) ; gr->SetFillColor (0) ; leg.AddEntry(gr,"Exp. Points"); leg.AddEntry(&f,"Th. Law"); leg.DrawClone("Same"); // Draw an arrow on the canvas TArrow arrow(8,8,6.2,23,0.02,"----|>"); arrow.SetLineWidth (2) ; arrow.DrawClone ( ) ; // Add some text to the plot TLatex text(8.2,7.5,"#splitline{Maximum}{Deviation}"); text.DrawClone ( ) ; mycanvas->Update(); mycanvas -> Print("example.pdf"); }
void DoCompare( char *Current, char *Reference=0 ){ TText* te = new TText(); te->SetTextSize(0.1); gROOT->ProcessLine(".x HistoCompare.C"); HistoCompare * myPV = new HistoCompare(); TFile * curfile = new TFile( TString(Current)+".root" ); TFile * reffile = curfile; if (Reference) reffile = new TFile(TString(Reference)+".root"); char * prefix="DQMData/MixingV/"; //1-Dimension Histogram TDirectory * refDir=reffile->GetDirectory(prefix); TDirectory * curDir=curfile->GetDirectory(prefix); TList* list = refDir->GetListOfKeys(); TObject* object = list->First(); int iHisto = 0; char title[50]; while (object) { // find histo objects TH1F * h1 = dynamic_cast<TH1F*>( refDir->Get(object->GetName())); TH1F * h2 = dynamic_cast<TH1F*>( curDir->Get(object->GetName())); bool isHisto = (refDir->Get(object->GetName()))->InheritsFrom("TH1F"); if (isHisto && h1 && h2 && *h1->GetName()== *h2->GetName()) { iHisto++; char title[50]; // draw and compare TCanvas c1; TH1F htemp2; h2->Copy(htemp2);// to keep 2 distinct histos h1->SetLineColor(2); htemp2.SetLineColor(3); h1->SetLineStyle(3); htemp2.SetLineStyle(5); TLegend leg(0.1, 0.15, 0.2, 0.25); leg.AddEntry(h1, "Reference", "l"); leg.AddEntry(&htemp2, "New ", "l"); h1->Draw(); htemp2.Draw("Same"); leg.Draw(); myPV->PVCompute(h1,&htemp2, te); sprintf(title,"%s%s", object->GetName(),".eps"); c1.Print(title); } // go to next object object = list->After(object); } }
void robot(){ matrixPush(ModelView); matrixRotate(ModelView, torso_angle, 0, 0, 1); torso(); matrixPush(ModelView); matrixTranslate(ModelView, 0, 10.2, 0); matrixRotate(ModelView, head_angle, 0, 0, 1); head(); matrixPush(ModelView); matrixTranslate(ModelView, .5, 2.5, 0); eye(); matrixPop(ModelView); matrixPop(ModelView); matrixPush(ModelView); matrixTranslate(ModelView, -4.5, 7, 0); matrixRotate(ModelView, -45, 0, 0, 1); arm(left_upper_arm_angle, left_lower_arm_angle, left_wrist_angle); matrixPop(ModelView); matrixPush(ModelView); matrixTranslate(ModelView, 4.5, 7, 0); matrixRotate(ModelView, 45, 0, 0, 1); arm(right_upper_arm_angle, right_lower_arm_angle, right_wrist_angle); matrixPop(ModelView); matrixPush(ModelView); lower_torso(); matrixPop(ModelView); matrixPush(ModelView); matrixTranslate(ModelView, -2, -1.5, 0); matrixRotate(ModelView, -30, 0, 0, 1); leg(left_upper_leg_angle, left_lower_leg_angle, left_foot_angle); matrixPop(ModelView); matrixPush(ModelView); matrixTranslate(ModelView, 2, -1.5, 0); matrixRotate(ModelView, 30, 0, 0, 1); right_leg(right_upper_leg_angle, right_lower_leg_angle, right_foot_angle); matrixPop(ModelView); matrixPop(ModelView); }
void combineHists( TFile* fSig, TFile* fBg, std::string histName, std::string plotOpt, std::string outputName, std::string label=""){ TH1::SetDefaultSumw2(); TCanvas c1; TH1D* hSig = fSig->Get(histName.c_str()); TH1D* hBg = fBg->Get(histName.c_str()); cout << "signal: " << hSig->Integral() << " bg: " << hBg->Integral() << endl; hSig->SetMarkerSize(0); doSignalHist(hSig); hBg->SetMarkerSize(0); doAltBGHist(hBg); THStack st("h",""); st.Add(hSig); st.Add(hBg); st.Draw((plotOpt+"NOSTACK").c_str()); st.GetXaxis()->SetTitle(hSig->GetXaxis()->GetTitle()); st.GetYaxis()->SetTitle(hSig->GetYaxis()->GetTitle()); setAltTitleLabelSizes(&st.GetHistogram()); st.SetTitle(""); st.Draw((plotOpt+"NOSTACK").c_str()); TLegend leg(0.65,0.6, 0.85,0.85); doStandardLegend(&leg); leg.AddEntry(hSig,"#splitline{Signal MC}{m_{#phi} = 8 GeV}","l"); leg.AddEntry(hBg,"QCD b#bar{b} MC","l"); leg.Draw(); TPaveText t(0.15, 0.7, 0.5, 0.8, "NDC"); t.AddText(label.c_str()); doStandardText(&t); if (label != "") { t.Draw(); } c1.SaveAs(outputName.c_str()); if (!hSig) delete hSig; if (!hBg) delete hBg; }
bool operator>(const Interval& lhs, const Interval& rhs) { return leg(lhs, rhs) > 0; }
TriangleSecondLeg::Result TriangleSecondLeg::Calculate(const TracePoint &c, unsigned best) const { // this is a heuristic to remove invalid triangles // we do as much of this in flat projection for speed const unsigned df_2 = b.flat_distance(c); const unsigned df_3 = c.flat_distance(a); const unsigned df_total = df_1+df_2+df_3; // require some distance! if (df_total<20) { return Result(0, 0); } // no point scanning if worst than best if (df_total<= best) { return Result(0, 0); } const unsigned shortest = min(df_1, min(df_2, df_3)); // require all legs to have distance if (!shortest) { return Result(0, 0); } if (is_fai && (shortest*4<df_total)) { // fails min < 25% worst-case rule! return Result(0, 0); } const unsigned d = df_3+df_2; // without FAI rules, allow any triangle if (!is_fai) { return Result(d, df_total); } if (shortest*25>=df_total*7) { // passes min > 28% rule, // this automatically means we pass max > 45% worst-case return Result(d, df_total); } const unsigned longest = max(df_1, max(df_2, df_3)); if (longest*20>df_total*9) { // fails max > 45% worst-case rule! return Result(0, 0); } // passed basic tests, now detailed ones // find accurate min leg distance fixed leg(0); if (df_1 == shortest) { leg = a.get_location().distance(b.get_location()); } else if (df_2 == shortest) { leg = b.get_location().distance(c.get_location()); } else if (df_3 == shortest) { leg = c.get_location().distance(a.get_location()); } // estimate total distance by scaling. // this is a slight approximation, but saves having to do // three accurate distance calculations. const fixed d_total((df_total*leg)/shortest); if (d_total>=fixed(500000)) { // long distance, ok that it failed 28% rule return Result(d, df_total); } return Result(0, 0); }
void plot(const char* type = "eps") { gROOT->ProcessLine(".x ../../style.C"); TFile *f = new TFile("../../SharedRootFiles/Osc.root"); TH1D *data[6]; TH1D *predOsc[6]; TH1D *acc[6]; TH1D *li9[6]; TH1D *fsn[6]; TH1D *afn[6]; TH1D *amc[6]; data[0] = (TH1D*)f->Get("ibd_spectrum_site1_det1"); data[1] = (TH1D*)f->Get("ibd_spectrum_site1_det2"); data[2] = (TH1D*)f->Get("ibd_spectrum_site2_det1"); data[3] = (TH1D*)f->Get("ibd_spectrum_site4_det1"); data[4] = (TH1D*)f->Get("ibd_spectrum_site4_det2"); data[5] = (TH1D*)f->Get("ibd_spectrum_site4_det3"); predOsc[0] = (TH1D*)f->Get("total_spectrum_expected_AD1"); predOsc[1] = (TH1D*)f->Get("total_spectrum_expected_AD2"); predOsc[2] = (TH1D*)f->Get("total_spectrum_expected_AD3"); predOsc[3] = (TH1D*)f->Get("total_spectrum_expected_AD4"); predOsc[4] = (TH1D*)f->Get("total_spectrum_expected_AD5"); predOsc[5] = (TH1D*)f->Get("total_spectrum_expected_AD6"); acc[0] = (TH1D*)f->Get("acc_spectrum_expected_AD1"); acc[1] = (TH1D*)f->Get("acc_spectrum_expected_AD2"); acc[2] = (TH1D*)f->Get("acc_spectrum_expected_AD3"); acc[3] = (TH1D*)f->Get("acc_spectrum_expected_AD4"); acc[4] = (TH1D*)f->Get("acc_spectrum_expected_AD5"); acc[5] = (TH1D*)f->Get("acc_spectrum_expected_AD6"); li9[0] = (TH1D*)f->Get("li9he8_spectrum_expected_AD1"); li9[1] = (TH1D*)f->Get("li9he8_spectrum_expected_AD2"); li9[2] = (TH1D*)f->Get("li9he8_spectrum_expected_AD3"); li9[3] = (TH1D*)f->Get("li9he8_spectrum_expected_AD4"); li9[4] = (TH1D*)f->Get("li9he8_spectrum_expected_AD5"); li9[5] = (TH1D*)f->Get("li9he8_spectrum_expected_AD6"); fsn[0] = (TH1D*)f->Get("fastn_spectrum_expected_AD1"); fsn[1] = (TH1D*)f->Get("fastn_spectrum_expected_AD2"); fsn[2] = (TH1D*)f->Get("fastn_spectrum_expected_AD3"); fsn[3] = (TH1D*)f->Get("fastn_spectrum_expected_AD4"); fsn[4] = (TH1D*)f->Get("fastn_spectrum_expected_AD5"); fsn[5] = (TH1D*)f->Get("fastn_spectrum_expected_AD6"); amc[0] = (TH1D*)f->Get("amc_spectrum_expected_AD1"); amc[1] = (TH1D*)f->Get("amc_spectrum_expected_AD2"); amc[2] = (TH1D*)f->Get("amc_spectrum_expected_AD3"); amc[3] = (TH1D*)f->Get("amc_spectrum_expected_AD4"); amc[4] = (TH1D*)f->Get("amc_spectrum_expected_AD5"); amc[5] = (TH1D*)f->Get("amc_spectrum_expected_AD6"); afn[0] = (TH1D*)f->Get("alphan_spectrum_expected_AD1"); afn[1] = (TH1D*)f->Get("alphan_spectrum_expected_AD2"); afn[2] = (TH1D*)f->Get("alphan_spectrum_expected_AD3"); afn[3] = (TH1D*)f->Get("alphan_spectrum_expected_AD4"); afn[4] = (TH1D*)f->Get("alphan_spectrum_expected_AD5"); afn[5] = (TH1D*)f->Get("alphan_spectrum_expected_AD6"); TH1D *data_site1 = data[0]->Clone("data_site1"); data_site1->GetXaxis()->SetTitle("Prompt Energy [MeV]"); data_site1->GetYaxis()->SetTitle("Events / 50KeV"); data_site1->SetTitle("IBDs at EH1"); TH1D *data_site2 = data[2]->Clone("data_site2"); data_site2->GetXaxis()->SetTitle("Prompt Energy [MeV]"); data_site2->GetYaxis()->SetTitle("Events / 50KeV"); data_site2->SetTitle("IBDs at EH2"); TH1D *data_site3 = data[3]->Clone("data_site3"); data_site3->GetXaxis()->SetTitle("Prompt Energy [MeV]"); data_site3->GetYaxis()->SetTitle("Events / 50KeV"); data_site3->SetTitle("IBDs at EH3"); TH1D *pred_site1 = predOsc[0]->Clone("pred_site1"); THStack *hs_site1 = new THStack("hs_site1", ""); TH1D *acc_site1 = acc[0]->Clone("acc_site1"); TH1D *li9_site1 = li9[0]->Clone("li9_site1"); TH1D *fsn_site1 = fsn[0]->Clone("fsn_site1"); TH1D *amc_site1 = amc[0]->Clone("amc_site1"); TH1D *afn_site1 = afn[0]->Clone("afn_site1"); TH1D *pred_site2 = predOsc[2]->Clone("pred_site2"); THStack *hs_site2 = new THStack("hs_site2", ""); TH1D *acc_site2 = acc[2]->Clone("acc_site2"); TH1D *li9_site2 = li9[2]->Clone("li9_site2"); TH1D *fsn_site2 = fsn[2]->Clone("fsn_site2"); TH1D *amc_site2 = amc[2]->Clone("amc_site2"); TH1D *afn_site2 = afn[2]->Clone("afn_site2"); TH1D *pred_site3 = predOsc[3]->Clone("pred_site3"); THStack *hs_site3 = new THStack("hs_site3", ""); TH1D *acc_site3 = acc[3]->Clone("acc_site3"); TH1D *li9_site3 = li9[3]->Clone("li9_site3"); TH1D *fsn_site3 = fsn[3]->Clone("fsn_site3"); TH1D *amc_site3 = amc[3]->Clone("amc_site3"); TH1D *afn_site3 = afn[3]->Clone("afn_site3"); data_site1->Reset(); pred_site1->Reset(); acc_site1->Reset(); li9_site1->Reset(); fsn_site1->Reset(); amc_site1->Reset(); afn_site1->Reset(); data_site2->Reset(); pred_site2->Reset(); acc_site2->Reset(); li9_site2->Reset(); fsn_site2->Reset(); amc_site2->Reset(); afn_site2->Reset(); data_site3->Reset(); pred_site3->Reset(); acc_site3->Reset(); li9_site3->Reset(); fsn_site3->Reset(); amc_site3->Reset(); afn_site3->Reset(); pred_site1->SetLineColor(2); pred_site1->SetMarkerColor(2); acc_site1->SetLineColor(9); acc_site1->SetMarkerColor(9); acc_site1->SetFillColor(9); li9_site1->SetLineColor(5); li9_site1->SetMarkerColor(5); li9_site1->SetFillColor(5); fsn_site1->SetLineColor(6); fsn_site1->SetMarkerColor(6); fsn_site1->SetFillColor(6); amc_site1->SetLineColor(7); amc_site1->SetMarkerColor(7); amc_site1->SetFillColor(7); afn_site1->SetLineColor(8); afn_site1->SetLineColor(8); afn_site1->SetFillColor(8); pred_site2->SetLineColor(2); pred_site2->SetMarkerColor(2); acc_site2->SetLineColor(9); acc_site2->SetMarkerColor(9); acc_site2->SetFillColor(9); li9_site2->SetLineColor(5); li9_site2->SetMarkerColor(5); li9_site2->SetFillColor(5); fsn_site2->SetLineColor(6); fsn_site2->SetMarkerColor(6); fsn_site2->SetFillColor(6); amc_site2->SetLineColor(7); amc_site2->SetMarkerColor(7); amc_site2->SetFillColor(7); afn_site2->SetLineColor(8); afn_site2->SetLineColor(8); afn_site2->SetFillColor(8); pred_site3->SetLineColor(2); pred_site3->SetMarkerColor(2); acc_site3->SetLineColor(9); acc_site3->SetMarkerColor(9); acc_site3->SetFillColor(9); li9_site3->SetLineColor(5); li9_site3->SetMarkerColor(5); li9_site3->SetFillColor(5); fsn_site3->SetLineColor(6); fsn_site3->SetMarkerColor(6); fsn_site3->SetFillColor(6); amc_site3->SetLineColor(7); amc_site3->SetMarkerColor(7); amc_site3->SetFillColor(7); afn_site3->SetLineColor(8); afn_site3->SetLineColor(8); afn_site3->SetFillColor(8); for (int i=0; i<2; i++) { data_site1->Add(data[i]); pred_site1->Add(predOsc[i]); acc_site1->Add(acc[i]); li9_site1->Add(li9[i]); fsn_site1->Add(fsn[i]); amc_site1->Add(amc[i]); afn_site1->Add(afn[i]); } for (int i=2; i<3; i++) { data_site2->Add(data[i]); pred_site2->Add(predOsc[i]); acc_site2->Add(acc[i]); li9_site2->Add(li9[i]); fsn_site2->Add(fsn[i]); amc_site2->Add(amc[i]); afn_site2->Add(afn[i]); } for (int i=3; i<6; i++) { data_site3->Add(data[i]); pred_site3->Add(predOsc[i]); acc_site3->Add(acc[i]); li9_site3->Add(li9[i]); fsn_site3->Add(fsn[i]); amc_site3->Add(amc[i]); afn_site3->Add(afn[i]); } hs_site1->Add(fsn_site1); hs_site1->Add(afn_site1); hs_site1->Add(amc_site1); hs_site1->Add(li9_site1); hs_site1->Add(acc_site1); hs_site2->Add(fsn_site2); hs_site2->Add(afn_site2); hs_site2->Add(amc_site2); hs_site2->Add(li9_site2); hs_site2->Add(acc_site2); hs_site3->Add(fsn_site3); hs_site3->Add(afn_site3); hs_site3->Add(amc_site3); hs_site3->Add(li9_site3); hs_site3->Add(acc_site3); TCanvas c1("c1", "c1", 800, 800); TPad *can_1 = new TPad("can_1", "can_1",0, 0.66, 1, 0.99); TPad *can_2 = new TPad("can_2", "can_2",0, 0.33, 1, 0.66); TPad *can_3 = new TPad("can_3", "can_3",0, 0, 1, 0.33); can_1->Draw(); can_1->cd(); can_1->SetBottomMargin(1e-05); can_1->SetFrameBorderMode(0); can_1->SetBorderMode(0); data_site1->Draw(); data_site1->SetTitle(""); hs_site1->Draw("same"); data_site1->Draw("same"); // pred_site1->Draw("same"); data_site1->GetXaxis()->SetLabelSize(0.09); data_site1->GetYaxis()->SetNdivisions(508); data_site1->GetYaxis()->SetTitleSize(0.08); data_site1->GetYaxis()->SetLabelSize(0.08); data_site1->GetYaxis()->SetTitleOffset(0.6); data_site1->GetYaxis()->CenterTitle(true); TLegend leg(0.65,0.85-0.20,0.85,0.85); leg.AddEntry(data_site1, " EH1", "lp"); leg.AddEntry(acc_site1, " Acc. Bkgd", "f"); leg.SetFillColor(kWhite); leg.Draw(); can_1->Modified(); c1.cd(); can_2->Draw(); can_2->cd(); can_2->SetTopMargin(1e-05); can_2->SetBottomMargin(1e-05); can_2->SetFrameBorderMode(0); can_2->SetBorderMode(0); data_site2->Draw(); hs_site2->Draw("same"); data_site2->SetTitle(""); // data_site2->Draw("same"); // pred_site2->Draw("same"); data_site2->GetXaxis()->SetLabelSize(0.09); data_site2->GetYaxis()->SetNdivisions(508); data_site2->GetYaxis()->SetTitleSize(0.08); data_site2->GetYaxis()->SetLabelSize(0.08); data_site2->GetYaxis()->SetTitleOffset(0.6); data_site2->GetYaxis()->CenterTitle(true); TLegend leg2(0.65,0.85-0.20,0.85,0.85); leg2.AddEntry(data_site2, " EH2", "lp"); leg2.AddEntry(acc_site2, " Acc. Bkgd", "f"); leg2.SetFillColor(kWhite); leg2.Draw(); can_2->Modified(); c1.cd(); can_3->Draw(); can_3->cd(); can_3->SetTopMargin(1e-05); can_3->SetFrameBorderMode(0); can_3->SetBottomMargin(0.3); can_3->SetBorderMode(0); data_site3->Draw(); hs_site3->Draw("same"); data_site3->SetTitle(""); // data_site3->Draw("same"); // pred_site3->Draw("same"); data_site3->GetXaxis()->SetTitle("Reconstructed Energy [MeV]"); data_site3->GetXaxis()->SetTitleSize(0.09); data_site3->GetXaxis()->SetTitleOffset(1.45); data_site3->GetXaxis()->SetLabelSize(0.09); data_site3->GetXaxis()->Draw(); data_site3->GetYaxis()->SetNdivisions(508); data_site3->GetYaxis()->SetLabelSize(0.08); data_site3->GetYaxis()->SetTitleSize(0.08); data_site3->GetYaxis()->SetTitleOffset(0.6); data_site3->GetYaxis()->CenterTitle(true); can_3->RedrawAxis(); TLegend leg3(0.65,0.85-0.20,0.85,0.85); leg3.AddEntry(data_site3, " EH3", "lp"); leg3.AddEntry(acc_site3, " Acc. Bkgd", "f"); leg3.SetFillColor(kWhite); leg3.Draw(); can_3->Modified(); c1.cd(); TString name("SpectraSite"); // print 3 figures by default c1.SaveAs(name + ".eps"); c1.SaveAs(name + ".pdf"); c1.SaveAs(name + ".png"); TString extra(type); if (! (extra == "eps" || extra == "pdf" || extra == "png")) { c1.SaveAs(name + "." + type); } }
CmsSpreadRangeAccrualLeg::operator Leg() const { QL_REQUIRE(!notionals_.empty(), "no notional given"); Size n = schedule_.size()-1; QL_REQUIRE(notionals_.size() <= n, "too many nominals (" << notionals_.size() << "), only " << n << " required"); QL_REQUIRE(fixingDays_.size() <= n, "too many fixingDays (" << fixingDays_.size() << "), only " << n << " required"); QL_REQUIRE(gearings_.size()<=n, "too many gearings (" << gearings_.size() << "), only " << n << " required"); QL_REQUIRE(spreads_.size()<=n, "too many spreads (" << spreads_.size() << "), only " << n << " required"); QL_REQUIRE(lowerTriggers_.size()<=n, "too many lowerTriggers (" << lowerTriggers_.size() << "), only " << n << " required"); QL_REQUIRE(upperTriggers_.size()<=n, "too many upperTriggers (" << upperTriggers_.size() << "), only " << n << " required"); Leg leg(n); // the following is not always correct Calendar calendar = schedule_.calendar(); Date refStart, start, refEnd, end; Date paymentDate; std::vector<boost::shared_ptr<Schedule> > observationsSchedules; for (Size i=0; i<n; ++i) { refStart = start = schedule_.date(i); refEnd = end = schedule_.date(i+1); paymentDate = calendar.adjust(end, paymentAdjustment_); if (i==0 && !schedule_.isRegular(i+1)) { BusinessDayConvention bdc = schedule_.businessDayConvention(); refStart = calendar.adjust(end - schedule_.tenor(), bdc); } if (i==n-1 && !schedule_.isRegular(i+1)) { BusinessDayConvention bdc = schedule_.businessDayConvention(); refEnd = calendar.adjust(start + schedule_.tenor(), bdc); } if (detail::get(gearings_, i, 1.0) == 0.0) { // fixed coupon leg.push_back(boost::shared_ptr<CashFlow>(new FixedRateCoupon(paymentDate, detail::get(notionals_, i, Null<Real>()), detail::get(spreads_, i, 0.0), paymentDayCounter_, start, end, refStart, refEnd))); } else { // floating coupon observationsSchedules.push_back( boost::shared_ptr<Schedule>(new Schedule(start, end, observationTenor_, calendar, observationConvention_, observationConvention_, DateGeneration::Forward, false))); leg.push_back(boost::shared_ptr<CashFlow>(new CmsSpreadRangeAccrualCoupon( paymentDate, detail::get(notionals_, i, Null<Real>()), index_, start, end, detail::get(fixingDays_, i, 2), paymentDayCounter_, detail::get(gearings_, i, 1.0), detail::get(spreads_, i, 0.0), refStart, refEnd, observationsSchedules.back(), detail::get(lowerTriggers_, i, Null<Rate>()), detail::get(upperTriggers_, i, Null<Rate>())))); } } return leg; }
void overlayCanvases (std::string fname1, std::string fname2, std::string canvas1, std::string canvas2, std::string leg1, std::string leg2, std::string oname) { TCanvas oc("oc", "oc", 600, 400); gStyle->SetOptStat("emrou"); TFile file1(fname1.c_str()); TH1F *h1 = 0; TCanvas *can1 = (TCanvas*)file1.Get(canvas1.c_str()); TList *list1 = can1->GetListOfPrimitives(); TIter iter1 = list1->begin(); while (TObject *obj1 = iter1()) { if (!obj1->InheritsFrom(TH1::Class())) continue; h1 = (TH1F*)can1->GetPrimitive(obj1->GetName()); h1->SetLineColor(kBlack); h1->SetMarkerColor(kBlack); } TFile file2(fname2.c_str()); TH1F *h2 = 0; TCanvas *can2 = (TCanvas*)file2.Get(canvas2.c_str()); TList *list2 = can2->GetListOfPrimitives(); TIter iter2 = list2->begin(); while (TObject *obj2 = iter2()) { if (!obj2->InheritsFrom(TH1::Class())) continue; h2 = (TH1F*)can2->GetPrimitive(obj2->GetName()); h2->SetLineColor(kRed); h2->SetMarkerColor(kRed); } // oc.cd(); bool h1_is_max = (h1->GetBinContent(h1->GetMaximumBin()) > h2->GetBinContent(h2->GetMaximumBin())); if (h1_is_max) { h1->Draw(); h2->Draw("sames"); } else { h2->Draw(); h1->Draw("sames"); } gPad->Update(); TPaveStats *s1 = (TPaveStats*)h1->GetListOfFunctions()->FindObject("stats"); TPaveStats *s2 = (TPaveStats*)h2->GetListOfFunctions()->FindObject("stats"); if (s1 != 0 && s2 != 0) { s2->SetTextColor(kRed); s2->SetX1NDC(s1->GetX1NDC()); s2->SetX2NDC(s1->GetX2NDC()); s2->SetY2NDC(s1->GetY1NDC()-0.02); s2->SetY1NDC(s2->GetY2NDC()-(s1->GetY2NDC()-s1->GetY1NDC())); gPad->Modified(); } TLegend leg(0.2,0.6,0.4,0.8); leg.SetFillColor(0); leg.SetBorderSize(0); leg.AddEntry(h1,leg1.c_str()); leg.AddEntry(h2,leg2.c_str()); leg.Draw(); oc.Print(Form("%s_comp.pdf",oname.c_str())); oc.Print(Form("%s_comp.png",oname.c_str())); oc.Print(Form("%s_comp.root",oname.c_str())); if (h1_is_max) { double rat = h1->Integral() / h2->Integral(); h2->Scale(rat); h1->Draw(); h2->Draw("sames"); } else { double rat = h2->Integral() / h1->Integral(); h1->Scale(rat); h2->Draw(); h1->Draw("sames"); } gPad->Update(); if (s1 != 0 && s2 != 0) { s2->SetTextColor(kRed); s2->SetX1NDC(s1->GetX1NDC()); s2->SetX2NDC(s1->GetX2NDC()); s2->SetY2NDC(s1->GetY1NDC()-0.02); s2->SetY1NDC(s2->GetY2NDC()-(s1->GetY2NDC()-s1->GetY1NDC())); gPad->Modified(); } leg.Draw(); oc.Print(Form("%s_comp_scaled.pdf",oname.c_str())); oc.Print(Form("%s_comp_scaled.png",oname.c_str())); oc.Print(Form("%s_comp_scaled.root",oname.c_str())); }
void draw(){ glPushMatrix(); glRotatef(T,0,0,1); glTranslatef(0,a+l,0); //body with diaphram as center body(b,d,a,c); /********TEST**********/ //the small dot at the center of the diaphram //cuboid(0.05,0.05,0.05); /**********TEST*******/ //right hand glPushMatrix(); //translate so that hands joint to body becomes origin glTranslatef(d,b,0); glRotatef(G1,-1,0,0); glRotatef(B1,0,0,1); //draw hand here starting from origin towards -ve y axis hand(h); glPushMatrix(); glTranslatef(0,-h,0); glRotatef(D1,0,0,-1); //draw palm here from origin towards -ve y axis palm(); glPopMatrix(); glPopMatrix(); //left hand glPushMatrix(); //translate so that hands joint to body becomes origin glTranslatef(-d,b,0); glRotatef(G2,-1,0,0); glRotatef(B2,0,0,-1); //draw hand here starting from origin towards -ve y axis hand(h); glPushMatrix(); glTranslatef(0,-h,0); glRotatef(D2,0,0,1); //draw palm here from origin towards -ve y axis palm(); glPopMatrix(); glPopMatrix(); //right leg glPushMatrix(); glTranslatef(c,-a,0); glRotatef(E1,-1,0,0); //draw leg starting from origin towards -ve y axis leg(l); glPopMatrix(); //left leg glPushMatrix(); glTranslatef(-c,-a,0); glRotatef(E2,-1,0,0); //draw leg starting from origin towards -ve y axis leg(l); glPopMatrix(); //head glPushMatrix(); glTranslatef(0,b,0); glRotatef(A,1,0,0); //draw head here starting from origin towards +ve y axis head(); glPopMatrix(); glPopMatrix(); /*******TEST***********/ //the thin vertical line running from top till //bottom and the blue bottom plate //cuboid(1,0.1,1); //glColor3f(0.1,0.8,0.1); //cuboid(0.01,5,0.01); /*******TEST******/ }
void make1DLimit(TString combine_dir,TString type= "WH",bool blind=true){ //TString combine_dir = "test_runSusyHgg/signalInj_sms_ChiWH_0_175/"; //WH wh_limits.push_back(wh_125); wh_limits.push_back(wh_150); wh_limits.push_back(wh_175); wh_limits.push_back(wh_200); //HH hh_limits.push_back(hh_125); hh_limits.push_back(hh_150); hh_limits.push_back(hh_175); hh_limits.push_back(hh_200); TGraph obser( (200-125)/25 ); TGraph graph( (200-125)/25 ); TGraphAsymmErrors error( (200-125)/25 ); TGraphAsymmErrors error2S( (200-125)/25 ); TGraph obser_r( (200-125)/25 ); TGraph graph_r( (200-125)/25 ); TGraphAsymmErrors error_r( (200-125)/25 ); TGraphAsymmErrors error_r2S( (200-125)/25 ); TGraphErrors* theo = 0; if(type=="WH") theo = getTheoXSec("xsecs/CharginoNeutralino.txt"); else theo = getTheoXSec("xsecs/Higgsino_ElectroHiggs.txt"); //else theo = getTheoXSec("/home/amott/HggApp/SusyHgg/xsecs/Higgsino.txt"); for(int m=125;m<=200;m+=25) { int i=(m-125)/25; TFile limit_file(Form("%s/higgsCombineChi%s_0_%d.Asymptotic.mH120.root",combine_dir.Data(),type.Data(),m) ); TTree *limit_tree = (TTree*)limit_file.Get("limit"); TTreeFormula limit_form("get_limit","limit",limit_tree); float down_2s = -1; float down = -1; float exp = -1; float up = -1; float up_2s = -1; float obs = -1; if( type == "WH" ) { down_2s = wh_limits.at(i)[0]; down = wh_limits.at(i)[1]; exp = wh_limits.at(i)[2]; up = wh_limits.at(i)[3]; up_2s = wh_limits.at(i)[4]; obs = wh_limits.at(i)[5]; } else if ( type == "HH") { down_2s = hh_limits.at(i)[0]; down = hh_limits.at(i)[1]; exp = hh_limits.at(i)[2]; up = hh_limits.at(i)[3]; up_2s = hh_limits.at(i)[4]; obs = hh_limits.at(i)[5]; } else { std::cerr << "UNRECOGNIZED OPTION!!! QUITTING" << std::endl; } if(i==0) m+=5; //first point is actually at m=130 graph.SetPoint(i,float(m), exp); error.SetPoint(i,float(m), exp); error2S.SetPoint(i, float(m), exp); error.SetPointError(i, 0, 0, exp-down, up-exp); error2S.SetPointError(i, 0 , 0 , exp-down_2s, up_2s-exp); graph_r.SetPoint(i,float(m),exp/theo->Eval(m)); error_r.SetPoint(i,float(m),exp/theo->Eval(m)); error_r2S.SetPoint(i,float(m),exp/theo->Eval(m)); error_r.SetPointError(i,0,0,(exp-down)/theo->Eval(m),(up-exp)/theo->Eval(m)); error_r2S.SetPointError(i, 0, 0, (exp-down_2s)/theo->Eval(m), (up_2s-exp)/theo->Eval(m) ); obser.SetPoint(i,float(m),obs); obser_r.SetPoint(i,float(m),obs/theo->Eval(m)); if(i==0) m-=5; } TCanvas cv; cv.SetLogy(); cv.SetGrid(1,1); theo->SetMaximum(1e2); theo->SetMinimum(1e-2); theo->GetYaxis()->SetLabelSize(0.05); theo->GetYaxis()->SetTitleSize(0.06); theo->GetYaxis()->SetTitleOffset(0.8); theo->GetYaxis()->SetTitle("95% CL #sigma upper limit (pb)"); theo->GetXaxis()->SetTitle("m_{chargino} (GeV)"); if(type=="HH") theo->GetXaxis()->SetTitle("m_{neutralino} (GeV)"); theo->SetFillColor(kBlue); theo->SetLineStyle(kDotted); theo->SetLineWidth(2); error.SetMaximum(1e2); error.SetMinimum(1e-2); error.GetYaxis()->SetLabelSize(0.04); error.GetYaxis()->SetTitleSize(0.06); error.GetYaxis()->SetTitleOffset(0.8); error.GetXaxis()->SetLabelSize(0.04); error.GetXaxis()->SetTitleSize(0.05); error.GetXaxis()->SetTitleOffset(0.9); error.GetYaxis()->SetTitle("95% CL #sigma upper limit (pb)"); error.GetXaxis()->SetTitle("m_{chargino} (GeV)"); if(type=="HH") error.GetXaxis()->SetTitle("m_{neutralino} (GeV)"); error.SetFillColor(kGreen); error2S.SetFillColor(kYellow); error2S.SetTitle(""); error.SetTitle(""); error.Draw("A3"); error2S.Draw("3SAME"); error.Draw("3"); theo->SetTitle(""); theo->Draw("3C"); graph.SetLineStyle(kDashed); graph.SetLineWidth(2.0); graph.SetTitle(""); graph.Draw("C"); obser.SetLineStyle(1); obser.SetLineWidth(2.0); obser.SetTitle(""); if(!blind) obser.Draw("C"); TLegend leg(0.65,0.65,0.89,0.89); leg.SetFillColor(0); leg.SetBorderSize(0); leg.AddEntry(&graph,"expected","l"); leg.AddEntry(&error,"expected #pm1#sigma","F"); leg.AddEntry(&error2S,"expected #pm2#sigma","F"); leg.AddEntry(theo,"theoretical","f"); if(!blind) leg.AddEntry(&obser,"observed","l"); leg.Draw("SAME"); TLatex latex; latex.SetNDC(); latex.SetTextAngle(0); latex.SetTextColor(kBlack); float extraTextSize = extraOverCmsTextSize*cmsSize; latex.SetTextFont(lumifont); latex.SetTextAlign(31); latex.SetTextSize(cmsSize); latex.DrawLatex(lumix, lumiy,lumiText); latex.SetTextFont(cmsTextFont); latex.SetTextAlign(31); latex.SetTextSize(cmsSize); latex.DrawLatex(cmsx, cmsy, CMSText); latex.SetTextFont(extraTextFont); latex.SetTextAlign(31); latex.SetTextSize(extraTextSize); latex.DrawLatex(extrax, extray, extraText); TString infix=(blind ? "" : "_OBS"); cv.SaveAs(combine_dir+"/expected_exclusion_"+type+"_1D"+infix+"_v2.png"); cv.SaveAs(combine_dir+"/expected_exclusion_"+type+"_1D"+infix+"_v2.pdf"); cv.SaveAs(combine_dir+"/expected_exclusion_"+type+"_1D"+infix+"_v2.C"); error_r.SetMaximum(1e2); error_r.SetMinimum(1e-2); error_r.SetTitle(""); error_r.GetYaxis()->SetLabelSize(0.04); error_r.GetYaxis()->SetTitleSize(0.06); error_r.GetYaxis()->SetTitleOffset(0.8); error_r.GetXaxis()->SetLabelSize(0.04); error_r.GetXaxis()->SetTitleSize(0.05); error_r.GetXaxis()->SetTitleOffset(0.9); error_r.GetYaxis()->SetTitle("#sigma_{95%}/#sigma_{NLO}"); if(type=="HH") error_r.GetXaxis()->SetTitle("m_{neutralino} (GeV)"); else error_r.GetXaxis()->SetTitle("m_{chargino} (GeV)"); error_r.SetFillColor(kGreen); error_r2S.SetFillColor(kYellow); error_r2S.SetTitle(""); error_r.Draw("A3"); error_r2S.Draw("3SAME"); error_r.Draw("3SAME"); graph_r.SetLineStyle(kDashed); graph_r.SetLineWidth(2); graph_r.SetTitle(""); graph_r.Draw("C"); TLine l(125,1,205,1); l.SetLineWidth(3); l.SetLineColor(kBlue); //l.Draw("SAME"); obser_r.SetLineWidth(2); if(!blind) obser_r.Draw("C"); leg.Draw("SAME"); //lbl.SetY(0.20); //leg.SetY1NDC(0.28); //leg.SetY2NDC(0.43); //prelim.Draw(); //lbl.Draw(); latex.SetTextFont(lumifont); latex.SetTextAlign(31); latex.SetTextSize(cmsSize); latex.DrawLatex(lumix, lumiy,lumiText); latex.SetTextFont(cmsTextFont); latex.SetTextAlign(31); latex.SetTextSize(cmsSize); latex.DrawLatex(cmsx, cmsy, CMSText); latex.SetTextFont(extraTextFont); latex.SetTextAlign(31); latex.SetTextSize(extraTextSize); latex.DrawLatex(extrax, extray, extraText); cv.SaveAs(combine_dir+"/expected_exclusion_ratio_"+type+"_1D"+infix+"_v2.png"); cv.SaveAs(combine_dir+"/expected_exclusion_ratio_"+type+"_1D"+infix+"_v2.pdf"); cv.SaveAs(combine_dir+"/expected_exclusion_ratio_"+type+"_1D"+infix+"_v2.C"); }
bool OrderWrapper::newOrder( API2::DATA_TYPES::RiskStatus &risk, const API2::DATA_TYPES::PRICE &priceLeg1, const API2::DATA_TYPES::QTY &qtyLeg1, const API2::DATA_TYPES::PRICE &priceLeg2, const API2::DATA_TYPES::QTY &qtyLeg2, const API2::DATA_TYPES::PRICE &priceLeg3, const API2::DATA_TYPES::QTY &qtyLeg3 ) { if(!_instrument) return false; _isReset = false; LegDetail *leg1 =0, *leg2=0, *leg3 =0; if(_numLegs>=1) { if(qtyLeg1 == 0) { risk = API2::CONSTANTS::RSP_RiskStatus_WRONG_QUANTITY; return false; } leg1 = &_orderLegData[0]; leg1->order->setQuantity(qtyLeg1); leg1->order->setPrice(priceLeg1); } else { DEBUG_MESSAGE(_context->reqQryDebugLog(), "Order Wrapper Not Set. num Leg <1. Terminating strategy"); _context->reqAddStrategyComment(API2::CONSTANTS::RSP_StrategyComment_STRATEGY_ERROR_STATE); _context->reqTerminateStrategy(); return false; } if(_numLegs>=2 && _orderLegData.size() >=2) { if(qtyLeg2 == 0) { risk = API2::CONSTANTS::RSP_RiskStatus_WRONG_QUANTITY; DEBUG_MESSAGE(_context->reqQryDebugLog(), "qty leg 2 0"); return false; } leg2 = &_orderLegData[1]; leg2->order->setQuantity(qtyLeg2); leg2->order->setPrice(priceLeg2); } if(_numLegs==3 && _orderLegData.size() ==3) { if(qtyLeg3 == 0) { risk = API2::CONSTANTS::RSP_RiskStatus_WRONG_QUANTITY; DEBUG_MESSAGE(_context->reqQryDebugLog(), "returning false qty leg3"); return false; } leg3 = &_orderLegData[2]; leg3->order->setQuantity(qtyLeg3); leg3->order->setPrice(priceLeg3); } if(_numLegs ==1) { if(leg1){ if(_context->reqNewSingleOrder(risk,leg1->instrument,leg1->order,leg1->orderId,_isSpread,_orderPriority)) { _isPendingNew = true; return true; } } else { DEBUG_MESSAGE(_context->reqQryDebugLog(), "Order Wrapper Not Set. Terminating strategy"); DEBUG_MESSAGE(_context->reqQryDebugLog(),"Leg 1 null"); _context->reqAddStrategyComment(API2::CONSTANTS::RSP_StrategyComment_STRATEGY_ERROR_STATE); _context->reqTerminateStrategy(); return false; } } else if(_numLegs >= 2) { std::vector<SGContext::OrderLegData> legData; for(std::vector<LegDetail>::iterator iter = _orderLegData.begin(); iter!= _orderLegData.end();iter++) { LegDetail legD = *iter; SGContext::OrderLegData leg(legD.instrument); leg.order = legD.order; leg.orderId = legD.orderId; if(leg.order && leg.orderId) legData.push_back(legD); } if( _context->reqNewMultilegOrder(risk,legData) ) { _isPendingNew = true; return true; } } return false; }
void test_date_time_implementation() { ULL timestamp = 20090618001732ULL; int dt; int tm; int Y,M,D,h,m,s; split_timestamp(timestamp, dt, tm); date_to_ymd(dt, Y, M, D); time_to_hms(tm, h, m, s); cout << "Timestamp: " << timestamp << endl; cout << "Date: " << dt << " -> " << Y << "/" << M << "/" << D << endl; cout << "Time: " << tm << " -> " << h << ":" << m << ":" << s << endl << endl; UL seconds = 31834133; Interval i = Interval(0,0,0,0,0,seconds); cout << "20080101 + 31834133 seconds = " << join_timestamp(20080101, 0) + i << endl; cout << "20080101 - -31834133 seconds = " << join_timestamp(20080101, 0) - -i << endl; cout << "20080101 - 31834133 seconds = " << join_timestamp(20080101, 0) - i << endl; cout << "20080101 + -31834133 seconds = " << join_timestamp(20080101, 0) + -i << endl; cout << endl; i = Interval(1, 3, 3, 25, 7, 38); cout << "20090601 + (1 year 3 months 3 days 25 hours 7 minutes 38 seconds) = " << join_timestamp(20090601, 0) + i << endl; cout << "20090601 - -(1 year 3 months 3 days 25 hours 7 minutes 38 seconds) = " << join_timestamp(20090601, 0) - (-i) << endl; cout << "20090601 - (1 year 3 months 3 days 25 hours 7 minutes 38 seconds) = " << join_timestamp(20090601, 0) - i << endl; cout << "20090601 + -(1 year 3 months 3 days 25 hours 7 minutes 38 seconds) = " << join_timestamp(20090601, 0) + (-i) << endl; cout << endl; Interval l = Interval(2, 3, 32, 25, 7, 112); Interval r = Interval(1, 15, 33, 1, 8, 52); cout << "(2 years 3 months 32 days 25 hours 7 minutes 112 seconds) <=> (1 year 15 months 33 days 1 hour 8 minutes 52 seconds) = " << leg(l,r) << endl; cout << endl; l = Interval(0,0,0,0,0,31834133); r = Interval(0, 0, 368, 10, 48, 52); cout << "(31834133 seconds) <=> (368 days 10 hours 48 minutes 52 seconds) = " << leg(l,r) << endl; cout << "(31834133 seconds) > (368 days 10 hours 48 minutes 52 seconds) = " << ((l > r) ? "true" : "false") << endl; r = Interval(0, 0, 368, 10, 48, 53); cout << "(31834133 seconds) <=> (368 days 10 hours 48 minutes 53 seconds) = " << leg(l,r) << endl; cout << "(31834133 seconds) == (368 days 10 hours 48 minutes 53 seconds) = " << ((l == r) ? "true" : "false") << endl; r = Interval(0, 0, 368, 10, 48, 54); cout << "(31834133 seconds) <=> (368 days 10 hours 48 minutes 54 seconds) = " << leg(l,r) << endl; cout << "(31834133 seconds) < (368 days 10 hours 48 minutes 54 seconds) = " << ((l < r) ? "true" : "false") << endl; cout << endl; ULL t1 = 19831129031500ULL; // my birth date (time?) ULL t2 = 20090626005206ULL; // now i = Interval::between(t1, t2); l = Interval(25, 6, 27, 21, 37, 6); r = Interval(0, 0, 9340, 21, 37, 6); cout << "Interval between 1983-11-29 03:15:00 and 2009-06-26 00:52:06 = " << i.to_s() << endl; cout << i.to_s() << " <=> " << l.to_s() << " = " << leg(i, l) << endl; cout << i.to_s() << " <=> " << r.to_s() << " = " << leg(i, r) << endl; cout << l.to_s() << " <=> " << r.to_s() << " = " << leg(l, r) << endl; cout << endl; l = Interval(0, 1, -29, 4, -29, 0); r = Interval(0, 0, 2, 3, 31, 0); cout << l.to_s() << " <=> " << r.to_s() << " = " << leg(l, r) << endl; cout << l.to_s() << " < " << r.to_s() << " -> " << ((l < r) ? "true" : "false") << endl; cout << l.to_s() << " == " << r.to_s() << " -> " << ((l == r) ? "true" : "false") << endl; cout << l.to_s() << " > " << r.to_s() << " -> " << ((l > r) ? "true" : "false") << endl; cout << endl; i = Interval(390, -1354, -3395, -6671, -5719, 0); // ~9.7556 days long divisor = 10000; cout << i.to_s() << " / " << divisor << " = " << (i / divisor).to_s() << endl; cout << endl; cout << "Day of week of 20090623 is a " << getDayOfWeek(6, 23, 2009, 1); }
// ################################################ double NeuralNetwork::LearnGivenData(int MiniBatchSize, int epochs, int TrainingsSize, bool TestOnTrainingsData, bool TestOnTestingData, std::string SavePath){ TCanvas c1("Accuracy", "Accuracy", 600, 500); TCanvas c2("Cost", "Cost", 600, 500); TCanvas c3("summary", "summary", 1200, 500); c3.SetGrid(); c3.Divide(2); c1.cd(); TH1F axis("axis", "Accuracy of Neural Network;epochs", epochs, 0.5, epochs+0.5); TH1F acc_test ("acc_test" , "Classification accuracy", epochs, 0.5, epochs+0.5); TH1F acc_train("acc_train", "Classification accuracy", epochs, 0.5, epochs+0.5); TH1F axis2("axis2", "Cost Function of Neural Network;epochs", epochs, 0.5, epochs+0.5); TH1F cost_test ("cost_test" , "Cost Function", epochs, 0.5, epochs+0.5); TH1F cost_train("cost_train", "Cost Function", epochs, 0.5, epochs+0.5); if (TrainingsSize == -1) TrainingsSize = fTrainingsSize; for (int k = 0; k < epochs; ++k){ // if (k % 5 == 0) std::cout << "Epoch nr. " << k << " started!" << std::endl; for (int i = 0; i < TrainingsSize / MiniBatchSize; ++i){ for (int j = 0; j < MiniBatchSize; ++j){ SetInputVectorInMiniBatch(fTrainingsdata[i*10 + j], fTrainingslabel[i*10 + j]); } LearnMiniBatches(); } if (TestOnTestingData){ double correct = 0; double cost = 0; for (int i = 0; i < fTestingSize; ++i){ if (Evaluate(fTestingdata[i], fTestinglabel[i]) == true) correct++; cost += EvaluateCost(fTestingdata[i], fTestinglabel[i]); } // std::cout << "Accuracy of test data: " << correct / fTestingSize << " %"<< std::endl; acc_test.SetBinContent(k+1, correct / fTestingSize); cost_test.SetBinContent(k+1, cost / fTestingSize); } if (TestOnTrainingsData){ double correct = 0; double cost = 0; for (int i = 0; i < TrainingsSize; ++i){ if (Evaluate(fTrainingsdata[i], fTrainingslabel[i]) == true) correct++; cost += EvaluateCost(fTrainingsdata[i], fTrainingslabel[i]); } // std::cout << "Accuracy of trainings data: " << correct / TrainingsSize << " %" << std::endl; acc_train.SetBinContent(k+1, correct / TrainingsSize); cost_train.SetBinContent(k+1, cost / fTrainingsSize); } } axis.SetStats(false); axis.GetYaxis()->SetNdivisions(524); axis.SetAxisRange(0.5, 1.1, "Y"); axis.Draw(""); double markersize = 1; if (epochs > 100) { markersize = 0.5; c1.SetLogx(); } acc_test.SetStats(false); acc_test.SetMarkerStyle(20); acc_test.SetMarkerColor(kOrange-3); acc_test.SetMarkerSize(1.); acc_test.Draw("p same"); acc_train.SetStats(false); acc_train.SetMarkerStyle(20); acc_train.SetMarkerColor(kAzure-2); acc_train.SetMarkerSize(1.); acc_train.Draw("p same"); // c1.SetLogx(); c1.SetGrid(); // Calculate maxima double max_trainingsdata = acc_train.GetMaximum(); double max_testdata = acc_test.GetMaximum(); TLegend leg(0.4,0.1,0.9,0.3); leg.SetHeader("Accuracy of"); leg.AddEntry(&acc_test, Form("Test data (Maximum: %4.3f)", max_testdata), "p"); leg.AddEntry(&acc_train, Form("Trainings data (Maximum: %4.3f)", max_trainingsdata), "p"); leg.Draw("same"); c1.SaveAs(Form("%saccuracy.pdf", SavePath.c_str())); c2.cd(); axis2.SetStats(false); axis2.GetYaxis()->SetNdivisions(524); axis2.SetAxisRange(cost_train.GetMinimum()*0.9, cost_test.GetMaximum()*1.1, "Y"); axis2.Draw(""); if (epochs > 100) { markersize = 0.5; c2.SetLogx(); } cost_train.SetStats(false); cost_train.SetMarkerStyle(20); cost_train.SetMarkerColor(kAzure-2); cost_train.SetMarkerSize(1.); cost_train.Draw("p same"); cost_test.SetStats(false); cost_test.SetMarkerStyle(20); cost_test.SetMarkerColor(kOrange-3); cost_test.SetMarkerSize(1.); cost_test.Draw("p same"); // c1.SetLogx(); c2.SetGrid(); // Calculate maxima double min_trainingsdata = cost_train.GetMinimum(); double min_testdata = cost_test.GetMinimum(); TLegend leg2(0.4,0.7,0.9,0.9); leg2.SetHeader("Cost Function"); leg2.AddEntry(&acc_test, Form("Test data (Minimum: %4.3f)", min_testdata), "p"); leg2.AddEntry(&acc_train, Form("Trainings data (Minimum: %4.3f)", min_trainingsdata), "p"); leg2.Draw("same"); c2.SaveAs(Form("%scost.pdf", SavePath.c_str())); c3.cd(1); axis.Draw(""); acc_test.Draw("p same"); acc_train.Draw("p same"); leg.Draw("same"); c3.cd(2); axis2.Draw(""); cost_test.Draw("p same"); cost_train.Draw("p same"); leg2.Draw("same"); c3.SaveAs(Form("%ssummary.pdf", SavePath.c_str())); // std::cout << "Learning completed" << std::endl; return max_testdata; }
bool operator!=(const Interval& lhs, const Interval& rhs) { return leg(lhs, rhs) != 0; }
void right_leg(float upperlegangle, float lowerlegangle, float footangle){ matrixPush(ModelView); matrixScale(ModelView, -1, 1, 1); leg(upperlegangle, lowerlegangle, footangle); matrixPop(ModelView); }
void CreateLandSCombineComparisonPlotExp ( const std::string& sample = "t2tt", const std::string& method = "hybrid", const std::string& label = "v0", const std::string& suffix = "pdf" ) { // inputs: const stop::Sample::Info sample_info = stop::GetSampleInfo(sample); // lands hists and graphs TFile lands_file("data/t2tt_onelep_bdt_AN-2013-89.root"); lands_file.ls(); // onlep hists and graphs TFile onelep_file(Form("plots/limits/%s/%s/%s/onelep/%s_xsec_excl_onelep.root", label.c_str(), method.c_str(), sample.c_str(), sample.c_str())); onelep_file.ls(); // histogram for axis TH2D& h_exp = *static_cast<TH2D*>(onelep_file.Get("h_ul_xsec_exp")); h_exp.GetXaxis()->SetRangeUser(100.0, 900); h_exp.GetYaxis()->SetRangeUser(0.0 , 700); // exclusion TGraphs TH2& h_lands_exp_1 = *static_cast<TH2F*>(lands_file.Get("hR_exp_smallDM")); h_lands_exp_1.SetLineColor(kRed+2); h_lands_exp_1.SetLineWidth(3); h_lands_exp_1.SetLineStyle(1); TH2& h_lands_expp1_1 = *static_cast<TH2F*>(lands_file.Get("hR_expp1_smallDM")); h_lands_expp1_1.SetLineColor(kRed+2); h_lands_expp1_1.SetLineWidth(3); h_lands_expp1_1.SetLineStyle(2); TH2& h_lands_expm1_1 = *static_cast<TH2F*>(lands_file.Get("hR_expm1_smallDM")); h_lands_expm1_1.SetLineColor(kRed+2); h_lands_expm1_1.SetLineWidth(3); h_lands_expm1_1.SetLineStyle(2); TH2& h_lands_exp_2 = *static_cast<TH2F*>(lands_file.Get("hR_exp")); h_lands_exp_2.SetLineColor(kRed+2); h_lands_exp_2.SetLineWidth(3); h_lands_exp_2.SetLineStyle(1); TH2& h_lands_expp1_2 = *static_cast<TH2F*>(lands_file.Get("hR_expp1")); h_lands_expp1_2.SetLineColor(kRed+2); h_lands_expp1_2.SetLineWidth(3); h_lands_expp1_2.SetLineStyle(2); TH2& h_lands_expm1_2 = *static_cast<TH2F*>(lands_file.Get("hR_expm1")); h_lands_expm1_2.SetLineColor(kRed+2); h_lands_expm1_2.SetLineWidth(3); h_lands_expm1_2.SetLineStyle(2); TGraph& g_onelep_exp = *static_cast<TGraph*>(onelep_file.Get("g_excl_xsec_exp")); g_onelep_exp.SetLineColor(kBlue); g_onelep_exp.SetLineWidth(3); g_onelep_exp.SetLineStyle(1); TGraph& g_onelep_exp_p1 = *static_cast<TGraph*>(onelep_file.Get("g_excl_xsec_exp_p1")); g_onelep_exp_p1.SetLineColor(kBlue); g_onelep_exp_p1.SetLineWidth(3); g_onelep_exp_p1.SetLineStyle(2); TGraph& g_onelep_exp_m1 = *static_cast<TGraph*>(onelep_file.Get("g_excl_xsec_exp_m1")); g_onelep_exp_m1.SetLineColor(kBlue); g_onelep_exp_m1.SetLineWidth(3); g_onelep_exp_m1.SetLineStyle(2); // TLegend TLegend leg(0.18, 0.78, 0.6, 0.68); leg.AddEntry(&h_lands_exp_1 , "LandS" , "l"); leg.AddEntry(&g_onelep_exp, "Higg's Combine", "l"); leg.SetFillColor(0); // 0 makes it the background clear on the pad leg.SetFillStyle(0); leg.SetBorderSize(0); TLine l_lands_p1; l_lands_p1.SetLineColor(kRed+2); l_lands_p1.SetLineWidth(2); l_lands_p1.SetLineStyle(2); TLine l_onelep_p1; l_onelep_p1.SetLineColor(kBlue); l_onelep_p1.SetLineWidth(2); l_onelep_p1.SetLineStyle(2); // labels TLatex t1(0.18, 0.85, Form("Expected exclusion on #sigma(%s)", sample_info.title.c_str())); t1.SetNDC(); t1.SetTextAlign(13); t1.SetTextFont(42); t1.SetTextSize(0.04); // overlay TCanvas c1("c1", "c1", 600, 600); rt::SetTDRStyle(); h_exp.SetTitle("CMS Preliminary, #sqrt{s} = 8 TeV"); h_exp.SetTitleFont(42); h_exp.SetTitleSize(0.05); h_exp.SetStats(false); h_exp.Draw("axis"); const double offset = 25.0/2.0; h_exp.GetXaxis()->SetRangeUser(100+offset, 800-offset); h_exp.GetXaxis()->SetTitleOffset(1.2); h_exp.GetXaxis()->SetTitleSize(0.05); h_exp.GetXaxis()->SetTitleFont(42); h_exp.GetXaxis()->SetLabelSize(0.03); h_exp.GetXaxis()->SetLabelFont(42); h_exp.GetYaxis()->SetRangeUser(0+offset , 400-offset); h_exp.GetYaxis()->SetTitleOffset(1.35); h_exp.GetYaxis()->SetTitleFont(42); h_exp.GetYaxis()->SetLabelSize(0.03); h_exp.GetYaxis()->SetLabelFont(42); c1.SetLeftMargin(0.14); c1.SetRightMargin(0.05); h_exp.Draw("axis"); h_lands_exp_1.Draw("cont3csame"); h_lands_expp1_1.Draw("cont3csame"); h_lands_expm1_1.Draw("cont3csame"); h_lands_exp_2.Draw("cont3csame"); h_lands_expp1_2.Draw("cont3csame"); h_lands_expm1_2.Draw("cont3csame"); g_onelep_exp.Draw("lsame"); g_onelep_exp_p1.Draw("lsame"); g_onelep_exp_m1.Draw("lsame"); leg.Draw(); l_lands_p1.DrawLineNDC (0.1975, 0.765, 0.265, 0.765); l_lands_p1.DrawLineNDC (0.1975, 0.745, 0.265, 0.745); l_onelep_p1.DrawLineNDC(0.1975, 0.715, 0.265, 0.715); l_onelep_p1.DrawLineNDC(0.1975, 0.695, 0.265, 0.695); t1.Draw(); // output const std::string output_file = Form("plots/limits/%s/%s/%s/compare/p_lands_combine_comparison_exp.%s", label.c_str(), method.c_str(), sample.c_str(), suffix.c_str()); lt::mkdir(lt::dirname(output_file), /*force=*/true); c1.Print(output_file.c_str()); }
int main(int argc, char* argv[]) { TH1::SetDefaultSumw2(); ProgramOptions options(argc, argv); double lumi = options.lumi; // input datasets Datasets datasets(options.iDir); datasets.readFile(options.datasetFile); // output file TFile* ofile = TFile::Open( (options.oDir+std::string("/ZMuMufromW.root")).c_str(), "RECREATE"); std::string oDir = options.oDir + std::string("/ZmumuFromW"); if (oDir!="") { boost::filesystem::path opath(oDir); if (!exists(opath)) { std::cout << "Creating output directory : " << oDir << std::endl; boost::filesystem::create_directory(opath); } std::cout << "Writing results to " << oDir << std::endl; } // cuts Cuts cuts; unsigned nCutsZMuMu = cuts.nCutsZMuMu(); TCut puWeight("puWeight"); TCut trigCorr( "(trigCorrWeight>0) ? trigCorrWeight : 1." ); // For lepton weights TCut muTightWeight = cuts.muTightWeight(options.leptCorr); TCut lVetoWeight = cuts.elVetoWeight(options.leptCorr) * cuts.muVetoWeight(options.leptCorr); TCut METNo2Muon130("metNo2Muon>130."); TCut cutLoDPhi = cuts.cut("dPhiJJ"); TCut cutHiDPhi("vbfDPhi>2.6"); TCut cutMe1DPhi("vbfDPhi>1.0 && vbfDPhi<=1.8"); TCut cutMe2DPhi("vbfDPhi>1.8 && vbfDPhi<=2.6"); // histograms double dphiEdges[5] = { 0., 1.0, 1.8, 2.6, TMath::Pi() }; // Observed signal MET>130 TH1D* hZ_DY_C_DPhi = new TH1D("hZ_DY_C_DPhi", "", 4, dphiEdges); // Z+jets MC ctrl region TH1D* hZ_BG_ZC_DPhi = new TH1D("hZ_BG_ZC_DPhi", "", 4, dphiEdges); // background MC ctrl region TH1D* hZ_Data_ZC_DPhi = new TH1D("hZ_Data_ZC_DPhi", "", 4, dphiEdges); // Data ctrl region // Predicted from Wmunu TH1D* hZ_W_C_DPhi = new TH1D("hZ_W_C_DPhi", "", 4, dphiEdges); // W+jets MC ctrl region TH1D* hZ_BG_WC_DPhi = new TH1D("hZ_BG_WC_DPhi", "", 4, dphiEdges); // background MC ctrl region TH1D* hZ_Data_WC_DPhi = new TH1D("hZ_Data_WC_DPhi", "", 4, dphiEdges); // Data W ctrl region TH1D* hZ_W_EffMu_D = new TH1D("hZ_W_EffMu_D", "", 1, 0., 1.); // denominator of MuMu efficiency from DY(pT<100) + DY(pT>100) + DY_EWK samples TH1D* hZ_W_EffMu_N = new TH1D("hZ_W_EffMu_N", "", 1, 0., 1.); // numerator of MuMu efficiency from DY(pT<100) + DY(pT>100) + DY_EWK samples TH1D* hZ_DY_EffMuMu_D = new TH1D("hZ_DY_EffMuMu_D", "", 1, 0., 1.); // denominator of MuMu efficiency from DY + DY_EWK samples TH1D* hZ_DY_EffMuMu_N = new TH1D("hZ_DY_EffMuMu_N", "", 1, 0., 1.); // numerator of MuMu efficiency from DY + DY_EWK samples TH1D* hZ_DY_EffVBFS_D = new TH1D("hZ_DY_EffVBFS_D", "", 1, 0., 1.); // denominator of VBF(S) efficiency from DY(pT<100) + DY(pT>100) + DY_EWK samples //TH1D* hZ_DY_EffVBFS_N = new TH1D("hZ_DY_EffVBFS_N", "", 1, 0., 1.); // numerator of VBF(S) efficiency from DY(pT<100) + DY(pT>100) + DY_EWK samples TH1D* hZ_DY_EffVBFS_NLo = new TH1D("hZ_DY_EffVBFS_NLo", "", 1, 0., 1.); TH1D* hZ_DY_EffVBFS_NHi = new TH1D("hZ_DY_EffVBFS_NHi", "", 1, 0., 1.); TH1D* hZ_DY_EffVBFS_NMe1 = new TH1D("hZ_DY_EffVBFS_NMe1", "", 1, 0., 1.); TH1D* hZ_DY_EffVBFS_NMe2 = new TH1D("hZ_DY_EffVBFS_NMe2", "", 1, 0., 1.); TH1D* hZ_W_EffVBFC_D = new TH1D("hZ_W_EffVBFC_D", "", 1, 0., 1.); // denominator of VBF(C) efficiency from DY(pT<100) + DY(pT>100) + DY_EWK samples //TH1D* hZ_W_EffVBFC_N = new TH1D("hZ_W_EffVBFC_N", "", 1, 0., 1.); // numerator of VBF(C) efficiency from DY(pT<100) + DY(pT>100) + DY_EWK samples TH1D* hZ_W_EffVBFC_NLo = new TH1D("hZ_W_EffVBFC_NLo", "", 1, 0., 1.); TH1D* hZ_W_EffVBFC_NHi = new TH1D("hZ_W_EffVBFC_NHi", "", 1, 0., 1.); TH1D* hZ_W_EffVBFC_NMe1 = new TH1D("hZ_W_EffVBFC_NMe1", "", 1, 0., 1.); TH1D* hZ_W_EffVBFC_NMe2 = new TH1D("hZ_W_EffVBFC_NMe2", "", 1, 0., 1.); // loop over MC datasets for (unsigned i=0; i<datasets.size(); ++i) { Dataset dataset = datasets.getDataset(i); TCut cutD = cuts.cutDataset(dataset.name); TCut wWeight(""); // bit of a fudge for mutight weight - data doesn't have the var in it, so need to add an exception (see below) // and then restore it for all other MC muTightWeight=cuts.muTightWeight(options.leptCorr); // check if it's DYJets bool isDY = false; bool isWJets = false; bool isQCD = false; bool isEwkW = false; if (dataset.name.compare(0,2,"DY")==0) { isDY = true; std::cout << "Analysing DY->ll MC : " << dataset.name << std::endl; } else if (dataset.name == "WJets" || dataset.name == "W1Jets" || dataset.name == "W2Jets" || dataset.name == "W3Jets" || dataset.name == "W4Jets" || dataset.name == "EWK_Wp2Jets" || dataset.name == "EWK_Wm2Jets") { if (dataset.name == "EWK_Wp2Jets" || dataset.name == "EWK_Wm2Jets") isEwkW = true; else isWJets = true; if(isWJets) wWeight = cuts.wWeight(); std::cout << "Analysing W MC : " << dataset.name << std::endl; } else if (dataset.name.compare(0,3,"QCD")==0) { isQCD = true; std::cout << "Analysing QCD : " << dataset.name << std::endl; } else if (dataset.isData) { muTightWeight=""; std::cout << "Analysing Data : " << dataset.name << std::endl; } else { std::cout << "Analysing BG MC : " << dataset.name << std::endl; } // get file & tree TFile* file = datasets.getTFile(dataset.name); TTree* tree = (TTree*) file->Get("invHiggsInfo/InvHiggsInfo"); // set up cuts TCut otherCuts = puWeight * trigCorr * wWeight; TCut cutZMuMu_C = otherCuts * muTightWeight * (cutD + cuts.zMuMuVBF() + METNo2Muon130); TCut cutWMuNu_C = otherCuts * muTightWeight * (cutD + cuts.wMuVBF() + cuts.cutWMu("MET")); // eps_mu from W trigger samples TCut cutEfficiencyMu_D = otherCuts * (cutD + cuts.HLTandMETFilters() + cuts.wMuGen()); TCut cutEfficiencyMu_N = otherCuts * muTightWeight * (cutD + cuts.HLTandMETFilters() + cuts.wMuGen() + cuts.cutWMu("wMu")); TCut cutEfficiencyMuMu_D = otherCuts * (cutD + cuts.HLTandMETFilters() + cuts.zMuMuGen()); TCut cutEfficiencyMuMu_N = otherCuts * muTightWeight * (cutD + cuts.HLTandMETFilters() + cuts.zMuMuGen() + cuts.zMuMuReco()); // eps_VBFS from DY-Trig TCut cutEfficiencyVBFS_D = otherCuts * muTightWeight * (cutD + cuts.HLTandMETFilters() + cuts.zMuMuGen() + cuts.zMuMuReco()); //TCut cutEfficiencyVBFS_N = otherCuts * (cutD + cuts.HLTandMETFilters() + cuts.zMuMuGen() + cuts.zMuMuReco() + cuts.vbf() + METNo2Muon130); TCut cutEfficiencyVBFS_NLoDPhi = otherCuts * muTightWeight * (cutD + cuts.HLTandMETFilters() + cuts.zMuMuGen() + cuts.zMuMuReco() + cuts.vbf() + METNo2Muon130 + cutLoDPhi); TCut cutEfficiencyVBFS_NHiDPhi = otherCuts * muTightWeight * (cutD + cuts.HLTandMETFilters() + cuts.zMuMuGen() + cuts.zMuMuReco() + cuts.vbf() + METNo2Muon130 + cutHiDPhi); TCut cutEfficiencyVBFS_NMe1DPhi = otherCuts * muTightWeight * (cutD + cuts.HLTandMETFilters() + cuts.zMuMuGen() + cuts.zMuMuReco() + cuts.vbf() + METNo2Muon130 + cutMe1DPhi); TCut cutEfficiencyVBFS_NMe2DPhi = otherCuts * muTightWeight * (cutD + cuts.HLTandMETFilters() + cuts.zMuMuGen() + cuts.zMuMuReco() + cuts.vbf() + METNo2Muon130 + cutMe2DPhi); // eps_VBFC from W TCut cutEfficiencyVBFC_D = otherCuts * muTightWeight * (cutD + cuts.HLTandMETFilters() + cuts.wMuGen() + cuts.cutWMu("wMu")); //TCut cutEfficiencyVBFC_N = otherCuts * (cutD + cuts.HLTandMETFilters() + cuts.wMuGen() + cuts.cutWMu("wMu") + cuts.vbf() + cuts.cutWMu("MET")); TCut cutEfficiencyVBFC_NLoDPhi = otherCuts * muTightWeight * (cutD + cuts.HLTandMETFilters() + cuts.wMuGen() + cuts.cutWMu("wMu") + cuts.vbf() + cuts.cutWMu("MET") + cutLoDPhi); TCut cutEfficiencyVBFC_NHiDPhi = otherCuts * muTightWeight * (cutD + cuts.HLTandMETFilters() + cuts.wMuGen() + cuts.cutWMu("wMu") + cuts.vbf() + cuts.cutWMu("MET") + cutHiDPhi); TCut cutEfficiencyVBFC_NMe1DPhi = otherCuts * muTightWeight * (cutD + cuts.HLTandMETFilters() + cuts.wMuGen() + cuts.cutWMu("wMu") + cuts.vbf() + cuts.cutWMu("MET") + cutMe1DPhi); TCut cutEfficiencyVBFC_NMe2DPhi = otherCuts * muTightWeight * (cutD + cuts.HLTandMETFilters() + cuts.wMuGen() + cuts.cutWMu("wMu") + cuts.vbf() + cuts.cutWMu("MET") + cutMe2DPhi); // fill tmp histograms for BG estimation //observed //TH1D* hZ_ZC_noDPhi = new TH1D("hZ_ZC_noDPhi", "", 1, 0., 1.); TH1D* hZ_ZC_DPhi = new TH1D("hZ_ZC_DPhi", "", 4, dphiEdges); //predicted //TH1D* hZ_WC_noDPhi = new TH1D("hZ_WC_noDPhi", "", 1, 0., 1.); TH1D* hZ_WC_DPhi = new TH1D("hZ_WC_DPhi", "", 4, dphiEdges); // this is for the actual BG estimation // fill tmp histograms for efficiency calculation TH1D* hZ_EffMuMu_D = new TH1D("hZ_EffMuMu_D", "", 1, 0., 1.); TH1D* hZ_EffMuMu_N = new TH1D("hZ_EffMuMu_N", "", 1, 0., 1.); TH1D* hZ_EffMu_D = new TH1D("hZ_EffMu_D", "", 1, 0., 1.); TH1D* hZ_EffMu_N = new TH1D("hZ_EffMu_N", "", 1, 0., 1.); TH1D* hZ_EffVBFS_D = new TH1D("hZ_EffVBFS_D", "", 1, 0., 1.); //TH1D* hZ_EffVBFS_N = new TH1D("hZ_EffVBFS_N", "", 1, 0., 1.); TH1D* hZ_EffVBFS_NLo = new TH1D("hZ_EffVBFS_NLo", "", 1, 0., 1.); TH1D* hZ_EffVBFS_NHi = new TH1D("hZ_EffVBFS_NHi", "", 1, 0., 1.); TH1D* hZ_EffVBFS_NMe1 = new TH1D("hZ_EffVBFS_NMe1","", 1, 0., 1.); TH1D* hZ_EffVBFS_NMe2 = new TH1D("hZ_EffVBFS_NMe2","", 1, 0., 1.); TH1D* hZ_EffVBFC_D = new TH1D("hZ_EffVBFC_D", "", 1, 0., 1.); //TH1D* hZ_EffVBFC_N = new TH1D("hZ_EffVBFC_N", "", 1, 0., 1.); TH1D* hZ_EffVBFC_NLo = new TH1D("hZ_EffVBFC_NLo", "", 1, 0., 1.); TH1D* hZ_EffVBFC_NHi = new TH1D("hZ_EffVBFC_NHi", "", 1, 0., 1.); TH1D* hZ_EffVBFC_NMe1 = new TH1D("hZ_EffVBFC_NMe1","", 1, 0., 1.); TH1D* hZ_EffVBFC_NMe2 = new TH1D("hZ_EffVBFC_NMe2","", 1, 0., 1.); // W control region DY is BG if (isDY) { //tree->Draw("0.5>>hZ_ZC_noDPhi", cutZMuMu_C); tree->Draw("vbfDPhi>>hZ_ZC_DPhi", cutZMuMu_C); //tree->Draw("0.5>>hZ_WC_noDPhi", cutWMuNu_C); tree->Draw("vbfDPhi>>hZ_WC_DPhi", cutWMuNu_C); tree->Draw("0.5>>hZ_EffMuMu_D", cutEfficiencyMuMu_D); tree->Draw("0.5>>hZ_EffMuMu_N", cutEfficiencyMuMu_N); tree->Draw("0.5>>hZ_EffVBFS_D", cutEfficiencyVBFS_D); //tree->Draw("0.5>>hZ_EffVBFS_N", cutEfficiencyVBFS_N); tree->Draw("0.5>>hZ_EffVBFS_NLo", cutEfficiencyVBFS_NLoDPhi); tree->Draw("0.5>>hZ_EffVBFS_NHi", cutEfficiencyVBFS_NHiDPhi); tree->Draw("0.5>>hZ_EffVBFS_NMe1", cutEfficiencyVBFS_NMe1DPhi); tree->Draw("0.5>>hZ_EffVBFS_NMe2", cutEfficiencyVBFS_NMe2DPhi); } else if(isWJets || isEwkW) { //tree->Draw("0.5>>hZ_WC_noDPhi", cutWMuNu_C); tree->Draw("vbfDPhi>>hZ_WC_DPhi", cutWMuNu_C); tree->Draw("0.5>>hZ_EffMu_D", cutEfficiencyMu_D); tree->Draw("0.5>>hZ_EffMu_N", cutEfficiencyMu_N); tree->Draw("0.5>>hZ_EffVBFC_D", cutEfficiencyVBFC_D); //tree->Draw("0.5>>hZ_EffVBFC_N", cutEfficiencyVBFC_N); tree->Draw("0.5>>hZ_EffVBFC_NLo", cutEfficiencyVBFC_NLoDPhi); tree->Draw("0.5>>hZ_EffVBFC_NHi", cutEfficiencyVBFC_NHiDPhi); tree->Draw("0.5>>hZ_EffVBFC_NMe1", cutEfficiencyVBFC_NMe1DPhi); tree->Draw("0.5>>hZ_EffVBFC_NMe2", cutEfficiencyVBFC_NMe2DPhi); } else if(isQCD) { //tree->Draw("0.5>>hZ_C_noDPhi", cutWMuNu_C); tree->Draw("vbfDPhi>>hZ_WC_DPhi", cutWMuNu_C); } else { tree->Draw("vbfDPhi>>hZ_ZC_DPhi", cutZMuMu_C); tree->Draw("vbfDPhi>>hZ_WC_DPhi", cutWMuNu_C); } // weight to lumi double weight = (dataset.isData) ? 1. : lumi * dataset.sigma / dataset.nEvents; hZ_ZC_DPhi->Scale(weight); hZ_WC_DPhi->Scale(weight); hZ_EffVBFS_D->Scale(weight); //hZ_EffVBFS_N->Scale(weight); hZ_EffVBFS_NLo->Scale(weight); hZ_EffVBFS_NHi->Scale(weight); hZ_EffVBFS_NMe1->Scale(weight); hZ_EffVBFS_NMe2->Scale(weight); hZ_EffVBFC_D->Scale(weight); //hZ_EffVBFC_N->Scale(weight); hZ_EffVBFC_NLo->Scale(weight); hZ_EffVBFC_NHi->Scale(weight); hZ_EffVBFC_NMe1->Scale(weight); hZ_EffVBFC_NMe2->Scale(weight); hZ_EffMu_D->Scale(weight); hZ_EffMu_N->Scale(weight); hZ_EffMuMu_D->Scale(weight); hZ_EffMuMu_N->Scale(weight); // add to output histograms if (dataset.isData) { hZ_Data_ZC_DPhi->Add(hZ_ZC_DPhi); hZ_Data_WC_DPhi->Add(hZ_WC_DPhi); } else if (isWJets || isEwkW) { //hZ_W_C_noDPhi->Add(hZ_C_noDPhi); hZ_W_C_DPhi->Add(hZ_WC_DPhi); hZ_W_EffMu_D->Add(hZ_EffMu_D); hZ_W_EffMu_N->Add(hZ_EffMu_N); hZ_W_EffVBFC_D->Add(hZ_EffVBFC_D); //hZ_W_EffVBFC_N->Add(hZ_EffVBFC_N); hZ_W_EffVBFC_NLo->Add(hZ_EffVBFC_NLo); hZ_W_EffVBFC_NHi->Add(hZ_EffVBFC_NHi); hZ_W_EffVBFC_NMe1->Add(hZ_EffVBFC_NMe1); hZ_W_EffVBFC_NMe2->Add(hZ_EffVBFC_NMe2); } else if (isDY) { hZ_DY_C_DPhi->Add(hZ_ZC_DPhi); hZ_BG_WC_DPhi->Add(hZ_WC_DPhi); hZ_DY_EffMuMu_D->Add(hZ_EffMuMu_D); hZ_DY_EffMuMu_N->Add(hZ_EffMuMu_N); hZ_DY_EffVBFS_D->Add(hZ_EffVBFS_D); //hZ_DY_EffVBFS_N->Add(hZ_EffVBFS_N); hZ_DY_EffVBFS_NLo->Add(hZ_EffVBFS_NLo); hZ_DY_EffVBFS_NHi->Add(hZ_EffVBFS_NHi); hZ_DY_EffVBFS_NMe1->Add(hZ_EffVBFS_NMe1); hZ_DY_EffVBFS_NMe2->Add(hZ_EffVBFS_NMe2); } else if (isQCD) { //hZ_BG_WC_DPhi->Add(hZ_WC_DPhi); } else { hZ_BG_WC_DPhi->Add(hZ_WC_DPhi); hZ_BG_ZC_DPhi->Add(hZ_ZC_DPhi); } std::cout << " N_Z ctrl (dphi<1.0) : " << hZ_ZC_DPhi->GetBinContent(1) << " +/- " << hZ_ZC_DPhi->GetBinError(1) << std::endl; std::cout << " N_W ctrl (dphi<1.0) : " << hZ_WC_DPhi->GetBinContent(1) << " +/- " << hZ_WC_DPhi->GetBinError(1) << std::endl; delete hZ_WC_DPhi; delete hZ_ZC_DPhi; delete hZ_EffMuMu_D; delete hZ_EffMuMu_N; delete hZ_EffMu_D; delete hZ_EffMu_N; delete hZ_EffVBFS_D; //delete hZ_EffVBFS_N; delete hZ_EffVBFS_NLo; delete hZ_EffVBFS_NMe1; delete hZ_EffVBFS_NMe2; delete hZ_EffVBFS_NHi; delete hZ_EffVBFC_D; //delete hZ_EffVBFC_N; delete hZ_EffVBFC_NLo; delete hZ_EffVBFC_NMe1; delete hZ_EffVBFC_NMe2; delete hZ_EffVBFC_NHi; // clean up delete tree; file->Close(); } // numbers - calculate these from MC in this program later! //double ratioBF = 5.626; // MCFM + NLO double ratioBF = 1144./14428.; TH1D* hZ_Est_ZC_DPhi = new TH1D("hZ_Est_ZC_DPhi", "", 4, dphiEdges); // bins dPhi TH1D* hZ_Est_WC_DPhi = new TH1D("hZ_Est_WC_DPhi", "", 4, dphiEdges); TH1D* hZ_Est_WS_DPhi = new TH1D("hZ_Est_WS_DPhi", "", 4, dphiEdges); TH1D* hZ_Eff_WS_DPhi = new TH1D("hZ_Eff_WS_DPhi", "", 4, dphiEdges); TH1D* hZ_W_EffMu = new TH1D("hZ_W_EffMu", "", 1, 0., 1.); // epsilon mumu hZ_W_EffMu->Add(hZ_W_EffMu_N); hZ_W_EffMu->Divide(hZ_W_EffMu_D); //double mu_syst = 0.025*hZ_W_EffMu->GetBinContent(1); //2.5% Muon ID/Iso efficiency uncertainty from EWK-10-002 //hZ_W_EffMu->SetBinError(1,TMath::Sqrt(hZ_W_EffMu->GetBinError(1)*hZ_W_EffMu->GetBinError(1) + mu_syst*mu_syst)); TH1D* hZ_DY_EffMuMu = new TH1D("hZ_DY_EffMuMu", "", 1, 0., 1.); // epsilon mumu hZ_DY_EffMuMu->Add(hZ_DY_EffMuMu_N); hZ_DY_EffMuMu->Divide(hZ_DY_EffMuMu_D); //mu_syst = 0.025*hZ_DY_EffMuMu->GetBinContent(1); //2.5% Muon ID/Iso efficiency uncertainty from EWK-10-002 //hZ_DY_EffMuMu->SetBinError(1,TMath::Sqrt(hZ_DY_EffMuMu->GetBinError(1)*hZ_DY_EffMuMu->GetBinError(1) + mu_syst*mu_syst)); //TH1D* hZ_DY_EffVBFS = new TH1D("hZ_DY_EffVBFS", "", 1, 0., 1.); // epsilon_s_vbf TH1D* hZ_DY_EffVBFSLo = new TH1D("hZ_DY_EffVBFSLo", "", 1, 0., 1.); TH1D* hZ_DY_EffVBFSHi = new TH1D("hZ_DY_EffVBFSHi", "", 1, 0., 1.); TH1D* hZ_DY_EffVBFSMe1 = new TH1D("hZ_DY_EffVBFSMe1", "", 1, 0., 1.); TH1D* hZ_DY_EffVBFSMe2 = new TH1D("hZ_DY_EffVBFSMe2", "", 1, 0., 1.); //TH1D* hZ_W_EffVBFC = new TH1D("hZ_W_EffVBFC", "", 1, 0., 1.); // epsilon_c_vbf TH1D* hZ_W_EffVBFCLo = new TH1D("hZ_W_EffVBFCLo", "", 1, 0., 1.); TH1D* hZ_W_EffVBFCHi = new TH1D("hZ_W_EffVBFCHi", "", 1, 0., 1.); TH1D* hZ_W_EffVBFCMe1 = new TH1D("hZ_W_EffVBFCMe1", "", 1, 0., 1.); TH1D* hZ_W_EffVBFCMe2 = new TH1D("hZ_W_EffVBFCMe2", "", 1, 0., 1.); //TH1D* hZ_W_RatioVBF = new TH1D("hZ_W_RatioVBF", "", 1, 0., 1.); // epsilon_s_vbf/epsilon_c_vbf TH1D* hZ_W_RatioVBFLo = new TH1D("hZ_W_RatioVBFLo", "", 1, 0., 1.); TH1D* hZ_W_RatioVBFHi = new TH1D("hZ_W_RatioVBFHi", "", 1, 0., 1.); TH1D* hZ_W_RatioVBFMe1 = new TH1D("hZ_W_RatioVBFMe1", "", 1, 0., 1.); TH1D* hZ_W_RatioVBFMe2 = new TH1D("hZ_W_RatioVBFMe2", "", 1, 0., 1.); //TH1D* hZ_W_TotalEff = new TH1D("hZ_W_TotalEff", "", 1, 0., 1.); TH1D* hZ_W_TotalEffLo = new TH1D("hZ_W_TotalEffLo", "", 1, 0., 1.); TH1D* hZ_W_TotalEffMe1 = new TH1D("hZ_W_TotalEffMe1", "", 1, 0., 1.); TH1D* hZ_W_TotalEffMe2 = new TH1D("hZ_W_TotalEffMe2", "", 1, 0., 1.); TH1D* hZ_W_TotalEffHi = new TH1D("hZ_W_TotalEffHi", "", 1, 0., 1.); //hZ_DY_EffVBFS->Add(hZ_DY_EffVBFS_N); //hZ_DY_EffVBFS->Divide(hZ_DY_EffVBFS_D); hZ_DY_EffVBFSLo->Add(hZ_DY_EffVBFS_NLo); hZ_DY_EffVBFSLo->Divide(hZ_DY_EffVBFS_D); hZ_DY_EffVBFSHi->Add(hZ_DY_EffVBFS_NHi); hZ_DY_EffVBFSHi->Divide(hZ_DY_EffVBFS_D); hZ_DY_EffVBFSMe1->Add(hZ_DY_EffVBFS_NMe1); hZ_DY_EffVBFSMe1->Divide(hZ_DY_EffVBFS_D); hZ_DY_EffVBFSMe2->Add(hZ_DY_EffVBFS_NMe2); hZ_DY_EffVBFSMe2->Divide(hZ_DY_EffVBFS_D); //hZ_W_EffVBFC->Add(hZ_W_EffVBFC_N); //hZ_W_EffVBFC->Divide(hZ_W_EffVBFC_D); hZ_W_EffVBFCLo->Add(hZ_W_EffVBFC_NLo); hZ_W_EffVBFCLo->Divide(hZ_W_EffVBFC_D); hZ_W_EffVBFCMe1->Add(hZ_W_EffVBFC_NMe1); hZ_W_EffVBFCMe1->Divide(hZ_W_EffVBFC_D); hZ_W_EffVBFCMe2->Add(hZ_W_EffVBFC_NMe2); hZ_W_EffVBFCMe2->Divide(hZ_W_EffVBFC_D); hZ_W_EffVBFCHi->Add(hZ_W_EffVBFC_NHi); hZ_W_EffVBFCHi->Divide(hZ_W_EffVBFC_D); //hZ_W_RatioVBF->Add(hZ_DY_EffVBFS); //hZ_W_RatioVBF->Divide(hZ_W_EffVBFC); hZ_W_RatioVBFLo->Add(hZ_DY_EffVBFSLo); hZ_W_RatioVBFLo->Divide(hZ_W_EffVBFCLo); hZ_W_RatioVBFMe1->Add(hZ_DY_EffVBFSMe1); hZ_W_RatioVBFMe1->Divide(hZ_W_EffVBFCMe1); hZ_W_RatioVBFMe2->Add(hZ_DY_EffVBFSMe2); hZ_W_RatioVBFMe2->Divide(hZ_W_EffVBFCMe2); hZ_W_RatioVBFHi->Add(hZ_DY_EffVBFSHi); hZ_W_RatioVBFHi->Divide(hZ_W_EffVBFCHi); hZ_W_TotalEffLo->Add(hZ_W_RatioVBFLo); hZ_W_TotalEffLo->Multiply(hZ_DY_EffMuMu); hZ_W_TotalEffLo->Divide(hZ_W_EffMu); hZ_W_TotalEffMe1->Add(hZ_W_RatioVBFMe1); hZ_W_TotalEffMe1->Multiply(hZ_DY_EffMuMu); hZ_W_TotalEffMe1->Divide(hZ_W_EffMu); hZ_W_TotalEffMe2->Add(hZ_W_RatioVBFMe2); hZ_W_TotalEffMe2->Multiply(hZ_DY_EffMuMu); hZ_W_TotalEffMe2->Divide(hZ_W_EffMu); hZ_W_TotalEffHi->Add(hZ_W_RatioVBFHi); hZ_W_TotalEffHi->Multiply(hZ_DY_EffMuMu); hZ_W_TotalEffHi->Divide(hZ_W_EffMu); //hZ_Eff_S_noDPhi->Add(hZ_W_RatioVBF); //hZ_Eff_S_noDPhi->Divide(hZ_W_EffMu); hZ_Eff_WS_DPhi->SetBinContent(1,hZ_W_TotalEffLo->GetBinContent(1)); hZ_Eff_WS_DPhi->SetBinError(1,hZ_W_TotalEffLo->GetBinError(1)); hZ_Eff_WS_DPhi->SetBinContent(2,hZ_W_TotalEffMe1->GetBinContent(1)); hZ_Eff_WS_DPhi->SetBinError(2,hZ_W_TotalEffMe1->GetBinError(1)); hZ_Eff_WS_DPhi->SetBinContent(3,hZ_W_TotalEffMe2->GetBinContent(1)); hZ_Eff_WS_DPhi->SetBinError(3,hZ_W_TotalEffMe2->GetBinError(1)); hZ_Eff_WS_DPhi->SetBinContent(4,hZ_W_TotalEffHi->GetBinContent(1)); hZ_Eff_WS_DPhi->SetBinError(4,hZ_W_TotalEffHi->GetBinError(1)); //for(int ibin = 1; ibin <= hZ_Eff_S_DPhi->GetNbinsX(); ++ibin) { // hZ_Eff_S_DPhi->SetBinContent(ibin,hZ_W_TotalEff->GetBinContent(1)); // hZ_Eff_S_DPhi->SetBinError (ibin,hZ_W_TotalEff->GetBinError(1)); //} // Observed hZ_Est_ZC_DPhi->Add(hZ_Data_ZC_DPhi, hZ_BG_ZC_DPhi, 1., -1.); // Predicted hZ_Est_WC_DPhi->Add(hZ_Data_WC_DPhi, hZ_BG_WC_DPhi, 1., -1.); hZ_Est_WS_DPhi->Add(hZ_Est_WC_DPhi,ratioBF); hZ_Est_WS_DPhi->Multiply(hZ_Eff_WS_DPhi); // print out std::cout << std::endl; std::cout << "##################################### Cross-check with W mu ctrl region #####################################" << std::endl; std::cout << std::endl; std::cout << " eps_mumu by histogram : " << hZ_DY_EffMuMu->GetBinContent(1) << " +/- " << hZ_DY_EffMuMu->GetBinError(1) << std::endl; std::cout << " eps_mu by histogram : " << hZ_W_EffMu->GetBinContent(1) << " +/- " << hZ_W_EffMu->GetBinError(1) << std::endl; std::cout << std::endl; std::cout << "dphi < 1.0" << std::endl; std::cout << std::endl; std::cout << " eps_s_vbf by histogram : " << hZ_DY_EffVBFSLo->GetBinContent(1) << " +/- " << hZ_DY_EffVBFSLo->GetBinError(1) << std::endl; std::cout << " eps_c_vbf by histogram : " << hZ_W_EffVBFCLo->GetBinContent(1) << " +/- " << hZ_W_EffVBFCLo->GetBinError(1) << std::endl; std::cout << " ratio_vbf by histogram : " << hZ_W_RatioVBFLo->GetBinContent(1) << " +/- " << hZ_W_RatioVBFLo->GetBinError(1) << std::endl; std::cout << " total eff by histogram : " << hZ_Eff_WS_DPhi->GetBinContent(1) << " +/- " << hZ_Eff_WS_DPhi->GetBinError(1) << std::endl; std::cout << std::endl; std::cout << " W+jets MC ctrl region : " << hZ_W_C_DPhi->GetBinContent(1) << " +/- " << hZ_W_C_DPhi->GetBinError(1) << std::endl; std::cout << " Background ctrl region : " << hZ_BG_WC_DPhi->GetBinContent(1) << " +/- " << hZ_BG_WC_DPhi->GetBinError(1) << std::endl; std::cout << " Data ctrl region : " << hZ_Data_WC_DPhi->GetBinContent(1) << " +/- " << hZ_Data_WC_DPhi->GetBinError(1) << std::endl; std::cout << " Data - BG : " << hZ_Est_WC_DPhi->GetBinContent(1) << " +/- " << hZ_Est_WC_DPhi->GetBinError(1) << std::endl; std::cout << std::endl; std::cout << " Predicted Zmumu : " << hZ_Est_WS_DPhi->GetBinContent(1) << " +/- " << hZ_Est_WS_DPhi->GetBinError(1) << std::endl; std::cout << " Observed Zmumu : " << hZ_Est_ZC_DPhi->GetBinContent(1) << " +/- " << hZ_Est_ZC_DPhi->GetBinError(1) << std::endl; std::cout << std::endl; std::cout << "dphi > 1.0 dphi < 1.8" << std::endl; std::cout << std::endl; std::cout << " eps_s_vbf by histogram : " << hZ_DY_EffVBFSMe1->GetBinContent(1) << " +/- " << hZ_DY_EffVBFSMe1->GetBinError(1) << std::endl; std::cout << " eps_c_vbf by histogram : " << hZ_W_EffVBFCMe1->GetBinContent(1) << " +/- " << hZ_W_EffVBFCMe1->GetBinError(1) << std::endl; std::cout << " ratio_vbf by histogram : " << hZ_W_RatioVBFMe1->GetBinContent(1) << " +/- " << hZ_W_RatioVBFMe1->GetBinError(1) << std::endl; std::cout << " total eff by histogram : " << hZ_Eff_WS_DPhi->GetBinContent(2) << " +/- " << hZ_Eff_WS_DPhi->GetBinError(2) << std::endl; std::cout << std::endl; std::cout << " W+jets MC ctrl region : " << hZ_W_C_DPhi->GetBinContent(2) << " +/- " << hZ_W_C_DPhi->GetBinError(2) << std::endl; std::cout << " Background ctrl region : " << hZ_BG_WC_DPhi->GetBinContent(2) << " +/- " << hZ_BG_WC_DPhi->GetBinError(2) << std::endl; std::cout << " Data ctrl region : " << hZ_Data_WC_DPhi->GetBinContent(2) << " +/- " << hZ_Data_WC_DPhi->GetBinError(2) << std::endl; std::cout << " Data - BG : " << hZ_Est_WC_DPhi->GetBinContent(2) << " +/- " << hZ_Est_WC_DPhi->GetBinError(2) << std::endl; std::cout << std::endl; std::cout << " Predicted Zmumu : " << hZ_Est_WS_DPhi->GetBinContent(2) << " +/- " << hZ_Est_WS_DPhi->GetBinError(2) << std::endl; std::cout << " Observed Zmumu : " << hZ_Est_ZC_DPhi->GetBinContent(2) << " +/- " << hZ_Est_ZC_DPhi->GetBinError(2) << std::endl; std::cout << std::endl; std::cout << "dphi > 1.8 dphi < 2.6" << std::endl; std::cout << std::endl; std::cout << " eps_s_vbf by histogram : " << hZ_DY_EffVBFSMe2->GetBinContent(1) << " +/- " << hZ_DY_EffVBFSMe2->GetBinError(1) << std::endl; std::cout << " eps_c_vbf by histogram : " << hZ_W_EffVBFCMe2->GetBinContent(1) << " +/- " << hZ_W_EffVBFCMe2->GetBinError(1) << std::endl; std::cout << " ratio_vbf by histogram : " << hZ_W_RatioVBFMe2->GetBinContent(1) << " +/- " << hZ_W_RatioVBFMe2->GetBinError(1) << std::endl; std::cout << " total eff by histogram : " << hZ_Eff_WS_DPhi->GetBinContent(3) << " +/- " << hZ_Eff_WS_DPhi->GetBinError(3) << std::endl; std::cout << std::endl; std::cout << " W+jets MC ctrl region : " << hZ_W_C_DPhi->GetBinContent(3) << " +/- " << hZ_W_C_DPhi->GetBinError(3) << std::endl; std::cout << " Background ctrl region : " << hZ_BG_WC_DPhi->GetBinContent(3) << " +/- " << hZ_BG_WC_DPhi->GetBinError(3) << std::endl; std::cout << " Data ctrl region : " << hZ_Data_WC_DPhi->GetBinContent(3) << " +/- " << hZ_Data_WC_DPhi->GetBinError(3) << std::endl; std::cout << " Data - BG : " << hZ_Est_WC_DPhi->GetBinContent(3) << " +/- " << hZ_Est_WC_DPhi->GetBinError(3) << std::endl; std::cout << std::endl; std::cout << " Predicted Zmumu : " << hZ_Est_WS_DPhi->GetBinContent(3) << " +/- " << hZ_Est_WS_DPhi->GetBinError(3) << std::endl; std::cout << " Observed Zmumu : " << hZ_Est_ZC_DPhi->GetBinContent(3) << " +/- " << hZ_Est_ZC_DPhi->GetBinError(3) << std::endl; std::cout << std::endl; std::cout << "dphi > 2.6" << std::endl; std::cout << std::endl; std::cout << " eps_s_vbf by histogram : " << hZ_DY_EffVBFSHi->GetBinContent(1) << " +/- " << hZ_DY_EffVBFSHi->GetBinError(1) << std::endl; std::cout << " eps_c_vbf by histogram : " << hZ_W_EffVBFCHi->GetBinContent(1) << " +/- " << hZ_W_EffVBFCHi->GetBinError(1) << std::endl; std::cout << " ratio_vbf by histogram : " << hZ_W_RatioVBFHi->GetBinContent(1) << " +/- " << hZ_W_RatioVBFHi->GetBinError(1) << std::endl; std::cout << " total eff by histogram : " << hZ_Eff_WS_DPhi->GetBinContent(4) << " +/- " << hZ_Eff_WS_DPhi->GetBinError(4) << std::endl; std::cout << std::endl; std::cout << " W+jets MC ctrl region : " << hZ_W_C_DPhi->GetBinContent(4) << " +/- " << hZ_W_C_DPhi->GetBinError(4) << std::endl; std::cout << " Background ctrl region : " << hZ_BG_WC_DPhi->GetBinContent(4) << " +/- " << hZ_BG_WC_DPhi->GetBinError(4) << std::endl; std::cout << " Data ctrl region : " << hZ_Data_WC_DPhi->GetBinContent(4) << " +/- " << hZ_Data_WC_DPhi->GetBinError(4) << std::endl; std::cout << " Data - BG region : " << hZ_Est_WC_DPhi->GetBinContent(4) << " +/- " << hZ_Est_WC_DPhi->GetBinError(4) << std::endl; std::cout << std::endl; std::cout << " Predicted Zmumu : " << hZ_Est_WS_DPhi->GetBinContent(4) << " +/- " << hZ_Est_WS_DPhi->GetBinError(4) << std::endl; std::cout << " Observed Zmumu : " << hZ_Est_ZC_DPhi->GetBinContent(4) << " +/- " << hZ_Est_ZC_DPhi->GetBinError(4) << std::endl; std::cout << std::endl; std::cout << "#####################################################################################" << std::endl; std::cout << std::endl; // draw control plots std::string pdfName; gStyle->SetOptStat(0); gStyle->SetOptFit(111111111); double x1[4] = {0.5, 1.4, 2.2, 2.6 + (TMath::Pi()-2.6)/2}; double ex1[4] = {0.5, 0.4, 0.4, (TMath::Pi()-2.6)/2}; double y1[4],ey1[4],y2[4],ey2[4],y3[4],ey3[4]; double diff[4],ediff[4]; double frac[4],efrac[4]; double y_syst[4],e_syst[4]; for(int i=0; i<4; ++i) { y1[i] = hZ_Est_WS_DPhi->GetBinContent(i+1); //Prediction ey1[i] = hZ_Est_WS_DPhi->GetBinError(i+1); y2[i] = hZ_Est_ZC_DPhi->GetBinContent(i+1); //Observation ey2[i] = hZ_Est_ZC_DPhi->GetBinError(i+1); y3[i] = hZ_DY_C_DPhi->GetBinContent(i+1); //MC Prediction ey3[i] = hZ_DY_C_DPhi->GetBinError(i+1); diff[i] = y1[i]-y2[i]; ediff[i] = sqrt(ey1[i]*ey1[i] + ey2[i]*ey2[i]); y_syst[i] = 0.; e_syst[i] = 0.21; if(y1[i] > 0) frac[i] = (y1[i]-y2[i])/y2[i]; efrac[i] = (y1[i]/y2[i])*sqrt(pow(ey1[i]/y1[i],2) + pow(ey2[i]/y2[i],2)); } TGraphErrors *graph1 = new TGraphErrors(4,x1,y1,ex1,ey1); TGraphErrors *graph2 = new TGraphErrors(4,x1,y2,ex1,ey2); TGraphErrors *graph6 = new TGraphErrors(4,x1,y3,ex1,ey3); TGraphErrors *graph3 = new TGraphErrors(4,x1,diff,ex1,ediff); TGraphErrors *graph4 = new TGraphErrors(4,x1,frac,ex1,efrac); TGraphErrors *graph5 = new TGraphErrors(4,x1,y_syst,ex1,e_syst); TH1D *h = new TH1D("h", "", 1, 0, TMath::Pi()); TCanvas canvas; canvas.SetCanvasSize(canvas.GetWindowWidth(), 1.2*canvas.GetWindowHeight()); graph1->SetTitle(""); graph1->SetMarkerStyle(20); graph1->SetMarkerSize(0.9); graph1->SetLineColor(kRed); graph1->SetMarkerColor(kRed); graph1->GetXaxis()->SetTitle("#Delta #phi_{jj}"); graph1->GetXaxis()->SetRangeUser(0,TMath::Pi()); graph1->GetYaxis()->SetTitle("N(Z#rightarrow #mu#mu)"); graph1->GetYaxis()->SetRangeUser(0,45); graph1->Draw("AP"); graph2->SetMarkerStyle(20); graph2->SetMarkerSize(0.9); graph2->SetLineColor(kBlue); graph2->SetMarkerColor(kBlue); graph2->Draw("P same"); graph6->SetMarkerStyle(20); graph6->SetMarkerSize(0.9); graph6->SetLineColor(kViolet); graph6->SetMarkerColor(kViolet); graph6->Draw("P same"); TLegend leg(0.12,0.67,0.37,0.88); leg.SetBorderSize(0); leg.SetFillColor(0); leg.AddEntry(graph1,"predicted (data)","P"); leg.AddEntry(graph2,"observed (data)","P"); leg.AddEntry(graph6,"predicted (MC)","P"); leg.Draw(); pdfName= oDir + std::string("/Zmumu_num.pdf"); canvas.Print(pdfName.c_str()); h->GetXaxis()->SetTitle("#Delta #phi_{jj}"); h->GetYaxis()->SetTitle("Predicted - Observed"); h->GetYaxis()->SetRangeUser(-20,20); h->SetLineColor(kBlue); h->Draw(); graph3->SetMarkerStyle(20); graph3->SetMarkerSize(0.9); graph3->SetMarkerColor(kGreen-2); TF1 *f1 = new TF1("f1","pol0",0,TMath::Pi()); graph3->Fit("f1","R"); h->Draw(); graph3->Draw("SAMEP"); pdfName= oDir + std::string("/Zmumu_diff.pdf"); canvas.Print(pdfName.c_str()); h->GetXaxis()->SetTitle("#Delta #phi_{jj}"); h->GetYaxis()->SetTitle("#frac{Predicted - Observed}{Observed}"); h->GetYaxis()->SetTitleOffset(1.2); h->GetYaxis()->SetRangeUser(-2,2); h->SetLineColor(kBlue); h->SetLineWidth(2); h->Draw(); graph5->SetLineColor(kGray+2); graph5->SetLineWidth(0); graph5->SetFillColor(kGray+2); graph5->SetFillStyle(3002); graph4->SetMarkerStyle(20); graph4->SetMarkerSize(1.2); graph4->SetMarkerColor(kGreen-2); graph4->Fit("f1","R"); h->Draw(); graph5->Draw("2 same"); graph4->Draw("P same"); TLegend leg2(0.12,0.67,0.40,0.87); leg2.SetBorderSize(0); leg2.SetFillColor(0); leg2.AddEntry(f1,"pol0 fit (0 < #Delta #phi_{jj} < #pi)","l"); leg2.AddEntry(graph5,"Systematic error","f"); leg2.Draw(); pdfName= oDir + std::string("/Zmumu_frac.pdf"); canvas.Print(pdfName.c_str()); //store histograms ofile->cd(); hZ_DY_C_DPhi->Write("",TObject::kOverwrite); hZ_BG_ZC_DPhi->Write("",TObject::kOverwrite); hZ_Data_ZC_DPhi->Write("",TObject::kOverwrite); hZ_W_C_DPhi->Write("",TObject::kOverwrite); hZ_BG_WC_DPhi->Write("",TObject::kOverwrite); hZ_Data_WC_DPhi->Write("",TObject::kOverwrite); hZ_Est_ZC_DPhi->Write("",TObject::kOverwrite); hZ_Est_WC_DPhi->Write("",TObject::kOverwrite); hZ_Est_WS_DPhi->Write("",TObject::kOverwrite); hZ_Eff_WS_DPhi->Write("",TObject::kOverwrite); hZ_DY_EffMuMu_D->Write("",TObject::kOverwrite); hZ_DY_EffMuMu_N->Write("",TObject::kOverwrite); hZ_W_EffMu_D->Write("",TObject::kOverwrite); hZ_W_EffMu_N->Write("",TObject::kOverwrite); hZ_DY_EffVBFS_D->Write("",TObject::kOverwrite); hZ_DY_EffVBFS_NLo->Write("",TObject::kOverwrite); hZ_DY_EffVBFS_NMe1->Write("",TObject::kOverwrite); hZ_DY_EffVBFS_NMe2->Write("",TObject::kOverwrite); hZ_DY_EffVBFS_NHi->Write("",TObject::kOverwrite); hZ_W_EffVBFC_D->Write("",TObject::kOverwrite); hZ_W_EffVBFC_NLo->Write("",TObject::kOverwrite); hZ_W_EffVBFC_NMe1->Write("",TObject::kOverwrite); hZ_W_EffVBFC_NMe2->Write("",TObject::kOverwrite); hZ_W_EffVBFC_NHi->Write("",TObject::kOverwrite); hZ_W_EffMu->Write("",TObject::kOverwrite); //hZ_DY_EffVBFS->Write("",TObject::kOverwrite); //hZ_W_EffVBFC->Write("",TObject::kOverwrite); //hZ_W_RatioVBF->Write("",TObject::kOverwrite); //hZ_W_TotalEff->Write("",TObject::kOverwrite); ofile->Close(); }
void make1DLimitHH(TString combine_dir,bool blind=true){ //TString combine_dir = "test_runSusyHgg/signalInj_sms_ChiHH_0_175/"; TGraph obser( (275-125)/25 ); TGraph graph( (275-125)/25 ); TGraphAsymmErrors error( (275-125)/25 ); for(int m=125;m<501;m+=25) { int i=(m-125)/25; TFile limit_file(Form("%s/higgsCombineChiHH_0_%d.Asymptotic.mH120.root",combine_dir.Data(),m) ); TTree *limit_tree = (TTree*)limit_file.Get("limit"); TTreeFormula limit_form("get_limit","limit",limit_tree); limit_tree->GetEntry(1); float down = limit_form.EvalInstance(); limit_tree->GetEntry(2); float exp = limit_form.EvalInstance(); limit_tree->GetEntry(3); float up = limit_form.EvalInstance(); limit_tree->GetEntry(5); float obs = limit_form.EvalInstance(); graph.SetPoint(i,float(m),exp); error.SetPoint(i,float(m),exp); error.SetPointError(i,0,0,exp-down,up-exp); obser.SetPoint(i,float(m),obs); } TGraphErrors* theo = getTheoXSec("/home/amott/HggApp/SusyHgg/xsecs/Higgsino.txt"); TCanvas cv; cv.SetLogy(); theo->SetMaximum(1e2); theo->SetMinimum(1e-2); theo->GetYaxis()->SetTitle("95% CL #sigma upper limit (pb)"); theo->GetXaxis()->SetTitle("m_{chargino}"); theo->SetFillColor(kBlue); theo->SetLineStyle(kDotted); theo->SetLineWidth(2.0); error.SetMaximum(1e2); error.SetMinimum(1e-2); error.GetYaxis()->SetTitle("95% CL #sigma upper limit (pb)"); error.GetXaxis()->SetTitle("m_{chargino}"); error.SetFillColor(kGreen); error.Draw("A3"); theo->Draw("3C"); graph.SetLineStyle(kDashed); graph.SetLineWidth(2); graph.Draw("C"); obser.SetLineStyle(1); obser.SetLineWidth(2); if(!blind) obser.Draw("C"); TLegend leg(0.7,0.7,0.85,0.85); leg.SetFillColor(0); leg.SetBorderSize(0); leg.AddEntry(&graph,"expected","l"); leg.AddEntry(&error,"expected #pm1#sigma","F"); leg.AddEntry(theo,"theoretical","f"); if(!blind) leg.AddEntry(&obser,"observed","l"); leg.Draw("SAME"); TLatex prelim(0.65,0.96,"CMS Preliminary"); prelim.SetNDC(); prelim.SetTextSize(0.045); prelim.Draw(); TLatex lbl(0.5,0.86,"#sqrt{s} = 8 TeV #int L dt = 19.78 fb^{-1}"); lbl.SetNDC(); lbl.SetTextSize(0.045); lbl.Draw(); cv.SaveAs(combine_dir+"expected_exclusion_HH_1D.png"); }
void* Monitoring::MonitorThread(void* arg){ //std::cout<<"d1"<<std::endl; monitor_thread_args* args= static_cast<monitor_thread_args*>(arg); std::string outpath=args->outputpath; zmq::socket_t Ireceive (*(args->context), ZMQ_PAIR); Ireceive.connect("inproc://MonitorThread"); // std::vector<CardData*> carddata; std::map<int,std::vector<TH1F> > PedTime; std::map<int,std::vector<TH1F> > PedRMSTime; std::vector<TH1F> rates; std::vector<TH1F> averagesize; std::vector<TH1I> tfreqplots; std::map<int,std::vector<std::vector<float > > > pedpars; TCanvas c1("c1","c1",600,400); bool running=true; bool init=true; std::vector<PMT> PMTInfo; /////////////////// Connect to sql /////////////////////// //std::cout<<"d2"<<std::endl; pqxx::connection *C; std::stringstream tmp; tmp<<"dbname=annie"<<" hostaddr=127.0.0.1"<<" port=5432" ; C=new pqxx::connection(tmp.str().c_str()); if (C->is_open()) { // std::cout << "Opened database successfully: " << C->dbname() << std::endl; } else { std::cout << "Can't open database" << std::endl; return false; } tmp.str(""); pqxx::nontransaction N(*C); tmp<<"select gx,gy,gz,vmecard,vmechannel from pmtconnections order by channel; "; /* Execute SQL query */ pqxx::result R( N.exec( tmp.str().c_str() )); //pqxx::result::const_iterator c = R.begin(); ///////// Fill PMT Info//////////////// for ( pqxx::result::const_iterator c = R.begin(); c != R.end(); ++c) { PMT tmp; tmp.gx= c[0].as<int>(); tmp.gy= c[1].as<int>(); tmp.gz= c[2].as<int>(); tmp.card= c[3].as<int>(); tmp.channel= c[4].as<int>()-1; PMTInfo.push_back(tmp); } //std::cout<<"d3"<<std::endl; while (running){ //std::cout<<"d4"<<std::endl; zmq::message_t comm; Ireceive.recv(&comm); std::istringstream iss(static_cast<char*>(comm.data())); std::string arg1=""; iss>>arg1; //std::cout<<"d5"<<std::endl; if(arg1=="Data"){ ////////// Setting up plots///////// std::vector<TGraph2D*> mg; TH2I EventDisplay ("Event Display", "Event Display", 10, -1, 8, 10, -1, 8); TH2I RMSDisplay ("RMS Display", "RMS Display", 10, -1, 8, 10, -1, 8); std::vector<TH1F> temporalplots; std::vector<TH1I> freqplots; CardData* carddata; int size=0; iss>>size; //freqplots.clear(); //std::cout<<"d6"<<std::endl; for(int i=0;i<size;i++){ //std::cout<<"d7"<<std::endl; long long unsigned int pointer; iss>>std::hex>>pointer; carddata=(reinterpret_cast<CardData *>(pointer)); if(init){ ////make initial freq plot and ped vector ped time and ped rms//// for(int j=0;j<carddata->channels;j++){ std::stringstream tmp; tmp<<"Channel "<<(i*4)+j<<" frequency"; TH1I tmpfreq(tmp.str().c_str(),tmp.str().c_str(),10,0,9); tfreqplots.push_back(tmpfreq); tmp.str(""); tmp<<"Channel "<<(i*4)+j<<" Pedistal"; TH1F tmppedtime(tmp.str().c_str(),tmp.str().c_str(),100,0,99); PedTime[carddata->CardID].push_back(tmppedtime); tmp.str(""); tmp<<"Channel "<<(i*4)+j<<" Pedistal RMS"; TH1F tmppedrmstime(tmp.str().c_str(),tmp.str().c_str(),100,0,99); PedRMSTime[carddata->CardID].push_back(tmppedrmstime); std::vector<float> tmppedpars; tmppedpars.push_back(0); tmppedpars.push_back(0); pedpars[carddata->CardID].push_back(tmppedpars); } if(i==size-1)init=false; } //std::cout<<"d8"<<std::endl; // std::cout<<"d1"<<std::endl; ///////Make temporal plot ////////// for(int j=0;j<carddata->channels;j++){ std::stringstream tmp; tmp<<"Channel "<<(i*4)+j<<" temporal"; TH1F temporal(tmp.str().c_str(),tmp.str().c_str(),carddata->buffersize,0,carddata->buffersize-1); long sum=0; //////////Make freq plot/////////////// tmp.str(""); tmp<<"Channel "<<(i*4)+j<<" frequency"; TH1I freq(tmp.str().c_str(),tmp.str().c_str(),200,200,399); // std::cout<<"d2"<<std::endl; //std::cout<<"d9"<<std::endl; ///// Calculate sum for event dispkay and fill freq plots ///////// for(int k=0;k<carddata->buffersize;k++){ //std::cout<<"d10"<<std::endl; // std::cout<<"i="<<i<<" j="<<j<<std::endl; //std::cout<<"d2.5 "<<(i*4)+j<<" feqplot.size = "<<freqplots.size()<<std::endl; if(carddata->Data[(j*carddata->buffersize)+k]>pedpars[carddata->CardID].at(j).at(0)+(pedpars[carddata->CardID].at(j).at(1)*5))sum+=carddata->Data[(j*carddata->buffersize)+k]; freq.Fill(carddata->Data[(j*carddata->buffersize)+k]); //temporal.SetBinContent(k,carddata->Data[(j*carddata->buffersize)+k]); } freqplots.push_back(freq); //////// find pedistall fill ped temporals////////// freq.Fit("gaus"); TF1 *gaus = freq.GetFunction("gaus"); pedpars[carddata->CardID].at(j).at(0)=(gaus->GetParameter(1)); pedpars[carddata->CardID].at(j).at(1)=(gaus->GetParameter(2)); gaus->SetLineColor(j+1); //std::cout<<"d11"<<std::endl; for(int bin=99;bin>0;bin--){ PedTime[carddata->CardID].at(j).SetBinContent(bin,PedTime[carddata->CardID].at(j).GetBinContent(bin-1)); PedRMSTime[carddata->CardID].at(j).SetBinContent(bin,PedRMSTime[carddata->CardID].at(j).GetBinContent(bin-1)); } PedTime[carddata->CardID].at(j).SetBinContent(0, pedpars[carddata->CardID].at(j).at(0)); PedRMSTime[carddata->CardID].at(j).SetBinContent(0, pedpars[carddata->CardID].at(j).at(1)); //////// fill temporal plot///////// for(int k=0;k<carddata->buffersize/4;k++){ //std::cout<<"d12"<<std::endl; //std::cout<<"j*4 = "<<j*4<<std::endl; //std::cout<<"(i*BufferSize)+(j*4) = "<<(i*BufferSize)+(j*4)<<std::endl; //std::cout<<"i*BufferSize)+(j*4)+(BufferSize/2) = "<<(i*BufferSize)+(j*4)+(BufferSize/2)<<std::endl; //std::cout<<"(i*BufferSize)+(j*4)+(BufferSize/2)+1 = "<<(i*BufferSize)+(j*4)+(BufferSize/2)+1<<std::endl; int offset=pedpars[carddata->CardID].at(j).at(0); double conversion=2.415/pow(2.0, 12.0); temporal.SetBinContent(k*4,(carddata->Data[(j*carddata->buffersize)+(k*2)]-offset)*conversion); temporal.SetBinContent((k*4)+1,(carddata->Data[(j*carddata->buffersize)+(k*2)+1]-offset)*conversion); temporal.SetBinContent((k*4)+2,(carddata->Data[(j*carddata->buffersize)+(k*2)+(carddata->buffersize/2)]-offset)*conversion); temporal.SetBinContent((k*4)+3,(carddata->Data[(j*carddata->buffersize)+(k*2)+(carddata->buffersize/2)+1]-offset)*conversion); } //std::cout<<"d13"<<std::endl; //std::cout<<"d3"<<std::endl; temporalplots.push_back(temporal); ////// find x,y,z fill event display ///////// int x=-10; int z=-10; int y=-10; for(int pmt=0;pmt<PMTInfo.size();pmt++){ //std::cout<<"d4"<<std::endl; if(PMTInfo.at(pmt).card==carddata->CardID && PMTInfo.at(pmt).channel==j){ x=PMTInfo.at(pmt).gx; z=PMTInfo.at(pmt).gz; y=PMTInfo.at(pmt).gy; //std::cout<<"d15"<<std::endl; } } /* int x=(((i*4)+j)%8); int y=(floor(((i*4)+j)/8.0)); if(x==0 && y==0){x=-10;y=-10;} if(x==7 && y==0){x=-10;y=-10;} if(x==0 && y==7){x=-10;y=-10;} if(x==7 && y==7){x=-10;y=-10;} if (y>7){x=-10;y=-10;} std::cout<<"i="<<i<<" j="<<j<<" (i*4)+j)="<<((i*4)+j)<<" x="<<x<<" y="<<y<<" sum="<<sum<<std::endl; EventDisplay.SetBinContent(x+1,y+1,sum); //EventDisplay.SetBinContent(((i*4)+j),sum); */ //std::cout<<"d16"<<std::endl; if(x!=-10 && z!=-10){ //std::cout<<"d17"<<std::endl; //std::cout<<"gx = "<<x<<" , gz="<<z<<std::endl; EventDisplay.SetBinContent(x+2,z+2,sum); RMSDisplay.SetBinContent(x+2,z+2,gaus->GetParameter(2)*100); //// Attempted 2ne event display /// TGraph2D *dt=new TGraph2D(1); dt->SetPoint(0,x,z,z); dt->SetMarkerStyle(20); //dt->GetXaxis()->SetRangeUser(-1,8); // dt->GetYaxis()->SetRangeUser(-1,8); //dt->GetZaxis()->SetRangeUser(-1,8); mg.push_back(dt); } } //std::cout<<"d18"<<std::endl; ///////Find max freq for scaling////////// int maxplot=0; long maxvalue=0; //std::cout<<"i="<<i<<" (i*4)="<<(i*4)<<" (i*4)+4="<<(i*4)+4<<" size="<<freqplots.size()<<std::endl; for(int j=(i*4);j<(i*4)+4;j++){ if (freqplots.at(j).GetMaximum()>maxvalue){ //std::cout<<"d19"<<std::endl; maxvalue=freqplots.at(j).GetMaximum(); maxplot=j; } } //std::cout<<"d20"<<std::endl; ////////Find current time and plot frewuency plot time_t t = time(0); // get time now struct tm * now = localtime( & t ); std::stringstream title; title<<"Card "<<carddata->CardID<<" frequency: "<<(now->tm_year + 1900) << '-' << (now->tm_mon + 1) << '-' << now->tm_mday<<','<<now->tm_hour<<':'<<now->tm_min<<':'<<now->tm_sec; //std::cout<<"d21"<<std::endl; freqplots.at(maxplot).SetTitle(title.str().c_str()); freqplots.at(maxplot).GetXaxis()->SetTitle("ADC Value"); freqplots.at(maxplot).GetYaxis()->SetTitle("Frequency"); freqplots.at(maxplot).SetLineColor((maxplot%4)+1); freqplots.at(maxplot).Draw(); TLegend leg(0.8,0.4,1.0,0.7); //leg.SetHeader("The Legend Title"); //std::cout<<"d22"<<std::endl; for(int j=(i*4);j<(i*4)+4;j++){ //std::cout<<"d23"<<std::endl; std::stringstream legend; legend<<"Channel "<<j-(i*4); leg.AddEntry(&freqplots.at(j),legend.str().c_str(),"l"); freqplots.at(j).SetLineColor((j%4)+1); if(j==maxplot){;}//freqplots.at(i).Draw(); else freqplots.at(j).Draw("same"); } leg.Draw(); //std::cout<<"d24"<<std::endl; std::stringstream tmp; tmp<<outpath<<carddata->CardID<<"freq.jpg"; c1.SaveAs(tmp.str().c_str()); //std::cout<<"d25"<<std::endl; ///////find max tmporal plot for scaling ///temporal maxplot=0; maxvalue=0; //std::cout<<"i="<<i<<" (i*4)="<<(i*4)<<" (i*4)+4="<<(i*4)+4<<" size="<<freqplots.size()<<std::endl; for(int j=(i*4);j<(i*4)+4;j++){ //std::cout<<"d26"<<std::endl; if (temporalplots.at(j).GetMaximum()>maxvalue){ maxvalue=temporalplots.at(j).GetMaximum(); maxplot=j; } } //std::cout<<"d27"<<std::endl; //////// Find time and plot temporal plot t = time(0); // get time now now = localtime( & t ); std::stringstream title2; title2<<"Card "<<carddata->CardID<<" Temporal: "<<(now->tm_year + 1900) << '-' << (now->tm_mon + 1) << '-' << now->tm_mday<<','<<now->tm_hour<<':'<<now->tm_min<<':'<<now->tm_sec; //std::cout<<"d28"<<std::endl; temporalplots.at(maxplot).SetTitle(title2.str().c_str()); temporalplots.at(maxplot).GetXaxis()->SetTitle("Samples"); temporalplots.at(maxplot).GetYaxis()->SetTitle("Volate (V)"); temporalplots.at(maxplot).SetLineColor((maxplot%4)+1); temporalplots.at(maxplot).Draw(); TLegend leg2(0.8,0.4,1.0,0.7); //std::cout<<"d29"<<std::endl; for(int j=(i*4);j<(i*4)+4;j++){ //std::cout<<"d30"<<std::endl; std::stringstream legend; legend<<"Channel "<<j-(i*4); leg2.AddEntry(&temporalplots.at(j),legend.str().c_str(),"l"); temporalplots.at(j).SetLineColor((j%4)+1); if(j==0){;} else temporalplots.at(j).Draw("same"); } //std::cout<<"d31"<<std::endl; leg2.Draw(); //std::cout<<"d6"<<std::endl; std::stringstream tmp2; tmp2<<outpath<<carddata->CardID<<"temporal.jpg"; c1.SaveAs(tmp2.str().c_str()); //std::cout<<"d32"<<std::endl; ///////plotting PED time and ped rms time ////// maxplot=0; maxvalue=0; for(int j=0;j<4;j++){ //std::cout<<"d26"<<std::endl; if ( PedTime[carddata->CardID].at(j).GetMaximum()>maxvalue){ maxvalue=PedTime[carddata->CardID].at(j).GetMaximum(); maxplot=j; } } t = time(0); // get time now now = localtime( & t ); title2.str(""); title2<<"Card "<<carddata->CardID<<" Pedistal Variation: "<<(now->tm_year + 1900) << '-' << (now->tm_mon + 1) << '-' << now->tm_mday<<','<<now->tm_hour<<':'<<now->tm_min<<':'<<now->tm_sec; //std::cout<<"d28"<<std::endl; PedTime[carddata->CardID].at(maxplot).SetTitle(title2.str().c_str()); PedTime[carddata->CardID].at(maxplot).GetXaxis()->SetTitle("Samples"); PedTime[carddata->CardID].at(maxplot).GetYaxis()->SetTitle("ADC Value"); PedTime[carddata->CardID].at(maxplot).SetLineColor((maxplot%4)+1); PedTime[carddata->CardID].at(maxplot).Draw(); TLegend leg3(0.8,0.4,1.0,0.7); //std::cout<<"d29"<<std::endl; for(int j=0;j<4;j++){ //std::cout<<"d30"<<std::endl; std::stringstream legend; legend<<"Channel "<<j; leg3.AddEntry(&PedTime[carddata->CardID].at(j),legend.str().c_str(),"l"); PedTime[carddata->CardID].at(j).SetLineColor((j%4)+1); PedTime[carddata->CardID].at(j).Draw("same"); } //std::cout<<"d31"<<std::endl; leg3.Draw(); //std::cout<<"d6"<<std::endl; tmp2.str(""); tmp2<<outpath<<"plots2/"<<carddata->CardID<<"PedTime.jpg"; c1.SaveAs(tmp2.str().c_str()); PedRMSTime[carddata->CardID].at(0).Draw(); for (int channel=1;channel<4;channel++){ PedRMSTime[carddata->CardID].at(channel).Draw("same"); } tmp2.str(""); tmp2<<outpath<<"plots2/"<<carddata->CardID<<"PedRMSTime.jpg"; c1.SaveAs(tmp2.str().c_str()); delete carddata; } /// size i /* //std::cout<<"d4"<<std::endl; int maxplot=0; long maxvalue=0; for(int i=0;i<freqplots.size();i++){ if (freqplots.at(i).GetMaximum()>maxvalue){ maxvalue=freqplots.at(i).GetMaximum(); maxplot=i; } } freqplots.at(maxplot).SetLineColor(maxplot+1); freqplots.at(maxplot).Draw(); for(int i=0;i<freqplots.size();i++){ // Double_t scale = 1/freqplots.at(i).GetMaximum(); // freqplots.at(i).Scale(scale); freqplots.at(i).SetLineColor(i+1); if(i==maxplot);//freqplots.at(i).Draw(); else freqplots.at(i).Draw("same"); //freqplots.at(i).Scale((1.0/scale)); } std::cout<<"d5"<<std::endl; std::stringstream tmp; tmp<<outpath<<"freq.jpg"; c1.SaveAs(tmp.str().c_str()); for(int i=0;i<temporalplots.size();i++){ temporalplots.at(i).SetLineColor(i+1); if(i==0)temporalplots.at(i).Draw(); else temporalplots.at(i).Draw("same"); } std::cout<<"d6"<<std::endl; std::stringstream tmp2; tmp2<<outpath<<"temporal.jpg"; c1.SaveAs(tmp2.str().c_str()); */ //std::cout<<"d33"<<std::endl; /////////plot event display ///////// EventDisplay.Draw("COLZ"); std::stringstream tmp3; tmp3<<outpath<<"0EventDisplay.jpg"; c1.SaveAs(tmp3.str().c_str()); //std::cout<<"d34 ="<<mg.size()<<std::endl; /////////plot RMS display ///////// RMSDisplay.Draw("COLZ"); tmp3.str(""); tmp3<<outpath<<"0RMSDisplay.jpg"; c1.SaveAs(tmp3.str().c_str()); ///plot atempted 3d event display/////// tmp3.str(""); if(mg.size()>0) mg.at(0)->Draw(); for(int plots=1;plots<mg.size();plots++){ mg.at(plots)->Draw("same"); //std::cout<<"d35"<<std::endl; } tmp3<<outpath<<"0EventDisplay3D.jpg"; //c1.SaveAs(tmp3.str().c_str()); } else if(arg1=="Quit"){