#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 searchTimeConditions() { 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"); tr->SetMarkerStyle(20); tr->SetMarkerSize(0.4); 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; Int_t conTimeMult = 1; TStopwatch stopwatch; stopwatch.Start(); ///////////////////////////////////////////////////////////////////// // c1 TCanvas *c1 = new TCanvas("c1", "time in thin detector", 1600, 1200); c1->Divide(4,4); firstThinStrip = 0; Int_t minTimeLthin[16] { 410, 410, 420, 415, 420, 410, 415, 415, 420, 420, 420, 420, 410, 425, 0, 0 }; Int_t maxTimeLthin[16] { 520, 525, 520, 530, 520, 530, 525, 525, 530, 530, 530, 520, 510, 525, 0, 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 < 15; i++) { c1->cd(i+1); varName.Form("SQ20E[%d]:tSQ20[%d]*0.3", i+firstThinStrip, i+firstThinStrip); condition.Form("tSQ20[%d]*0.3>300 && tSQ20[%d]*0.3<700 && SQ20E[%d]>0 && SQ20E[%d]<4", i+firstThinStrip, i+firstThinStrip, i+firstThinStrip, i+firstThinStrip); tr->SetMarkerColor(kBlack); tr->Draw(varName, condition, "col", drawEntries); c1->Update(); condition.Form("tSQ20[%d]>0 && SQ20E[%d]>0 && SQ20E[%d]<40 && SQ20timeMult==%d", i+firstThinStrip, i+firstThinStrip, i+firstThinStrip, conTimeMult); tr->SetMarkerColor(kRed); tr->Draw(varName, condition, "same", 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; Double_t minTimeLX[32] { 0, 0, 325, 328, 330, 0, 0, 330, 326, 328, 326, 335, 326, 328, 328, 330, // 420, 425, 420, 420, 420, 420, 420, 420, 430, 425, 420, 420, 415, 415, 425, 415 }; Double_t maxTimeLX[32] { 0, 0, 345, 345, 350, 0, 0, 350, 345, 345, 345, 350, 340, 342, 345, 345, // 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, 460, 453 }; 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]>310 && 0.3*tSQX_L[%d]<380 && SQLXE[%d]>0 && trigger==3", 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); cout << condition << endl; tr->Draw(varName, condition, "same", drawEntries); 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]>390 && 0.3*tSQX_L[%d]<480 && SQLXE[%d]>0", i+firstThinStrip, i+firstThinStrip, i+firstThinStrip); 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); tr->Draw(varName, condition, "same", drawEntries); c2_1->Update(); }//for */ // return; ///////////////////////////////////////////////////////////////////// // c3 TCanvas *c3 = new TCanvas("c3", "time issues in 16 Y-strips", 1600, 1200); c3->Divide(4,4); firstThinStrip = 0; 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++) { c3->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("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); c3->Update(); 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); tr->SetMarkerColor(kRed); tr->Draw(varName, condition, "same", drawEntries); // tAlphaCal->Draw(varName, "", "same"); c3->Update(); }//for */ // return; ///////////////////////////////////////////////////////////////////// // c4 TCanvas *c4 = new TCanvas("c4", "Multiplicity", 1800, 900); c4->Divide(3,2); cout << tr->GetEntries() << " events." << endl; cout << trCal->GetEntries() << " calibrated events." << endl; drawEntries = 1000000; cout << drawEntries << " entries in input chain will be processed." << endl; c4->cd(1); varName.Form("SQLXmult"); condition.Form("trigger==3 && SQLXmult>0 && SQLXmult<8"); tr->Draw(varName, condition, "", drawEntries); c4->Update(); c4->cd(4); varName.Form("SQLXtimeMult"); condition.Form("trigger==3 && SQLXtimeMult>0 && SQLXtimeMult<8"); tr->Draw(varName, condition, "", drawEntries); c4->Update(); c4->cd(2); varName.Form("SQLYmult"); condition.Form("trigger==3 && SQLYmult>0 && SQLYmult<8"); tr->Draw(varName, condition, "", drawEntries); c4->Update(); c4->cd(5); varName.Form("SQLYtimeMult"); condition.Form("trigger==3 && SQLYtimeMult>0 && SQLYtimeMult<18"); tr->Draw(varName, condition, "", drawEntries); c4->Update(); c4->cd(3); varName.Form("SQ20EcorrMult"); condition.Form("trigger==3 && SQ20EcorrMult>0"); tr->Draw(varName, condition, "", drawEntries); c4->Update(); c4->cd(6); varName.Form("SQ20timeMult"); condition.Form("trigger==3 && SQ20timeMult>0"); tr->Draw(varName, condition, "", drawEntries); c4->Update(); //*/ return; }