Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-21 07:51:41

0001 #ifndef PLOTTHELPER_ASICLFHCAL_H
0002 #define PLOTTHELPER_ASICLFHCAL_H
0003 
0004   //*****************************************************************
0005   // ASIC geom sorted by LFHCal layer geom in addtion
0006   //===========================================================
0007     
0008   //__________________________________________________________________________________________________________
0009   // Plot Corr with Fits for Full Asic 2D
0010   //__________________________________________________________________________________________________________
0011   inline void PlotCorr2DAsicLFHCal (TCanvas* canvas, TPad** pads, 
0012                               Double_t* topRCornerX,  Double_t* topRCornerY, Double_t* relSize8P, Int_t textSizePixel, 
0013                               std::map<int,TileSpectra> spectra, int option,
0014                               Double_t xMin, Double_t xMax, Double_t minY, Double_t maxY, int asic, TString nameOutput, RunInfo currRunInfo, bool noCalib = 0, int triggCh = -1 ){
0015                                   
0016     Setup* setupT = Setup::GetInstance();
0017     
0018     std::map<int, TileSpectra>::iterator ithSpectra;    
0019 
0020     
0021     int nChA  = setupT->GetAbsNMaxROChannel()+1;
0022     int skipped = 0;
0023     ReadOut::Type rotype = ReadOut::Type::Undef;
0024     
0025     bool isTriggCh = false;
0026     canvas->cd();
0027 
0028     if (triggCh != -1)
0029       isTriggCh = true;
0030     
0031     for (int ch = 0; ch < nChA; ch++){
0032       int tempCellID = setupT->GetCellID(asic, ch);
0033       if (tempCellID == -1 ) continue;    
0034       int chInLayer  = setupT->GetChannelInLayer(tempCellID); 
0035       int layer      = setupT->GetLayer(tempCellID); 
0036       int row        = setupT->GetRow(tempCellID); 
0037       int col        = setupT->GetColumn(tempCellID); 
0038       int mod        = setupT->GetModule(tempCellID); 
0039         
0040       int cp         = layer%8*8+chInLayer;
0041       // std::cout << "cell ID: " << tempCellID << "\t row " << row << "\t column " << col << "\t layer " << layer << "\t module " << mod << "\t asic " << asic << "\tro ch asic " << ch << "\t " << cp<< std::endl;    
0042       canvas->cd();
0043       pads[cp]->Draw();
0044       // pads[cp]->Clear();
0045       pads[cp]->SetLogy(0);
0046       pads[cp]->SetLogz(1);
0047       pads[cp]->cd();
0048       ithSpectra=spectra.find(tempCellID);
0049       if(ithSpectra==spectra.end()){
0050         skipped++;
0051         std::cout << "WARNING: PlotCorr2DAsicLFHCal skipping cell ID: " << tempCellID << "\t row " << row << "\t column " << col << "\t layer " << layer << "\t module " << mod << "\t asic " << asic << "\tro ch asic " << ch << std::endl;
0052         pads[cp]->Clear();
0053         pads[cp]->Draw();
0054         if (cp ==63 ){
0055           DrawLatex(topRCornerX[cp]-0.04, topRCornerY[cp]-1*0.85*relSize8P[cp]-2.4*relSize8P[cp], GetStringFromRunInfo(currRunInfo, 2), true, 0.85*relSize8P[cp], 42);
0056           DrawLatex(topRCornerX[cp]-0.04, topRCornerY[cp]-1*0.85*relSize8P[cp]-3.2*relSize8P[cp], GetStringFromRunInfo(currRunInfo, 3), true, 0.85*relSize8P[cp], 42);
0057         }
0058         continue;
0059       } else {
0060         rotype = ithSpectra->second.GetROType();
0061       }
0062       TProfile* tempProfile = nullptr;
0063       TH2D* temp2D          = nullptr;        
0064       // LG-HG correlation CAEN
0065       if (option == 0){
0066         tempProfile     = ithSpectra->second.GetLGHGcorr();
0067         temp2D          = ithSpectra->second.GetCorr();
0068       // HGCROC waveform
0069       } else if (option == 1){
0070         // tempProfile     = ithSpectra->second.GetWave1D();
0071         temp2D          = ithSpectra->second.GetCorr();          
0072       // HGCROC TOA-ADC correlation
0073       } else if (option == 2){
0074         tempProfile     = ithSpectra->second.GetTOAADC();
0075         temp2D          = ithSpectra->second.GetCorrTOAADC();                    
0076       } else if (option == 3){
0077         temp2D          = ithSpectra->second.GetCorrTOASample();
0078       } else if (option == 4){
0079         temp2D          = ithSpectra->second.GetCorrADCTOT();
0080         tempProfile     = ithSpectra->second.GetADCTOT();
0081       }
0082       if (!temp2D && option != 4) continue;
0083       if (temp2D){
0084         SetStyleHistoTH2ForGraphs( temp2D, temp2D->GetXaxis()->GetTitle(), temp2D->GetYaxis()->GetTitle(), 0.85*textSizePixel, textSizePixel, 0.85*textSizePixel, textSizePixel,0.9, 1.5, 510, 510, 43, 63);  
0085         temp2D->GetYaxis()->SetRangeUser(minY,maxY);
0086         temp2D->GetXaxis()->SetRangeUser(xMin,xMax);
0087         temp2D->Draw("col");
0088 
0089         if( !noCalib ){
0090           DrawCorrectBadChannelBox(ithSpectra->second.GetCalib()->BadChannel,xMin, minY, xMax, maxY);
0091           temp2D->Draw("axis,same");
0092         }
0093         if (isTriggCh && triggCh == ch){
0094           std::cout << "entered highlighting" << std::endl;
0095           DrawHighlightTrigg(xMin, minY, xMax, maxY);
0096           temp2D->Draw("axis,same");
0097         }
0098       } else {
0099         if (!tempProfile) continue;
0100         TH1D* dummyhist = new TH1D("dummyhist", "", tempProfile->GetNbinsX(), tempProfile->GetXaxis()->GetXmin(), tempProfile->GetXaxis()->GetXmax());
0101         SetStyleHistoTH1ForGraphs( dummyhist, tempProfile->GetXaxis()->GetTitle(), tempProfile->GetYaxis()->GetTitle(), 0.85*textSizePixel, textSizePixel, 0.85*textSizePixel, textSizePixel,0.9, 1.5, 510, 510, 43, 63);  
0102         dummyhist->GetXaxis()->SetRangeUser(xMin,xMax);
0103         dummyhist->GetYaxis()->SetRangeUser(minY,maxY);
0104         dummyhist->Draw("axis");
0105         if( !noCalib ){
0106           DrawCorrectBadChannelBox(ithSpectra->second.GetCalib()->BadChannel,xMin, minY, xMax, maxY);
0107           dummyhist->Draw("axis,same");
0108         }                              
0109         if (isTriggCh && triggCh == ch){
0110           std::cout << "entered highlighting" << std::endl;
0111           DrawHighlightTrigg(xMin, minY, xMax, maxY);
0112           dummyhist->Draw("axis,same");
0113         }
0114       }      
0115       if (tempProfile ){
0116         if (option == 2)
0117           SetMarkerDefaultsProfile(tempProfile, 24, 0.7, kBlue+1, kBlue+1);           
0118         else 
0119           SetMarkerDefaultsProfile(tempProfile, 24, 0.7, kRed+2, kRed+2);           
0120         tempProfile->Draw("pe, same");
0121       }
0122       TString label           = Form("r:%d c:%d, ro-ch:%d", row, col, ch);
0123       TString labelAsic       = "";
0124       if (cp%8 == 7)
0125         labelAsic = Form("layer:%d", layer);
0126       if (cp == 63){
0127         labelAsic = Form("layer:%d module:%d, asic:%d", layer, mod, asic);
0128       }
0129       if(option == 1) label = Form("%s, entries=%d",label.Data(),(Int_t)(temp2D->GetEntries()/11) ) ;
0130       TLatex *labelChannel    = new TLatex(topRCornerX[cp]-0.04,topRCornerY[cp]-1.2*relSize8P[cp],label);
0131       SetStyleTLatex( labelChannel, 0.85*textSizePixel,4,1,43,kTRUE,31);
0132       TLatex *labelLayer;
0133       if (cp%8 == 7){
0134         labelLayer    = new TLatex(topRCornerX[cp]-0.04,topRCornerY[cp]-2.2*relSize8P[cp],labelAsic);
0135         SetStyleTLatex( labelLayer, 0.85*textSizePixel,4,1,43,kTRUE,31);
0136       }
0137       TF1* fit            = ithSpectra->second.GetCorrModel(0);
0138       if (rotype == ReadOut::Type::Hgcroc && option != 4)
0139         fit            = ithSpectra->second.GetCorrModel(2);
0140       int nlinesTot = 1;
0141       if(option == 2 || option == 3){ 
0142         if (ithSpectra->second.GetCalib()->HGLGCorrOff != -1000.){
0143           DrawLines(ithSpectra->second.GetCalib()->HGLGCorrOff, ithSpectra->second.GetCalib()->HGLGCorrOff,0, 0.7*maxY, 1, 1, 7);
0144         }
0145       }
0146       if (fit){
0147         Double_t rangeFit[2] = {0,0};
0148         fit->GetRange(rangeFit[0], rangeFit[1]);
0149         SetStyleFit(fit , rangeFit[0], rangeFit[1], 7, 3, kRed+3);
0150         fit->Draw("same");
0151         TLegend* legend = nullptr;
0152         if (rotype == ReadOut::Type::Caen){
0153           legend = GetAndSetLegend2( topRCornerX[cp]-0.4, topRCornerY[cp]-4*0.85*relSize8P[cp]-0.4*relSize8P[cp], topRCornerX[cp]+0.045, topRCornerY[cp]-0.6*relSize8P[cp],0.85*textSizePixel, 1, label+" "+labelAsic, 43,0.1);
0154           legend->AddEntry(fit, "linear fit, trigg.", "l");
0155           legend->AddEntry((TObject*)0, Form("#scale[0.8]{b = %2.3f #pm %2.4f}",fit->GetParameter(0), fit->GetParError(0) ) , " ");
0156           legend->AddEntry((TObject*)0, Form("#scale[0.8]{a = %2.3f #pm %2.4f}",fit->GetParameter(1), fit->GetParError(1) ) , " ");
0157           nlinesTot = 4;
0158         } else {
0159           legend = GetAndSetLegend2( topRCornerX[cp]-0.4, topRCornerY[cp]-4*0.85*relSize8P[cp]-1.4*relSize8P[cp], topRCornerX[cp]+0.045, topRCornerY[cp]-0.6*relSize8P[cp],0.85*textSizePixel, 1, label+" "+labelAsic, 43,0.1);
0160           legend->AddEntry(fit, "const fit", "l");
0161           legend->AddEntry((TObject*)0, Form("#scale[0.8]{a = %2.1f #pm %2.1f}",fit->GetParameter(0), fit->GetParError(0) ) , " "); 
0162           nlinesTot = 3;
0163         }
0164         legend->Draw();
0165       } else {
0166         labelChannel->Draw();  
0167         if (cp%8 == 7)
0168           labelLayer->Draw();  
0169       }
0170       if (cp ==63 ){
0171         DrawLatex(topRCornerX[cp]-0.04, topRCornerY[cp]-nlinesTot*0.85*relSize8P[cp]-2.4*relSize8P[cp], GetStringFromRunInfo(currRunInfo, 2), true, 0.85*relSize8P[cp], 42);
0172         DrawLatex(topRCornerX[cp]-0.04, topRCornerY[cp]-nlinesTot*0.85*relSize8P[cp]-3.2*relSize8P[cp], GetStringFromRunInfo(currRunInfo, 3), true, 0.85*relSize8P[cp], 42);
0173       }
0174     }
0175     if (skipped < 64)
0176       canvas->SaveAs(nameOutput.Data());
0177   }
0178     
0179 #endif
0180