#include #include #include "TFile.h" void quicksort( Double_t* arr1, Int_t* arr2, int left, int right) { auto i = left; auto j = right; auto tmp = arr1[0]; auto pivot = arr1[(int)((left + right)/2)]; // Partition while (i <= j) { while (arr1[i] < pivot) i++; while (arr1[j] > pivot) j--; if (i <= j) { // swap arr1 elements tmp = arr1[i]; arr1[i] = arr1[j]; arr1[j] = tmp; // swap arr2 elements tmp = arr2[i]; arr2[i] = arr2[j]; arr2[j] = tmp; i++; j--; } }; // Recursion if (left < j) quicksort(arr1, arr2, left, j); if (i < right) quicksort(arr1, arr2, i, right); return; } void TimeSync() { Char_t* f; TChain* MUSICdata = new TChain("tree"); f ="/fs2data/bavarians/MUSIC_Devel/FSUDAQ/Run_001_B0.root"; std::cout<Add(f); f ="/fs2data/bavarians/MUSIC_Devel/FSUDAQ/Run_001_B1.root"; std::cout<Add(f); f ="/fs2data/bavarians/MUSIC_Devel/FSUDAQ/Run_001_B2.root"; std::cout<Add(f); f ="/fs2data/bavarians/MUSIC_Devel/FSUDAQ/Run_001_B3.root"; std::cout<Add(f); double run_portion=0.01; //""""""""""""""""""""" //TIME synchronization of the digital board //""""""""""""""""""""" Double_t shiftTime[4] ={0.0, 0.0 , 0.0, 0.0}; //""""""""""""""""""""" //MAP //""""""""""""""""""""" //Left 0->15 //Right 16->31 //Individual{32=Grid, 33=S0, 34=cathode, 35=S17, 40-43 pulser}, //100=empty int Map_DAQCha_to_MUSICStrip[4][16]={{34,100, 1, 100, 33, 40, 5, 100, 0, 100, 9, 100, 17, 13, 100, 32}, {2, 100, 16, 100, 21, 41, 20, 100, 8, 100, 24, 100, 27, 28, 100, 14}, {19, 100, 3, 100, 6, 42, 7, 100, 25, 100, 11, 100, 12, 15, 100, 31}, {4, 100, 18, 36, 23, 43, 22, 100, 10, 100, 26, 100, 29, 30, 100, 35}}; //""""""""""""""""""""" //Data tree structure //""""""""""""""""""""" MUSICdata->SetBranchStatus("*", 0); int MAX_MULTI =100; unsigned short bd[MAX_MULTI] ; unsigned short ch[MAX_MULTI] ; unsigned long long e_t[MAX_MULTI] ; MUSICdata->SetBranchStatus("ch", 1);MUSICdata->SetBranchAddress("ch", &ch); MUSICdata->SetBranchStatus("bd", 1);MUSICdata->SetBranchAddress("bd", &bd); MUSICdata->SetBranchStatus("e_t", 1);MUSICdata->SetBranchAddress("e_t", &e_t); double Ibeam = 30000.; int nStat = MUSICdata->GetEntries(); std::cout<LR16)",5000, 1000,1000+1,80,0,80); Double_t* timestampVec = new Double_t[nStat]; Int_t* entryVec = new Int_t[nStat]; for(int j=0;jGetEntry(j); ChTimeBefore->Fill((e_t[0]*1e-9)*1e+4 , bd[0]*16+ch[0]); timestampVec[j]= (e_t[0] - shiftTime[bd[0]]*1e+9); entryVec[j]=j; } quicksort(timestampVec, entryVec,0,nStat-1); std::cout<<"sorted "<=0){ PositiveTime=j; break; } } //""""""""""""""""""""" //checking synchronization //""""""""""""""""""""" Double_t TimeEv = timestampVec[PositiveTime]*1e-9; //""""""""""""""""""""" //Plot definition //""""""""""""""""""""" TH2F* ChTimeAfter = new TH2F("ChTimeAfter", ";time(0.1 ms);channel(S0->LR16)",5000, 1000, 1000+1,80,0,80); for(int i=0;iGetEntry(entryVec[i]); ChTimeAfter->Fill((timestampVec[i]*1e-9)*1e+4, bd[0]*16+ch[0]); } TCanvas* c= new TCanvas("c","c",800,800);c->Divide(1,2); gStyle->SetPalette(kThermometer); c->cd(1);ChTimeBefore->Draw("colz"); c->cd(2);ChTimeAfter->Draw("colz"); }