#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 TimSyncComp() { Char_t* f; TChain* MUSICdata = new TChain("Data_R"); f ="/home/bavarians/exp/test0/DAQ/run/RAW/DataR_run.root"; std::cout<Add(f); double run_portion=0.01; //""""""""""""""""""""" //TIME synchronization of the digital board //""""""""""""""""""""" // Double_t shiftTime[4] ={0.30026482, 0.200206944, 0.100003416, 0.0};//pulser // Double_t shiftTime[4] ={0.192828788, 0.137373792 , 0.058816296, 0.0};//run28 Double_t shiftTime[4] ={0, 0 ,0., 0.0}; //""""""""""""""""""""" //MAP //""""""""""""""""""""" //Left 0->15 //Right 16->31 //Individual{32=Grid, 33=S0, 34=cathode, 35=S17}, //100=empty int Map_DAQCha_to_MUSICStrip[4][16]={{34,100, 1, 100, 33, 100, 5, 100, 0, 100, 9, 100, 17, 13, 100, 32}, {2, 100, 16, 100, 21, 100, 20, 100, 8, 100, 24, 100, 27, 28, 100, 14}, {19, 100, 3, 100, 6, 100, 7, 100, 25, 100, 11, 100, 12, 15, 100, 31}, {4, 100, 18, 36, 23, 100, 22, 100, 10, 100, 26, 100, 29, 30, 100, 35}}; //""""""""""""""""""""" //Data tree structure //""""""""""""""""""""" MUSICdata->SetBranchStatus("*", 0); UShort_t Channel; ULong64_t Timestamp; UShort_t Board; UShort_t Energy; MUSICdata->SetBranchStatus("Channel", 1);MUSICdata->SetBranchAddress("Channel", &Channel); MUSICdata->SetBranchStatus("Timestamp", 1);MUSICdata->SetBranchAddress("Timestamp", &Timestamp); MUSICdata->SetBranchStatus("Board", 1);MUSICdata->SetBranchAddress("Board", &Board); MUSICdata->SetBranchStatus("Energy", 1);MUSICdata->SetBranchAddress("Energy", &Energy); double Ibeam = 30000.; int nStat = MUSICdata->GetEntries(); std::cout<LR16)",5000, 0,0+0.5,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((Timestamp*1e-12)*1000. , Board*16+Channel); timestampVec[j]= (Timestamp - shiftTime[Board]*1e+12); entryVec[j]=j; } quicksort(timestampVec, entryVec,0,nStat-1); std::cout<<"sorted "<=0){ PositiveTime=j; break; } } //""""""""""""""""""""" //checking synchronization //""""""""""""""""""""" Double_t TimeEv = timestampVec[PositiveTime]*1e-12; //""""""""""""""""""""" //Plot definition //""""""""""""""""""""" TH2F* ChTimeAfter = new TH2F("ChTimeAfter", ";time(ms);channel(S0->LR16)",5000, 0, 0+0.5,80,0,80); for(int i=0;iGetEntry(entryVec[i]); ChTimeAfter->Fill((timestampVec[i]*1e-12)*1e+3, Board*16+Channel); } 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"); }