void KVAvailableRunsFile::GetRunInfos(Int_t run, KVList * dates, KVList * files) { //Look for a given run number in the file, and read the file's modification date/time and filename //These informations are stored in the two TList as TObjString objects (these objects belong to the //lists and will be deleted by them). //We do not stop at the first run found, but continue until the end of the file, adding //informations for every occurence of the run in the file. //If available runs file does not exist, Update() is called to create it. //does runlist exist ? if (!OpenAvailableRunsFile()) { Error("GetRunInfos", "Error opening available runs file"); return; } //clear lists - delete objects dates->Delete(); files->Delete(); //loop over lines in fRunlist file //look for line beginning with 'run|' TString line; line.ReadLine(fRunlist); while (fRunlist.good()) { if (line.BeginsWith(Form("%d|", run))) { //found it TObjArray *toks = line.Tokenize('|'); // split into fields // check date is not identical to a previous entry // i.e. there are spurious duplicate entries TObjString* rundate = (TObjString*)toks->At(1)->Clone(); if(dates->FindObject(rundate->GetName())){ delete toks; delete rundate; line.ReadLine(fRunlist); continue; } //add date string dates->Add(toks->At(1)->Clone()); //backwards compatibility //an old available_runs file will not have the filename field //in this case we assume that the name of the file is given by the //dataset's base file name (i.e. with no date/time suffix) if (toks->GetEntries() > 2) { files->Add(toks->At(2)->Clone()); } else { files-> Add(new TObjString(fDataSet-> GetBaseFileName(GetDataType(), run))); } delete toks; } line.ReadLine(fRunlist); } CloseAvailableRunsFile(); }
//___________________________________________________________________________// void KVParticle::AddGroups(KVUniqueNameList* un) { //list of groups added to the current one TObjString* os = 0; TIter no(un); while ((os = (TObjString*)no.Next())) { AddGroup(os->GetName()); } }
void KVParticle::ListGroups(void) const { //List all stored groups if (!fGroups.GetEntries()) { cout << "Cette particle n appartient a aucun groupe" << endl; return; } else { cout << "--------------------------------------------------" << endl; cout << "Liste des groupes auxquels la particule appartient" << endl; } TObjString* os = 0; TIter no(GetGroups()); while ((os = (TObjString*)no.Next())) cout << os->GetName() << endl; cout << "--------------------------------------------------" << endl; }
//________________________________________________________________________________ void StarMCHits::Step() { // static Int_t Idevt0 = -1; static Double_t Gold = 0; #if 0 if (Debug() && gMC->IsA()->InheritsFrom("TGeant3TGeo")) { TGeant3TGeo *geant3 = (TGeant3TGeo *)gMC; geant3->Gdebug(); } #endif // cout << "Call StarMCHits::Step" << endl; TGeoNode *nodeT = gGeoManager->GetCurrentNode(); assert(nodeT); TGeoVolume *volT = nodeT->GetVolume(); assert(volT); const TGeoMedium *med = volT->GetMedium(); /* fParams[0] = isvol; fParams[1] = ifield; fParams[2] = fieldm; fParams[3] = tmaxfd; fParams[4] = stemax; fParams[5] = deemax; fParams[6] = epsil; fParams[7] = stmin; */ Int_t Isvol = (Int_t) med->GetParam(0); fCurrentDetector = 0; if (Isvol <= 0) return; fCurrentDetector = (StarVMCDetector *) fVolUserInfo->At(volT->GetNumber()); if (! fCurrentDetector) { volT = nodeT->GetMotherVolume(); fCurrentDetector = (StarVMCDetector *) fVolUserInfo->At(volT->GetNumber()); if (! fCurrentDetector) { TString path(gGeoManager->GetPath()); TObjArray *obj = path.Tokenize("_/"); Int_t N = obj->GetEntries(); for (Int_t i = N-2; i >= 0; i -= 2) { TObjString *o = (TObjString *) obj->At(i); const Char_t *name = o->GetName(); volT = gGeoManager->GetVolume(name); assert (volT); fCurrentDetector = (StarVMCDetector *) fVolUserInfo->At(volT->GetNumber()); if (fCurrentDetector) break; } delete obj; } } if (Isvol && ! fCurrentDetector && Debug()) { cout << "Active medium:" << med->GetName() << "\t for volume " << volT->GetName() << " has no detector description" << endl; } // Int_t Idevt = gMC->CurrentEvent(); gMC->TrackPosition(fHit.Current.Global.xyzT); gMC->TrackMomentum(fHit.Current.Global.pxyzE); TGeoHMatrix *matrixC = gGeoManager->GetCurrentMatrix(); fHit.Current.Global2Local(matrixC); if (gMC->IsTrackEntering()) { fHit.Detector= fCurrentDetector; fHit.Entry = fHit.Current; fHit.Sleng = gMC->TrackLength(); fHit.Charge = (Int_t) gMC->TrackCharge(); fHit.Mass = gMC->TrackMass(); fHit.AdEstep = fHit.AStep = 0; return; } Double_t GeKin = fHit.Current.Global.pxyzE.E() - fHit.Mass; fHit.Sleng = gMC->TrackLength(); if (fHit.Sleng == 0.) Gold = GeKin; Double_t dEstep = gMC->Edep(); Double_t Step = gMC->TrackStep(); fHit.iPart = gMC->TrackPid(); fHit.iTrack = StarVMCApplication::Instance()->GetStack()->GetCurrentTrackId(); // GetCurrentTrackNumber() + 1 to be consistent with g2t // - - - - - - - - - - - - - energy correction - - - - - - - - - - if (gMC->IsTrackStop() && TMath::Abs(fHit.iPart) == kElectron) { TArrayI proc; Int_t Nproc = gMC->StepProcesses(proc); Int_t Mec = 0; for (Int_t i = 0; i < Nproc; i++) if (proc[i] == kPAnnihilation || proc[i] == kPStop) Mec = proc[i]; Int_t Ngkine = gMC->NSecondaries(); if (fHit.iPart == kElectron && Ngkine == 0 && Mec == kPStop) dEstep = Gold; else { if (fHit.iPart == kPositron && Ngkine < 2 && Mec == kPAnnihilation) { dEstep = Gold + 2*fHit.Mass; if (Ngkine == 1) { TLorentzVector x; TLorentzVector p; Int_t IpartSec; gMC->GetSecondary(0,IpartSec,x,p); dEstep -= p.E(); } } } } // - - - - - - - - - - - - - - - - user - - - - - - - - - - - - - - - // user step // - - - - - - - - - - - - - - - sensitive - - - - - - - - - - - - - fHit.AdEstep += dEstep; fHit.AStep += Step; if (fHit.AdEstep == 0) return; if (! gMC->IsTrackExiting() && ! gMC->IsTrackStop()) return; fHit.Exit = fHit.Current; fHit.Middle = fHit.Entry; fHit.Middle += fHit.Exit; fHit.Middle *= 0.5; if (! fCurrentDetector) return; fHit.VolumeId = fCurrentDetector->GetVolumeId(gGeoManager->GetPath()); FillG2Table(); }
/** * Analyse the reweighting option string and set options on task * appropriately. The string is a comma or space separated list of * what to reweigh and how to do it. * * What to reweigh can be specfied using one or more of the strings * * - pt Reweight in pT * - pid Reweight particle abundance of pi, K, proton * - str Reweight particles from strange weak decays * * How to reweigh can be specifed as * * - + or up Increase weights (for pt < 0.05 by +30%) * - - or down Decrease weights (for pt < 0.05 by -30%) * - If none of these are given, then the weights are used as is. * * If pid rewighting is done and one of up or down are given, then * one can specify which particle type to reweigh * * - pi or pion Reweight (up or down) pions * - K or kaon Reweight (up or down) kaons * - p or proton Reweight (up or down) protons * * Note, if PID, with explicit selection of pions, and strangeness * reweighting are specified, then the up/down flag applies to both * PID reweighting and the strangeness reweighting * * @param task The task to modify */ void SetupReweighting(AliAnalysisTaskSE* task) { TString sel = fOptions.AsString("reweight"); sel.ToLower(); if (sel.IsNull() || sel.BeginsWith("no")) return; TList files; Int_t what = 0; Int_t opt = 0; TObjArray* tokens = sel.Tokenize(", "); TIter next(tokens); TObjString* ostr; // First find what should be done while ((ostr = static_cast<TObjString*>(next()))) { const TString& token = ostr->String(); if (token.EqualTo("pt")) { what |= 0x1; files.Add(new TObjString("REWEIGHTpt.root")); Printf("Will reweigh in pT"); } else if (token.EqualTo("pid")) { what |= 0x2; Printf("Will reweigh particle species"); } else if (token.EqualTo("str")) { what |= 0x4; Printf("Will reweight particles from strange weak decays"); } } if (what == 0x0) return; // Now figure out how to do it next.Reset(); TString part; while ((ostr = static_cast<TObjString*>(next()))) { const TString& token = ostr->String(); Int_t aOpt = TMath::Abs(opt); if (token.EqualTo("up") || token.EqualTo("+")) opt = (aOpt==0 ? +1 : +aOpt); else if (token.EqualTo("down") || token.EqualTo("-")) opt = (aOpt==0 ? -1 : -aOpt); else if (token.EqualTo("pi") || token.EqualTo("pion")){ opt = 1; part = "pi"; } else if (token.EqualTo("k") || token.EqualTo("kaon")) { opt = 2; part = "ka"; } else if (token.EqualTo("p") || token.EqualTo("proton")) { opt = 3; part = "pr"; } } if (opt != 0) Printf("Will reweigh %s (%c30%% for pT<0.05)", opt < 0 ? "down" : "up", opt < 0 ? '-' : '+'); if (what & 0x2) { if (!part.IsNull()) { Printf("Will reweight %s in particular", part.Data()); part.Prepend("_"); part.Append(opt < 0 ? "-" : "+"); } files.Add(new TObjString(Form("REWEIGHTpid%s.root", part.Data()))); } if (what & 0x4) files.Add(new TObjString(Form("REWEIGHTstr%s.root", opt == -1 ? "-" : opt == +1 ? "+" : ""))); delete tokens; Printf("Setting reweighing flag=0x%x with option=%d", what, opt); SetOnTask(task, "ReweightStack", what); SetOnTask(task, "ReweightFlag", opt); TIter nextF(&files); while ((ostr = static_cast<TObjString*>(nextF()))) { Printf("Loading reweighting file %s", ostr->GetName()); fRailway->LoadAux(ostr->GetName()); } }
void NBD::fit(){ TFile *fdata = TFile::Open(dataname.GetName()); TH1D *histo_obs = (TH1D*)fdata->Get(histoname.GetName()); TFile *fGlauber = TFile::Open(Glaubername.GetName()); TH1D *histo_exp = (TH1D*)histo_obs->Clone(); TF1 *NBD_fun = new TF1("NBD_fun","[0]*TMath::Gamma(x+[1])/(TMath::Gamma(x+1)*TMath::Gamma([1]))*TMath::Power([2]/[1],x)/TMath::Power([2]/[1]+1,x+[1])",0,100); UInt_t iniseed = gRandom->GetSeed(); // reproduce the "random" numbers std::vector<double> muvector, kvector, chisvector, ndfvector; double mu,k; for(mu=mumin;mu<=mumax;mu+=mustep){ for(k=kmin;k<=kmax;k+=kstep){ // if(npar%50==0) cout<<"Have run "<<npar<<" parameter sets"<<endl; NBD_fun->SetParameter(0,1); //[0]: Normalized constant NBD_fun->SetParameter(1,k); //[1]: k value NBD_fun->SetParameter(2,mu); //[2]: mu value TTree *t = (TTree*)fGlauber->Get("nt_Pb_Pb"); Float_t Ncoll, Npart, B; Long_t Nevent; t->SetBranchAddress("Ncoll",&Ncoll); t->SetBranchAddress("Npart",&Npart); t->SetBranchAddress("B",&B); Nevent = (Long_t) t->GetEntries(); Long_t Ev; Int_t Bino; Double_t Para, Bi_Para; gRandom->SetSeed(iniseed); histo_exp->Reset("M"); for (Ev=0; Ev<Nevent; Ev++){ //if(Ev%100000==0) cout<<"\t"<<"Have run "<<Ev<<" events"<<endl; t->GetEntry(Ev); Para = 0; //make sure that Para doesn't accumulate through loops for(Bino=0; Bino<Ncoll; Bino++){ // Bi_Para = unr.SampleDiscr(); Bi_Para = NBD_fun->GetRandom(); Para += Bi_Para; } histo_exp->Fill(Para); } double ndf; double chi_square = chisquare(histo_obs,histo_exp,xmin[0],xmax[0],ndf); if(chi_square>=0){ chisvector.push_back(chi_square); muvector.push_back(mu); kvector.push_back(k); ndfvector.push_back(ndf); } cout<<mu<<"\t"<<k<<"\t"<<chi_square<<"\t"<<ndf<<endl;//<<"\t"<<ndf<<"\t"<<p<<endl; } } double *amu = &muvector[0]; double *ak = &kvector[0]; double *achis = &chisvector[0]; int loc = TMath::LocMin(chisvector.size(),achis); mubest[0] = muvector[loc]; kbest[0] = kvector[loc]; chis[0] = chisvector[loc]; Ndf[0] = ndfvector[loc]; cout<<"{"<<mubest[0]<<","<<kbest[0]<<"}"<<endl; cout<<chis[0]<<"\t"<<Ndf[0]<<endl; Grgrid = new TGraph2D("Grgrid","",chisvector.size(),amu,ak,achis); }
void NBD::calcvar(){ double mumin_temp = mumin; double mumax_temp = mumax; double kmin_temp = kmin; double kmax_temp = kmax; this->initmu(mubest[0],mubest[0],mustep); this->initk(kbest[0],kbest[0],kstep); this->fit(); this->initmu(mumin_temp,mumax_temp,mustep); this->initk(kmin_temp,kmax_temp,kstep); TFile *fdata = TFile::Open(dataname.GetName()); TH1D *histo_obs = (TH1D*)fdata->Get(histoname.GetName()); TFile *fGlauber = TFile::Open(Glaubername.GetName()); int binnum = histo_obs->GetNbinsX(); double Minx = histo_obs->GetXaxis()->GetXmin(); double Maxx = histo_obs->GetXaxis()->GetXmax(); TH1D *histo_exp = new TH1D("histo_exp","Simulated distribution;Multiplicity;# of events",binnum,Minx,Maxx); TF1 *NBD_fun = new TF1("NBD_fun","[0]*TMath::Gamma(x+[1])/(TMath::Gamma(x+1)*TMath::Gamma([1]))*TMath::Power([2]/[1],x)/TMath::Power([2]/[1]+1,x+[1])",0,100); NBD_fun->SetParameter(0,1); NBD_fun->SetParameter(1,kbest[0]); NBD_fun->SetParameter(2,mubest[0]); TTree *t = (TTree*) fGlauber ->Get("nt_Pb_Pb"); Float_t Ncoll, Npart, B; Long_t Nevent; t->SetBranchAddress("Ncoll",&Ncoll); t->SetBranchAddress("Npart",&Npart); t->SetBranchAddress("B",&B); Nevent = (Long_t) t->GetEntries(); Long_t Ev; Int_t Bino; Double_t Para, Bi_Para, Mult; TString treestr=Form("tree%.f.root",kbest[0]*mubest[0]*1000); TFile *treefile = new TFile(treestr,"Recreate"); TTree *GlauEvent = new TTree("GlauEvent","Glauber Events"); GlauEvent -> Branch("Mult",&Para,"Mult/D"); GlauEvent -> Branch("Ncoll",&Ncoll,"Ncoll/F"); GlauEvent -> Branch("Npart",&Npart,"Npart/F"); GlauEvent -> Branch("B",&B,"B/F"); for(Ev=0; Ev<Nevent; Ev++){ //if(Ev%100000==0) cout<<"Have run "<<Ev<<" events"<<endl; t->GetEntry(Ev); Para = 0; //make sure that Para doesn't accumulate through loops for(Bino=0; Bino<Ncoll; Bino++){ // Bi_Para = unr.SampleDiscr(); Bi_Para = NBD_fun->GetRandom(); Para += Bi_Para; } histo_exp->Fill(Para); GlauEvent->Fill(); } GlauEvent->SetBranchAddress("Ncoll",&Ncoll); GlauEvent->SetBranchAddress("Npart",&Npart); GlauEvent->SetBranchAddress("B",&B); GlauEvent->SetBranchAddress("Mult",&Mult); Int_t i; if(method[0]==0){ /* double Glau_array[1000000]; Long_t count_Ev=0; for(Ev=0;Ev<Nevent;Ev++){ GlauEvent->GetEntry(Ev); if(Mult>=Minx&&Mult<=Maxx){ count_Ev++; Glau_array[count_Ev-1]=Mult; } } int low=0; int high=count_Ev-1; int k0[N+1]; for(i=0;i<N+1;i++){ k0[i]=count_Ev*(1-centbin[i]); kpoint[i]=findkth(Glau_array,low,high,k0[i]); count_Ev=0; for(Ev=0;Ev<Nevent;Ev++){ GlauEvent->GetEntry(Ev); if(Mult>=Minx&&Mult<=Maxx){ count_Ev++; Glau_array[count_Ev-1]=Mult; } } } */ for(i=0;i<N+1;i++){ kpoint[i] = findpoint(histo_exp,centbin[i]); kpoint_[i] = findpoint(histo_obs,centbin[i]); } } TH1D* hNpart[N+1]; for(i=0; i<N; i++){ //Initialization hNpart[i] = new TH1D(Form("Npart_%d-%d",i,i+1),Form("Npart distribution for %dth bin",i),4000,0,4000); } hNpart[N] = new TH1D(Form("Npart_0-%d",N),Form("Npart distribution for all bin"),4000,0,4000); std::vector<double> PartEvent(N);std::vector<double> PartEvent_(N+1); double TotalEvent=0; for(Ev=0; Ev<Nevent; Ev++){ //if(Ev%100000==0) cout<<"Have run "<<Ev<<" events"<<endl; GlauEvent->GetEntry(Ev); for(i=0; i<N; i++){ if(Mult>kpoint[i]&&Mult<=kpoint[i+1]){ NcollAver[i] += Ncoll; NpartAver[i] += Npart; BAver[i] += B; PartEvent[i]++; TotalEvent++; hNpart[i]->Fill(Npart); } } hNpart[N]->Fill(Npart); for(i=0; i<N+1; i++){ if(method[0]!=0 && Mult>kpoint[i]) PartEvent_[i]++; } } if(method[0]!=0){ for(i=0; i<N+1; i++){ centbin[i]=(double)PartEvent_[i]/TotalEvent; centbin_[i]=(double)histo_obs->Integral(histo_obs->GetXaxis()->FindBin(kpoint[i]),histo_obs->GetXaxis()->GetLast())/histo_obs->Integral(); } } for(i=0; i<N; i++){ if(PartEvent[i]){ NcollAver[i]/=PartEvent[i]; NpartAver[i]/=PartEvent[i]; BAver[i]/=PartEvent[i]; //hNpart[i]->Scale(1.0/PartEvent[i]); Npartdis->Add(hNpart[i]); } } //hNpart[N]->Scale(1.0/TotalEvent); Npartdis->Add(hNpart[N]); treefile->Close(); remove(treestr); }
void hPYphocalc(){ gStyle->SetOptStat(kFALSE); const int maxNpart = 100; int sth=0, Gth=0; TFile *f = TFile::Open(outG); if(sth==0){TString dirname = "std";} else if(sth==1){TString dirname ="Gri055";} else {TString dirname ="Gri101";} TObjString* dataname = (TObjString*)f->Get(Form("dataname")); TObjString* histoname = (TObjString*)f->Get(Form("histoname")); TFile *fdata = TFile::Open(dataname->GetName()); TString name; if(Gth==0) name = "G0"; else if(Gth<nGlau) name = Form("Glau_%d",Gth); else name = Form("bin_%d",Gth-nGlau+1); TObjString* Glaubername = (TObjString*)f->Get(Form("%s/%s/Glaubername",dirname.Data(),name.Data())); TVectorD* k0 = (TVectorD*)f->Get(Form("%s/%s/k0",dirname.Data(),name.Data())); TVectorD* theta0 = (TVectorD*)f->Get(Form("%s/%s/theta0",dirname.Data(),name.Data())); TVectorD* xmin = (TVectorD*)f->Get(Form("%s/%s/xmin",dirname.Data(),name.Data())); TVectorD* xmax = (TVectorD*)f->Get(Form("%s/%s/xmax",dirname.Data(),name.Data())); TVectorD* thetabest = (TVectorD*)f->Get(Form("%s/%s/thetabest",dirname.Data(),name.Data())); TVectorD* kbest = (TVectorD*)f->Get(Form("%s/%s/kbest",dirname.Data(),name.Data())); TVectorD* kpoint = (TVectorD*)f->Get(Form("%s/%s/kpoint",dirname.Data(),name.Data())); TVectorD* NcollAver = (TVectorD*)f->Get(Form("%s/%s/NcollAver",dirname.Data(),name.Data())); TVectorD* centbin = (TVectorD*)f->Get(Form("%s/%s/centbin",dirname.Data(),name.Data())); TFile *fGlauber = TFile::Open(Glaubername->GetName()); //(*k0)[0]=1.39; (*kbest)[0]=0.425; //(*theta0)[0]=3.41; (*thetabest)[0]=1.30; TF1 *gammafun[maxNpart]; TF1 *gammafunevt[maxNpart]; TF1 *gammafunnucl[maxNpart]; TF1 *gammafunnuclNcoll[maxNpart]; double kevt = (*k0)[0]-(*kbest)[0]; for(int iNpart=0;iNpart<maxNpart;iNpart++){ gammafun[iNpart] = new TF1("gammafun","TMath::GammaDist(x,[0],0,[1])",0,200); gammafunevt[iNpart] = new TF1("gammafunevt","TMath::GammaDist(x,[0],0,[1])",0,200); gammafunnucl[iNpart] = new TF1("gammafunnucl","TMath::GammaDist(x,[0],0,[1])",0,200); gammafunnuclNcoll[iNpart] = new TF1("gammafunnuclNcoll","TMath::GammaDist(x,[0],0,[1])",0,200); double k_=(*k0)[0]+(*kbest)[0]*(iNpart-2); double theta_=(*theta0)[0]+(*thetabest)[0]*TMath::Log(iNpart-1); gammafun[iNpart]->SetParameter(0,k_); //[1]: k value gammafun[iNpart]->SetParameter(1,theta_); //[2]: theta value gammafunevt[iNpart]->SetParameter(0,kevt); gammafunevt[iNpart]->SetParameter(1,theta_); gammafunnucl[iNpart]->SetParameter(0,(*kbest)[0]); gammafunnucl[iNpart]->SetParameter(1,theta_); gammafunnuclNcoll[iNpart]->SetParameter(0,(*kbest)[0]*(iNpart-1)); gammafunnuclNcoll[iNpart]->SetParameter(1,theta_); if(iNpart==2){ gammafunnuclNcoll[iNpart]->SetNpx(1e4); gammafunnuclNcoll[iNpart]->SetRange(1e-11,200); } } TTree *t = (TTree*)fGlauber->Get("nt_p_Pb"); Float_t Ncoll, Npart, B; Long_t Nevent; t->SetBranchAddress("Ncoll",&Ncoll); t->SetBranchAddress("Npart",&Npart); t->SetBranchAddress("B",&B); Nevent = (Long_t) t->GetEntries(); Long_t Ev; Int_t Bino; Double_t Para, Para_nucl, Para_p, Para_evt, Bi_Para_nucl, Bi_Para_evt; double yUCM[8]={}; double yPCM[8]={}; double yVCM[8]={}; double yUCM_[200]={}; double yPCM_[200]={}; double yVCM_[200]={}; double C=1e-4; double PNcoll[maxNpart]={}; TH1D *histo_obs = (TH1D*)fdata->Get(histoname->GetName()); TH1D *histo_obs_norm = (TH1D*)histo_obs->Clone(); histo_obs_norm->Scale(1/histo_obs->Integral()); TH1D* hUCM = new TH1D("hUCM","hUCM",200,0,200); TH1D* hPCM = new TH1D("hPCM","hPCM",200,0,200); TH1D* hVCM = new TH1D("hVCM","hVCM",200,0,200); TH2D* NcollvsET = new TH2D("NcollvsET","NcollvsET",100,0,100,2000,0,400); for(Ev=0;Ev<Nevent;Ev++){ t->GetEntry(Ev); PNcoll[(int)Ncoll]++; } for(int i=0;i<maxNpart;i++){ PNcoll[i]/=Nevent; cout<<PNcoll[i]<<"\t"; } cout<<endl; for(Ev=0;Ev<Nevent;Ev++){ if(Ev%100000==0) cout<<"\t"<<"Have run "<<Ev<<" events"<<endl; t->GetEntry(Ev); Para = gammafun[(int)Npart]->GetRandom(); Para_nucl = gammafunnuclNcoll[(int)Npart]->GetRandom(); Para_p = gammafunnuclNcoll[(int)Npart]->GetRandom(); Para_evt = 0; for(int i=0;i<N-1;i++) if(Para>=(*kpoint)[i] && Para<(*kpoint)[i+1]) int ibin = i; for(int Bino=0;Bino<Ncoll;Bino++){ Bi_Para_evt = gammafunevt[(int)Npart]->GetRandom(); Para_evt += Bi_Para_evt; } double PNcollET = gammafun[(int)Npart]->Eval(Para); // double k = gammafun[(int)Npart]->GetParameter(0); double theta=(*theta0)[0]+(*thetabest)[0]*TMath::Log(Npart-1); double YNcollUCM = C*Ncoll; double YNcollPCM = C/1.0/(*kbest)[0]/theta*(Para_nucl); double YNcollVCM = C/2.0*(Para_nucl/(*kbest)[0]/theta+Ncoll); yUCM[ibin] += PNcoll[(int)Ncoll]*PNcollET*YNcollUCM; yPCM[ibin] += PNcoll[(int)Ncoll]*PNcollET*YNcollPCM; yVCM[ibin] += PNcoll[(int)Ncoll]*PNcollET*YNcollVCM; yUCM_[(int)Para] += PNcoll[(int)Ncoll]*PNcollET*YNcollUCM; yPCM_[(int)Para] += PNcoll[(int)Ncoll]*PNcollET*YNcollPCM; yVCM_[(int)Para] += PNcoll[(int)Ncoll]*PNcollET*YNcollVCM; NcollvsET->Fill(Ncoll,Para); } for(int ibin=1;ibin<hUCM->GetNbinsX();ibin++){ hUCM->SetBinContent(ibin,yUCM_[ibin-1]); hPCM->SetBinContent(ibin,yPCM_[ibin-1]); hVCM->SetBinContent(ibin,yVCM_[ibin-1]); } TCanvas *c1 = new TCanvas(); TCanvas *c2 = new TCanvas(); c1->SetLogy(); c2->SetLogx(); c2->SetLogy(); c2->SetLogz(); c1->cd(); TH1D* hFrame = new TH1D("","",200,0,200); hFrame->SetTitle(""); hFrame->GetXaxis()->SetTitle("HF #Sigma E_{T} |#eta|>4"); hFrame->GetYaxis()->SetTitle("Yield no units"); hFrame->GetXaxis()->SetRangeUser(0,150); hFrame->GetYaxis()->SetRangeUser(1e-6,1); hFrame->Draw(); histo_obs_norm->SetMarkerStyle(20); histo_obs_norm->SetMarkerSize(1.0); histo_obs_norm->SetMarkerColor(1); histo_obs_norm->Draw("Psame"); hUCM->SetMarkerStyle(24); hUCM->SetMarkerSize(1.0); hUCM->SetMarkerColor(2); hPCM->SetMarkerStyle(29); hPCM->SetMarkerSize(1.0); hPCM->SetMarkerColor(4); hVCM->SetMarkerStyle(34); hVCM->SetMarkerSize(1.0); hVCM->SetMarkerColor(5); hUCM->Draw("Psame"); hPCM->Draw("Psame"); hVCM->Draw("Psame"); TLegend *leg = new TLegend(0.1,0.2,0.5,0.45); leg->SetFillColor(0); leg->SetFillStyle(0); leg->SetBorderSize(0); leg->SetTextFont(42); leg->SetTextSize(0.03); leg->AddEntry(histo_obs_norm,"minimum bias events","lp"); leg->AddEntry(hUCM,"hard scattering events(UCM)","lp"); leg->AddEntry(hPCM,"hard scattering events(PCM)","lp"); leg->AddEntry(hVCM,"hard scattering events(VCM)","lp"); leg->Draw("same"); c1->Print("paperfig3_CMS.png"); c2->cd(); gStyle->SetOptStat("nemr"); NcollvsET->GetXaxis()->SetTitle("Ncoll"); NcollvsET->GetYaxis()->SetTitle("HF #Sigma E_{T} |#eta|>4"); NcollvsET->Draw("colz"); c2->Print("NcollvsET2D.png"); ofstream fstr("result_CMS.dat"); fstr<<"i"<<"\t"<<"centbin"<<"\t"<<"kpoint"<<"\t"<<"NcollAver"<<"\t"<<"UCM"<<"\t"<<"PCM"<<"\t"<<"VCM"<<"\t"<<"pho1"<<"\t"<<"pho2"<<"\t"<<"MB"<<endl; for(int i=0;i<N-1;i++){ fstr<<i<<"\t"<<(*centbin)[i]*100<<"% to "<<(*centbin)[i+1]*100<<"% \t"<<(*kpoint)[i]<<" to "<<(*kpoint)[i+1]<<"\t"<<(*NcollAver)[i]<<"\t"<<yUCM[i]<<"\t"<<yPCM[i]<<"\t"<<yVCM[i]<<"\t"<<yPCM[i]/yUCM[i]<<"\t"<<yVCM[i]/yUCM[i]<<"\t"<<"undetermined"<<endl; } }
void scanDirectory(const char *dirname) { TDirectoryIter iter(dirname); const char *filename = 0; TString ent; TString file; TString html; html.Form(gPreamble,dirname,dirname); TList dirList; TList fileList; while( (filename=iter.Next()) ) { if (filename[0]!='.') { ent.Form("%s/%s", dirname, filename); FileStat_t st; gSystem->GetPathInfo(ent.Data(), st); if (R_ISDIR(st.fMode)) { //fprintf(stderr,"Seeing directory %s\n",ent.Data()); scanDirectory(ent.Data()); dirList.Add(new TObjString(filename)); } else { size_t len = strlen(filename); if (len > 8 && strncmp(filename,"pt_",3)==0 && strncmp(filename+len-5,".root",5)==0) { //fprintf(stderr,"Seeing file %s\n",ent.Data()); file = filename; file[len-5]='\0'; fileList.Add(new TObjString(file)); } } } } dirList.Sort(); fileList.Sort(); TIter next(&dirList); TObjString *obj; html += "<table width=\"500\">\n"; html += gLine; html += gParentDir; while ( (obj = (TObjString*)next()) ) { html += TString::Format(gDirFmt,obj->GetName(),obj->GetName()); } html += gLine; if (!fileList.IsEmpty()) { next = &fileList; while ( (obj = (TObjString*)next()) ) { html += "<tr>"; html += TString::Format(gFiles,obj->GetName(),obj->GetName(),obj->GetName(),obj->GetName()); obj = (TObjString*)next(); if (obj) { html += TString::Format(gFiles,obj->GetName(),obj->GetName(),obj->GetName(),obj->GetName()); } else { html += "<td></td></tr>"; break; } } html += gLine; } html += "</table>\n"; dirList.Delete(); fileList.Delete(); html += "</body>\n"; html += "</html>\n"; ent.Form("%s/pt_index.html",dirname); FILE *output = fopen(ent.Data(),"w"); fprintf(output,"%s",html.Data()); fclose(output); }
void TriggerInputsForMuonEventCuts ( TString runListFilename, TString selectedInputs="", TString defaultStorage = "raw://" ) { AliCDBManager::Instance()->SetDefaultStorage(defaultStorage.Data()); TObjArray inputsList; inputsList.SetOwner(); TObjArray* selectedInputsList = selectedInputs.Tokenize(","); // Read input run list ifstream inFile(runListFilename.Data()); TString srun = ""; if ( inFile.is_open() ) { while ( ! inFile.eof() ) { srun.ReadLine(inFile,kFALSE); if ( ! srun.IsDigit() ) continue; // For each run, read trigger inputs from OCDB Int_t runNumber = srun.Atoi(); AliCDBManager::Instance()->SetRun(runNumber); // Get trigger class configuration AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/CTP/Config"); if ( ! entry ) continue; THashList* runInputs = new THashList(); runInputs->SetOwner(); runInputs->SetUniqueID((UInt_t)runNumber); AliTriggerConfiguration* trigConf = (AliTriggerConfiguration*)entry->GetObject(); const TObjArray& trigInputsArray = trigConf->GetInputs(); AliTriggerInput* trigInput = 0x0; TIter next(&trigInputsArray); while ( ( trigInput = static_cast<AliTriggerInput*>(next()) ) ) { if ( selectedInputsList->GetEntriesFast() > 0 && ! selectedInputsList->FindObject(trigInput->GetName()) ) continue; Int_t inputId = (Int_t)TMath::Log2(trigInput->GetMask()); TObjString* currInput = new TObjString(trigInput->GetName()); currInput->SetUniqueID(inputId); runInputs->Add(currInput); } inputsList.Add(runInputs); } inFile.close(); } delete selectedInputsList; // Loop on the trigger inputs // and group runs with an equal list of inputs Int_t nentries = inputsList.GetEntries(); TArrayI checkMask(nentries); checkMask.Reset(1); for ( Int_t irun=0; irun<nentries; irun++ ) { if ( checkMask[irun] == 0 ) continue; THashList* currList = static_cast<THashList*>(inputsList.At(irun)); TString runRange = Form("Run range: %u", currList->GetUniqueID()); for ( Int_t jrun=irun+1; jrun<nentries; jrun++ ) { if ( checkMask[jrun] == 0 ) continue; THashList* checkList = static_cast<THashList*>(inputsList.At(jrun)); Bool_t isDifferent = kFALSE; for ( Int_t itrig=0; itrig<currList->GetEntries(); itrig++ ) { TObjString* currInput = static_cast<TObjString*>(currList->At(itrig)); TObject* checkInput = checkList->FindObject(currInput->GetName()); if ( ! checkInput || checkInput->GetUniqueID() != currInput->GetUniqueID() ) { isDifferent = kTRUE; break; } } // loop on trigger inputs if ( isDifferent ) continue; checkMask[jrun] = 0; runRange += Form(",%u", checkList->GetUniqueID()); } // loop on runs TString outString = "\nSetTrigInputsMap(\""; for ( Int_t itrig=0; itrig<currList->GetEntries(); itrig++ ) { TObjString* currInput = static_cast<TObjString*>(currList->At(itrig)); outString += Form("%s:%u,",currInput->GetString().Data(), currInput->GetUniqueID()); } outString.Append("\");\n"); outString.ReplaceAll(",\"","\""); outString += runRange; printf("%s\n", outString.Data()); } // loop on runs }