// ECAHists.cc // Contact person: Gabriel Orebi Gann - Author and contact // Contact person: Javier Caravaca - Contact // See ECAHists.hh for more details //———————————————————————// #include #include #include #include #include #include #include #include #include #include #include "TStyle.h" using namespace std; namespace RAT { ECAHists::ECAHists() { } ECAHists::~ECAHists() { } void ECAHists::InitialiseHists(int eca_type, int dodroop) { if(eca_type==0)return; if(eca_type==1){ float pedmin[4] = {0., 0., 0., 0.}; float pedmax[4] = {3000., 3000., 3000., 5000.}; float widmin[4] = {-0.5, -0.5, -0.5, -0.5}; float widmax[4] = {99.5, 99.5, 99.5, 99.5}; float diffmin[4] = {-100.0, -100., -100., -100.}; float diffmax[4] = {100.0, 100., 100., 100.}; //Javi fQHSvsQHL = new TH2F("fQHSvsQHL","",500,pedmin[0],pedmax[0],500,pedmin[1],pedmax[1]); for(int i=0;i<4;++i){ TString hid = "fPedestal"; hid += (i+1); fPedestal[i] = new TH1F(hid,"",500,pedmin[i],pedmax[i]); hid = "fPWidth"; hid += (i+1); fPWidth[i] = new TH1F(hid,"",100,widmin[i],widmax[i]); hid = "fDiff"; hid += (i+1); fDiff[i] = new TH1F(hid,"",400,diffmin[i],diffmax[i]); hid = "fPedAve"; hid += (i+1); fPedAve[i] = new TH1F(hid,"",500,pedmin[i],pedmax[i]); hid = "fWidthAve"; hid += (i+1); fWidthAve[i] = new TH1F(hid,"",100,widmin[i],widmax[i]); hid = "fDiffAve"; hid += (i+1); fDiffAve[i] = new TH1F(hid,"",400,diffmin[i],diffmax[i]); hid = "fAbsDiffAve"; hid += (i+1); fAbsDiffAve[i] = new TH1F(hid,"",250,0.,diffmax[i]); } fNCeEv = new TH1I("fNCeEv","", 1401, -0.5, 1400.5); fNBadSeq = new TH1I("fNBadSeq","", 101, -0.5, 100.5); fNBadMB = new TH1I("fNBadMB","", 101, -0.5, 100.5); fNBadDB = new TH1I("fNBadDB","", 101, -0.5, 100.5); fNBadNev = new TH1I("fNBadNev","", 101, -0.5, 100.5); fNBad0ev = new TH1I("fNBad0ev","", 101, -0.5, 100.5); fNBad = new TH1I("fNBad","", 101, -0.5, 100.5); for(int i=0;i<5;++i){ for(int j=0;j<4;++j){ TString hid = "fNBadPed"; hid += (i+1); hid += (j+1); fNBadPed[i][j] = new TH1I(hid,"", 101, -0.5, 100.5); } } if(dodroop==1){ for(int i=0;i<4;++i){ for(int j=0;j<10;++j){ TString hid = "fDroop"; hid += (i+1); hid += (j+1); fDroop[i][j] = new TH1F(hid,"", 500, -250., 250.); hid = "fDroopValid"; hid += (i+1); hid += (j+1); fDroopValid[i][j] = new TH1F(hid,"", 500, -250., 250.); } } for(int i=0;i<16;++i){ TString hid = "fDroopByCell"; hid += (i+1); fDroopByCell[i] = new TH1F(hid,"", 500, -250., 250.); } } //Javi NCellFailedPed = new TH1I("NCellFailedPed","",1,0,1); } if(eca_type==2){ float indvalsmin[3][2] = {{-10.,-40.},{-0.2,-0.4},{-0.0002,-0.0004}}; float indvalsmax[3][2] = {{30.,40.},{0.2,0.4},{0.0002,0.0004}}; int indvalsbin[3][2] = {{200,400},{200,400},{200,400}}; for(int i=0;i<3;++i){ for(int j=0;j<2;++j){ TString hid = "fCubFitPar"; hid += (i+1); hid += (j+1); fCubFitPar[i][j] = new TH1F(hid,"", indvalsbin[i][j], indvalsmin[i][j], indvalsmax[i][j]); } } fCubInt = new TH1F("fCubInt","", 500, -200.0, 800.0); fCubIntDiff = new TH1F("fCubIntDiff","", 500, -200.0, 200.0); fNUsed = new TH1I("fNUsed","",32, -0.5, 31.5); fWidth = new TH1F("fWidth","", 300, -0.5, 299.5); fNBadCeWidth = new TH1I("fNBadCeWidth","", 32, -0.5, 31.5); fNEvPerTStep = new TH1I("fNEvPerTStep","", 15, -0.5, 14.5); fNBadStepNev = new TH1I("fNBadStepNev","", 32, -0.5, 31.5); fNSuspStep = new TH1I("fNSuspStep","", 32, -0.5, 31.5); for(int icrate=0; icrate<19; icrate++) fWidthCrates[icrate] = new TH1F(Form("fWidthCrate%d",icrate),"",300,-0.5,299.5); for(int ipoint=0; ipoint<50; ipoint++) fWidthPoints[ipoint] = new TH1F(Form("fWidthPoint%d",ipoint),"",300,-0.5,299.5); float cravalsmin[3][3] = {{-10.,-40.,0.},{-0.2,-0.4,0.},{-0.0002,-0.0004,0.}}; float cravalsmax[3][3] = {{30.,40.,40.},{0.2,0.4,0.4},{0.0002,0.0004,0.0004}}; int cravalsbin[3][3] = {{200,400,200},{200,400,200},{200,400,200}}; float faivalsmin[3][2] = {{-0.5,-0.5},{-0.5,-0.5},{-0.5,-0.5}}; float faivalsmax[3][2] = {{100.5,100.5},{100.5,100.5},{100.5,100.5}}; int faivalsbin[3][2] = {{101, 101},{101, 101},{101, 101}}; for(int i=0;i<3;++i){ for(int j=0;j<3;++j){ TString hid = "fCubFitParAve"; hid += (i+1); hid += (j+1); fCubFitParAve[i][j] = new TH1F(hid,"", cravalsbin[i][j], cravalsmin[i][j], cravalsmax[i][j]); } for(int j=0;j<2;++j){ TString hid = "fNBadChCub"; hid += (i+1); hid += (j+1); fNBadChCub[i][j] = new TH1I(hid,"", faivalsbin[i][j], faivalsmin[i][j], faivalsmax[i][j]); } } fNBadChNfit = new TH1I("fNBadChNfit","", 101, -0.5, 100.5); fNBadChWidth = new TH1I("fNBadChWidth","", 101, -0.5, 100.5); fNBadChNev = new TH1I("fNBadChNev","", 101, -0.5, 100.5); fNBadCh0ev = new TH1I("fNBadCh0ev","", 101, -0.5, 100.5); fNBadChSeq = new TH1I("fNBadChSeq","", 101, -0.5, 100.5); fNBadChMB = new TH1I("fNBadChMB","", 101, -0.5, 100.5); fNBadChDB = new TH1I("fNBadChDB","", 101, -0.5, 100.5); fNBadChSusp = new TH1I("fNBadChSusp","", 101, -0.5, 100.5); fNBadCh = new TH1I("fNBadCh","", 101, -0.5, 100.5); NCellFailedTSlope = new TH1I("NCellFailedTSlope","",1,0,1); //Javi fPResetNPoints = new TH1F("fPResetNPoints","",20,0.,20.); fPResetDiffComp = new TH1F("fPResetDiffComp","",1000,-1500.,1500.); fPResetDiffCompFailed = new TH1F("fPResetDiffCompFailed","",1000,-500.,500.); fPResetNev = new TH1F("fPResetNev","",50,0,15); fPResetNevFailed = new TH1F("fPResetNevFailed","",50,0,15); } } void ECAHists::WriteHists(int eca_type, TFile *rootfile, int dodroop) { if(eca_type==0)return; rootfile->cd(); if(eca_type==1){ for(int i=0;i<4;++i){ fPedestal[i]->Write(); fPWidth[i]->Write(); fDiff[i]->Write(); fPedAve[i]->Write(); fWidthAve[i]->Write(); fDiffAve[i]->Write(); fAbsDiffAve[i]->Write(); if(dodroop==1){ for(int j=0;j<10;++j){ fDroop[i][j]->Write(); fDroopValid[i][j]->Write(); } } for(int j=0;j<5;++j){ fNBadPed[j][i]->Write(); } } if(dodroop==1){ for(int i=0;i<16;++i){ fDroopByCell[i]->Write(); } } fNCeEv->Write(); fNBadSeq->Write(); fNBadMB->Write(); fNBadDB->Write(); fNBadNev->Write(); fNBad0ev->Write(); fNBad->Write(); //Javi NCellFailedPed->Write(); fQHSvsQHL->Write(); } //end pedestals if(eca_type==2){ fCubInt->Write(); fCubIntDiff->Write(); for(int i=0;i<3;++i){ for(int j=0;j<2;++j){ fCubFitPar[i][j]->Write(); fCubFitParAve[i][j]->Write(); fNBadChCub[i][j]->Write(); } fCubFitParAve[i][2]->Write(); } for(int icrate=0; icrate<19; icrate++) fWidthCrates[icrate]->Write(); for(int ipoint=0; ipoint<50; ipoint++) fWidthPoints[ipoint]->Write(); fNUsed->Write(); fWidth->Write(); fNBadCeWidth->Write(); fNEvPerTStep->Write(); fNBadStepNev->Write(); fNSuspStep->Write(); fNBadChNfit->Write(); fNBadChWidth->Write(); fNBadChNev->Write(); fNBadCh0ev->Write(); fNBadChSeq->Write(); fNBadChMB->Write(); fNBadChDB->Write(); fNBadChSusp->Write(); fNBadCh->Write(); //Javi fPResetNPoints->Write(); fPResetDiffComp->Write(); fPResetDiffCompFailed->Write(); fPResetNev->Write(); fPResetNevFailed->Write(); NCellFailedTSlope->Write(); } } void ECAHists::SetAxes(int eca_type, int dodroop) { if(eca_type==0)return; if(eca_type==1){ TString xax[5] = {"QHS", "QHL", "QLX", "TAC", "QHS&&TAC"}; for(int i=0;i<4;++i){ TString title = xax[i]; title += " pedestal /cell"; fPedestal[i]->GetXaxis()->SetTitle(title); title = xax[i]; title += " width /cell"; fPWidth[i]->GetXaxis()->SetTitle(title); title = xax[i]; title += " ped, diff from previous run"; fDiff[i]->GetXaxis()->SetTitle(title); title = xax[i]; title += " pedestal: per-crate average"; fPedAve[i]->GetXaxis()->SetTitle(title); title = xax[i]; title += " width: per-crate average"; fWidthAve[i]->GetXaxis()->SetTitle(title); title = xax[i]; title += " diff: per-crate average"; fDiffAve[i]->GetXaxis()->SetTitle(title); title = xax[i]; title += " |diff|: per-crate average"; fAbsDiffAve[i]->GetXaxis()->SetTitle(title); } fNCeEv->GetXaxis()->SetTitle("Number of events /cell"); fNBadSeq->GetXaxis()->SetTitle("NChan failed /crate: Bad Seq"); fNBadMB->GetXaxis()->SetTitle("NChan failed /crate: Bad MB"); fNBadDB->GetXaxis()->SetTitle("NChan failed /crate: Bad DB"); fNBadNev->GetXaxis()->SetTitle("NChan failed /crate: N events"); fNBad0ev->GetXaxis()->SetTitle("NChan failed /crate: 0 events"); fNBad->GetXaxis()->SetTitle("NChan failed /crate: total"); TString test[4] = {" tests", " pedestal", " width", " diff"}; for(int i=0;i<5;++i){ for(int j=0;j<4;++j){ TString title = "NChan failed /crate: "; title += xax[i]; title += test[j]; fNBadPed[i][j]->GetXaxis()->SetTitle(title); } } if(dodroop==1){ for(int i=0;i<4;++i){ for(int j=0;j<10;++j){ TString title = "CMOS Droop: "; title += xax[i]; title += " (median - event "; title += j; title += ")"; fDroop[i][j]->GetXaxis()->SetTitle(title); title += " - enabled chan only"; fDroopValid[i][j]->GetXaxis()->SetTitle(title); } } for(int i=0;i<16;++i){ TString title = "CMOS Droop: TAC (median - event 0, for event 0 on cell "; title += i; title += ")"; fDroopByCell[i]->GetXaxis()->SetTitle(title); } } //Javi NCellFailedPed->SetTitle("Number of cells failing any test"); fQHSvsQHL->SetTitle("QHS vs QHL"); }//end pedestal if(eca_type==2){ // Axis Titles TString xax2[3] = {"range", "diff", "abs diff"}; for(int i=0;i<3;++i){ for(int j=0;j<3;++j){ TString xax = "x^{"; xax += (i+1); xax += "} fit coeff "; xax += xax2[j]; if(j<2){ fCubFitPar[i][j]->GetXaxis()->SetTitle(xax); TString xax3 = "NChan failed /crate due to "; xax3 += xax; fNBadChCub[i][j]->GetXaxis()->SetTitle(xax3); } TString xax4 = xax; xax4 += " : per-crate average"; fCubFitParAve[i][j]->GetXaxis()->SetTitle(xax4); } } fCubInt->GetXaxis()->SetTitle("x^{0} fit coeff range"); fCubIntDiff->GetXaxis()->SetTitle("x^{0} fit coeff range diff"); fNUsed->GetXaxis()->SetTitle("N TSteps/cell used in cubic fit"); fWidth->GetXaxis()->SetTitle("TStep width"); for(int icrate=0; icrate<19; icrate++) fWidthCrates[icrate]->GetXaxis()->SetTitle(dformat("Crate %d widths",icrate).c_str()); for(int ipoint=0; ipoint<50; ipoint++) fWidthPoints[ipoint]->GetXaxis()->SetTitle(dformat("TSLP Point %d widths",ipoint).c_str()); fNBadCeWidth->GetXaxis()->SetTitle("N TSteps/cell with bad widths"); fNEvPerTStep->GetXaxis()->SetTitle("N Events per TStep"); fNBadStepNev->GetXaxis()->SetTitle("N TSteps/cell with bad N events"); fNSuspStep->GetXaxis()->SetTitle("N suspicious TSteps/cell"); fNBadChNfit->GetXaxis()->SetTitle("NChan failed /crate: N TSteps in fit"); fNBadChWidth->GetXaxis()->SetTitle("NChain failed /crate: Widths"); fNBadChNev->GetXaxis()->SetTitle("NChan failed /crate: N events"); fNBadCh0ev->GetXaxis()->SetTitle("NChan failed /crate: 0 events"); fNBadChSeq->GetXaxis()->SetTitle("NChan failed /crate: Bad Seq"); fNBadChMB->GetXaxis()->SetTitle("NChan failed /crate: Bad MB"); fNBadChDB->GetXaxis()->SetTitle("NChan failed /crate: Bad DB"); fNBadChSusp->GetXaxis()->SetTitle("NChan failed /crate: N suspicious points"); fNBadCh->GetXaxis()->SetTitle("NChan failed /crate: total"); //Javi NCellFailedTSlope->SetTitle("Number of cells failing any test"); fPResetNPoints->SetTitle("Number of post reset points"); fPResetDiffComp->SetTitle("Difference between post reset and comparison point"); fPResetDiffCompFailed->SetTitle("Difference between post reset and comparison point Failed Bit30"); fPResetNev->SetTitle("Number of events in post reset point"); fPResetNevFailed->SetTitle("Number of events in failed post reset point"); }//end tslope } void ECAHists::Beautify() { gStyle->SetCanvasBorderMode(0); gStyle->SetPadBorderMode(0); //gStyle->SetOptTitle(0); gStyle->SetLabelFont(132,"XYZ"); gStyle->SetTextFont(132); gStyle->SetOptStat(0); gStyle->SetTitleFont(132,"XYZ"); gStyle->SetPadColor(0); gStyle->SetCanvasColor(0); gStyle->SetOptFit(); // Show fit parameters in plot gStyle->SetStatColor(kWhite); gStyle->SetHistFillColor(0); gStyle->SetFrameFillColor(0); gStyle->SetStatBorderSize(0); gStyle->SetStatX(0.65); gStyle->SetStatY(0.88); gStyle->SetStatW(0.13); gStyle->SetStatFontSize(.03); gStyle->SetStatFont(132); gStyle->SetTitleColor(kWhite,""); gStyle->SetTitleBorderSize(0); gStyle->SetPadTopMargin(0.075);//.1 gStyle->SetPadRightMargin(0.05); //.075 gStyle->SetPadBottomMargin(0.075); // .1 gStyle->SetPadLeftMargin(0.075); // .1 } } // namespace RAT