UInt_t RanBit(UInt_t hRead) { // // UInt_t bit7 = (fgShreg & 0x00000040) != 0; UInt_t bit28 = (fgShreg & 0x08000000) != 0; UInt_t bit29 = (fgShreg & 0x10000000) != 0; UInt_t bit30 = (fgShreg & 0x20000000) != 0; UInt_t newbit = (bit30 ^ bit29 ^ bit28 ^ bit7) & 0x1; fgShreg = ( (hRead == 2 ? newbit : hRead) | (fgShreg << 1 )) & 0x3FFFFFFF; return newbit; } // UInt_t fgShreg = 416864460; // Initial value of 11000110110001101100011001100, 0x18D8D8CC void NewPseudoRanBitGenR(){ // define style here // general parameters gStyle->SetOptDate(0); gStyle->SetOptTitle(0); gStyle->SetStatColor(10); gStyle->SetStatH(0.2); gStyle->SetStatW(0.3); gStyle->SetOptStat(0); // canvas parameters gStyle->SetFrameBorderMode(0); gStyle->SetFrameBorderSize(0); gStyle->SetFrameFillColor(10); // pads parameters // gStyle->SetPadColor(39); gStyle->SetPadColor(0); gStyle->SetPadBorderMode(0); gStyle->SetPadBorderSize(0); gStyle->SetPadBottomMargin(0.18); gStyle->SetPadRightMargin(0.05); gStyle->SetPadLeftMargin(0.14); gStyle->SetLabelSize(0.04,"x"); gStyle->SetLabelSize(0.04,"y"); gStyle->SetTitleXSize(0.08); gStyle->SetPaperSize(10,12); gStyle->SetTitleYOffset(0.8); gStyle->SetTitleYSize(0.10); gROOT->ForceStyle(); // TString pstit; ofstream outfile; char ofile[200]; sprintf(ofile,"NewPseudoRanBitGenR.dat"); outfile.open(ofile); // b1 = new TCanvas("b1","Helicity Sequence",40,40,700,1000); b1->Divide(1,2); // h1 = new TH1F("h1","Helicity Pattern",6,-1,2); h1->SetFillColor(46); h2 = new TH2F("h2","Helicity Pattern",100,0,100,6,-1,2); h2->SetFillColor(38); // Predict the helicity pattern cout << " -> Predict the helicity pattern:" << endl; // The Shift Registor repeats every 2^(30) - 1 = 1,073,741,823 pairs, 25 days (500 Hz). for(Int_t j=0; j<100; j++){ cout << "LFSR = " << fgShreg << endl; Printf("fgShreg = 0x%0x",fgShreg); UInt_t eb = RanBit(2); outfile << eb << " " << fgShreg <Fill(eb); h2->Fill(j,eb); } b1->cd(1); h1->GetXaxis()->CenterTitle(); h1->GetXaxis()->SetTitleOffset(1.0); h1->GetXaxis()->SetTitleSize(0.06); TString tit = "Helicity Pattern"; h1->GetXaxis()->SetTitle(tit.Data()); h1->Draw(); b1->cd(2); h2->GetXaxis()->CenterTitle(); h2->GetXaxis()->SetTitleOffset(1.0); h2->GetXaxis()->SetTitleSize(0.06); TString tit = "Helicity Sequence, first window"; h2->GetXaxis()->SetTitle(tit.Data()); h2->Draw("BOX"); b1->cd(); b1->Update(); pstit = "NewPseudoRanBitGenR.gif"; b1->Print(pstit.Data()); }