#include "TSystem.h" #include "TFile.h" #include "TTree.h" #include "TChain.h" #include "TCanvas.h" #include "TBox.h" #include "TCut.h" #include "TCutG.h" #include "TStopwatch.h" using std::cout; using std::endl; void showBananas2() { Long64_t drawEntries = 10000000; // TFile *fr = new TFile("~/data/exp1804/h5_11_00.root"); TChain *tr = new TChain("AnalysisxTree"); tr->Add("~/data/exp1804/h5_14_0?.root"); // tr->Add("~/data/exp1804/be10_0?_?0.root"); TChain *trCal = new TChain("cal"); // trCal->Add("~/data/exp1804/h5_11_0?_calib.root"); trCal->Add("~/data/exp1804/h5_14_0?_calib.root"); // trCal->Add("~/data/exp1804/be10_0?_?0_calib.root"); tr->AddFriend(trCal); TFile *fcal = new TFile("~/data/exp1804/calib/si_20_03_calib.root"); TTree *tAlphaCal = (TTree*)fcal->Get("cal"); tAlphaCal->SetMarkerColor(kRed); tAlphaCal->SetMarkerStyle(20); tAlphaCal->SetMarkerSize(.6); TFile *fc = new TFile("cutsIdentification.root", "READ"); TCutG *cUS = (TCutG*)fc->Get("c7UpperShadow"); TCutG *cLS = (TCutG*)fc->Get("c7LowerShadow"); cLS->SetLineColor(kMagenta); TCutG *cMA = (TCutG*)fc->Get("c7MainAlpha"); TCutG *cA = (TCutG*)fc->Get("c7All"); TCutG *cBL = (TCutG*)fc->Get("cBeamLeft"); TCutG *cBR = (TCutG*)fc->Get("cBeamRight"); // const Int_t drawEntries = 6000000; // const Int_t drawEntries = tr->GetEntries(); tr->GetListOfFiles()->Print(); trCal->GetListOfFiles()->Print(); cout << tr->GetEntries() << " events." << endl; cout << trCal->GetEntries() << " calibrated events." << endl; TString varName; TString condition; // cout << drawEntries << " entries in input chain will be processed." << endl; TString timeSiLeftCondition; timeSiLeftCondition.Form("(SQLXtime[0]>0"); for (Int_t j = 1; j<32; j++) { condition.Form("|| SQLXtime[%d]>0", j); timeSiLeftCondition.Append(condition); } timeSiLeftCondition.Append(")"); Int_t firstThinStrip = 5; TStopwatch stopwatch; stopwatch.Start(); ///////////////////////////////////////////////////////////////////// // c1 TCanvas *c1 = new TCanvas("c1", "time in thin detector", 1600, 1200); c1->Divide(4,4); firstThinStrip = 0; cout << tr->GetEntries() << " events." << endl; cout << trCal->GetEntries() << " calibrated events." << endl; drawEntries = 10000000; cout << drawEntries << " entries in input chain will be processed." << endl; for (Int_t i = 0; i < 16; i++) { c1->cd(i+1); varName.Form("SQ20E[%d]:tSQ20[%d]*0.3", i+firstThinStrip, i+firstThinStrip); condition.Form("tSQ20[%d]>0 && SQ20E[%d]>1.2", i+firstThinStrip, i+firstThinStrip); tr->SetMarkerColor(kBlack); tr->SetMarkerStyle(20); tr->SetMarkerSize(0.1); tr->Draw(varName, condition, "col", drawEntries); c1->Update(); }//*/ // return; ///////////////////////////////////////////////////////////////////// // c2 TCanvas *c2 = new TCanvas("c2", "time issues in 32 X-strips: 0-15", 1600, 1200); c2->Divide(4,4); firstThinStrip = 0; Int_t conTimeMult = 1; cout << tr->GetEntries() << " events." << endl; cout << trCal->GetEntries() << " calibrated events." << endl; drawEntries = 1000000; cout << drawEntries << " entries in input chain will be processed." << endl; for (Int_t i = 0; i < 16; i++) { c2->cd(i+1); varName.Form("SQLXE[%d]:0.3*tSQX_L[%d]", i+firstThinStrip, i+firstThinStrip); condition.Form("0.3*tSQX_L[%d]>200 && 0.3*tSQX_L[%d]<500 && SQLXE[%d]>0", i+firstThinStrip, i+firstThinStrip, i+firstThinStrip); tr->SetMarkerColor(kRed); tr->SetMarkerStyle(20); tr->SetMarkerSize(.4); tr->Draw(varName, condition, "col", drawEntries); varName.Form("SQLXE[%d]:SQLXtime[%d]", i+firstThinStrip, i+firstThinStrip); condition.Form("SQLXtime[%d]>0 && SQLXE[%d]>0 && SQLXtimeMult==%d", i+firstThinStrip, i+firstThinStrip, conTimeMult); varName.Form("SQLXEtimeFiltered[%d]:0.3*tSQX_L[%d]", i+firstThinStrip, i+firstThinStrip); condition.Form("0.3*tSQX_L[%d]>200 && 0.3*tSQX_L[%d]<500 && SQLXEtimeFilteredSum>0 && SQLXtimeMult==%d", i+firstThinStrip, i+firstThinStrip, conTimeMult); // condition.Form("SQLXtimeSum>0 && SQLXtimeSum<470 && SQLXtimeMult==%d && %s", // conTimeMult, timeSiLeftCondition.Data()); cout << condition << endl; tr->Draw(varName, condition, "same", drawEntries); // tAlphaCal->Draw(varName, "", "same"); c2->Update(); }//for */ return; ///////////////////////////////////////////////////////////////////// // c2_1 /*TCanvas *c2_1 = new TCanvas("c2_1", "time issues in 32 X-strips: 16-31", 1600, 1200); c2_1->Divide(4,4); firstThinStrip = 16; cout << tr->GetEntries() << " events." << endl; cout << trCal->GetEntries() << " calibrated events." << endl; drawEntries = 1000000; cout << drawEntries << " entries in input chain will be processed." << endl; for (Int_t i = 0; i < 16; i++) { c2_1->cd(i+1); varName.Form("SQLXE[%d]:0.3*tSQX_L[%d]", i+firstThinStrip, i+firstThinStrip); condition.Form("0.3*tSQX_L[%d]>300 && 0.3*tSQX_L[%d]<600 && SQLXE[%d]>0", i+firstThinStrip, i+firstThinStrip, i+firstThinStrip); // tr->SetMarkerColor(kBlack); tr->Draw(varName, condition, "col", drawEntries); // tr->Draw(varName, condition, "", drawEntries); varName.Form("SQLXE[%d]:SQLXtime[%d]", i+firstThinStrip, i+firstThinStrip); condition.Form("SQLXtime[%d]>0 && SQLXE[%d]>0 && SQLXtimeMult==%d", i+firstThinStrip, i+firstThinStrip, conTimeMult); tr->Draw(varName, condition, "same", drawEntries); c2_1->Update(); }//for */ // return; ///////////////////////////////////////////////////////////////////// // c3 /*TCanvas *c3 = new TCanvas("c3", "Multiplicity", 1600, 1200); c3->Divide(2,2); cout << tr->GetEntries() << " events." << endl; cout << trCal->GetEntries() << " calibrated events." << endl; drawEntries = 10000000; cout << drawEntries << " entries in input chain will be processed." << endl; c3->cd(1); varName.Form("SQ20timeMult"); condition.Form("trigger==3 && SQ20timeMult>0"); tr->Draw(varName, condition, "", drawEntries); c3->Update(); c3->cd(2); varName.Form("SQLXtimeMult"); condition.Form("trigger==3 && SQLXtimeMult>0 && SQLXtimeMult<8"); tr->Draw(varName, condition, "", drawEntries); c3->Update(); c3->cd(3); varName.Form("SQ20EcorrMult"); condition.Form("trigger==3 && SQ20EcorrMult>0"); tr->Draw(varName, condition, "", drawEntries); c3->Update(); c3->cd(4); varName.Form("SQLXmult"); condition.Form("trigger==3 && SQLXmult>0"); tr->Draw(varName, condition, "", drawEntries); c3->Update(); //*/ // return; ///////////////////////////////////////////////////////////////////// // c4 /*TCanvas *c4 = new TCanvas("c4", "time issues in 16 Y-strips", 1600, 1200); c4->Divide(4,4); firstThinStrip = 0; Int_t conTimeMult = 1; cout << tr->GetEntries() << " events." << endl; cout << trCal->GetEntries() << " calibrated events." << endl; drawEntries = 1000000; cout << drawEntries << " entries in input chain will be processed." << endl; Float_t timeCorr[16] = {0, -2, 0, 2, -2.5, 5, -6, 4, 7, 3, 3, 4, 6, 4, -4, 13 }; for (Int_t i = 0; i < 16; i++) { c4->cd(i+1); varName.Form("SQLYE[%d]:0.3*tSQY_L[%d]+%f", i+firstThinStrip, i+firstThinStrip, timeCorr[i]); condition.Form("0.3*tSQY_L[%d]>300 && 0.3*tSQY_L[%d]<360 && SQLYE[%d]>0", i+firstThinStrip, i+firstThinStrip, i+firstThinStrip); tr->SetMarkerColor(kRed); tr->SetMarkerStyle(20); tr->SetMarkerSize(.4); tr->Draw(varName, condition, "col", drawEntries); // tr->Draw(varName, condition, "", drawEntries); varName.Form("SQLYEtimeFiltered[%d]:SQLYtime[%d]", i+firstThinStrip, i+firstThinStrip); // condition.Form("SQLYtime[%d]>0 && SQLYE[%d]>0 && SQLYtimeMult==%d", // i+firstThinStrip, i+firstThinStrip, conTimeMult); // varName.Form("SQLYEtimeFiltered[%d]:0.3*tSQY_L[%d]", i+firstThinStrip, i+firstThinStrip); condition.Form("0.3*tSQY_L[%d]>200 && 0.3*tSQY_L[%d]<500 && SQLYEtimeFilteredSum>0 && SQLYtimeMult==%d", i+firstThinStrip, i+firstThinStrip, conTimeMult); cout << condition << endl; tr->Draw(varName, condition, "same", drawEntries); // varName.Form("SQLXE[%d]:SQLXtime[%d]", i+firstThinStrip, i+firstThinStrip); condition.Form("0.3*tSQY_L[%d]+%f>325 && 0.3*tSQY_L[%d]+%f<333 && SQLYE[%d]>0", i+firstThinStrip, timeCorr[i], i+firstThinStrip, timeCorr[i], i+firstThinStrip); // // varName.Form("SQLXEtimeFiltered[%d]:0.3*tSQX_L[%d]", i+firstThinStrip, i+firstThinStrip); // condition.Form("0.3*tSQX_L[%d]>200 && 0.3*tSQX_L[%d]<500 && SQLXEtimeFilteredSum>0 && SQLXtimeMult==%d", // i+firstThinStrip, i+firstThinStrip, conTimeMult); // // condition.Form("SQLXtimeSum>0 && SQLXtimeSum<470 && SQLXtimeMult==%d && %s", // // conTimeMult, timeSiLeftCondition.Data()); // // cout << condition << endl; // tr->SetMarkerColor(kRed); // tr->Draw(varName, condition, "same", drawEntries); // tAlphaCal->Draw(varName, "", "same"); c4->Update(); }//for */ // return; ///////////////////////////////////////////////////////////////////// // c5 TCanvas *c5 = new TCanvas("c5", "Multiplicity", 1400, 900); c5->Divide(3,3); cout << tr->GetEntries() << " events." << endl; cout << trCal->GetEntries() << " calibrated events." << endl; drawEntries = 10000000; cout << drawEntries << " entries in input chain will be processed." << endl; c5->cd(1); // varName.Form("SQ20timeMult"); // condition.Form("trigger==3 && SQ20timeMult>0"); tr->Draw("angleLeft", "angleLeft<3", "", drawEntries); c5->Update(); c5->cd(2); varName.Form("SQLYtimeMult"); condition.Form("trigger==3 && SQLYtimeMult>0 && SQLYtimeMult<8"); tr->Draw(varName, condition, "", drawEntries); c5->Update(); c5->cd(3); varName.Form("y1mm:x1mm>>h(32, -30., 30, 16, -30., 30)"); condition.Form("trigger==3 && y1mm>-80. && x1mm>-80."); tr->Draw(varName, condition, "col", drawEntries); c5->Update(); c5->cd(4); varName.Form("mapXbin"); condition.Form("trigger==3 && mapXbin>-1"); tr->Draw(varName, condition, "col", drawEntries); c5->Update(); c5->cd(5); varName.Form("mapYbin"); condition.Form("trigger==3 && mapYbin>-1"); tr->Draw(varName, condition, "col", drawEntries); c5->Update(); c5->cd(6); varName.Form("yThin:xThin"); condition.Form("trigger==3 && yThin>-80. && xThin>-80."); // condition.Form("yThin>-80. && xThin>-80."); tr->Draw(varName, condition, "col", drawEntries); TBox *boxThinDet = new TBox(25., -25., -25., 25.); boxThinDet->SetLineColor(kRed); boxThinDet->SetLineWidth(3); boxThinDet->SetFillStyle(0); boxThinDet->Draw("same"); c5->Update(); c5->cd(7); // varName.Form("nx1"); // condition.Form("nx1>0 && nx1<10"); //// condition.Form("yThin>-80. && xThin>-80."); // tr->Draw(varName, condition, "col", drawEntries); tr->Draw("dEbeam:TOF>>IDplot(200,,,200,,)", "TOF<400 && TOF>0 && dEbeam < 4000 && trigger==1", "col", 1000000); // tr->Draw("dEbeam:TOF>>IDplot(200,,,200,,)", " trigger==1", "col", 1000000); TBox *beamBox = new TBox(156, 2300, 165, 1800); beamBox->SetFillStyle(0); beamBox->SetLineWidth(3); beamBox->SetLineColor(kRed); beamBox->Draw(); c5->Update(); c5->cd(8); varName.Form("ny1"); condition.Form("ny1>0 && ny1<10"); tr->Draw(varName, condition, "", drawEntries); c5->Update(); condition.Form("ny1>0 && ny1<10 && TOF>156 && TOF<165 && dEbeam > 1800 && dEbeam<2300 && trigger==1"); // condition.Form("yThin>-80. && xThin>-80."); tr->Draw(varName, condition, "same", drawEntries); c5->Update(); c5->cd(9); varName.Form("yt:xt"); condition.Form("trigger==3"); // condition.Form("yThin>-80. && xThin>-80."); tr->Draw(varName, condition, "col", drawEntries); //*/ // return; ///////////////////////////////////////////////////////////////////// // c9 /*TCanvas *c9 = new TCanvas("c9", "dE-E uncorrected", 1600, 800); c9->Divide(4,2); firstThinStrip = 5; Int_t drawnEvents1[8]; cout << tr->GetEntries() << " events." << endl; cout << trCal->GetEntries() << " calibrated events." << endl; drawEntries = 10000000; Long64_t drawEntriesCorrected = 20000000; cout << drawEntries << " entries in input chain will be processed." << endl; for (Int_t i = 0; i < 8; i++) { c9->cd(i+1); varName.Form("SQ20E[%d]:SQ20E[%d]+SQLXEsum", i+firstThinStrip, i+firstThinStrip); condition.Form("SQ20E[%d]>1.2 && SQ20E[%d]<5 " "&& SQLXEsum>1.1 && SQLXEsum<30 " // "&& SQLXtimeMult==1" "&& trigger==3", i+firstThinStrip, i+firstThinStrip); tr->SetMarkerColor(kRed); tr->SetMarkerStyle(20); tr->SetMarkerSize(.4); tr->Draw(varName, condition, "col", drawEntries); varName.Form("SQ20E[%d]:SQ20E[%d]+SQLXEtimeFilteredSum", i+firstThinStrip, i+firstThinStrip); condition.Form("SQ20E[%d]>1.2 && SQ20E[%d]<5 " "&& SQLXEsum>1.1 && SQLXEsum<30 " "&& SQLXtimeMult==1" // "&& %s" "&& SQLXEtimeFilteredSum>0" "&& trigger==3", i+firstThinStrip, i+firstThinStrip); drawnEvents1[i] = tr->Draw(varName, condition, "same", drawEntriesCorrected); // cout << "noevents in strip " << i << ": " << drawnEvents << endl; c9->Update(); }//*/ // return; ///////////////////////////////////////////////////////////////////// // c10 /*TCanvas *c10 = new TCanvas("c10", "dE-E corrected", 1600, 800); c10->Divide(4,2); Int_t drawnEvents2[8]; firstThinStrip = 5; cout << tr->GetEntries() << " events." << endl; cout << trCal->GetEntries() << " calibrated events." << endl; drawEntries = 10000000; // drawEntriesCorrected = 100000000; drawEntriesCorrected = drawEntriesCorrected/0.4; cout << drawEntries << " entries in input chain will be processed." << endl; for (Int_t i = 0; i < 8; i++) { c10->cd(i+1); varName.Form("SQ20Ecorr[%d]:SQ20Ecorr[%d]+SQLXEsum", i+firstThinStrip, i+firstThinStrip); condition.Form("SQ20Ecorr[%d]>1.2 && SQ20Ecorr[%d]<5 " "&& SQLXEsum>1.1 && SQLXEsum<30 " // "&& SQLXtimeMult==1" "&& trigger==3", i+firstThinStrip, i+firstThinStrip); tr->Draw(varName, condition, "col", drawEntries); c10->Update(); tr->SetMarkerStyle(20); tr->SetMarkerSize(.4); tr->SetMarkerColor(kRed); varName.Form("SQ20Ecorr[%d]:SQ20Ecorr[%d]+SQLXEsum", i+firstThinStrip, i+firstThinStrip); condition.Form("SQ20Ecorr[%d]>1.2 && SQ20Ecorr[%d]<5 " "&& SQLXEsum>1.1 && SQLXEsum<30 " // "&& SQLXtimeMult==1" // "&& SQLXEtimeFilteredSum>0" "&& trigger==3", i+firstThinStrip, i+firstThinStrip); tr->Draw(varName, condition, "same", drawEntries); c10->Update(); tr->SetMarkerColor(kGreen); // tr->SetMarkerColor(kRed); varName.Form("SQ20EcorrHit[%d]:SQ20EcorrHit[%d]+SQLXEtimeFilteredSum", i+firstThinStrip, i+firstThinStrip); condition.Form("SQ20EcorrHit[%d]>1.2 && SQ20EcorrHit[%d]<5 " "&& SQLXEsum>1.1 && SQLXEsum<30 " "&& SQLXtimeMult==1" "&& SQLXEtimeFilteredSum>0.5" "&& trigger==3", i+firstThinStrip, i+firstThinStrip); drawnEvents2[i] = tr->Draw(varName, condition, "same", drawEntriesCorrected); // tAlphaCal->Draw(varName, "", "same"); c10->Update(); } for (Int_t i = 0; i < 8; i++) { cout << "noevents in strip " << i+firstThinStrip << ": " << drawnEvents1[i] << " (first choice)" << endl; cout << "noevents in strip " << i+firstThinStrip << ": " << drawnEvents2[i] << " (second choice)" << endl; }//*/ // return; ///////////////////////////////////////////////////////////////////// // c11 /*TCanvas *c11 = new TCanvas("c11", "dE-E uncorrected", 1600, 800); c11->Divide(4,2); firstThinStrip = 5; Int_t drawnEvents1[8]; cout << tr->GetEntries() << " events." << endl; cout << trCal->GetEntries() << " calibrated events." << endl; drawEntries = 1000000000; cout << drawEntries << " entries in input chain will be processed." << endl; for (Int_t i = 0; i < 8; i++) { c11->cd(i+1); varName.Form("SQ20E[%d]:SQ20E[%d]+SQLXEsum", i+firstThinStrip, i+firstThinStrip); condition.Form("SQ20E[%d]>1.2 && SQ20E[%d]<5 " "&& SQLXEsum>1.1 && SQLXEsum<30 " // "&& SQLXtimeMult==1" "&& trigger==3", i+firstThinStrip, i+firstThinStrip); tr->SetMarkerColor(kRed); tr->SetMarkerStyle(20); tr->SetMarkerSize(.4); tr->Draw(varName, condition, "col", drawEntries); c11->Update(); }//*/ // return; ///////////////////////////////////////////////////////////////////// // c12 /*TCanvas *c12 = new TCanvas("c12", "dE-E corrected (first approximation)", 1600, 800); c12->Divide(4,2); Int_t drawnEvents2[8]; firstThinStrip = 5; cout << tr->GetEntries() << " events." << endl; cout << trCal->GetEntries() << " calibrated events." << endl; drawEntries = 1000000000; cout << drawEntries << " entries in input chain will be processed." << endl; for (Int_t i = 0; i < 8; i++) { c12->cd(i+1); varName.Form("SQ20Ecorr[%d]:SQ20Ecorr[%d]+SQLXEsum", i+firstThinStrip, i+firstThinStrip); condition.Form("SQ20Ecorr[%d]>1.2 && SQ20Ecorr[%d]<5 " "&& SQLXEsum>1.1 && SQLXEsum<30 " // "&& SQLXtimeMult==1" "&& trigger==3", i+firstThinStrip, i+firstThinStrip); tr->Draw(varName, condition, "col", drawEntries); c12->Update(); }//*/ // return; ///////////////////////////////////////////////////////////////////// // c13 TCanvas *c13 = new TCanvas("c13", "dE-E corrected (second approximation)", 1600, 800); c13->Divide(4,2); firstThinStrip = 5; cout << tr->GetEntries() << " events." << endl; cout << trCal->GetEntries() << " calibrated events." << endl; drawEntries = 1000000000; cout << drawEntries << " entries in input chain will be processed." << endl; for (Int_t i = 0; i < 8; i++) { c13->cd(i+1); varName.Form("SQ20EcorrHit[%d]:SQ20EcorrHit[%d]+SQLXEtimeFilteredSum", i+firstThinStrip, i+firstThinStrip); condition.Form("SQ20EcorrHit[%d]>1.2 && SQ20EcorrHit[%d]<5 " "&& SQLXEsum>1.1 && SQLXEsum<30 " "&& SQLXtimeMult==1" "&& SQLXEtimeFilteredSum>0.5" "&& trigger==3", i+firstThinStrip, i+firstThinStrip); tr->Draw(varName, condition, "col", drawEntries); c13->Update(); }//*/ cout << "Finished in "<< stopwatch.RealTime() << " seconds" << endl; cout << "Finished in "<< stopwatch.RealTime()/60. << " minutes" << endl; return; }