#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "TMath.h" #include #include #include #include #include #include #include #include "TSystem.h" #include #include #include #include #include #include #include #include "TVirtualFFT.h" #define SizeOfArray(a) (sizeof(a)/sizeof(a[0])) #include #include #include #include void HiLumRead() { struct scintMIPs { double scintMIP[3]; }; struct pedestalWindows { int nPedWindows; int firstSample[25]; int lastSample[25]; void Print() { printf("nPed=%d\n", nPedWindows); for (int i=0; iGet(treeName); // extract a spill TTree from file sprintf(treeName, "run%04dspills", myRun); TTree *burstTree = (TTree*)f->Get(treeName); // extract a run TTree from file sprintf(treeName, "run%04d", myRun); TTree *runTree = (TTree*)f->Get(treeName); /* sprintf(treeName, "run%04d", myRun); runTree = new TTree(treeName, treeName); runTree -> Branch("S123inBeam", RH->GetS123pointer(), "S123inBeam/B"); runTree -> Branch("HVmod", RH->GetHVsetPointer(), "HVmod[4]/D"); runTree -> Branch("AntennaModule", RH->GetAntennaPointer(), "AntennaModule/I"); runTree -> Branch("CryoX", RH->GetCryoXPointer(), "CryoX[3]/D"); runTree -> Branch("CryoPos", RH->GetCryoPositionPointer(), "CryoPos[3]/D"); runTree -> Branch("ScintMIPs", myMIPcounter->GetMIPaveragePointer(), "ScintMIPs[3]/D"); sprintf(treeName, "run%04dspills", myRun); spillsTree = new TTree(treeName, treeName); spillsTree -> Branch("miniBirstHeader", &miniBH.burst, "burst/I:ChMPIF/F:ChGADC/F"); spillsTree -> Branch("nLaps", CherBuffer->GetNlapsPointer(), "nLaps/I"); spillsTree -> Branch("LapSum", CherBuffer->GetLapsSumPointer(), "lapSum[nLaps]/F"); // all filled bunches, summed over laps spillsTree -> Branch("LapFill", CherBuffer->GetFilledSumPointer(), "lapFill[30]/D"); // accumulated amplitudes for 30 bunches spillsTree -> Branch("LapBool", CherBuffer->GetFilledSamplePointer(), "lapBool[30]/B"); // true for filled, false for empty spillsTree -> Branch("LapActn", ProcStatus->GetBunchActionPointer(), "lapActn[30]/I"); // 0 - no action 1 - signal 2 - ped spillsTree -> Branch("HVbeam", RH->GetHVbeamPointer(), "HVbeam[4]/D"); sprintf(treeName, "run%04devents", myRun); eventsTree = new TTree(treeName, treeName); eventsTree -> Branch("EventHeaderBranch", &miniEH.burst, "burst/I:event:burstEvent:scaler10mhz:scaler6mhz:firstGated:isEmpty/O:notEmpty:S123inBeam:filledSegment:RFperiod/D:RFfreq:RFamp:TimeGlobal:SignalFactor");// branch for event header; eventsTree -> Branch("EventGADC", &evtEssentials.GADCevent[0], "GADCevent[40]/F"); eventsTree -> Branch("MPICevent", &evtEssentials.MPICevent[0], "MPICevent[40]/F"); eventsTree -> Branch("firstGADCsample", &evtEssentials.firstGADCsample, "firstGADCsample/I"); eventsTree -> Branch("bunchAction", &evtEssentials.bunchAction[0], "bunchAction[40]/I"); eventsTree -> Branch("scintFFT", &evtEssentials.scintFFT[0], "scintFFT[120]/F"); eventsTree -> Branch("mipCount", &evtEssentials.mipCount[0], "mipCount[40]/I"); eventsTree -> Branch("mipCount2", &evtEssentials.mipCount2[0], "mipCount2[40]/I"); eventsTree -> Branch("mipCount3", &evtEssentials.mipCount3[0], "mipCount3[40]/I"); eventsTree -> Branch("isIsolated", &evtEssentials.isIsolated[0], "isIsolated[40]/B"); eventsTree -> Branch("isCluster0", &evtEssentials.isCluster0[0], "isCluster0[40]/B"); eventsTree -> Branch("isCluster1", &evtEssentials.isCluster1[0], "isCluster1[40]/B"); eventsTree -> Branch("inScope", &evtEssentials.inScope[0], "inScope[40]/B"); eventsTree -> Branch("HGoverflow", &evtEssentials.HGoverflow[0], "HGoverflow[4]/B"); eventsTree -> Branch("LGoverflow", &evtEssentials.LGoverflow[0], "LGoverflow[4]/B"); eventsTree -> Branch("RFclust0", &evtEssentials.RFclust0[0], "RFclust0[5]/I"); eventsTree -> Branch("RFclust1", &evtEssentials.RFclust1[0], "RFclust1[5]/I"); eventsTree -> Branch("miniModule", &evtEssentials.miniModule[0], "miniModule[200]/F"); for (int iMod=0; iMod<5; iMod++) { TModule *Module = &Setup[iMod]; int iChan1=5; if (iMod==4) iChan1=4; // no sum for counters for (int iChan=0; iChanGetChannel(iChan); for (int iGain=0; iGain<2; iGain++) { TSignal *Signal = Channel->GetSignalLong(iGain); if (iGain==0) { // Pedestal Windows are same for both gains, do it once sprintf(branchName, "nPedWindows_mod%dchan%d", iMod, iChan); eventsTree -> Branch(branchName, Signal->GetNPedWindowsPointer(), "nPedWindows/I"); sprintf(branchName, "firstPedWindowSample_mod%dchan%d", iMod, iChan); eventsTree -> Branch(branchName, Signal->GetFirstSamplePointer(), "firstSample[25]/I"); sprintf(branchName, "lastPedWindowSample_mod%dchan%d", iMod, iChan); eventsTree -> Branch(branchName, Signal->GetLastSamplePointer(), "lastSample[25]/I"); } sprintf(branchName, "signal_mod%dchan%dgain%d", iMod, iChan, iGain); // MPI ADC signals, mV eventsTree -> Branch(branchName, Signal->GetAmpIFpoint(), "ampIF[512]/F"); if (iMod != 4) { sprintf(branchName, "current_mod%dchan%dgain%d", iMod, iChan, iGain); // Module currents, mA eventsTree -> Branch(branchName, Signal->GetAmpFinalFpoint(), "signalFinalF[512]/F"); } else { } } } } */ Int_t eventEntries = (Int_t)eventTree->GetEntries(); Int_t burstEntries = (Int_t)burstTree->GetEntries(); Int_t runEntries = (Int_t)runTree->GetEntries(); printf("Entries: Events=%d Bursts=%d Runs=%d\n", eventEntries, burstEntries, runEntries); // connect to Run branches runTree -> SetBranchAddress("ScintMIPs", &s123mips.scintMIP[0]); runTree -> SetBranchAddress("HVmod", &moduleHV[0]); runTree -> GetEntry(0); printf(" Scintillator MIPs (FFT) ->"); for (int i=0; i<3; i++) {printf(" S%d=%.1f", i+1, s123mips.scintMIP[i]);} printf("\n"); for (int i=0; i<4; i++) printf(" HV[%d]=%.1fV ", i, moduleHV[i]); printf("\n"); // connect to Burst tree branches burstTree -> SetBranchAddress("miniBirstHeader", &BH.burst); burstTree -> SetBranchAddress("nLaps", &cherEssentials.ns30); burstTree -> SetBranchAddress("LapSum", &cherEssentials.sum30[0]); burstTree -> SetBranchAddress("LapFill", &cherEssentials.lapFill[0]); //burstTree -> SetBranchAddress("LapBool", &cherEssentials.lapBool[0]); burstTree -> SetBranchAddress("LapActn", &cherEssentials.lapActn[0]); // connect to Event tree Branches eventTree->SetBranchAddress("EventHeaderBranch", &MH.burst); eventTree->SetBranchAddress("EventGADC", &evtEssentials.GADCevent[0]); eventTree -> SetBranchAddress("mipCount", &evtEssentials.mipCount[0]); eventTree -> SetBranchAddress("mipCount2", &evtEssentials.mipCount2[0]); eventTree -> SetBranchAddress("mipCount3", &evtEssentials.mipCount3[0]); for (int iMod=0; iMod<5; iMod++) { int iCh1=5; if (iMod==4) iCh1=4; for (int iCh=0; iCh SetBranchAddress(branchName, &pedWindows[id].nPedWindows); sprintf(branchName, "firstPedWindowSample_mod%dchan%d", iMod, iCh); eventTree -> SetBranchAddress(branchName, &pedWindows[id].firstSample[0]); sprintf(branchName, "lastPedWindowSample_mod%dchan%d", iMod, iCh); eventTree -> SetBranchAddress(branchName, &pedWindows[id].lastSample[0]); for (int iG=0; iG<2; iG++) { id=iG+2*iCh+10*iMod; sprintf(branchName, "signal_mod%dchan%dgain%d", iMod, iCh, iG); eventTree -> SetBranchAddress(branchName, &Module[id].ampI[0]); if (iMod != 4) { // for scintillators - different story!!!! sprintf(branchName, "current_mod%dchan%dgain%d", iMod, iCh, iG); eventTree -> SetBranchAddress(branchName, &Module[id].ampF[0]); } else { // FFT signal for PMTs not implemented yet! } } } } //============================================================== int burstEnt=0; for (int iEnt=0; iEntGetEntry(iEnt); printf("#%4d burst=%4d\t event=%5d burstEvent=%3d \n", iEnt, MH.burst, MH.event, MH.burstEvent); if (MH.burst != burstSet) { // first or new burst, load burst entry if (burstEntGetEntry(burstEnt++); if (BH.burst != MH.burst) { printf("Wrong burst number in Burst Tree BH.burst=%d\n", BH.burst); exit(-1); } burstSet=BH.burst; } else { printf("Burst Entry #%d is out of range: nBursts=%d\n", burstEnt, burstEntries); continue; } } if (MH.isEmpty) continue; moduleCanvas->Clear(); moduleCanvas->Divide(1,4); moduleCanvas1->Clear(); moduleCanvas1->Divide(1,4); int iZone=1; for (int iMod=0; iMod<4; iMod++) { // do not go into scintillators iMod=4; int iG=1; int iCh=4; int id=iG+2*iCh+10*iMod; double amin=0.; double amax=0.; double aminF=0.; double amaxF=0.; for (int i=0; i<512; i++) { // printf("id=%2d is=%3d ampI=%5.1f ampF=%5.1f\n", id, i, Module[id].ampI[i], Module[id].ampF[i]); if (amin >Module[id].ampI[i]) amin =Module[id].ampI[i]; if (amax Module[id].ampF[i]) aminF=Module[id].ampF[i]; if (amaxFcd(iZone); dummy->GetYaxis()->SetRangeUser(amin-0.05*dd, amax+0.05*dd); sprintf(titleH, "mod#%d", iMod); dummy->SetTitle(titleH); dummy->SetStats(0); dummy->DrawCopy(); myLine->SetLineWidth(13); myLine->SetLineColor(kYellow); for (int iWin=0; iWinDrawLine(time[pedWindows[id1].firstSample[iWin]], 0., time[pedWindows[id1].lastSample[iWin]], 0.); } myLine->SetLineWidth(2); myLine->SetLineColor(kBlack); for (int i=1; i<512; i++) { myLine->DrawLine(time[i-1], Module[id].ampI[i-1], time[i], Module[id].ampI[i] ); } moduleCanvas1->cd(iZone); dummy->GetYaxis()->SetRangeUser(aminF-0.05*df, amaxF+0.05*df); sprintf(titleH, "mod#%d", iMod); dummy->SetTitle(titleH); dummy->DrawCopy(); myLine->SetLineWidth(13); myLine->SetLineColor(kYellow); for (int iWin=0; iWinDrawLine(time[pedWindows[id1].firstSample[iWin]], 0., time[pedWindows[id1].lastSample[iWin]], 0.); } myLine->SetLineWidth(2); myLine->SetLineColor(kBlack); for (int i=1; iDrawLine(time[is0+i-1], Module[id].ampF[i-1], time[is0+i], Module[id].ampF[i] ); } myLine->SetLineWidth(1); for (int iCh1=0; iCh1<4; iCh1++) { myLine->SetLineColor(iCh1+1); int id2=iG+2*iCh1+10*iMod; for (int i=1; iDrawLine(time[is0+i-1], Module[id2].ampF[i-1], time[is0+i], Module[id2].ampF[i] ); } } iZone++; } // GADC response // double GADCmin=0.; double GADCmax=0.; double ddGADC=0.; for (int i=0; i<40 && 165.*(i+1)<6400.; i++) { if (GADCmin>evtEssentials.GADCevent[i]) GADCmin=evtEssentials.GADCevent[i]; if (GADCmaxGetYaxis()->SetRangeUser(GADCmin-0.05*ddGADC, GADCmax+0.05*ddGADC); moduleCanvas ->cd(iZone); dummy->SetTitle("Gated Cherenkov"); dummy->DrawCopy(); for (int i=0; i<40 && 165.*(i+1)<6400.; i++) { myLine->DrawLine(165.*i, evtEssentials.GADCevent[i], 165.*(i+1), evtEssentials.GADCevent[i]); if (i>0) { myLine->DrawLine(165.*i, evtEssentials.GADCevent[i-1], 165.*i, evtEssentials.GADCevent[i]); } } // S123 track counting double mipCountMAX=3.; for (int i=0; i<40 && 165.*(i+1)<6400.; i++) { if (mipCountMAXGetYaxis()->SetRangeUser(0., mipCountMAX+0.5); moduleCanvas1 ->cd(iZone); dummy->SetTitle("S123 trac counting"); dummy->DrawCopy(); myLine->SetLineColor(kBlack); for (int i=0; i<40 && 165.*(i+1)<6400.; i++) { myLine->DrawLine(165.*i, evtEssentials.mipCount[i], 165.*(i+1), evtEssentials.mipCount[i]); if (i>0) { myLine->DrawLine(165.*i, evtEssentials.mipCount[i-1], 165.*i, evtEssentials.mipCount[i]); } } myLine->SetLineColor(kRed); for (int i=0; i<40 && 165.*(i+1)<6400.; i++) { myLine->DrawLine(165.*i-10., evtEssentials.mipCount2[i], 165.*(i+1)-10., evtEssentials.mipCount2[i]); if (i>0) { myLine->DrawLine(165.*i-10., evtEssentials.mipCount2[i-1], 165.*i-10., evtEssentials.mipCount2[i]); } } myLine->SetLineColor(kBlue); for (int i=0; i<40 && 165.*(i+1)<6400.; i++) { myLine->DrawLine(165.*i+10., evtEssentials.mipCount3[i], 165.*(i+1)+10., evtEssentials.mipCount3[i]); if (i>0) { myLine->DrawLine(165.*i+10., evtEssentials.mipCount3[i-1], 165.*i+10., evtEssentials.mipCount3[i]); } } myLine->SetLineColor(kBlack); moduleCanvas ->Update(); moduleCanvas1->Update(); if (iqq != 2) { printf("push->"); cin >> iqq; if (iqq==0) break; } } f->Close(); }