// Integral Theta float GetIntegralTheta(float thetaMin, float thetaMax, float ymin, float ymax, int loopnumber, float sigma) { //xmin und xmax sind die thetas float dy, theta, dTheta, y, integral, xmin, xmax, x; int accepted = 0; dTheta = thetaMax - thetaMin; //cout << "dtheta = " << dTheta << endl; dy = ymax - ymin; for (int i = 0; i < loopnumber; i++) { //cout << "NUMBER = " << i << endl; theta = tr3.Rndm() * dTheta + thetaMin; //cout << "theta = " << theta << endl; y = tr3.Rndm() * dy + ymin; //cout << "y = " << y << endl; xmin = theta - 5 * sigma; xmax = theta + 5 * sigma; x = GetRndGaus(theta, xmin, xmax, sigma); //cout << "x = " << x << endl; if (CheckCrossFctComplete(x, y)) { accepted++; } } integral = (((float) accepted) / (float) loopnumber) * dTheta * dy; cout << "Integralwert: " << integral << endl; return integral; }
float GetRndGaus(float mu, float xmin, float xmax, float sigma) { float xRnd = 0.; float yRnd = 0.; const float width = xmax - xmin; do { xRnd = width * tr3.Rndm() + xmin; yRnd = tr3.Rndm() / (sigma * sqrt(2 * M_PI)); } while (!CheckGaus(xRnd, yRnd, mu, sigma)); return xRnd; }
void eta() { // declare and define two histograms (their number of bins and boundaries) TH1F* h_eta = new TH1F("h_eta","",100,-10,10); TH1F* h_theta = new TH1F("h_theta","",100,0,TMath::Pi()); // start producing distributions // set the number of events to be 10000 const int neve=10000; TRandom3* myrndm = new TRandom3(); for(unsigned int i=0; i<neve; i++){ // produce a flat theta distributions float theta = myrndm->Rndm()*TMath::Pi(); h_theta->Fill(theta); float eta = -TMath::Log(TMath::Tan(0.5*theta)); h_eta->Fill(eta); } h_theta->Draw(); h_eta->Draw(); // save the histograms in a root file TFile* outFile = new TFile("eta_theta.root","recreate"); h_theta->Write(); h_eta->Write(); outFile->Close(); }
void gtime2(Int_t nsteps = 200, Int_t np=5000) { if (np > 5000) np = 5000; Int_t color[5000]; Double_t cosphi[5000], sinphi[5000], speed[5000]; TRandom3 r; Double_t xmin = 0, xmax = 10, ymin = -10, ymax = 10; TGraphTime *g = new TGraphTime(nsteps,xmin,ymin,xmax,ymax); g->SetTitle("TGraphTime demo 2;X;Y"); Int_t i,s; Double_t phi,fact = xmax/Double_t(nsteps); for (i=0;i<np;i++) { //calculate some object parameters speed[i] = r.Uniform(0.5,1); phi = r.Gaus(0,TMath::Pi()/6.); cosphi[i] = fact*speed[i]*TMath::Cos(phi); sinphi[i] = fact*speed[i]*TMath::Sin(phi); Double_t rc = r.Rndm(); color[i] = kRed; if (rc > 0.3) color[i] = kBlue; if (rc > 0.7) color[i] = kYellow; } for (s=0;s<nsteps;s++) { //fill the TGraphTime step by step for (i=0;i<np;i++) { Double_t xx = s*cosphi[i]; if (xx < xmin) continue; Double_t yy = s*sinphi[i]; TMarker *m = new TMarker(xx,yy,25); m->SetMarkerColor(color[i]); m->SetMarkerSize(1.5 -s/(speed[i]*nsteps)); g->Add(m,s); } g->Add(new TPaveLabel(.70,.92,.98,.99,Form("shower at %5.3f nsec",3.*s/nsteps),"brNDC"),s); } g->Draw(); }
void FillHisto(TH2D * h, int n, double * p) { const double mx1 = p[1]; const double my1 = p[3]; const double sx1 = p[2]; const double sy1 = p[4]; const double mx2 = p[6]; const double my2 = p[8]; const double sx2 = p[7]; const double sy2 = p[9]; //const double w1 = p[0]*sx1*sy1/(p[5]*sx2*sy2); const double w1 = 0.5; double x, y; for (int i = 0; i < n; ++i) { // generate randoms with larger gaussians rndm.Rannor(x,y); double r = rndm.Rndm(1); if (r < w1) { x = x*sx1 + mx1; y = y*sy1 + my1; } else { x = x*sx2 + mx2; y = y*sy2 + my2; } h->Fill(x,y); } }
int rndm(int range) { int x; do { x=rndmgen.Rndm()*range; } while(x==range); return x; }
int main() { //Teil a) int array[100]; for(int i = 0; i < 100; i++) { array[i] = i+1; //cout << array[i] << endl; } //Teil b) double array2d[100][8]; TRandom3 randomgen; for(int i = 0; i < 100; i++) { //0.Spalte array2d[i][0] = i+1; //1. Spalte array2d[i][1] = randomgen.Rndm(); //2. Spalte array2d[i][2] = randomgen.Rndm() * 10; //3. Spalte array2d[i][3] = randomgen.Rndm() * 10 + 20; //4. Spalte array2d[i][4]= randomgen.Gaus(); //5. Spalte array2d[i][5] = randomgen.Gaus(5, 2); //6. Spalte array2d[i][6] = array2d[i][0] * array2d[i][0]; //7. Spalte array2d[i][7] = TMath::Cos(array2d[i][0]); } return 0; }
Double_t Reconstruct( Double_t xt, TRandom3& R ) { // apply some Gaussian smearing + bias and efficiency corrections to fake reconstruction const Double_t cutdummy = -99999.0; Double_t xeff = 0.3 + (1.0 - 0.3)/20.0*(xt + 10.0); // efficiency Double_t x = R.Rndm(); if (x > xeff) return cutdummy; else { Double_t xsmear= R.Gaus(-2.5,0.2); // bias and smear return xt+xsmear; } }
int main(int argc, char** argv){ TApplication theApp("App", &argc, argv); // this must be instantiated only once TRandom3 *randgen = new TRandom3(0); Histogram h1("Example Histogram"); Histogram h2("Histogram Example"); Histogram h3("Histogram a Example"); h1.setXLabel("Xh1 $x^2$"); h1.setYLabel("Yh1"); //h1.show(); //h2.show(); //h3.show(); for (Int_t i = 0; i < 100000; i++) { Float_t x = randgen->Rndm(); Float_t y = randgen->Rndm(); while (x< y *y) { x = randgen->Rndm(); y = randgen->Rndm(); } h1.fill(x*350, 1.0f); h2.fill(350 - x*350, 1.0f); h3.fill(x*x*350, 1.0f); } Histostack hstack("test histostack"); hstack.add(h1); hstack.add(h2); hstack.add(h3); hstack.draw(); hstack.draw("Leg"); cerr << "Hanging for X11" << endl; theApp.Run(); return 0; }
double GetRandom(const double kp1, const double weight){ const double quantile(rng.Rndm()); double left(0.0), right(DBL_MAX); double middle(left+0.5*(right-left)); while(left<middle && middle<right){ if(TMath::Gamma(kp1, middle)<=quantile){ left=middle; }else{ right=middle; } middle=left+0.5*(right-left); } return middle*weight; }
void fit(Int_t i, Double_t va=-0.43, Double_t vb=0.){ sprintf(namestr,"%d_%.2f_%.2f",i,va,vb); Double_t g1, g2; g1 = 0.1*r.Rndm() - 0.05; g2 = r.Rndm() - 0.5; //a->setVal(va); //b->setVal(vb); //G001->setVal(g1); //G002->setVal(g2); //RooRealVar * G000 = new RooRealVar("G000", "G000", 0.5); //RooRealVar * G001 = new RooRealVar("G001", "G001", g1, -5., 5.); //RooRealVar * G002 = new RooRealVar("G002", "G002", g2, -5., 5.); //RooRealVar * G003 = new RooRealVar("G003", "G003", 0.0);//, -1., 1.); //RooRealVar * G004 = new RooRealVar("G004", "G004", 0.0);//, -1., 1.); //RooRealVar * a = new RooRealVar("a", "a", va); //RooRealVar * b = new RooRealVar("b", "b", vb); //RooRealVar * n = new RooRealVar("n", "n", 1000., -100., 5000.); RooRealVar G000("G000", "G000", 0.5); RooRealVar G001("G001", "G001", g1, -5., 5.); RooRealVar G002("G002", "G002", g2, -5., 5.); RooRealVar G003("G003", "G003", 0.0);//, -1., 1.); RooRealVar G004("G004", "G004", 0.0);//, -1., 1.); RooRealVar a("a", "a", va); RooRealVar b("b", "b", vb); RooRealVar n("n", "n", 1000., -100., 5000.); RooB2Kll pdf("pdf", "pdf", *cosTheta, G000, G001, G002, G003, G004, a, b, n); RooFitResult * fitresult = pdf.fitTo(*data,Save(kTRUE), Minos(kFALSE), NumCPU(4), SumW2Error(kTRUE)); RooPlot * frame = cosTheta->frame(); data->plotOn(frame); pdf.plotOn(frame); if(fitresult->minNll() == fitresult->minNll() && fitresult->minNll()>0 ) { fout << i << "\t" << a.getVal() << "\t" << b.getVal() << "\t" << fitresult->minNll() << "\t" << fitresult->status() << "\t" << G000.getVal() << "\t" << G001.getVal() << "\t" << G002.getVal() << "\t" << G003.getVal() << "\t" << G004.getVal() << endl; } gROOT->ProcessLine(".x ~/lhcb/lhcbStyle.C"); TCanvas c("fit","fit", 800, 800); frame->Draw(); c.SaveAs("fits/fit"+TString(namestr)+".png"); c.SaveAs("fits/fit"+TString(namestr)+".pdf"); }
void TestDetector() { TRandom3 *grandom = new TRandom3(0); //TDetector *d1 = new TDetector(); //TDetector *d2 = new TDetector(9, 8); //TDetector *d3 = new TDetector(9, 8, 0.5); TDetector *detector = new TDetector("../detector_config.txt"); /* cout << "Constructor default:" << endl; d1->Dump(); cout << "Constructor with standard permeability." << endl; d2->Dump(); cout << "Constructor with predefined permeability." << endl; d3->Dump();*/ //TDetector *detector = new TDetector(9, 8); //cout << "Edge length: " << detector->GetEdgeLength() << endl; /* vector<double> test; test.push_back(2); test.push_back(1); test.push_back(1); TSensor *sens = new TSensor(test, 0.2); detector->Dump(); detector->AddSensor(*sens);*/ unsigned int temp, NoE; temp = detector->GetNumberOfGroups(); NoE = detector->GetGroup(1).size(); cout << "Number of groups: " << temp << endl; cout << "Number of Elements: " << NoE << endl; for (unsigned int i = 0; i < temp; i++) { cout << "Id = " << i+1 << endl; for (unsigned int j = 0; j < detector->GetGroup(i+1).size(); j++) { detector->GetGroup(i+1).at(j)->Dump(); } } vector<double> position, sensor; // Event Position position.push_back(1); position.push_back(0); position.push_back(0); TEvent *event = new TEvent(100, position, 0, 0); detector->Detect(*event, grandom->Rndm()); cout << "Intensity = " << detector->GetSensors().at(0)->GetIntensity() << endl; }
int main (int argc, char** argv) { double phi, ctheta; std::ofstream output ("isotropo.txt", std::ios::out | std::ios::trunc); TRandom3* RandomNumber = new TRandom3(0); for (int i = 0; i < 5000000; i++) { if (i%500000 == 0) {std::cout << i << std::endl;} // generazione casuale dell'evento in cos(theta), phi phi = (RandomNumber -> Rndm()) * 2. * PI; ctheta = (RandomNumber->Rndm() * 2.) -1. ; output << ctheta << " " << phi << std::endl; } output.close(); return 0; }
void httpserver(const char* jobname = "job1", Long64_t maxcnt = 0) { TString filename = Form("%s.root", jobname); TFile *hfile = new TMemFile(filename,"RECREATE","Demo ROOT file with histograms"); // Create some histograms, a profile histogram and an ntuple TH1F *hpx = new TH1F("hpx","This is the px distribution",100,-4,4); hpx->SetFillColor(48); TH2F *hpxpy = new TH2F("hpxpy","py vs px",40,-4,4,40,-4,4); TProfile *hprof = new TProfile("hprof","Profile of pz versus px",100,-4,4,0,20); TNtuple *ntuple = new TNtuple("ntuple","Demo ntuple","px:py:pz:random:i"); hfile->Write(); // http server with port 8080, use jobname as top-folder name THttpServer* serv = new THttpServer(Form("http:8080?top=%s", jobname)); // fastcgi server with port 9000, use jobname as top-folder name // THttpServer* serv = new THttpServer(Form("fastcgi:9000?top=%s_fastcgi", jobname)); // dabc agent, connects to DABC master_host:1237, works only when DABC configured // THttpServer* serv = new THttpServer(Form("dabc:master_host:1237?top=%s_dabc", jobname)); // when read-only mode disabled one could execute object methods like TTree::Draw() serv->SetReadOnly(kFALSE); // One could specify location of newer version of JSROOT // serv->SetJSROOT("https://root.cern.ch/js/latest/"); // serv->SetJSROOT("http://jsroot.gsi.de/latest/"); gBenchmark->Start(jobname); // Create a new canvas. TCanvas *c1 = new TCanvas("c1","Dynamic Filling Example",200,10,700,500); c1->SetFillColor(42); c1->GetFrame()->SetFillColor(21); c1->GetFrame()->SetBorderSize(6); c1->GetFrame()->SetBorderMode(-1); // Fill histograms randomly TRandom3 random; Float_t px, py, pz; const Int_t kUPDATE = 1000; Long64_t i = 0; while (true) { random.Rannor(px,py); pz = px*px + py*py; Float_t rnd = random.Rndm(1); hpx->Fill(px); hpxpy->Fill(px,py); hprof->Fill(px,pz); // fill only first 25000 events in NTuple if (i<25000) ntuple->Fill(px,py,pz,rnd,i); if (i && (i%kUPDATE) == 0) { if (i == kUPDATE) hpx->Draw(); c1->Modified(); c1->Update(); if (i == kUPDATE) hfile->Write(); if (gSystem->ProcessEvents()) break; } i++; if ((maxcnt>0) && (i>=maxcnt)) break; } gBenchmark->Show(jobname); }
void randomcone(int condor_iter, string flist, string tag, int centmin, int centmax) { using namespace std; string buffer; vector<string> listoffiles; int nlines = 0; ifstream infile(flist.data()); if (!infile.is_open()) { cout << "Error opening file. Exiting." << endl; return; } else { while (!infile.eof()) { infile >> buffer; listoffiles.push_back(buffer); nlines++; } } HiForest * c = new HiForest(listoffiles[condor_iter].data(),"forest",cPPb,0); // TH2D * etaphi = new TH2D(); int nevents = c->GetEntries(); const int netabins = 48; TRandom3 r; float rConeEta = 0; float rConePhi = 0; float dR = 0.3; float thisdR = 0; float pfPtSum; float pfVsPtSum; float pfVsPtInitialSum; TFile * outf = new TFile(Form("randcone_%s_centmin%d_centmax%d_%d.root",tag.data(),centmin,centmax,condor_iter),"recreate"); TH1D * hpfPtSum = new TH1D("hpfPtSum","pfPtSum;#Sigma p_{T}",240,0,120); TH1D * hpfVsPtSum = new TH1D("hpfVsPtSum","pfVsPtSum;#Sigma p_{T}",200,-50,50); TH1D * hpfVsPtInitialSum = new TH1D("hpfVsPtInitialSum","hpfVsPtInitialSum;#Sigma p_{T}",200,-50,50); TH1D * hpfPtSumEta[netabins]; TH1D * hpfVsPtSumEta[netabins]; TH1D * hpfVsPtInitialSumEta[netabins]; for(int i = 0 ; i < netabins ; ++i) { hpfPtSumEta[i] = new TH1D(Form("hpfPtSumEta_%d",i),Form("pfPtSum_%d;#Sigma p_{T}",i),200,-100,100); hpfVsPtSumEta[i] = new TH1D(Form("hpfVsPtSumEta_%d",i),Form("pfVsPtSum_%d;#Sigma p_{T}",i),200,-100,100); hpfVsPtInitialSumEta[i] = new TH1D(Form("hpfVsPtInitialSumEta_%d",i),Form("hpfVsPtInitialSum_%d;#Sigma p_{T}",i),200,-100,100); } TH1D * hConeEta = new TH1D("hConeEta","hConeEta;#eta",netabins,-2.4,2.4); for(int i = 0 ; i < nevents ; ++i) { if(i%1000==0) cout<<i<<"/"<<nevents<<endl; c->GetEntry(i); if(c->evt.hiBin < centmin || c->evt.hiBin >= centmax) continue; rConeEta = 4.8*(r.Rndm()-0.5); // uniform dist. +- 2.4 eta rConePhi = 2*TMath::Pi()*(r.Rndm()-0.5); // uniform dist. +- pi hConeEta->Fill(rConeEta); int whichbin = hConeEta->FindBin(rConeEta); pfPtSum = 0.0; pfVsPtSum = 0.0; pfVsPtInitialSum = 0.0; for(int j = 0 ; j < c->pf.nPFpart ; ++j) { thisdR = getdR(rConeEta,c->pf.pfEta[j],rConePhi,c->pf.pfPhi[j]); if(thisdR < dR) { pfPtSum+=c->pf.pfPt[j]; pfVsPtSum+=c->pf.pfVsPt[j]; pfVsPtInitialSum+=c->pf.pfVsPtInitial[j]; } } hpfPtSum->Fill(pfPtSum); hpfVsPtSum->Fill(pfVsPtSum); hpfVsPtInitialSum->Fill(pfVsPtInitialSum); hpfPtSumEta[whichbin-1]->Fill(pfPtSum); hpfVsPtSumEta[whichbin-1]->Fill(pfVsPtSum); hpfVsPtInitialSumEta[whichbin-1]->Fill(pfVsPtInitialSum); } TH1D * hmeanpfPtSumEta = new TH1D("hmeanpfPtSumEta","hmeanpfPtSumEta;#eta;mean #Sigma p_{T}",netabins,-2.4,2.4); TH1D * hmeanpfVsPtSumEta = new TH1D("hmeanpfVsPtSumEta","hmeanpfVsPtSumEta;#eta;mean #Sigma p_{T}",netabins,-2.4,2.4); TH1D * hmeanpfVsPtInitialSumEta = new TH1D("hmeanpfVsPtInitialSumEta","hmeanpfVsPtInitialSumEta;#eta;mean #Sigma p_{T}",netabins,-2.4,2.4); for(int i = 1 ; i <= netabins ; ++i) { hmeanpfPtSumEta->SetBinContent(i,hpfPtSumEta[i-1]->GetMean()); hmeanpfPtSumEta->SetBinError(i,hpfPtSumEta[i-1]->GetMeanError()); hmeanpfVsPtSumEta->SetBinContent(i,hpfVsPtSumEta[i-1]->GetMean()); hmeanpfVsPtSumEta->SetBinError(i,hpfVsPtSumEta[i-1]->GetMeanError()); hmeanpfVsPtInitialSumEta->SetBinContent(i,hpfVsPtInitialSumEta[i-1]->GetMean()); hmeanpfVsPtInitialSumEta->SetBinError(i,hpfVsPtInitialSumEta[i-1]->GetMeanError()); } TH1D * one = new TH1D("one","",1,0,1); one->Fill(0.5); outf->Write(); outf->Close(); }
void pickRandomThetaPhiOnSphere(Double_t &phi, Double_t &theta) { phi=2*TMath::Pi()*fRandom.Rndm(); theta=TMath::Pi()*fRandom.Rndm(); }
void pickRandomDowngoingDirection(Double_t &phi, Double_t &theta) { phi=2*TMath::Pi()*fRandom.Rndm(); theta=0.5*TMath::Pi()*fRandom.Rndm(); }
int main(int argc, char *argv[]){ OptionParser(argc,argv); RooMsgService::instance().setGlobalKillBelow(RooFit::ERROR); RooMsgService::instance().setSilentMode(true); system(Form("mkdir -p %s",outdir_.c_str())); vector<string> procs; split(infilenames_,infilenamesStr_,boost::is_any_of(",")); TPython::Exec("import os,imp,re"); for (unsigned int i =0 ; i<infilenames_.size() ; i++){ TFile *infile = TFile::Open(infilenames_[i].c_str()); string outname =(string) TPython::Eval(Form("'%s'.split(\"/\")[-1].replace('root','_reduced.root')",infilenames_[i].c_str())); TFile *outfile = TFile::Open(outname.c_str(),"RECREATE") ; TDirectory* saveDir = outfile->mkdir("tagsDumper"); saveDir->cd(); RooWorkspace *inWS = (RooWorkspace*) infile->Get("tagsDumper/cms_hgg_13TeV"); RooRealVar *intLumi = (RooRealVar*)inWS->var("IntLumi"); RooWorkspace *outWS = new RooWorkspace("cms_hgg_13TeV"); outWS->import(*intLumi); std::list<RooAbsData*> data = (inWS->allData()) ; std::cout <<" [INFO] Reading WS dataset contents: "<< std::endl; for (std::list<RooAbsData*>::const_iterator iterator = data.begin(), end = data.end(); iterator != end; ++iterator ) { RooDataSet *dataset = dynamic_cast<RooDataSet *>( *iterator ); if (dataset) { RooDataSet *datasetReduced = (RooDataSet*) dataset->emptyClone(dataset->GetName(),dataset->GetName()); TRandom3 r; r.Rndm(); double x[dataset->numEntries()]; r.RndmArray(dataset->numEntries(),x); int desiredEntries = floor(0.5+ dataset->numEntries()*fraction_); int modFraction = floor(0.5+ 1/fraction_); int finalEventCount=0; for (int j =0; j < dataset->numEntries() ; j++){ if( j%modFraction==0){ finalEventCount++; } } float average_weight= dataset->sumEntries()/finalEventCount; for (int j =0; j < dataset->numEntries() ; j++){ if( j%modFraction==0){ dataset->get(j); datasetReduced->add(*(dataset->get(j)),average_weight); } } float entriesIN =dataset->sumEntries(); float entriesOUT =datasetReduced->sumEntries(); if(verbose_){ std::cout << "Original dataset " << *dataset <<std::endl; std::cout << "Reduced dataset " << *datasetReduced <<std::endl; std::cout << "********************************************" <<std::endl; std::cout << "fraction (obs) : " << entriesOUT/entriesIN << std::endl; std::cout << "fraction (exp) : " << fraction_ << std::endl; std::cout << "********************************************" <<std::endl; std::cout << "" <<std::endl; std::cout << "" <<std::endl; std::cout << "" <<std::endl; std::cout << "********************************************" <<std::endl; } outWS->import(*datasetReduced); } RooDataHist *datahist = dynamic_cast<RooDataHist *>( *iterator ); if (datahist) { RooDataHist *datahistOUT = (RooDataHist*) datahist->emptyClone(datahist->GetName(),datahist->GetName()); TRandom3 r; r.Rndm(); for (int j =0; j < datahist->numEntries() ; j++){ datahistOUT->add(*(datahist->get(j)),datahist->weight()); } float w =datahistOUT->sumEntries(); float z =datahist->sumEntries(); if(verbose_){ std::cout << "Original datahist " << *datahist <<std::endl; std::cout << "Reduced datahist " << *datahistOUT<<std::endl; std::cout << "********************************************" <<std::endl; std::cout << "WH fraction (obs) : " << w/(z) <<std::endl; std::cout << "WH fraction (exp) : " << fraction_ << std::endl; std::cout << "********************************************" <<std::endl; std::cout << "" <<std::endl; std::cout << "" <<std::endl; std::cout << "" <<std::endl; std::cout << "********************************************" <<std::endl; } outWS->import(*datahistOUT); } } saveDir->cd(); outWS->Write(); outfile->Close(); infile->Close(); } }
int testRandom3() { Float_t RefValue[] = // running using a seed of 4357 ROOT 5.13.07 and checked with GSL 1.8 { 0.999741749, 0.162909875, 0.282617805, 0.947201082, 0.231656543, 0.484973614, 0.957476957, 0.744305343, 0.540043658, 0.739952981, 0.759943798, 0.658636614, 0.315637622, 0.804403015, 0.519672115, 0.168572422, 0.47552973, 0.392313994, 0.221667687, 0.213190459,0.0303352042, 0.33353925, 0.194148851, 0.943716781, 0.579931675, 0.898304858, 0.665563931, 0.49861031, 0.560628257, 0.182284646, 0.296525531, 0.117408933, 0.0629176658, 0.648125575, 0.725418529, 0.637131158, 0.713885062,0.0995762432, 0.699267196, 0.10781247, 0.129242751, 0.502403039, 0.207779906, 0.288910306,0.0831747944, 0.128124215, 0.547371411,0.0823195996, 0.292141427, 0.891623737, 0.227117839, 0.431845463, 0.140733001, 0.400392135, 0.686946901, 0.170670911, 0.440820868, 0.045336565, 0.311296414, 0.506181051, 0.18241084, 0.511032015, 0.740788205, 0.365988627, 0.160808837, 0.460106785, 0.627836472, 0.677603688, 0.698196523, 0.478536868,0.0901075942, 0.338728522, 0.0952137967, 0.436541964, 0.474673352, 0.419245926, 0.777536852, 0.624610565, 0.98043655, 0.370430201, 0.830812636, 0.140806447, 0.744085307, 0.82973968, 0.391104318, 0.621956392, 0.346699478,0.0461695245, 0.613066321, 0.567374048, 0.498894026, 0.723802079, 0.144550525,0.0423031633, 0.310787023, 0.121641154, 0.242069671, 0.381058855, 0.440128537, 0.599795902, 0.644574654, 0.432626217, 0.555968262, 0.716841168, 0.642362515, 0.685776725,0.0961581462, 0.122933464,0.0569974151, 0.820072044, 0.125539286, 0.315745071, 0.180566925, 0.142227219, 0.664429613, 0.685189223, 0.191001933, 0.436343019, 0.964459225, 0.86816359, 0.130879965, 0.48444228, 0.374654451, 0.900475122, 0.178656787, 0.679635131, 0.62287431, 0.98365595, 0.44071478, 0.804737277, 0.994845061, 0.541550961, 0.255905455, 0.638945635, 0.57591027, 0.25872142, 0.191593001, 0.445663047, 0.149266509, 0.996723689, 0.121762222, 0.65153928,0.0277950978, 0.389977602, 0.827913044, 0.283813907, 0.610203644, 0.23641275, 0.41082105, 0.677714617, 0.847126588, 0.649256228, 0.0813826511, 0.120830484, 0.479199264, 0.777878358, 0.471977701, 0.943337511, 0.980800992, 0.334554731, 0.202667924, 0.342841234, 0.653544244, 0.682758797, 0.60993614,0.0999271029, 0.766254981, 0.735581528, 0.24113914, 0.263178711, 0.960869899, 0.423395737, 0.336058146,0.000249497825, 0.868841017,0.00375315035, 0.165846311,0.0118208411, 0.606455074, 0.729972019, 0.613824557, 0.965768184, 0.497098261, 0.529885403, 0.461607532, 0.713033701, 0.579959768, 0.682802555, 0.953921514,0.0236552036, 0.280110147, 0.869526353, 0.299333274, 0.319553603, 0.300951709, 0.941111486, 0.848127064, 0.753346129, 0.538244087, 0.408481381, 0.212371316,0.0761404021, 0.289934908,0.0197818337, 0.241247899, 0.384619165, 0.454906886, 0.373982521, 0.440188796, 0.117896808, 0.805429845, 0.164892641, 0.282529936, 0.172685399, 0.93584233, 0.68095306, 0.133696739, 0.254761223, 0.399444876, 0.369235365, 0.726361892, 0.277837459, 0.693569104, 0.500354689, 0.118405538, 0.151303335, 0.681446943, 0.720665918, 0.979646939, 0.696779111, 0.557210072, 0.680821482, 0.95535205, 0.598208956, 0.770453895, 0.913597486, 0.658958649, 0.670974613, 0.578185175, 0.95303929, 0.162923458, 0.335056986, 0.951824704, 0.109661644, 0.619302303, 0.956816742, 0.985243094,0.0707377489, 0.50233039, 0.680721226, 0.553320066, 0.587005581, 0.691620562, 0.46264791, 0.574254294, 0.072890088, 0.638266518, 0.387757288, 0.220960217,0.00223180233, 0.495656775, 0.191316523, 0.022265008, 0.903589021, 0.738628175, 0.44453089, 0.417702243, 0.760861122, 0.437753222, 0.190982861, 0.577112962, 0.132688343, 0.317824347, 0.48691649, 0.939091069, 0.933946281, 0.073660135, 0.612436295, 0.514748724, 0.624663582, 0.130645262, 0.645210441, 0.13414855, 0.652925968, 0.265210009, 0.381805269, 0.59021506, 0.669704082, 0.55433248,0.0195047602, 0.184346962, 0.991180462, 0.573677764, 0.637762085, 0.594857598, 0.515244688, 0.330693509, 0.39674245, 0.88396548, 0.771485266, 0.599075381,0.0247266297,0.0122587895, 0.698452319, 0.265991009, 0.736700721, 0.999972619, 0.749792316, 0.484955589, 0.823700529, 0.62277709, 0.902512094, 0.0565051287, 0.739077389, 0.37617622, 0.036800765, 0.776198219, 0.837354186, 0.34508193,0.0818426476, 0.222621545, 0.152476319, 0.401177195, 0.531612608, 0.811706602,0.0407775661, 0.117889008, 0.575189965, 0.832362208, 0.204641853, 0.238721773, 0.9969287, 0.258590596, 0.892055968, 0.846859788, 0.306583706, 0.0333624918, 0.706420498, 0.193615608, 0.508978138,0.0215451468, 0.672732793, 0.813562444, 0.807284052, 0.481526843, 0.537519095, 0.780848606, 0.335848908, 0.699259371, 0.425855299, 0.825240663, 0.945613692, 0.55484125, 0.710495188, 0.378360366, 0.648338731,0.0456727168, 0.155477323, 0.885353968, 0.721565725, 0.961667201, 0.430300885, 0.132031354, 0.439331209, 0.467187736, 0.410083217, 0.277196711, 0.278509559, 0.954620806, 0.804357491, 0.968510466, 0.999722791, 0.947160283, 0.248551138,0.0067049861, 0.444727315, 0.674048778, 0.496480361,0.0210092501, 0.831763222, 0.108545852,0.0931516394, 0.89020564, 0.445945211, 0.906906768, 0.554039821, 0.759434349, 0.815551384, 0.532968503,0.0551351462,0.0539856541, 0.89918819, 0.146907374, 0.482647314,0.0673029809, 0.281161865, 0.932849165, 0.507317933, 0.564503014, 0.8007132, 0.645887499, 0.309219498,0.0478066066, 0.25196583, 0.713881142, 0.670994017, 0.60528576, 0.148271899, 0.79525035, 0.665277353, 0.854302043, 0.810533677,0.0711439839,0.0687935678, 0.890466573, 0.758045957, 0.0703105873, 0.852094478, 0.775356902, 0.684895203, 0.234552787, 0.461575694, 0.936435457, 0.664946419, 0.45967959, 0.88782351, 0.574622261,0.0301686234, 0.767354721, 0.345478555, 0.609123143, 0.21754287, 0.643760561, 0.571392649, 0.802311049, 0.962335547, 0.401769856, 0.996553418, 0.745945812, 0.448411183, 0.39578428, 0.123389926, 0.532614913, 0.833379602, 0.91767313, 0.825607567, 0.4459154, 0.267136201, 0.6643989, 0.766860694, 0.665968275, 0.503955105, 0.835153702, 0.622405379, 0.457538918, 0.554983278, 0.36581371, 0.656302231, 0.917038669, 0.276054591, 0.121214441, 0.966178254, 0.697439008, 0.443547789, 0.630195824, 0.368346675, 0.238191956, 0.300273821, 0.710332172,0.0474748381, 0.492525443,0.0812539798, 0.122016782, 0.99310218, 0.355091027, 0.764863731, 0.904099543, 0.396109613, 0.817134856, 0.348974222, 0.266193634, 0.367501958, 0.752316213, 0.587800024, 0.489421095, 0.673474061, 0.328296139, 0.853945839, 0.832380736, 0.159588686, 0.322411022, 0.950173707, 0.095376712, 0.231019855, 0.860607752, 0.359627192, 0.984843699,0.0319756679, 0.828649914, 0.51680949, 0.489407924, 0.963977298, 0.960131739, 0.681816791, 0.860788169, 0.455829282, 0.332390656,0.0591498043, 0.452245977, 0.217354216, 0.34560744, 0.549971993, 0.317622252, 0.892976443, 0.49004545, 0.25647901, 0.968998638, 0.910636465, 0.226717598, 0.327828572, 0.28670209, 0.142515054,0.0992817392, 0.192332409, 0.308376869, 0.871415959, 0.391148786, 0.788660882, 0.200816041, 0.986475959, 0.882862126, 0.109862451, 0.354283255, 0.555742682, 0.690698458, 0.643815752, 0.363104285,0.0788627111, 0.200820414, 0.71697353, 0.744353746, 0.76763643, 0.245442451, 0.668009119, 0.886989377, 0.366849931, 0.531556628, 0.502843979, 0.31454367, 0.622541364,0.0199038582, 0.676355134, 0.429818622, 0.232835212, 0.987619457, 0.306572135, 0.494637038, 0.748614893, 0.891843561,0.0452854959, 0.427561072, 0.226978442, 0.484072985, 0.16464563,0.0898074883, 0.384263737,0.0238354723, 0.329734547, 0.531230736, 0.476683361, 0.877482474, 0.455501628, 0.497302495, 0.396184301, 0.886124728, 0.736070092, 0.108917595, 0.397921902, 0.842575021, 0.82620032, 0.936655165, 0.24558961, 0.639688616, 0.493335031, 0.0734495069, 0.780138101,0.0421121232, 0.701116477, 0.940523267, 0.70054817, 0.776760272, 0.192742581, 0.0069252688, 0.842983626, 0.919324176, 0.242083269, 0.190100674, 0.735084639, 0.164522319, 0.99030645, 0.98284794, 0.657169539,0.0187736442, 0.759596482, 0.357567611, 0.509016344, 0.738899681, 0.567923164, 0.289056634, 0.41501714, 0.981054561, 0.365884479, 0.517878261, 0.844209022, 0.968122653, 0.258894528, 0.478310441, 0.437340986, 0.379398001, 0.203081884, 0.550820748, 0.255542723, 0.550098031, 0.870477939, 0.241230214, 0.157108238, 0.218260827, 0.116277737, 0.749018275, 0.158290659, 0.476353907, 0.545327323, 0.878978121,0.0171442169, 0.542981987, 0.318018082, 0.788805343, 0.871721374, 0.738490409,0.0923330146, 0.301398643, 0.637103286, 0.571564271, 0.712810342, 0.644289242, 0.230476008, 0.971695586, 0.966159428, 0.291883909, 0.175285818, 0.312882552, 0.98465128, 0.568391354, 0.844468564, 0.144433908, 0.45994061, 0.607897905, 0.184122705, 0.342805493, 0.606432998, 0.838196585, 0.186188518,0.0302744689, 0.307391858, 0.125286029, 0.270394965, 0.874161481, 0.370509557, 0.89423337, 0.407995674, 0.881878469, 0.647951238, 0.236986727, 0.528807336, 0.293731542,0.0943204253, 0.934538626, 0.121679332, 0.34968176,0.0670268578, 0.642196769, 0.692447138, 0.334926733, 0.374244194, 0.313885051, 0.538738295, 0.098592523, 0.490514225, 0.32873567, 0.709725794, 0.88169803, 0.393000481, 0.854243273, 0.463776593, 0.52705639, 0.493309892, 0.267784336, 0.583077476,0.0573514167, 0.959336368, 0.771417173,0.0427184631, 0.498433369,0.0522942701, 0.56155145, 0.960361909, 0.619817314, 0.528628368, 0.698235179, 0.186162042, 0.553998168, 0.666120292, 0.152731049, 0.948750157, 0.186825789, 0.580512664, 0.851024442, 0.106865844, 0.675861737, 0.79604524, 0.657646103,0.00934952381, 0.206267588, 0.636420368,0.0382564603, 0.67771025, 0.677917925, 0.671684269, 0.396317716, 0.661597047, 0.633360383, 0.962124239, 0.992711418,0.0993448263,0.0678932741, 0.426013152, 0.947045502, 0.708326009, 0.466817846,0.0448362886, 0.748580922, 0.678370694, 0.210921343, 0.398490306, 0.953675585,0.0289022848, 0.935766569, 0.846930474, 0.662760176, 0.867910903, 0.652359324, 0.45280494, 0.305228982, 0.352034987, 0.279643402, 0.236045594,0.0270034608, 0.652062389, 0.712000227, 0.619930867, 0.125439078, 0.452789963, 0.92233151, 0.120844359, 0.403808975, 0.260290446, 0.778843638, 0.6678412, 0.0267894373, 0.491332301, 0.915060888, 0.704025347, 0.628200853, 0.578338467, 0.629156416, 0.730410649, 0.641318334, 0.463709335, 0.614291239, 0.254470656, 0.808682692, 0.22898373, 0.450477996, 0.874235142, 0.202773906, 0.523711192, 0.126518266, 0.579402899, 0.26188467, 0.207769057, 0.55283816, 0.851395364, 0.513594437, 0.558259845, 0.666148535, 0.998974657, 0.178274074, 0.116739636,0.0684255431, 0.622713377, 0.31448295, 0.889827933, 0.80647766, 0.429916949, 0.524695458, 0.45267553, 0.630743121, 0.566594485, 0.958860663, 0.908052286, 0.700898262, 0.377025384, 0.683796226, 0.198088462, 0.617400699, 0.413726158, 0.823588417, 0.755577948, 0.703097317, 0.364294278, 0.819786986, 0.751581763, 0.048769509, 0.528569003, 0.616748192, 0.270942831, 0.800841747, 0.235174223, 0.903786552, 0.258801569, 0.191336412, 0.012410342, 0.853413998, 0.621008712, 0.855861931, 0.140106201, 0.872687964, 0.708839735,0.0926409892,0.0207504195, 0.782636518,0.0300825236, 0.504610632,0.0816221782, 0.773493745, 0.872577282, 0.880031248, 0.883524299, 0.872427328, 0.458722225, 0.902298841, 0.547904952,0.0559884352, 0.591179888, 0.563941709, 0.776130076, 0.295569778,0.0408536533, 0.398567183, 0.28227462, 0.806716321, 0.507159362, 0.688150965, 0.49466404, 0.45454604, 0.421480091,0.0392517329,0.0911962031, 0.393815309, 0.135373195, 0.968650583, 0.811676111, 0.325965411, 0.961999178, 0.100281202, 0.102924612, 0.30725909, 0.33368206, 0.857966134, 0.522921736, 0.615500041, 0.981558684, 0.797484739, 0.198809674, 0.45670419, 0.570970797, 0.214908696, 0.686433314, 0.278602115, 0.179739848, 0.397497946, 0.162858935, 0.802621762,0.0836459133, 0.638270752, 0.230856518, 0.580094379, 0.864292514, 0.932738287, 0.821393124, 0.480590473, 0.636373016, 0.181508656, 0.469200501, 0.309276441, 0.668810431, 0.722341161, 0.574856669, 0.527854513, 0.809231559, 0.986882661, 0.323860496, 0.606396459, 0.759558966, 0.79096818,0.0699298142, 0.550465414,0.00929828244, 0.784629475, 0.689044114, 0.963588091, 0.516441598, 0.357178305, 0.482336892, 0.429959602, 0.996306147, 0.601176011, 0.785004207, 0.970542121, 0.487854549,0.0949267522, 0.979331773, 0.120877739, 0.630260336, 0.19424754, 0.213081703, 0.0145987798, 0.366671115, 0.340100777, 0.721786347, 0.367533113,0.0210335371, 0.131687992, 0.586759676, 0.73360464, 0.863635151, 0.136994646,0.0524269778, 0.406223408, 0.241656947, 0.472450703, 0.872215979, 0.454719233,0.0715790696, 0.314061244, 0.492823114, 0.741721134, 0.694783663, 0.982867872, 0.319748137, 0.804203704,0.0534678153, 0.746155348, 0.303474931,0.0930815139, 0.934531664, 0.746868186, 0.100048471, 0.720296508, 0.21075374, 0.96309675, 0.749189411, 0.739621932, 0.510072327,0.0872929865, 0.650020469, 0.0823648495, 0.726920745, 0.532618265, 0.749305866, 0.86126694,0.0346994482,0.0931224583, 0.655257095, 0.959517847, 0.487057231, 0.859895745, 0.084794421, 0.718541715, 0.850918328, 0.818884782, 0.71627446, 0.40822393, 0.63658567, 0.523838703, 0.372038872, 0.353426097, 0.598049047,0.0974868746, 0.276353038 }; Int_t rc1 = 0; Int_t rc2 = 0; TRandom3 r(4357); Float_t x; Int_t i; // check whether the sequence is ok or not for (i=0;i<1000;i++) { x = r.Rndm(); // printf("%e ",x-RefValue[i]); if(i%8==7) printf("\n"); if (TMath::Abs(x-RefValue[i]) > 10e-8) { printf("i=%d x=%.8f but should be %.8f\n",i,x,RefValue[i]); rc1 += 1; } } // check whether a state can be saved and restored TFile *file = new TFile("random3.root","RECREATE"); file->SetCompressionLevel(0); r.Write("r"); delete file; file = new TFile("random3.root"); TRandom3 *rs = (TRandom3*) file->Get("r"); for (i=0;i<1000;i++) { if (r.Rndm() - rs->Rndm() != 0) rc2 += 1; } if (rc2 != 0) printf("state restoration failed\n"); return rc1 + rc2; }
int main(int argc, char *argv[]) { cout << argv[0] << endl; int numberIterations = 1e6; if (argc > 1) { numberIterations = atoi(argv[1]); } //tr3 = new TRandom3(); //A1.(i) TH1F histogramGaus("histogramGaus", "Gausverteilung um #pi/2 mit #sigma=0.1", numberIterations / 100, (M_PI / 2) - 0.6, (M_PI / 2) + 0.6); const float mu = M_PI / 2; float xmin = mu - 5 * SIGMA; float xmax = mu + 5 * SIGMA; for (int i = 0; i < iterations; i++) { xRndGaus = GetRndGaus(mu, xmin, xmax, SIGMA); histogramGaus.Fill(xRndGaus); } //A1.(ii) float theta, thetaRec; TH1F histogramTheta("histogramTheta", "Normalverteilung for 0.5 #leq #theta #leq 2.8", 1000, 0, 2.5); TH1F histogramThetaFehler("histogramThetaFehler", "Faltung Gaus mit Normalverteilung, ", 1000, 0, 2.5); for (int i = 0; i < iterations; i++) { theta = tr3.Rndm() * 1.5 + 0.5; xmin = theta - 5 * SIGMA; xmax = theta + 5 * SIGMA; thetaRec = GetRndGaus(theta, xmin, xmax, SIGMA); histogramTheta.Fill(theta); histogramThetaFehler.Fill(thetaRec); } //A1.(iii) // Integration von thete > 1.8 bis // Integriere von (pi/2)-0.1 bis (pi/2)+0.1 i_a = (2 * M_PI) * GetIntegralTheta(1.8, M_PI - 0.05, 0, 8, numberIterations, SIGMA); //Integral über Phi =*2pi cout << "(i) A= " << i_a << endl; i_events = GetEvents(i_a, 2000); cout << "Number of Events: " << i_events << endl; TCanvas* c1 = new TCanvas("c1", "c1", 800, 600); gStyle->SetOptStat(0); c1->Divide(2, 2); c1->cd(1); histogramGaus.Draw(); c1->cd(2); histogramTheta.Draw(); c1->cd(3); histogramThetaFehler.Draw(); c1->cd(4); histogramTheta.SetTitle("Gemeinsames Bildchen"); //histogramTheta.SetColor("kRed"); histogramTheta.SetLineStyle(3001); histogramTheta.SetLineColor(kRed); histogramTheta.Draw(); histogramThetaFehler.Draw("SAME"); c1->SaveAs("Gaus.png"); /* //A1.(ii) //Integral über toten Winkelbereich wird abgezogen float ii_a, ii_dead, ii_res; int ii_events; ii_a = (2*M_PI)*GetIntegra TH1F histogramGaus("histogramGaus", "Gausverteilung um #pi/2 mit #sigma=0.1", 100, 1, 2); for (int i=0; i<iterations; i++){ xRndGaus = GetRndGaus(); //cout << i << endl; //cout << "Random xGaus: " << xRndGaus << endl; histogramGaus.Fill(xRndGaus); } //xRndGaus = GetRndGaus(); //cout << "Random xGaus: " << xRndGaus << endl; //A1.(ii) float theta, thetaRec; TH1F histogramTheta("histogramTheta", "Normalverteilung for 0.5 #leq #theta #leq 2.8", 100, 0, 3); TH1F histogramThetaFehler("histogramThetaFehler", "Faltung Gauß mit Normalverteilung, ", 100,0,3); for (int i=0; i<iterations; i++){ theta = tr3.Rndm()*1.5+0.5; thetaRec = GetRndGaus()+ TH1F histogramGaus("histogramGaus", "Gausverteilung um #pi/2 mit #sigma=0.1", 100, 1, 2); for (int i=0; i<iterations; i++){ xRndGaus = GetRndGaus(); //cout << i << endl; //cout << "Random xGaus: " << xRndGaus << endl; histogramGaus.Fill(xRndGaus); } //xRndGaus = GetRndGaus(); //cout << "Random xGaus: " << xRndGaus << endl; //A1.(ii)s float theta, thetaRec; TH1F histogramTheta("histogramTheta", "Normalverteilung for 0.5 #leq #theta #leq 2.8", 100, 0, 3); TH1F histogramThetaFehler("histogramThetaFehler", "Faltung Gauß mit Normalverteilung, ", 100,0,3); for (int i=0; i<iterations; i++){ theta = tr3.Rndm()*1.5+0.5; thetaRec = GetRndGaus()+lTheta(0.05, M_PI-0.05,0,2,1000000); ii_dead = (0.3-0.2)*GetIntegralTheta(1.0,1.5,0,2,1000000); //Integral über Phi =*0.1 ii_res = ii_a-ii_dead; cout << "(ii) A'(ohne Strahlachse)= " << ii_a << endl; cout << "A''(Blind_durch_Katze)= " << ii_dead << endl; cout << "A=A'-A''= " << ii_res << endl; ii_events = GetEvents(ii_res, 2000); cout << "Number of Events: " << ii_events << endl; */ }
void simul(int Nevents = 200000, double Twist_width = 0.04, double Asy_wdith = 0.06){ char name[200]; TFile *OutFile=new TFile("Simu3.root","recreate"); OutFile->cd(); TRandom3 ran; //20-25% events have ~1092 multiplicity const int MEAN_MULT =1092,SIGMA_MULT=86 ;//Mean and rms of total multiplicity (det0+det1+det2) int min=MEAN_MULT-5*SIGMA_MULT; int max=MEAN_MULT+5*SIGMA_MULT; if(min<0) min=0; TF1 *Mult_func=new TF1("mult_func","exp(-(x-[0])*(x-[0])/(2*[1]*[1]))",min,max); Mult_func->SetParameter(0,MEAN_MULT ); Mult_func->SetParameter(1,SIGMA_MULT); // TFile* fout = new TFile("toyout.root","recreate"); TF1* v2_func=new TF1("v2_func","x*exp(-(x*x+[0]*[0])/(2*[1]))*TMath::BesselI0(x*[0]/[1])",0,0.40); v2_func->SetParameter(0,9.13212e-02); v2_func->SetParameter(1,1.20361e-03); // Float_t v2 =0 ;//true v2 at eta=0, this will be the refer Float_t Psi2 =0 ;//true Psi2 at eta=0 float vncut[] = {0.00, 0.04, 0.06,0.1, 0.12, 0.14, 0.15}; TProfile* hpr_qn[2]; for (int iq=0; iq<2; iq++) { sprintf(name, "hpr_qn_%d", iq); hpr_qn[iq] = new TProfile(name,"", 7, 0, 7); } TH1* hebin = new TH1D("hebin","", 7, 0, 7); TH1* hmul = new TH1D("hmul","", 2000, 0, 2000); TH1* hmuleta = new TH1D("hmuleta","", NETA, -ETAMAX, ETAMAX); TH1* hmulphi = new TH1D("hmulphi","", 120 , -PI, PI); TH1* hv2 = new TH1D("hv2","",1000, 0, 0.5); TH1* hv4 = new TH1D("hv4","",1000, 0, 0.5); double q2[2]; double q4[2]; float qw; for(int iev=0; iev<Nevents; iev++){ if(iev%10000==0) cout<<iev<<endl; v2 = v2_func->GetRandom();//0.05;//True v2 Psi2 = ((ran.Rndm()-0.5)*2*PI)/2.0; //True Psi_2 angle // int ntrk = 1092; int ntrk = 8000; qw = 0; std::memset(q2, 0, sizeof(q2) ); std::memset(q4, 0, sizeof(q4) ); for(int itrk =0; itrk<ntrk; itrk++){ float phi = (ran.Rndm()-0.5)*2*PI;//random angle for the particle float trk_vn = v2 ; float trk_psin = Psi2; phi =add_flow(phi ,trk_vn, trk_psin); q2[0] += cos(2*phi); q2[1] += sin(2*phi); q4[0] += cos(4*phi); q4[1] += sin(4*phi); qw++; }//end of itrk double mv2 = sqrt(q2[0]*q2[0] + q2[1]*q2[1]); double mv4 = sqrt(q4[0]*q4[0] + q4[1]*q4[1]); mv2 = mv2/qw; mv4 = mv4/qw; int ebin = 0; for (int j=0; j<7; j++) { if(mv2>= vncut[7-1-j]){ ebin = 7-1-j; break; } } hv2->Fill( mv2 ); hv4->Fill( mv4 ); hpr_qn[0]->Fill(ebin, mv2); hpr_qn[1]->Fill(ebin, mv4); hebin->Fill( ebin ); }//end of iev float xx[7] = {0}; float xxE[7] = {0}; float yy[7] = {0}; float yyE[7] = {0}; for (int j=0; j<7; j++) { xx[j] =hpr_qn[0]->GetBinContent( j+1); xxE[j] =hpr_qn[0]->GetBinError( j+1); yy[j] =hpr_qn[1]->GetBinContent( j+1); yyE[j] =hpr_qn[1]->GetBinError( j+1); } TGraphErrors* gr = new TGraphErrors(7,xx, yy, xxE, yyE); hv2->Write(); hv4->Write(); gr->SetName("gr"); gr->Write(); hebin->Write(); hpr_qn[0]->Write(); hpr_qn[1]->Write(); v2_func->Write(); cout<<"Task ends"<<endl; }//end of sim
int main(int iargv, const char **argv) { ///// //... simulate the output from java application with rates TRandom3 * rdn = new TRandom3(0); //........................................................ //.... start with the header from the java application std::ifstream * header = new std::ifstream("check-header.txt",std::ifstream::in); while (1) { std::string output; (*header) >> output; if (! header->good() ) break; std::cout << output << '\n'; } std::cout << "===START===" << std::endl; //........................................................ float wfactor=1; for( int i=0; i < 1100; ++i) // while(1) { //TTU_1 for(int ttu=1; ttu <= 3; ++ttu) { for( int trig=8; trig <= 9; ++trig) { if (ttu == 2 && trig == 9 ) continue; if (ttu == 3 && trig == 9 ) wfactor = 5.0; else wfactor = 1.0; int wheel = (int) 100 + wfactor*trig*( (rdn->Rndm()) * ( 2.0 )); std::cout << wheel << " "; for( int k=0; k<12; ++k ) { int sector = (int) (k+5) + 10*wfactor*( (rdn->Rndm()) * ( .8 )); std::cout << sector << " "; } std::cout << '\n'; } } gSystem->Sleep(1); } //std::cout << -1 << '\n'; return 1; }
int main() { // creat 224 array // creat 8 arry int frame[FRM]; int crc[8] = {}; int crcTemp[8]; int flipN; unsigned equ = 0; unsigned nequ = 0; TRandom3 rnd; double rndTemp; static double div[224]; // Initialize global variable for (int n=0; n<224; n++) div[n] = n / 224.0; // 1 million loop start for (int j=0; j<1000000; j++) { for (int i=0; i<FRM; i++) { rndTemp = rnd.Rndm(); //while (rndTemp == 0.5) //rndTemp = rnd.Rndm(); frame[i] = randTo0or1(rndTemp); // Generate a random number between 0 and 1 //std::cout << "frame " << i << " " << frame[i] << std::endl; } // go through CRC CRC(frame, crc); // store crc data to crcTemp for (int i=0; i<8; i++) crcTemp[i] = crc[i]; // flip one element flipN = randTo0to223(rnd.Rndm(), div); frame[flipN] = !frame[flipN]; // 2nd go through CRC CRC(frame, crc); // compare crc with crcTemp check(crcTemp, crc) ? equ++ : nequ++ ; } // end of 1 million loop std::cout << "equ emans difference can not be tested" << std::endl; std::cout << "equ " << equ << std::endl; std::cout << "nequ means difference can be tested" << std::endl; std::cout << "nequ " << nequ << std::endl; return 0; }
int addAgedVarsTPfinal(TString infname, TString outfile){ cout << "Processing File " << infname << endl; TFile *f = TFile::Open(infname.Data(), "READ"); if (! f || f->IsZombie()) { cout << "File does not exist!" << endl; return 1; } TTree* t = (TTree*)f->Get("t"); if (! t || t->IsZombie()) { cout << "Tree does not exist!" << endl; return 2; } // old branches Float_t lep1pt; Float_t lep1eta; Float_t lep1phi; Float_t lep2pt; Float_t lep2eta; Float_t lep2phi; Int_t nleps; Float_t pujetmet; Float_t pujetmetphi; Float_t pujetmt; Int_t nb; Int_t nbgen; Int_t ncgen; Float_t bjet1pt; Float_t bjet1eta; Float_t bjet2pt; Float_t bjet2eta; TBranch* b_lep1pt; TBranch* b_lep1eta; TBranch* b_lep1phi; TBranch* b_lep2pt; TBranch* b_lep2eta; TBranch* b_lep2phi; TBranch* b_nleps; TBranch* b_pujetmet; TBranch* b_pujetmetphi; TBranch* b_pujetmt; TBranch* b_nb; TBranch* b_nbgen; TBranch* b_ncgen; TBranch* b_bjet1pt; TBranch* b_bjet1eta; TBranch* b_bjet2pt; TBranch* b_bjet2eta; // new branches Float_t agedweight = 1.; Int_t agednleps = -999; Float_t agedlep1pt = -999.; Float_t agedlep1eta = -999.; Float_t agedlep1phi = -999.; Float_t smearmet = -999.; Float_t smearmetphi = -999.; Float_t smearmt = -999.; // random generator TRandom3 rand; const float sigma = 20.; // smear by 20 GeV //------------------------------------------------------------- // Removes all non *_CMS2.* branches //-------------------------------------------------------------` t->SetBranchStatus("*", 1); TFile *out = TFile::Open(outfile.Data(), "RECREATE"); TTree *clone; clone = t->CloneTree(-1, "fast"); cout << "Cloning to File " << outfile << endl; //------------------------------------------------------------- // existing branches clone->SetBranchAddress("lep1pt" , &lep1pt , &b_lep1pt ); clone->SetBranchAddress("lep1eta" , &lep1eta , &b_lep1eta ); clone->SetBranchAddress("lep1phi" , &lep1phi , &b_lep1phi ); clone->SetBranchAddress("lep2pt" , &lep2pt , &b_lep2pt ); clone->SetBranchAddress("lep2eta" , &lep2eta , &b_lep2eta ); clone->SetBranchAddress("lep2phi" , &lep2phi , &b_lep2phi ); clone->SetBranchAddress("nleps" , &nleps , &b_nleps ); clone->SetBranchAddress("pujetmet" , &pujetmet , &b_pujetmet ); clone->SetBranchAddress("pujetmetphi", &pujetmetphi, &b_pujetmetphi ); clone->SetBranchAddress("pujetmt" , &pujetmt , &b_pujetmt ); clone->SetBranchAddress("nb" , &nb , &b_nb ); clone->SetBranchAddress("nbgen" , &nbgen , &b_nbgen ); clone->SetBranchAddress("ncgen" , &ncgen , &b_ncgen ); clone->SetBranchAddress("bjet1pt" , &bjet1pt , &b_bjet1pt ); clone->SetBranchAddress("bjet1eta" , &bjet1eta , &b_bjet1eta ); clone->SetBranchAddress("bjet2pt" , &bjet2pt , &b_bjet2pt ); clone->SetBranchAddress("bjet2eta" , &bjet2eta , &b_bjet2eta ); // new branches TBranch* b_agedweight = clone->Branch("agedweight", &agedweight, "agedweight/F"); TBranch* b_agednleps = clone->Branch("agednleps", &agednleps, "agednleps/I"); TBranch* b_agedlep1pt = clone->Branch("agedlep1pt", &agedlep1pt, "agedlep1pt/F"); TBranch* b_agedlep1eta = clone->Branch("agedlep1eta", &agedlep1eta, "agedlep1eta/F"); TBranch* b_agedlep1phi = clone->Branch("agedlep1phi", &agedlep1phi, "agedlep1phi/F"); TBranch* b_smearmet = clone->Branch("smearmet", &smearmet, "smearmet/F"); TBranch* b_smearmetphi = clone->Branch("smearmetphi", &smearmetphi, "smearmetphi/F"); TBranch* b_smearmt = clone->Branch("smearmt", &smearmt, "smearmt/F"); Long64_t nentries = t->GetEntries(); //Long64_t nentries = 100; for(Long64_t i = 0; i < nentries; i++) { clone->GetEntry(i); agedweight = 1.; // set weight for reduced btagging eff if (nb == 2) { // both jets are from heavy flavor - use both SFs if ((nbgen+ncgen) == 2) { agedweight *= getBtagSF(bjet1pt,bjet1eta); agedweight *= getBtagSF(bjet2pt,bjet2eta); } // only one HF jet - randomly guess which is fake else if ((nbgen+ncgen) == 1) { if (rand.Rndm() > 0.5) agedweight *= getBtagSF(bjet1pt,bjet1eta); else agedweight *= getBtagSF(bjet2pt,bjet2eta); } } // cout << "nb: " << nb << ", nbgen: " << nbgen << ", ncgen: " << ncgen // << ", bjet1 pt: " << bjet1pt << ", eta: " << bjet1eta // << ", bjet2 pt: " << bjet2pt << ", eta: " << bjet2eta // << ", agedweight: " << agedweight << endl; // reduce lepton efficiency by 0.84 if (nleps > 0) { int keeplep1 = 1; int keeplep2 = 1; // roll the dice for each lepton if (rand.Rndm() > 0.84) keeplep1 = 0; if (nleps == 1 || rand.Rndm() > 0.84) keeplep2 = 0; agednleps = keeplep1+keeplep2; // cout << "nleps: " << nleps << ", keeplep1: " << keeplep1 // << ", keeplep2: " << keeplep2 << ", agednleps: " << agednleps << endl; if (keeplep1 == 1) { agedlep1pt = lep1pt; agedlep1eta = lep1eta; agedlep1phi = lep1phi; } else if (keeplep2 == 1) { agedlep1pt = lep2pt; agedlep1eta = lep2eta; agedlep1phi = lep2phi; } else { agedlep1pt = -999; agedlep1eta = -999; agedlep1phi = -999; } } // smear met and propagate to MT float metx = pujetmet * cos(pujetmetphi); float mety = pujetmet * sin(pujetmetphi); float smearmetx = metx + rand.Gaus(0,sigma); float smearmety = mety + rand.Gaus(0,sigma); TVector2 smearmetvec(smearmetx,smearmety); smearmet = smearmetvec.Mod(); smearmetphi = smearmetvec.Phi(); if (agedlep1pt > 0.) { smearmt = sqrt( 2 * smearmet * agedlep1pt * ( 1 - cos( smearmetphi - agedlep1phi) ) ); } else { smearmt = -99.; } // cout << "pujetmet: " << pujetmet << ", pujetmetphi: " << pujetmetphi // << ", smearmet: " << smearmet << ", smearmetphi: " << smearmetphi // << ", pujetmt: " << pujetmt << ", smearmt: " << smearmt << endl; // fill new branches b_agedweight->Fill(); b_agednleps->Fill(); b_agedlep1pt->Fill(); b_agedlep1eta->Fill(); b_agedlep1phi->Fill(); b_smearmet->Fill(); b_smearmetphi->Fill(); b_smearmt->Fill(); } //------------------------------------------------------------- clone->Write(); out->Close(); f->Close(); cout << "Processed Events: " << nentries << endl; return 0; }
int main(int argc, char *argv[]){ OptionParser(argc,argv); RooMsgService::instance().setGlobalKillBelow(RooFit::ERROR); RooMsgService::instance().setSilentMode(true); system(Form("mkdir -p %s",outdir_.c_str())); vector<string> procs; split(infilenames_,infilenamesStr_,boost::is_any_of(",")); TPython::Exec("import os,imp,re"); const char * env = gSystem->Getenv("CMSSW_BASE") ; std::string globeRt = env; TPython::Exec(Form("buildSMHiggsSignalXSBR = imp.load_source('*', '%s/src/flashggFinalFit/Signal/python/buildSMHiggsSignalXSBR.py')",globeRt.c_str())); TPython::Eval(Form("buildSMHiggsSignalXSBR.Init%dTeV()", 13)); for (unsigned int i =0 ; i<infilenames_.size() ; i++){ int mH =(int) TPython::Eval(Form("int(re.search('_M(.+?)_','%s').group(1))",infilenames_[i].c_str())); double WH_XS = (double)TPython::Eval(Form("buildSMHiggsSignalXSBR.getXS(%d,'%s')",mH,"WH")); double ZH_XS = (double)TPython::Eval(Form("buildSMHiggsSignalXSBR.getXS(%d,'%s')",mH,"ZH")); float tot_XS = WH_XS + ZH_XS; float wFrac= WH_XS /tot_XS ; float zFrac= ZH_XS /tot_XS ; std::cout << "mass "<< mH << " wh fraction "<< WH_XS /tot_XS << ", zh fraction "<< ZH_XS /tot_XS <<std::endl; TFile *infile = TFile::Open(infilenames_[i].c_str()); string outname =(string) TPython::Eval(Form("'%s'.split(\"/\")[-1].replace(\"VH\",\"WH_VH\")",infilenames_[i].c_str())); TFile *outfile = TFile::Open(outname.c_str(),"RECREATE") ; TDirectory* saveDir = outfile->mkdir("tagsDumper"); saveDir->cd(); RooWorkspace *inWS = (RooWorkspace*) infile->Get("tagsDumper/cms_hgg_13TeV"); RooRealVar *intLumi = (RooRealVar*)inWS->var("IntLumi"); RooWorkspace *outWS = new RooWorkspace("cms_hgg_13TeV"); outWS->import(*intLumi); std::list<RooAbsData*> data = (inWS->allData()) ; std::cout <<" [INFO] Reading WS dataset contents: "<< std::endl; for (std::list<RooAbsData*>::const_iterator iterator = data.begin(), end = data.end(); iterator != end; ++iterator ) { RooDataSet *dataset = dynamic_cast<RooDataSet *>( *iterator ); if (dataset) { string zhname =(string) TPython::Eval(Form("'%s'.replace(\"wzh\",\"zh\")",dataset->GetName())); string whname =(string) TPython::Eval(Form("'%s'.replace(\"wzh\",\"wh\")",dataset->GetName())); RooDataSet *datasetZH = (RooDataSet*) dataset->emptyClone(zhname.c_str(),zhname.c_str()); RooDataSet *datasetWH = (RooDataSet*) dataset->emptyClone(whname.c_str(),whname.c_str()); TRandom3 r; r.Rndm(); double x[dataset->numEntries()]; r.RndmArray(dataset->numEntries(),x); for (int j =0; j < dataset->numEntries() ; j++){ if( x[j] < wFrac){ dataset->get(j); datasetWH->add(*(dataset->get(j)),dataset->weight()); } else{ dataset->get(j); datasetZH->add(*(dataset->get(j)),dataset->weight()); } } float w =datasetWH->sumEntries(); float z =datasetZH->sumEntries(); if(verbose_){ std::cout << "Original dataset " << *dataset <<std::endl; std::cout << "WH dataset " << *datasetWH <<std::endl; std::cout << "ZH dataset " << *datasetZH <<std::endl; std::cout << "********************************************" <<std::endl; std::cout << "WH fraction (obs) : WH " << w/(w+z) <<", ZH "<< z/(w+z) << std::endl; std::cout << "WH fraction (exp) : WH " << wFrac <<", ZH "<< zFrac << std::endl; std::cout << "********************************************" <<std::endl; std::cout << "" <<std::endl; std::cout << "" <<std::endl; std::cout << "" <<std::endl; std::cout << "********************************************" <<std::endl; } outWS->import(*datasetWH); outWS->import(*datasetZH); } RooDataHist *datahist = dynamic_cast<RooDataHist *>( *iterator ); if (datahist) { string zhname =(string) TPython::Eval(Form("'%s'.replace(\"wzh\",\"zh\")",datahist->GetName())); string whname =(string) TPython::Eval(Form("'%s'.replace(\"wzh\",\"wh\")",datahist->GetName())); RooDataHist *datahistZH = (RooDataHist*) datahist->emptyClone(zhname.c_str(),zhname.c_str()); RooDataHist *datahistWH = (RooDataHist*) datahist->emptyClone(whname.c_str(),whname.c_str()); TRandom3 r; r.Rndm(); double x[datahist->numEntries()]; r.RndmArray(datahist->numEntries(),x); for (int j =0; j < datahist->numEntries() ; j++){ datahistWH->add(*(datahist->get(j)),datahist->weight()*wFrac); datahistZH->add(*(datahist->get(j)),datahist->weight()*zFrac); } float w =datahistWH->sumEntries(); float z =datahistZH->sumEntries(); if(verbose_){ std::cout << "Original datahist " << *datahist <<std::endl; std::cout << "WH datahist " << *datahistWH <<std::endl; std::cout << "ZH datahist " << *datahistZH <<std::endl; std::cout << "********************************************" <<std::endl; std::cout << "WH fraction (obs) : WH " << w/(w+z) <<", ZH "<< z/(w+z) << std::endl; std::cout << "WH fraction (exp) : WH " << wFrac <<", ZH "<< zFrac << std::endl; std::cout << "********************************************" <<std::endl; std::cout << "" <<std::endl; std::cout << "" <<std::endl; std::cout << "" <<std::endl; std::cout << "********************************************" <<std::endl; } outWS->import(*datahistWH); outWS->import(*datahistZH); } } saveDir->cd(); outWS->Write(); outfile->Close(); infile->Close(); } }
TFile *hsimple(Int_t get=0) { // This program creates : // - a one dimensional histogram // - a two dimensional histogram // - a profile histogram // - a memory-resident ntuple // // These objects are filled with some random numbers and saved on a file. // If get=1 the macro returns a pointer to the TFile of "hsimple.root" // if this file exists, otherwise it is created. // The file "hsimple.root" is created in $ROOTSYS/tutorials if the caller has // write access to this directory, otherwise the file is created in $PWD TString filename = "hsimple.root"; TString dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName()); dir.ReplaceAll("hsimple.C",""); dir.ReplaceAll("/./","/"); TFile *hfile = 0; if (get) { // if the argument get =1 return the file "hsimple.root" // if the file does not exist, it is created TString fullPath = dir+"hsimple.root"; if (!gSystem->AccessPathName(fullPath,kFileExists)) { hfile = TFile::Open(fullPath); //in $ROOTSYS/tutorials if (hfile) return hfile; } //otherwise try $PWD/hsimple.root if (!gSystem->AccessPathName("hsimple.root",kFileExists)) { hfile = TFile::Open("hsimple.root"); //in current dir if (hfile) return hfile; } } //no hsimple.root file found. Must generate it ! //generate hsimple.root in current directory if we have write access if (gSystem->AccessPathName(".",kWritePermission)) { printf("you must run the script in a directory with write access\n"); return 0; } hfile = (TFile*)gROOT->FindObject(filename); if (hfile) hfile->Close(); hfile = new TFile(filename,"RECREATE","Demo ROOT file with histograms"); // Create some histograms, a profile histogram and an ntuple TH1F *hpx = new TH1F("hpx","This is the px distribution",100,-4,4); hpx->SetFillColor(48); TH2F *hpxpy = new TH2F("hpxpy","py vs px",40,-4,4,40,-4,4); TProfile *hprof = new TProfile("hprof","Profile of pz versus px",100,-4,4,0,20); TNtuple *ntuple = new TNtuple("ntuple","Demo ntuple","px:py:pz:random:i"); gBenchmark->Start("hsimple"); // Create a new canvas. TCanvas *c1 = new TCanvas("c1","Dynamic Filling Example",200,10,700,500); c1->SetFillColor(42); c1->GetFrame()->SetFillColor(21); c1->GetFrame()->SetBorderSize(6); c1->GetFrame()->SetBorderMode(-1); // Fill histograms randomly TRandom3 random; Float_t px, py, pz; const Int_t kUPDATE = 1000; for (Int_t i = 0; i < 25000; i++) { random.Rannor(px,py); pz = px*px + py*py; Float_t rnd = random.Rndm(1); hpx->Fill(px); hpxpy->Fill(px,py); hprof->Fill(px,pz); ntuple->Fill(px,py,pz,rnd,i); if (i && (i%kUPDATE) == 0) { if (i == kUPDATE) hpx->Draw(); c1->Modified(); c1->Update(); if (gSystem->ProcessEvents()) break; } } gBenchmark->Show("hsimple"); // Save all objects in this file hpx->SetFillColor(0); hfile->Write(); hpx->SetFillColor(48); c1->Modified(); return hfile; // Note that the file is automatically close when application terminates // or when the file destructor is called. }
//this algorithm uses the weighted difference between evenness in probabilities of winning to deterimine a winner offset. This attempt also runs a Monte Carlo method to determine the outcomes. { gROOT->SetStyle("Plain"); TRandom3 r(0); // generate a number in interval ]0,1] (0 is excluded) r.Rndm(); double rand; rand=r.Rndm(); cerr<<rand<<endl; int roundOneWinners[4][8]={0}; int roundTwoWinners[4][4]={0}; int roundThreeWinners[4][2]={0}; int finalFour[4]={0}; int finalTwo[2]={}0; double probOfWinning[17]={0}; TString location[4]; //ofstream screen; location[0]="south"; location[1]="west"; location[2]="midwest"; location[3]="east"; double pAdv[17][5]; //probability of advancing in each round given http://theweek.com/article/index/258018/heres-definitive-proof-that-you-should-pick-a-1-seed-to-win-your-march-madness-bracket //1 seed pAdv[1][1]=.999; pAdv[1][2]=0.9; pAdv[1][3]=0.7; pAdv[1][4]=0.4;
void revCalSimulation (Int_t runNumber, string b, string A) { int numFiles = 180;//(b==std::string("inf")?200:(A==std::string("-1")?200:20)); bool allEvtsTrigg = false; //This just removes the use of the trigger function for an initial calibration. // Once a calibration is established (or if running on Betas), you can keep this false bool simProperStatistics = false; // If True, this uses the actual data run to determine the number of Type 0s to simulate cout << "Running reverse calibration for run " << runNumber << endl; UInt_t BetaEvents = 0; //Holds the number of electron like Type 0 events to process Char_t temp[500],tempE[500],tempW[500]; //First get the number of total electron events around the source position from the data file and also the length of the run //sprintf(temp,"%s/replay_pass4_%i.root",getenv("REPLAY_PASS4"),runNumber); sprintf(temp,"%s/replay_pass3_%i.root",getenv("REPLAY_PASS3"),runNumber); TFile *dataFile = new TFile(temp,"READ"); TTree *data = (TTree*)(dataFile->Get("pass3")); sprintf(tempE,"Type<4 && Type>=0 && PID==1 && Side==0 && (xE.center*xE.center+yE.center*yE.center)<2500. && (xW.center*xW.center+yW.center*yW.center)<2500."); sprintf(tempW,"Type<4 && Type>=0 && PID==1 && Side==1 && (xW.center*xW.center+yW.center*yW.center)<2500. && (xE.center*xE.center+yE.center*yE.center)<2500."); BetaEvents = data->GetEntries(tempE) + data->GetEntries(tempW); cout << "Electron Events in Data file: " << BetaEvents << endl; cout << "East: " << data->GetEntries(tempE) << "\tWest: " << data->GetEntries(tempW) << endl; delete data; dataFile->Close(); //If we have a Beta run and we don't want exact statistics, simulate 16 times the number of events if ( !simProperStatistics ) { BetaEvents = 100*BetaEvents; } std::cout << "Processing " << BetaEvents << " events...\n"; ///////////////////////// SETTING GAIN OF FIRST and second DYNYODE Double_t g_d = 16.; Double_t g_rest = 12500.; /////// Loading other run dependent quantities vector <Int_t> pmtQuality = getEreconPMTQuality(runNumber); // Get the quality of the PMTs for that run UInt_t calibrationPeriod = getSrcRunPeriod(runNumber); // retrieve the calibration period for this run UInt_t XePeriod = getXeRunPeriod(runNumber); // Get the proper Xe run period for the Trigger functions //GetPositionMap(XePeriod); PositionMap posmap(5.0,50.); //Load position map with 5 mm bins posmap.readPositionMap(XePeriod,"endpoint"); vector <Double_t> alpha = GetAlphaValues(calibrationPeriod); // fill vector with the alpha (nPE/keV) values for this run period /////////////// Load trigger functions ////////////////// TriggerFunctions trigger(runNumber); std::vector < std::vector <Double_t> > pedestals = loadPMTpedestals(runNumber); std::vector < Double_t > PMTgain = loadGainFactors(runNumber); //Load the simulated relationship between EQ and Etrue EreconParameterization eRecon(runNumber); // Int_t pol = source=="Beta" ? getPolarization(runNumber) : 1; LinearityCurve linCurve(calibrationPeriod,false); std::cout << "Loaded Linearity Curves\n"; //Decide which simulation to use... TChain *chain = new TChain("anaTree"); std::string geom; if (runNumber<20000) geom = "2011-2012_geom"; else if (runNumber>=21087 && runNumber<21679) geom = "2012-2013_isobutane_geom"; else geom = "2012-2013_geom"; TString fileLocation = TString::Format("/extern/mabrow05/ucna/xuan_stuff/AbFit_Fierz_2011-2013/%s/A_%s_b_%s/", geom.c_str(),A.c_str(),b.c_str()); std::cout << "Using simulation from " << fileLocation << "...\n"; //Read in simulated data and put in a TChain TRandom3 *randFile = new TRandom3(runNumber*2); int fileNum = (int)(randFile->Rndm()*numFiles); delete randFile; for (int i=0; i<numFiles; i++) { if (fileNum==numFiles) fileNum=0; chain->AddFile(TString::Format("%s/xuan_analyzed_%i.root",fileLocation.Data(),fileNum)); fileNum++; } // Set the addresses of the information read in from the simulation file /*chain->SetBranchAddress("MWPCEnergy",&mwpcE); x chain->SetBranchAddress("time",&Time); x chain->SetBranchAddress("Edep",&edep); x chain->SetBranchAddress("EdepQ",&edepQ); x chain->SetBranchAddress("MWPCPos",&mwpc_pos); x chain->SetBranchAddress("ScintPos",&scint_pos); x chain->SetBranchAddress("primKE",&primKE); x chain->SetBranchAddress("primTheta",&primTheta); chain->SetBranchAddress("Cath_EX",Cath_EX); chain->SetBranchAddress("Cath_EY",Cath_EY); chain->SetBranchAddress("Cath_WX",Cath_WX); chain->SetBranchAddress("Cath_WY",Cath_WY); chain->SetBranchAddress("hitCountSD",hitCountSD);*/ //These are for feeding in Xuan's simulations... this needs to be updated so that I can pass a flag and change these on the fly chain->SetBranchAddress("primaryParticleSpecies",&primaryID); chain->SetBranchAddress("mwpcEnergy",&mwpcE); chain->SetBranchAddress("scintTimeToHit",&Time); chain->SetBranchAddress("scintillatorEdep",&edep); chain->SetBranchAddress("scintillatorEdepQuenched",&edepQ); chain->SetBranchAddress("MWPCPos",&mwpc_pos); chain->SetBranchAddress("ScintPos",&scint_pos); chain->SetBranchAddress("primaryKE",&primKE); chain->SetBranchAddress("primaryMomentum",primMom); //Set random number generator TRandom3 *seed = new TRandom3( 3*runNumber ); // seed generator TRandom3 *rand0 = new TRandom3( (unsigned int) (seed->Rndm()*10000.) ); TRandom3 *rand1 = new TRandom3( (unsigned int) (seed->Rndm()*10000.) ); TRandom3 *rand2 = new TRandom3( (unsigned int) (seed->Rndm()*10000.) ); TRandom3 *rand3 = new TRandom3( (unsigned int) (seed->Rndm()*10000.) ); //Initialize random numbers for 8 pmt trigger probabilities TRandom3 *randPMTE1 = new TRandom3( (unsigned int) (seed->Rndm()*10000.) ); TRandom3 *randPMTE2 = new TRandom3( (unsigned int) (seed->Rndm()*10000.) ); TRandom3 *randPMTE3 = new TRandom3( (unsigned int) (seed->Rndm()*10000.) ); TRandom3 *randPMTE4 = new TRandom3( (unsigned int) (seed->Rndm()*10000.) ); TRandom3 *randPMTW1 = new TRandom3( (unsigned int) (seed->Rndm()*10000.) ); TRandom3 *randPMTW2 = new TRandom3( (unsigned int) (seed->Rndm()*10000.) ); TRandom3 *randPMTW3 = new TRandom3( (unsigned int) (seed->Rndm()*10000.) ); TRandom3 *randPMTW4 = new TRandom3( (unsigned int) (seed->Rndm()*10000.) ); std::vector <Double_t> triggRandVec(4,0.); // Wirechamber information bool EastScintTrigger, WestScintTrigger, EMWPCTrigger, WMWPCTrigger; //Trigger booleans Double_t MWPCAnodeThreshold=0.; // keV dep in the wirechamber.. //Get total number of events in TChain UInt_t nevents = chain->GetEntries(); cout << "events = " << nevents << endl; //Start from random position in evt sequence if we aren't simulating veryHighStatistics UInt_t evtStart = seed->Rndm()*nevents; UInt_t evtTally = 0; //To keep track of the number of events UInt_t evt = evtStart; //current event number vector < vector <Int_t> > gridPoint; //Create simulation output file TFile *outfile = new TFile(TString::Format("%s/revCalSim_%i.root",fileLocation.Data(),runNumber), "RECREATE"); //Setup the output tree TTree *tree = new TTree("revCalSim", "revCalSim"); SetUpTree(tree); //Setup the output tree and branches //Histograms of event types for quick checks vector <TH1D*> finalEn (6,NULL); finalEn[0] = new TH1D("finalE0", "Simulated Weighted Sum East Type 0", 400, 0., 1200.); finalEn[1] = new TH1D("finalW0", "Simulated Weighted Sum West Type 0", 400, 0., 1200.); finalEn[2] = new TH1D("finalE1", "Simulated Weighted Sum East Type 1", 400, 0., 1200.); finalEn[3] = new TH1D("finalW1", "Simulated Weighted Sum West Type 1", 400, 0., 1200.); finalEn[4] = new TH1D("finalE23", "Simulated Weighted Sum East Type 2/3", 400, 0., 1200.); finalEn[5] = new TH1D("finalW23", "Simulated Weighted Sum West Type 2/3", 400, 0., 1200.); //Read in events and determine evt type based on triggers while (evtTally<=BetaEvents) { if (evt>=nevents) evt=0; //Wrapping the events back to the beginning EastScintTrigger = WestScintTrigger = EMWPCTrigger = WMWPCTrigger = false; //Resetting triggers each event chain->GetEvent(evt); //Checking that the event occurs within the fiducial volume in the simulation to minimize // contamination from edge effects and interactions with detector walls // This is also the fiducial cut used in extracting asymmetries and doing calibrations Double_t fidCut = 50.; /////////////// Do position and Wirechamber stuff /////////////////// // Following negative sign is to turn x-coordinate into global coordinate on East scint_pos_adj.ScintPosAdjE[0] = scint_pos.ScintPosE[0]*sqrt(0.6)*1000.; scint_pos_adj.ScintPosAdjE[1] = scint_pos.ScintPosE[1]*sqrt(0.6)*1000.; scint_pos_adj.ScintPosAdjW[0] = scint_pos.ScintPosW[0]*sqrt(0.6)*1000.;//sqrt(0.6)*10.*scint_pos.ScintPosW[0]+displacementX; scint_pos_adj.ScintPosAdjW[1] = scint_pos.ScintPosW[1]*sqrt(0.6)*1000.;//sqrt(0.6)*10.*scint_pos.ScintPosW[1]+displacementY; scint_pos_adj.ScintPosAdjE[2] = scint_pos.ScintPosE[2]*1000.; scint_pos_adj.ScintPosAdjW[2] = scint_pos.ScintPosW[2]*1000.; Double_t mwpcAdjE[3] = {0.,0.,0.}; Double_t mwpcAdjW[3] = {0.,0.,0.}; mwpcAdjE[0] = mwpc_pos.MWPCPosE[0] * sqrt(0.6) * 1000.; mwpcAdjE[1] = mwpc_pos.MWPCPosE[1] * sqrt(0.6) * 1000.; mwpcAdjW[0] = mwpc_pos.MWPCPosW[0] * sqrt(0.6) * 1000. ; mwpcAdjW[1] = mwpc_pos.MWPCPosW[1] * sqrt(0.6) * 1000. ; mwpcAdjE[2] = mwpc_pos.MWPCPosE[2] * 1000. ; mwpcAdjW[2] = mwpc_pos.MWPCPosW[2] * 1000. ; //std::cout << mwpcAdjE[0] << "\t" << mwpcAdjW[0] << std::endl; //if (evtTally==5) exit(0); ///////////////////////////////////////////////////////////////////// // Creating all extra structs to hold the alternate position reconstruction // crap before writing it all out ///////////////////////////////////////////////////////////////////// std::vector <Double_t> eta; std::vector <Double_t> trueEta; // This is the position map value of the actual event position, not the position as determined // by cathode reconstruction trueEta = posmap.getInterpolatedEta(scint_pos_adj.ScintPosAdjE[0], scint_pos_adj.ScintPosAdjE[1], scint_pos_adj.ScintPosAdjW[0], scint_pos_adj.ScintPosAdjW[1]); eta = posmap.getInterpolatedEta(scint_pos_adj.ScintPosAdjE[0], scint_pos_adj.ScintPosAdjE[1], scint_pos_adj.ScintPosAdjW[0], scint_pos_adj.ScintPosAdjW[1]); //MWPC triggers if (mwpcE.MWPCEnergyE>MWPCAnodeThreshold) EMWPCTrigger=true; if (mwpcE.MWPCEnergyW>MWPCAnodeThreshold) WMWPCTrigger=true; std::vector<Double_t> ADCvecE(4,0.); std::vector<Double_t> ADCvecW(4,0.); //East Side smeared PMT energies for (UInt_t p=0; p<4; p++) { if ( edep.EdepE>0. ) { //Check to make sure that there is light to see in the scintillator if (eta[p]>0.) { pmt.etaEvis[p] = (1./(alpha[p]*g_d*g_rest)) * (rand3->Poisson(g_rest*rand2->Poisson(g_d*rand1->Poisson(alpha[p]*trueEta[p]*edepQ.EdepQE)))); Double_t ADC = linCurve.applyInverseLinCurve(p, pmt.etaEvis[p]) + rand0->Gaus(0.,pedestals[p][1]); //Take into account non-zero width of the pedestal ADCvecE[p] = ADC; pmt.etaEvis[p] = linCurve.applyLinCurve(p, ADC); pmt.Evis[p] = pmt.etaEvis[p]/eta[p]; } else { //To avoid dividing by zero.. these events won't be used in analysis since they are outside the fiducial cut pmt.etaEvis[p] = (1./(alpha[p]*g_d*g_rest)) * (rand3->Poisson(g_rest*rand2->Poisson(g_d*rand1->Poisson(alpha[p]*edepQ.EdepQE)))); Double_t ADC = linCurve.applyInverseLinCurve(p, pmt.etaEvis[p]);// + rand0->Gaus(0.,pedestals[p][1]); //Take into account non-zero width of the pedestal ADCvecE[p] = ADC; pmt.etaEvis[p] = linCurve.applyLinCurve(p, ADC); pmt.Evis[p] = pmt.etaEvis[p]; } pmt.nPE[p] = alpha[p]*pmt.etaEvis[p] ; } // If eQ is 0... else { pmt.etaEvis[p] = 0.; pmt.Evis[p] = 0.; pmt.nPE[p] = 0.; } } Double_t numer=0., denom=0.; for (UInt_t p=0;p<4;p++) { numer += ( pmtQuality[p] ) ? pmt.nPE[p] : 0.; denom += ( pmtQuality[p] ) ? eta[p]*alpha[p] : 0.; //numer += ( pmtQuality[p] && pmt.etaEvis[p]>0. ) ? pmt.nPE[p] : 0.; //denom += ( pmtQuality[p] && pmt.etaEvis[p]>0. ) ? eta[p]*alpha[p] : 0.; } Double_t totalEnE = denom>0. ? numer/denom : 0.; evis.EvisE = totalEnE; //Now we apply the trigger probability triggRandVec[0] = randPMTE1->Rndm(); triggRandVec[1] = randPMTE2->Rndm(); triggRandVec[2] = randPMTE3->Rndm(); triggRandVec[3] = randPMTE4->Rndm(); if ( (allEvtsTrigg && totalEnE>0.) || ( trigger.decideEastTrigger(ADCvecE,triggRandVec) ) ) EastScintTrigger = true; //West Side for (UInt_t p=4; p<8; p++) { if ( !(p==5 && runNumber>16983 && runNumber<17249) && edep.EdepW>0. ) { //Check to make sure that there is light to see in the scintillator and that run isn't one where PMTW2 was dead if (eta[p]>0.) { pmt.etaEvis[p] = (1./(alpha[p]*g_d*g_rest)) * (rand3->Poisson(g_rest*rand2->Poisson(g_d*rand1->Poisson(alpha[p]*trueEta[p]*edepQ.EdepQW)))); Double_t ADC = linCurve.applyInverseLinCurve(p, pmt.etaEvis[p]) + rand0->Gaus(0.,pedestals[p][1]); //Take into account non-zero width of the pedestal ADCvecW[p-4] = ADC; //cout << ADCvecW[p-4] << endl; pmt.etaEvis[p] = linCurve.applyLinCurve(p, ADC); pmt.Evis[p] = pmt.etaEvis[p]/eta[p]; } else { //To avoid dividing by zero.. these events won't be used in analysis since they are outside the fiducial cut pmt.etaEvis[p] = (1./(alpha[p]*g_d*g_rest)) * (rand3->Poisson(g_rest*rand2->Poisson(g_d*rand1->Poisson(alpha[p]*edepQ.EdepQW)))); Double_t ADC = linCurve.applyInverseLinCurve(p, pmt.etaEvis[p]);// + rand0->Gaus(0.,pedestals[p][1]); //Take into account non-zero width of the pedestal ADCvecW[p-4] = ADC; pmt.etaEvis[p] = linCurve.applyLinCurve(p, ADC); pmt.Evis[p] = pmt.etaEvis[p]; } pmt.nPE[p] = alpha[p]*pmt.etaEvis[p]; } // If PMT is dead and EQ=0... else { pmt.etaEvis[p] = 0.; pmt.Evis[p] = 0.; pmt.nPE[p] = 0.; } } //Calculate the total weighted energy numer=denom=0.; for (UInt_t p=4;p<8;p++) { numer += ( pmtQuality[p] ) ? pmt.nPE[p] : 0.; denom += ( pmtQuality[p] ) ? eta[p]*alpha[p] : 0.; //numer += ( pmtQuality[p] && pmt.etaEvis[p]>0. ) ? pmt.nPE[p] : 0.; //denom += ( pmtQuality[p] && pmt.etaEvis[p]>0. ) ? eta[p]*alpha[p] : 0.; } //Now we apply the trigger probability Double_t totalEnW = denom>0. ? numer/denom : 0.; evis.EvisW = totalEnW; triggRandVec[0] = randPMTW1->Rndm(); triggRandVec[1] = randPMTW2->Rndm(); triggRandVec[2] = randPMTW3->Rndm(); triggRandVec[3] = randPMTW4->Rndm(); if ( (allEvtsTrigg && totalEnW>0.) || ( trigger.decideWestTrigger(ADCvecW,triggRandVec) ) ) WestScintTrigger = true; //if (totalEnW<25.) std::cout << totalEnW << " " << WestScintTrigger << "\n"; //Fill proper total event histogram based on event type PID=6; //This is an unidentified particle type=4; //this is a lost event side=2; //This means there are no scintillator triggers //Type 0 East if (EastScintTrigger && EMWPCTrigger && !WestScintTrigger && !WMWPCTrigger) { PID=1; type=0; side=0; //finalEn[0]->Fill(evis.EvisE); //cout << "Type 0 East E = " << totalEnE << endl; } //Type 0 West else if (WestScintTrigger && WMWPCTrigger && !EastScintTrigger && !EMWPCTrigger) { PID=1; type=0; side=1; //finalEn[1]->Fill(totalEnW); } //Type 1 else if (EastScintTrigger && EMWPCTrigger && WestScintTrigger && WMWPCTrigger) { PID=1; type=1; //East if (Time.timeE<Time.timeW) { //finalEn[2]->Fill(totalEnE); side=0; } //West else if (Time.timeE>Time.timeW) { //finalEn[3]->Fill(totalEnW); side=1; } } //Type 2/3 East else if (EastScintTrigger && EMWPCTrigger && !WestScintTrigger && WMWPCTrigger) { PID=1; type=2; side=0; //finalEn[4]->Fill(totalEnE); //cout << "Type 2/3 East E = " << totalEnE << endl; } //Type 2/3 West else if (!EastScintTrigger && EMWPCTrigger && WestScintTrigger && WMWPCTrigger) { PID=1; type=2; side=1; //finalEn[5]->Fill(totalEnW); //cout << "Type 2/3 East W = " << totalEnW << endl; } //Gamma events and missed events (Type 4) else { if (!WMWPCTrigger && !EMWPCTrigger) { if (EastScintTrigger && !WestScintTrigger) { PID=0; type=0; side=0; } else if (!EastScintTrigger && WestScintTrigger) { PID=0; type=0; side=1; } else if (EastScintTrigger && WestScintTrigger) { PID=0; type=1; if (Time.timeE<Time.timeW) { side=0; } else { side=1; } } else { PID=6; type=4; side=2; } } else { PID=1; type=4; side = (WMWPCTrigger && EMWPCTrigger) ? 2 : (WMWPCTrigger ? 1 : 0); //Side==2 means the event triggered both wirechambers, but neither scint } } //Calculate Erecon Erecon = -1.; Int_t typeIndex = (type==0 || type==4) ? 0:(type==1 ? 1:2); //for retrieving the parameters from EQ2Etrue if (side==0) { Double_t totalEvis = type==1 ? (evis.EvisE+evis.EvisW):evis.EvisE; if (evis.EvisE>0. && totalEvis>0.) { Erecon = eRecon.getErecon(0,typeIndex,totalEvis); if (type==0) finalEn[0]->Fill(Erecon); else if (type==1) finalEn[2]->Fill(Erecon); else if(type==2 ||type==3) finalEn[4]->Fill(Erecon); } else Erecon=-1.; } if (side==1) { Double_t totalEvis = type==1 ? (evis.EvisE+evis.EvisW):evis.EvisW; if (evis.EvisW>0. && totalEvis>0.) { Erecon = eRecon.getErecon(1,typeIndex,totalEvis); if (type==0) finalEn[1]->Fill(Erecon); else if (type==1) finalEn[3]->Fill(Erecon); else if(type==2 ||type==3) finalEn[5]->Fill(Erecon); } else Erecon=-1.; } if ( PID==1 && Erecon>0. && sqrt( scint_pos_adj.ScintPosAdjE[0]*scint_pos_adj.ScintPosAdjE[0] + scint_pos_adj.ScintPosAdjE[1]*scint_pos_adj.ScintPosAdjE[1] )<fidCut && sqrt( scint_pos_adj.ScintPosAdjW[0]*scint_pos_adj.ScintPosAdjW[0] + scint_pos_adj.ScintPosAdjW[1]*scint_pos_adj.ScintPosAdjW[1] )<fidCut ) evtTally++; evt++; tree->Fill(); if (evtTally%10000==0) {std::cout << evtTally << " PID=" << PID << " Erecon=" << Erecon << std::endl;}//cout << "filled event " << evt << endl; } cout << endl; delete chain; delete seed; delete rand0; delete rand1; delete rand2; delete rand3; delete randPMTE1; delete randPMTE2; delete randPMTE3; delete randPMTE4; delete randPMTW1; delete randPMTW2; delete randPMTW3; delete randPMTW4; outfile->Write(); outfile->Close(); }
void FindConstant::produceSIMEvents( std::vector<double>& SIMEvents, const double eRes) { // DEKLARACJE ZMIENNYCH Double_t przekroj, E_0, E, stala, fi, firad, pi; Int_t i; Double_t T, kos, x, y, max, Eprim; TRandom3 los; Double_t rozdzielczosc, g, sigma, rozmyciex, Troz; // INICJALIZACJIA przekroj = 0.0; E = 1.0; stala = pow((2.82 * 1E-13), 2.0) * 0.5; E_0 = 511.0 ; fi = 0.0; i = 0; firad = 0; pi = 3.14159265358979323846; kos = 0.0; T = 0.0; Eprim = 0.0; rozdzielczosc = 0.0; g = 0.0; sigma = 0.0; rozmyciex = 0.0; Troz = 0.0; //Ek. Kin. rozmyta // jeden stopien to okolo 0.0175 radiana bo 1* pi /180 = 0.0175 rozdzielczosc = eRes; fi = 0; firad = fi * pi / 180.0; E = E_0 * 511.0 / (511.0 + E_0 * ( 1 - cos(firad))); max = E * (2 * E / 511) / (1 + 2 * E / 511); //// PETLA DO RYSOWANIA WIDMA for (i = 0; i < 100000;) { x = los.Rndm() * max; y = los.Rndm() * 10.0; g = los.Gaus(0, 1); T = x; kos = (511.0 / E * T + T - E) / (T - E); Eprim = E - T; przekroj = 2.0 * 3.14 * stala * pow(Eprim / E, 2.0) * (E / Eprim + Eprim / E - 1.0 + pow(kos, 2.0) ) * ((511.0 / E + 1.0) / (T - E) - (511.0 / E * T + T - E) / (pow((T - E), 2.0))) * (-1.0) * 1E27; if (przekroj > y) { sigma = rozdzielczosc * sqrt(x); rozmyciex = sigma * g; Troz = x + rozmyciex; SIMEvents.push_back(Troz); i++; } } }
void MakeDALITree(UInt_t run){ gSystem->Load("libXMLParser.so"); gSystem->Load("libanaroot.so"); TArtStoreManager * sman = TArtStoreManager::Instance(); TArtEventStore *estore = new TArtEventStore(); estore->SetInterrupt(&stoploop); //estore->Open(0); Char_t* name = "calibration"; UInt_t run_=run; if(run>200){ name = "calib2XO"; run_=run-200; }else if(run>100){ name = "labr14Ni"; run_=run-100; } estore -> Open(Form("data/ridf/ggdaq04/%s%04d.ridf",name,run_)); // estore -> Open(Form("ridf/ggdaq04/labr14Ni%04d.ridf",run)); TArtDALIParameters *dpara = TArtDALIParameters::Instance(); dpara->LoadParameter("db/DALI.xml"); TArtCalibDALI *dalicalib= new TArtCalibDALI(); //check if the tree is readable, otherwise change here to array and save once in a while during the loop and delete the tree, start again. //TFile *fout[100]; //TTree *tree; Char_t* path = "data/Histo/calib/"; Char_t* rename; if(run<34) rename = "before_empty/run"; else if(run<39) rename = "before_Sn132/run"; else if(run<43) rename = "before_Sn128/run"; else if(run<46) rename = "during_Sn128/run"; else if(run<52) rename = "after_Sn128/run"; else rename = "after_exp/run"; TFile *fout = new TFile(Form("%s%s%04d.root",path,rename,run),"RECREATE"); TTree *tree = new TTree("tree","tree"); // define data nodes which are supposed to be dumped to tree TClonesArray * info_array = (TClonesArray *)sman->FindDataContainer("EventInfo"); TArtRawEventObject* frawevent = (TArtRawEventObject *)sman->FindDataContainer("RawEvent"); std::cout<<info_array->GetName()<<std::endl; //std::cout<<info_array->GetDate()<<std::endl; tree->Branch(info_array->GetName(),&info_array); TClonesArray * dali_array= (TClonesArray *)sman->FindDataContainer("DALINaI"); tree->Branch(dali_array->GetName(),&dali_array); Int_t MIDGAIN[8] = {0x0}; Int_t LOWGAIN[8] = {0x0}; Int_t HIGAIN[8] = {0x0}; tree->Branch("MIDGAIN",MIDGAIN,"MIDGAIN[8]/I"); tree->Branch("LOWGAIN",LOWGAIN,"LOWGAIN[8]/I"); tree->Branch("HIGAIN" ,HIGAIN ,"HIGAIN[8]/I"); int neve = 0; Int_t ii = -1; UInt_t fQTC[3][8] = {28, 29, 30, 1, 31, 4, 3, 2, 24, 25, 26, 6, 27, 9, 8, 7, 20, 21, 22,11, 23,14,13,12}; TRandom3 rndm; while( estore->GetNextEvent() ){ //while(neve<9000000){ // estore->GetNextEvent(); if(neve%500000==0){ std::cout << "event: " << neve << std::endl; //not tested /* if(neve%(Int_t)1e7==0){ if(neve!=0){ fout[ii]->Write(); delete tree; } ii++; if(ii > 99){ std::cout<< "file array is not big enough please increase the array size"<<std::endl; return; } tree = new TTree("tree","tree"); fout[ii] = new TFile(Form("rootfiles/calibration/calibration%04d_%i.root",run,ii),"RECREATE"); }*/ } dalicalib->ClearData(); dalicalib->ReconstructData(); Int_t tref = -9000; Int_t qtc_dummy[2][130]; for( int i=0; i<130; i++ ){ for( int j=0; j<2; j++ ){ qtc_dummy[j][i] = -9999; } } for(int i=0; i<frawevent -> GetNumSeg(); i++){ TArtRawSegmentObject *seg = frawevent -> GetSegment(i); Int_t fpl = seg -> GetFP(); if(fpl==8){ for(int j=0; j < seg -> GetNumData(); j++){ TArtRawDataObject *d = seg -> GetData(j); Int_t geo = d -> GetGeo(); Int_t ch = d -> GetCh(); Int_t val = d -> GetVal(); Int_t edge = d -> GetEdge(); if(geo==9) qtc_dummy[edge][ch] = val + (rndm.Rndm()- 0.5); //if(ch == fQTC[1][1] )cout<<qtc_dummy[edge][ch]<< " qtc_dummy "<<ch<<endl; if(geo ==9 && ch==127 && edge == 0) tref = val; }//for }//if }//for for(short ilabr=0; ilabr<8; ilabr++){ HIGAIN[ilabr] = (qtc_dummy[1][ fQTC[0][ilabr] ] - qtc_dummy[0][ fQTC[0][ilabr] ]); MIDGAIN[ilabr] = (qtc_dummy[1][ fQTC[1][ilabr] ] - qtc_dummy[0][ fQTC[1][ilabr] ]); LOWGAIN[ilabr] = (qtc_dummy[1][ fQTC[2][ilabr] ] - qtc_dummy[0][ fQTC[2][ilabr] ]); } tree->Fill(); neve ++; } fout->Write(); fout->Close(); }