//--------------------------------------------- // Go4 Tasca analysis // Author: Hans G. Essel // H.Essel@gsi.de // GSI, Experiment Electronics, Data Processing // modified by r.maendl // July 2021 - cleanup by JAM (j.adamczewski@gsi.de) //--------------------------------------------- #include "TascaCaliProc.h" #include "TGo4EventEndException.h" #include "Riostream.h" #include "TApplication.h" #include #include "TObjArray.h" #include "TObjString.h" #include "TGraph.h" #include "TH1.h" #include "TH2.h" #include "TGo4Fitter.h" #include "snprintf.h" #include "TPaveStats.h" #include "TGo4Picture.h" #include "TGo4WinCond.h" #include "TascaCalibration.h" #include "TascaCaliEvent.h" #include "TascaUnpackEvent.h" #include "TascaAnalysis.h" //#define Graf_On //*********************************************************** TascaCaliProc::TascaCaliProc() : TGo4EventProcessor() { } //*********************************************************** // this one is used TascaCaliProc::TascaCaliProc(const char* name) : TGo4EventProcessor(name) { cout << "Tasca> TascaCaliProc: Create" << endl; TString obname; TString obtitle; fCalibration = dynamic_cast(MakeParameter("Calibration", "TascaCalibration", "set_Calibration.C")); if (fCalibration == 0) { cout << "Could not create TascaCalibration. exiting-" << endl; gApplication->Terminate(); } // sets coefficients a0,a2 to 0, a1 to 1. fCalibration->Preset(); if (fCalibration->UseCalibration) { // was set in setcali.C fCalibration->ReadCoefficients(); cout << "Tasca> TascaCaliProc: Use calibration" << endl; } else cout << "Tasca> TascaCaliProc: No calibration used" << endl; fhdStopXL = MakeTH1('D', "Cali/Sum/FPGA_content_XL", "All XL Events FPGA_E", 192, 0, 192); fhdStopYL = MakeTH1('D', "Cali/Sum/FPGA_content_YL", "All YL Events FPGA_E", 50, 0, 50); fhdAnswers_TX = MakeTH1('D', "Cali/Sum/Answers_TX_all", "Energies of Answers_TX", 8000, 0.5, 16000.5); fhdAnswers_TX_Pa = MakeTH1('D', "Cali/Sum/Answers_TX_Pa", "Energies of Answers_TX (beam-off)", 8000, 0.5, 16000.5); // fhdAnswers_TX_Pu=MakeTH1('D',"Cali/Sum/Answers_TX_Pu", "Energies of Answers_TX (beam-on)",8000,0.5,16000.5); fhdAnswers_BX = MakeTH1('D', "Cali/Sum/Answers_BX_all", "Energies of Answers_BXwn ", 8000, 0.5, 16000.5); fhdAnswers_BX_Pa = MakeTH1('D', "Cali/Sum/Answers_BX_Pa", "Energies of Answers_BXwn (beam-off)", 8000, 0.5, 16000.5); fhdAnswers_TY = MakeTH1('D', "Cali/Sum/Answers_TY_all", "Energies of Answers_TY", 8000, 0.5, 16000.5); fhdAnswers_TY_Pa = MakeTH1('D', "Cali/Sum/Answers_TY_Pa", "Energies of Answers_TY (beam-off)", 8000, 0.5, 16000.5); // fhdAnswers_TY_Pu=MakeTH1('D',"Cali/Sum/Answers_TY_Pu", "Energies of Answers_TY (beam-on)",8000,0.5,16000.5); fhdAnswers_BY = MakeTH1('D', "Cali/Sum/Answers_BY_all", "Energies of Answers_BYwn ", 8000, 0.5, 16000.5); fhdAnswers_BY_Pa = MakeTH1('D', "Cali/Sum/Answers_BY_Pa", "Energies of Answers_BYwn (beam-off)", 8000, 0.5, 16000.5); if (fCalibration->UseCalibration) { // fhdAnswers_TX->GetXaxis()->SetLimits(0,15000); // fhdAnswers_TX_Pa->GetXaxis()->SetLimits(0,15000); // fhdAnswers_TX_Pu->GetXaxis()->SetLimits(0,15000); // fhdAnswers_BX->GetXaxis()->SetLimits(0,200000); // fhdAnswers_BX_Pa->GetXaxis()->SetLimits(0,200000); // fhdAnswers_BX_Pu->GetXaxis()->SetLimits(0,200000); // fhdStopXHsum->GetXaxis()->SetLimits(0,25000); fhdAnswers_TX_Pa->GetXaxis()->SetLimits(0, 16000); fhdAnswers_BX_Pa->GetXaxis()->SetLimits(0, 16000); fhdAnswers_TY_Pa->GetXaxis()->SetLimits(0, 160000); fhdAnswers_BY_Pa->GetXaxis()->SetLimits(0, 160000); fhdAnswers_TX->GetXaxis()->SetTitle("Energy [keV]"); fhdAnswers_BX->GetXaxis()->SetTitle("Energy [keV]"); fhdAnswers_TY->GetXaxis()->SetTitle("Energy [keV]"); fhdAnswers_BY->GetXaxis()->SetTitle("Energy [keV]"); fhdAnswers_TX_Pa->GetXaxis()->SetTitle("Energy [keV]"); fhdAnswers_BX_Pa->GetXaxis()->SetTitle("Energy [keV]"); fhdAnswers_TY_Pa->GetXaxis()->SetTitle("Energy [keV]"); fhdAnswers_BY_Pa->GetXaxis()->SetTitle("Energy [keV]"); } for (i = 0; i < 48; i++) { // obname.Form("Board%d/Loop%d/Brd%d-Loop%d-Sum", brd, loop, brd, loop); // obtitle.Form("QFW Board %d Loop %d Accumulated", brd, loop); obname.Form("Cali/StopXL/StopXL_%03d", i); obtitle.Form("StopX FPGA %03d", i); fhStopXL[i] = MakeTH1('I', obname.Data(), obtitle.Data(), 16000, 0.5, 16000.5); fhStopXL[i]->GetXaxis()->SetTitle("Channels"); fhStopXL[i]->GetYaxis()->SetTitle("Counts"); } for (i = 0; i < 96; i++) { obname.Form("Cali/StopYL/StopYL_%03d", i); obtitle.Form("StopY FPGA %03d", i); fhStopYL[i] = MakeTH1('I', obname.Data(), obtitle.Data(), 1600, 0.5, 1600.5); fhStopYL[i]->GetXaxis()->SetTitle("Channels"); fhStopYL[i]->GetYaxis()->SetTitle("Counts"); } for (i = 0; i < 6; i++) { obname.Form("Cali/GammaKev/GammaKev_%d", i); obtitle.Form("Gamma [Kev] %d", i); fhGammaKev[i] = MakeTH1('I', obname.Data(), obtitle.Data(), 10000, 0.5, 3000.5); obname.Form("Cali/GammaMysec/GammaMysec_%d", i); obtitle.Form("Gamma [mysec] %d", i); fhGammaMysec[i] = MakeTH1('I', obname.Data(), obtitle.Data(), 2000, -2000.5, 10000.5); } for (i = 0; i < 24; i++) { obname.Form("Cali/Answers_TX_Pa/Answers_TX_Pa%03d", i); obtitle.Form("Answers_TX Pause %03d", i); fhAnswers_TX_fpga_Pa[i] = MakeTH1('I', obname.Data(), obtitle.Data(), 1600, 0.5, 16000.5); fhAnswers_TX_fpga_Pa[i]->GetXaxis()->SetTitle("keV"); fhAnswers_TX_fpga_Pa[i]->GetYaxis()->SetTitle("Counts"); obname.Form("Cali/Answers_BX_Pa/Answers_BX_Pa%03d", i); obtitle.Form("Answers_BX_Pause %03d", i); fhAnswers_BX_fpga_Pa[i] = MakeTH1('I', obname.Data(), obtitle.Data(), 1600, 0.5, 16000.5); fhAnswers_BX_fpga_Pa[i]->GetXaxis()->SetTitle("keV"); fhAnswers_BX_fpga_Pa[i]->GetYaxis()->SetTitle("Counts"); } for (i = 0; i < 48; i++) { obname.Form("Cali/Answers_TY_Pa/Answers_TY_Pa%03d", i); obtitle.Form("Answers_TY Pause %03d", i); fhAnswers_TY_fpga_Pa[i] = MakeTH1('I', obname.Data(), obtitle.Data(), 8000, 0.5, 160000.5); fhAnswers_TY_fpga_Pa[i]->GetXaxis()->SetTitle("keV"); fhAnswers_TY_fpga_Pa[i]->GetYaxis()->SetTitle("Counts"); obname.Form("Cali/Answers_BY_Pa/Answers_BY_Pa%03d", i); obtitle.Form("Answers_BY_Pause %03d", i); fhAnswers_BY_fpga_Pa[i] = MakeTH1('I', obname.Data(), obtitle.Data(), 18000, 0.5, 160000.5); fhAnswers_BY_fpga_Pa[i]->GetXaxis()->SetTitle("keV"); fhAnswers_BY_fpga_Pa[i]->GetYaxis()->SetTitle("Counts"); } } //*********************************************************** TascaCaliProc::~TascaCaliProc() { cout << "Tasca> TascaCaliProc: Delete" << endl; } //*********************************************************** //----------------------------------------------------------- void TascaCaliProc::TascaCalibrate(TascaCaliEvent* poutevt) { poutevt->SetValid(kFALSE); // not to store fInput = (TascaUnpackEvent*) GetInputEvent(); // from this poutevt->fiSystemSec = fInput->fiSystemSec; poutevt->fievcount = fInput->fievent_number; poutevt->fiChopper = fInput->fiChopper; poutevt->ffChopper_Amp = fInput->ffChopper_Amp; //ADN poutevt->fiChopper_hit_time = fInput->fiChopper_hit_time; //ADN poutevt->fiChopper_SystemSec = fInput->fiChopper_SystemSec; //ADN // COMPACT_114 Configuration 2015// // FEBEX 0 ch 0-15 Comp 1 UP // FEBEX 1 ch 16-31 Comp 1 UP // FEBEX 2 ch 0-15 Comp 1 DOWN // FEBEX 3 ch 16-31 Comp 1 DOWN // FEBEX 4 ch 0-15 Comp 2 UP // FEBEX 5 ch 16-31 Comp 2 UP // FEBEX 6 ch 0-15 Comp 2 DOWN // FEBEX 7 ch 16-31 Comp 2 DOWN // FEBEX 8 ch 0-15 FPD Front positive // FEBEX 9 ch 0-15 FPD Back negative // FEBEX 10 ch 0 Beam status, 1 chopper //Int_t k=0; Int_t One_sig_Answers_TX = 0; Int_t One_sig_Answers_BX = 0; //Int_t One_sig_Answers_TY=0; //Int_t One_sig_Answers_BY=0; if (fInput->fiMicro == 1) { poutevt->fiMicro = 1; } if (fInput->fiMicro == 0) { poutevt->fiMicro = 0; } if (fInput->fiMacro == 0) { poutevt->fiMacro = 0; } if (fInput->fiMacro == 1) { poutevt->fiMacro = 1; } for (i = 0; i < 48; i++) { /* if(i>144) {poutevt->ffStopXL[i]=fInput->ffStopXH[i]/100.*3.6; fhStopXL[i]->Fill(poutevt->ffStopXL[i]); if(poutevt->ffStopXL[i]>2000.) fhdStopXL->Fill(i); } */ sign = 1; if ((fInput->ffStopXH[i] > 10. && fInput->ffStopXH[i] < 10000000.) || (fInput->ffStopXH[i] > -10000000. && fInput->ffStopXH[i] < -10.)) { if (i < 48) { poutevt->ffStopXL[i] = fCalibration->CalibrateStopXL(fInput->ffStopXH[i] * sign, i); // poutevt->ffStopXL[i]=fInput->ffStopXH[i]*sign; // poutevt->ffStopXL[i]=fInput->ffStopXH[i]*sign; if (poutevt->fiMicro == 0) fhStopXL[i]->Fill(poutevt->ffStopXL[i]); } if (i < 16) { fhdAnswers_TX->Fill(poutevt->ffStopXL[i]); poutevt->fiTX_TAC[i] = fInput->fiStopXL_TAC[i]; poutevt->ffTX[i] = poutevt->ffStopXL[i]; One_sig_Answers_TX = One_sig_Answers_TX + 1; if (poutevt->fiMicro == 0) { fhdAnswers_TX_Pa->Fill(poutevt->ffStopXL[i]); fhAnswers_TX_fpga_Pa[i]->Fill(poutevt->ffStopXL[i]); } } if (i > 23 && i < 32) { fhdAnswers_TX->Fill(poutevt->ffStopXL[i]); poutevt->fiTX_TAC[i - 24 + 16] = fInput->fiStopXL_TAC[i]; poutevt->ffTX[i - 24 + 16] = poutevt->ffStopXL[i]; One_sig_Answers_TX = One_sig_Answers_TX + 1; if (poutevt->fiMicro == 0) { fhdAnswers_TX_Pa->Fill(poutevt->ffStopXL[i]); fhAnswers_TX_fpga_Pa[i - 24 + 16]->Fill(poutevt->ffStopXL[i]); } } if (i > 31 && i < 48) { fhdAnswers_BX->Fill(poutevt->ffStopXL[i]); poutevt->fiBX_TAC[i - 24 - 8] = fInput->fiStopXL_TAC[i]; poutevt->ffBX[i - 24 - 8] = poutevt->ffStopXL[i]; One_sig_Answers_BX = One_sig_Answers_BX + 1; if (poutevt->fiMicro == 0) { fhdAnswers_BX_Pa->Fill(poutevt->ffStopXL[i]); fhAnswers_BX_fpga_Pa[i - 24 - 8]->Fill(poutevt->ffStopXL[i]); } } if (i > 15 && i < 24) { fhdAnswers_BX->Fill(poutevt->ffStopXL[i]); poutevt->fiBX_TAC[i] = fInput->fiStopXL_TAC[i]; poutevt->ffBX[i] = poutevt->ffStopXL[i]; One_sig_Answers_BX = One_sig_Answers_BX + 1; if (poutevt->fiMicro == 0) { fhdAnswers_BX_Pa->Fill(poutevt->ffStopXL[i]); fhAnswers_BX_fpga_Pa[i]->Fill(poutevt->ffStopXL[i]); } } } } for (i = 0; i < 96; i++) { sign = 1; if ((fInput->ffStopYL[i] > 10. && fInput->ffStopYL[i] < 10000000.) || (fInput->ffStopYL[i] > -10000000. && fInput->ffStopYL[i] < -10.)) { poutevt->ffStopYL[i] = fCalibration->CalibrateStopYL(fInput->ffStopYL[i] / 10. * sign, i); // if(i<96) poutevt->ffStopYL[i]=fInput->ffStopYL[i]*sign; // cout<ffStopYL[i]<fiMicro == 0) fhStopYL[i]->Fill(poutevt->ffStopYL[i]); // if(poutevt->ffStopYL[i]>1000.) fhdStopXL->Fill(i); if (i < 48) { fhdAnswers_TY->Fill(poutevt->ffStopYL[i]); // poutevt->fiTY_TAC[i]=fInput->fiStopYL_TAC[i]; poutevt->ffTY[i] = poutevt->ffStopYL[i]; // One_sig_Answers_TY=One_sig_Answers_TY+1; if (poutevt->fiMicro == 0) { fhdAnswers_TY_Pa->Fill(poutevt->ffStopYL[i]); // fhAnswers_TY_fpga_Pa[i]->Fill(poutevt->ffStopYL[i]); } } if (i > 47 && i < 96) { fhdAnswers_BY->Fill(poutevt->ffStopYL[i]); // poutevt->fiBY_TAC[96-i]=fInput->fiStopYL_TAC[i]; poutevt->ffBY[96 - i] = poutevt->ffStopYL[i]; // One_sig_Answers_BY=One_sig_Answers_BY+1; if (poutevt->fiMicro == 0) { fhdAnswers_BY_Pa->Fill(poutevt->ffStopYL[i]); // fhAnswers_BY_fpga_Pa[96-i]->Fill(poutevt->ffStopYL[i]); } } } } if (fInput->ffGammaE[0] < 0.) { poutevt->fiGammaMysec[0] = fInput->fiGammaT[0]; fhGammaMysec[0]->Fill(poutevt->fiGammaMysec[0]); // poutevt->ffGammaKev[i] = fCalibration->CalibrateGammaE(fInput->ffGammaE[i],i); //poutevt->ffGammaKev[0]=fInput->ffGammaE[0]/100.*0.208609-0.438476; //poutevt->ffGammaKev[0]=fInput->ffGammaE[0]/100.*0.205346-0.249; // below calib for BeGenew // poutevt->ffGammaKev[0]=(fInput->ffGammaE[0]/100.*(-1.))^2*5e-8+0.422*fInput->ffGammaE[0]/100.*(-1.)+0.1028; poutevt->ffGammaKev[0] = fInput->ffGammaE[0] / 100. * (-1.) * 0.36612 - 1.4; fhGammaKev[0]->Fill(poutevt->ffGammaKev[0]); if ((-40 < fInput->fiGammaT[0]) && fInput->fiGammaT[0] < 100) { fhGammaKev[2]->Fill(poutevt->ffGammaKev[0]); if (poutevt->fiMicro == 0) fhGammaKev[4]->Fill(poutevt->ffGammaKev[0]); } // cout<<"energy" << fInput->ffGammaE[0]<< " "<ffGammaKev[0]<<" "fInput->fiGammaT[0]<< " "<fiGammaMysec[0]<< endl; } if (fInput->ffGammaE[1] > 0.) { poutevt->fiGammaMysec[1] = fInput->fiGammaT[1]; fhGammaMysec[1]->Fill(poutevt->fiGammaMysec[1]); // poutevt->ffGammaKev[i] = fCalibration->CalibrateGammaE(fInput->ffGammaE[i],i); //poutevt->ffGammaKev[1]=fInput->ffGammaE[1]/100.*0.208609-0.438476; poutevt->ffGammaKev[1] = ((fInput->ffGammaE[1] / 100. * 0.1724 + 0.1236)); // poutevt->ffGammaKev[1]=((fInput->ffGammaE[1]/100.*0.1724+0.1236)*1.055212759-0.341); // poutevt->ffGammaKev[1]=fInput->ffGammaE[1]/100.; fhGammaKev[1]->Fill(poutevt->ffGammaKev[1]); if ((-40 < fInput->fiGammaT[1]) && fInput->fiGammaT[1] < 100) { fhGammaKev[2]->Fill(poutevt->ffGammaKev[1]); if (poutevt->fiMicro == 0) fhGammaKev[4]->Fill(poutevt->ffGammaKev[1]); } // cout<<"energy" << fInput->ffGammaE[1]<< " "<ffGammaKev[1]<<" "fInput->fiGammaT[1]<< " "<fiGammaMysec[1]<< endl; } /* if(fInput->ffGammaE[0]>0.){ poutevt->fiGammaMysec[0]=fInput->fiGammaT[0]; fhGammaMysec[0]->Fill(poutevt->fiGammaMysec[0]); // poutevt->ffGammaKev[i] = fCalibration->CalibrateGammaE(fInput->ffGammaE[i],i); // poutevt->ffGammaKev[0]=fInput->ffGammaE[0]/100.*0.199236-0.53207; poutevt->ffGammaKev[0]=((fInput->ffGammaE[0]/100.*0.1763-0.1365)*1.0673644696+0.179); //poutevt->ffGammaKev[0]=fInput->ffGammaE[0]/100.; fhGammaKev[0]->Fill(poutevt->ffGammaKev[0]); if((-40fiGammaT[0]) && fInput->fiGammaT[0]<100) { fhGammaKev[3]->Fill(poutevt->ffGammaKev[0]); if(poutevt->fiMicro==0) fhGammaKev[5]->Fill(poutevt->ffGammaKev[0]); } // cout<<"energy" << k <<" "<< fInput->ffGammaE[1]<< " "<ffGammaKev[1]<<" "<fiGammaT[1]<< " "<fiGammaMysec[1]<< endl; // k=k+1; }*/ poutevt->SetValid(kTRUE); // store }