void xrootdTestVanderbilt(const int iOption=0) { TDatime *dateTime = new TDatime; int iDate = dateTime->GetDate(); int iTime = dateTime->GetTime(); cout << " Begin Vanderbilt access testing " << iDate << " at " << iTime << endl; if(iOption == 0 || iOption == 1) { TFile *f = TFile::Open("root://cmsxrootd.fnal.gov//store/test/xrootd/T2_US_Vanderbilt//store/mc/SAM/GenericTTbar/GEN-SIM-RECO/CMSSW_5_3_1_START53_V5-v1/0013/CE4D66EB-5AAE-E111-96D6-003048D37524.root"); if(f) { cout << "\n cmsxrootd.fnal.gov successful access to Vanderbilt" << endl; f->ls(); f->Close(); } else { cout << "\n cmsxrootd.fnal.gov unsuccessful access to Vanderbilt" << endl; } dateTime->Set(); // set to system date/time iDate = dateTime->GetDate(); iTime = dateTime->GetTime(); cout << " Completed Vanderbilt access test from FNAL on " << iDate << " at " << iTime << endl; } // check on iOption = 0 or iOption = 1 if(iOption == 0 || iOption == 2) { TFile *g = TFile::Open("root://cms-xrd-global.cern.ch//store/test/xrootd/T2_US_Vanderbilt//store/mc/SAM/GenericTTbar/GEN-SIM-RECO/CMSSW_5_3_1_START53_V5-v1/0013/CE4D66EB-5AAE-E111-96D6-003048D37524.root"); if(g) { cout << "\n cms-xrd-global.cern.ch successful access to Vanderbilt" << endl; g->ls(); g->Close(); } else { cout << "\n cms-xrd-global.cern.ch unsuccessful access to Vanderbilt" << endl; } dateTime->Set(); // set to system date/time iDate = dateTime->GetDate(); iTime = dateTime->GetTime(); cout << " Completed Vanderbilt access test from CERN on " << iDate << " at " << iTime << endl; } // check on iOption = 0 or iOption = 2 dateTime->Set(); // set to system date/time cout << "\n Completed Vanderbilt access testing " << iDate << " at " << iTime << endl; return; }
//================================================ void toyMC_Cent() { gStyle->SetOptStat(0); gStyle->SetOptFit(1); gStyle->SetStatY(0.9); gStyle->SetStatX(0.9); gStyle->SetStatW(0.2); gStyle->SetStatH(0.2); myRandom = new TRandom3(); TDatime *clock = new TDatime(); myRandom->SetSeed(clock->GetTime()); // Get true refMult vs Ncoll distribution TH2F *hRefMultVsNcoll = 0x0; // Get different efficiency curve vs. refMult const int nEff = 2; const int nMult = 2; TF1 *funcEff[nEff]; funcEff[0] = new TF1("funcEff_0", "pol1",0,1000); funcEff[0]->SetParameters(0.9, -2e-4); funcEff[1] = new TF1("funcEff_1", "pol0",0,1000); funcEff[1]->SetParameter(0,0.6); TCanvas *c = new TCanvas("cEff","cEff",800,600); TH1F *hplot = new TH1F("hplot",";Mult;",100,0,1000); hplot->SetYTitle("Efficiency"); hplot->DrawCopy(); for(int i=0; i<2; i++) { funcEff[i]->SetLineColor(i+1); funcEff[i]->SetLineWidth(1.5); funcEff[i]->Draw("sames"); } TPaveText *title = GetTitleText("TPC tracking efficiency"); title->Draw(); TLegend *leg = new TLegend(0.4,0.2,0.7,0.4); leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetTextSize(0.04); leg->AddEntry(funcEff[0], "Efficiency 1", "L"); leg->AddEntry(funcEff[1], "Efficiency 2", "L"); leg->Draw(); // Get ngTrack distribution to mimic efficiency distribution TH1F *hMcMult[nMult]; }
/** * This is an alternative to bfcMixer_pythia() allowing the user to explicitly * specify BFC options for all three chains. * * Sample input values: * * daqFileList = "@run10148002.list" * fzdFile = "/path/to/my_pythia.fzd" * flag = "W" * */ void EmbeddingReco(const int nEvents, const std::string daqFileList, const std::string fzdFile, const std::string bfcOptionsChain1, const std::string bfcOptionsChain2, const std::string bfcOptionsChain3, const std::string flag) { // Dynamically link some shared libs gROOT->LoadMacro("bfc.C"); if (gClassTable->GetID("StBFChain") < 0) Load(); //______________Create the main chain object______________________________________ Chain = new StChain("Embedding"); //________________________________________________________________________________ bfc(-1, bfcOptionsChain1.c_str(), daqFileList.c_str()); chain1 = chain; chain1->SetName("One"); chain1->SetAttr(".call", "SetActive(0)", "St_db_Maker::"); // Use DB cache to reduce overhead Chain->cd(); //________________________________________________________________________________ bfc(-1, bfcOptionsChain2.c_str(), fzdFile.c_str()); chain2 = chain; chain2->SetName("Two"); Chain->cd(); if (chain2->GetOption("TRS")) { StTrsMaker *trsMk = (StTrsMaker *) chain2->GetMaker("Trs"); if (!trsMk) { cout << "Cannot find Trs in chain2" << endl; return; } trsMk->setNormalFactor(1.32); trsMk->SetMode(0); } //________________________________________________________________________________ // gSystem->Load("StFtpcMixerMaker"); // StFtpcMixerMaker *ftpcmixer = new StFtpcMixerMaker("FtpcMixer","daq","trs"); //________________________________________________________________________________ TString OutputFileName(gSystem->BaseName(fzdFile.c_str())); OutputFileName.ReplaceAll("*", ""); OutputFileName.ReplaceAll(".fzd", ""); // OutputFileName.Append("_emb.root"); OutputFileName.Append(".root"); bfc(-1, bfcOptionsChain3.c_str(), 0, OutputFileName); chain3 = chain; chain3->SetName("Three"); Chain->cd(); //________________________________________________________________________________ StTpcMixerMaker *mixer = (StTpcMixerMaker *) chain3->Maker("TpcMixer"); mixer->SetInput("Input1", "TpxRaw/.data/Event"); if (bfcOptionsChain2.find("TpcRS") != std::string::npos) { mixer->SetInput("Input2", "TpcRS/Event"); } else { mixer->SetInput("Input2", "Trs/.const/Event"); } Chain->cd(); if (flag == "W") { // blacklist some detectors to save DB load St_db_Maker *dbMk = (St_db_Maker *)chain3->GetMaker("db"); dbMk->SetAttr("blacklist", "svt"); dbMk->SetAttr("blacklist", "ssd"); // dbMk->SetAttr("blacklist", "ftpc"); // S.F. } //------------------------------------ EMC MIXERS ------------------------------------ // Add BEMC mixer to chain3 StEmcRawMaker *emcRaw = (StEmcRawMaker *)chain3->GetMaker("emcRaw"); emcRaw->getBemcRaw()->saveAllStEvent(true); // use all 4800 BEMC towers gSystem->Load("StEmcMixerMaker"); StEmcMixerMaker *bemcMixer = new StEmcMixerMaker; chain3->AddAfter("EmcSimulator", bemcMixer); // Set EEMC fast and slow simulator in embedding mode StEEmcFastMaker *eefs = (StEEmcFastMaker *)chain3->GetMaker("eefs"); eefs->SetEmbeddingMode(); // Use local StEmcCollection eefs->UseFullTower(true); // Use full ETOW detector StEEmcSlowMaker *eess = new StEEmcSlowMaker; eess->setEmbeddingMode(true); // Add EEMC mixer to chain3 StEEmcMixerMaker *eemcMixer = new StEEmcMixerMaker; //------------------------------------------------------------------------------------ //----------------------------- TRIGGER FILTER ----------------------------- // We want to achieve the following ordering for makers: // 1. BBC simulator // 2. BEMC simulator // 3. BEMC mixer // 4. EEMC fast simulator // 5. EEMC slow simulator // 6. EEMC mixer // 7. Pythia event maker // 8. Trigger simulator // 9. Trigger filter // 10. TPC maker // Place TPC chain after EMC makers chain3->AddAfter("eefs", chain3->GetMaker("tpcChain")); chain3->AddAfter("eefs", eemcMixer); chain3->AddAfter("eefs", eess); if (flag == "Jet") { // Place Pythia maker after GEANT maker // and trigger filter after EMC makers gSystem->Load("StJetSkimEvent"); gSystem->Load("StMCAsymMaker"); gSystem->Load("StBfcTriggerFilterMaker"); StPythiaEventMaker *pythia = new StPythiaEventMaker; TString pyfile = gSystem->BaseName(fzdFile.c_str()); pyfile.ReplaceAll(".fzd", ".pythia.root"); pythia->SetPythiaFile(pyfile); chain3->AddAfter("geant", pythia); // Place trigger simulator after EMC makers gSystem->Load("StTriggerUtilities"); StTriggerSimuMaker *trgsim = new StTriggerSimuMaker; trgsim->setMC(1); // BBC was not used in Run 9 jet triggers //trgsim->useBbc(); //trgsim->bbc->setSource("StEvent"); trgsim->useBemc(); trgsim->bemc->setConfig(StBemcTriggerSimu::kOnline); trgsim->useEemc(); trgsim->eemc->setSource("StEvent"); /* trgsim->bemc->setBarrelJetPatchTh0(32); trgsim->bemc->setBarrelJetPatchTh1(43); trgsim->bemc->setBarrelJetPatchTh2(64); */ trgsim->setBarrelJetPatchTh(0, 32); // set for Run-11 based on trigger versioning page 20130728 trgsim->setBarrelJetPatchTh(1, 43); trgsim->setBarrelJetPatchTh(2, 64); trgsim->setOverlapJetPatchTh(0, 32); trgsim->setOverlapJetPatchTh(1, 43); trgsim->setOverlapJetPatchTh(2, 64); trgsim->setEndcapJetPatchTh(0, 32); trgsim->setEndcapJetPatchTh(1, 43); trgsim->setEndcapJetPatchTh(2, 64); trgsim->setBarrelHighTowerTh(0, 11); trgsim->setBarrelHighTowerTh(1, 18); trgsim->setBarrelHighTowerTh(2, 25); trgsim->setBarrelHighTowerTh(3, 31); trgsim->setEndcapHighTowerTh(0, 25); trgsim->setEndcapHighTowerTh(1, 31); // StBfcTriggerFilterMaker* trgfilt = new StBfcTriggerFilterMaker; // no trigger filter for Run-11 VPDMB // trgfilt->SetOkAllEvents(1); // The BFC trigger filter will select only JP1, AJP and BHT3 events // trgfilt->SetJP1(); // trgfilt->SetAJP(); // trgfilt->SetBHT3(); // Lower all jet patch thresholds by one unit from // their values obtained from the database using // the current timestamp. //trgfilt->changeJPThresh(-1); chain3->AddBefore("tpcChain", trgsim); // chain3->AddBefore("tpcChain",trgfilt); // no trigger filter for Run-11 VPDMB // Move these makers after trigger decision // *** VERY IMPORTANT *** // The order of TpxRaw and TpcRS *must* be preserved // or the embedding will *not* work. [RT# 2299] // http://www.star.bnl.gov/rt2/Ticket/Display.html?id=2299 StTpcRSMaker *TpcRS = (StTpcRSMaker *)chain2->GetMaker("TpcRS"); StTpcHitMaker *TpxRaw = (StTpcHitMaker *)chain1->GetMaker("TpxRaw"); chain3->AddBefore("TpcMixer", TpxRaw); chain3->AddBefore("TpcMixer", TpcRS); #if 0 // Turn on debugging of DB maker St_db_Maker *db = (St_db_Maker *)chain1->GetMaker("db"); db->SetDebug(2); #endif //-------------------------------------------------------------------------- TString trgfile = gSystem->BaseName(fzdFile.c_str()); trgfile.ReplaceAll(".fzd", ".trig.root"); TFile *ofile = TFile::Open(trgfile, "recreate"); assert(ofile); TH2F *hBarrelHighTowerSimu = new TH2F("hBarrelHighTowerSimu", "BEMC high tower simu;trigger patch;high tower", 300, 0, 300, 64, 0, 64); TH2F *hBarrelPatchSumSimu = new TH2F("hBarrelPatchSumSimu", "BEMC patch sum simu;trigger patch;patch sum", 300, 0, 300, 64, 0, 64); TH2F *hEndcapHighTowerSimu = new TH2F("hEndcapHighTowerSimu", "EEMC high tower simu;trigger patch;high tower", 90, 0, 90, 64, 0, 64); TH2F *hEndcapPatchSumSimu = new TH2F("hEndcapPatchSumSimu", "EEMC patch sum simu;trigger patch;patch sum", 90, 0, 90, 64, 0, 64); TH2F *hBarrelJetPatchSimu = new TH2F("hBarrelJetPatchSimu", "BEMC jet patch;jet patch;adc", 18, 0, 18, 160, 0, 160); TH2F *hEndcapJetPatchSimu = new TH2F("hEndcapJetPatchSimu", "EEMC jet patch;jet patch;adc", 6, 0, 6, 160, 0, 160); TH2F *hOverlapJetPatchSimu = new TH2F("hOverlapJetPatchSimu", "BEMC-EEMC-overlap;jet patch;adc", 6, 0, 6, 160, 0, 160); } //-------------------------------------------------------------------------- // Initialize chain Chain->Init(); PrintTimer(Chain); puts("Order of makers in BFCMIXER:"); StMaker::lsMakers(Chain); // Event loop int mNTotal = 0; int mNFailed = 0; TBenchmark evnt; StIOMaker *inputStream = (StIOMaker *)chain1->GetMaker("inputStream"); for (int iEvent = 1; iEvent <= nEvents; ++iEvent) { evnt.Reset(); evnt.Start("QAInfo:"); Chain->Clear(); int iMake = Chain->Make(iEvent); if (iMake == kStErr) ++mNFailed; if (inputStream->GetMakeReturn() % 10 == kStEOF) { inputStream->Rewind(); --iEvent; continue; } //if (iMake == kStSkip) continue; if (iMake % 10 == kStEOF || iMake % 10 == kStFatal) break; ++mNTotal; PrintTimer(Chain); //-------------------------------------------------------------------------- if (flag == "Jet") { // BEMC high towers and trigger patches for (int triggerpatch = 0; triggerpatch < 300; ++triggerpatch) { hBarrelHighTowerSimu->Fill(triggerpatch, trgsim->bemc->getBEMC_FEE_HT_ADC()[triggerpatch]); hBarrelPatchSumSimu->Fill(triggerpatch, trgsim->bemc->getBEMC_FEE_TP_ADC()[triggerpatch]); } // for triggerpatch // BEMC jet patches for (int jetpatch = 0; jetpatch < 18; ++jetpatch) { hBarrelJetPatchSimu->Fill(jetpatch, trgsim->bemc->barrelJetPatchAdc(jetpatch)); } // for jetpatch // EEMC high towers and trigger patches for (int triggerpatch = 0; triggerpatch < 90; ++triggerpatch) { hEndcapHighTowerSimu->Fill(triggerpatch, trgsim->eemc->getEndcapHighTower(triggerpatch)); hEndcapPatchSumSimu->Fill(triggerpatch, trgsim->eemc->getEndcapPatchSum(triggerpatch)); } // for triggerpatch // EEMC jet patches for (int jetpatch = 0; jetpatch < 6; ++jetpatch) { hEndcapJetPatchSimu->Fill(jetpatch, trgsim->eemc->endcapJetPatchAdc(jetpatch)); } // for jetpatch // BEMC-EEMC-overlap jet patches for (int i = 0; i < 2; ++i) { int jetpatch, adc; trgsim->emc->getOverlapJetPatchAdc(i, jetpatch, adc); hOverlapJetPatchSimu->Fill(jetpatch, adc); } // for i } //end of if("jet") //-------------------------------------------------------------------------- evnt.Stop("QAInfo:"); printf("QAInfo: Done with Event [no. %d/run %d/evt. %d/Date.Time %d.%d/sta %d] Real Time = %10.2f seconds Cpu Time = %10.2f seconds\n", iEvent, Chain->GetRunNumber(), Chain->GetEventNumber(), Chain->GetDate(), Chain->GetTime(), chain3->GetMakeReturn(), evnt.GetRealTime("QAInfo:"), evnt.GetCpuTime("QAInfo:")); } // End event loop printf("QAInfo:EventLoop completed code %d\n", iMake); gSystem->Exec("date"); TDatime t; printf("QAInfo:Run is finished at Date/Time %i/%i; Total events processed: %i and not completed: %i\n", t.GetDate(), t.GetTime(), mNTotal, mNFailed); //-------------------------------------------------------------------------- if (flag == "Jet") { ofile->Write(); ofile->Close(); } }
//_____________________________________________________________________ void bfcMixer_Ftpc(const Int_t Nevents=20, const Char_t *daqfile="/star/rcf/test/daq/2008/emb/st_fmsslow_adc_9069059_raw_1520001.daq", const Char_t *tagfile="/star/rcf/test/daq/2008/emb/daqtags/st_fmsslow_adc_9069059_raw_1520001.tags.root", const Double_t pt_low=0.2, const Double_t pt_high=0.5, const Double_t eta_low=2.25, const Double_t eta_high=4.45, const Double_t vzlow = -50.0, const Double_t vzhigh = 50.0, const Int_t pid=8, const Double_t mult=1, const std::vector<Int_t> triggers = 0, const Char_t *prodName = "P08iepp", const Char_t* type = "FlatPt") { // production chains for P08ic - p+p, Au+Au 9 GeV and d+Au TString prodP08iepp("DbV20081117 B2008a ITTF IAna ppOpt l3onl emcDY2 fpd ftpc trgd ZDCvtx NosvtIT NossdIT Corr4 OSpaceZ2 OGridLeak3D VFMCE -hitfilt"); // TString prodP08icpp("DbV20080712,pp2008,ITTF,OSpaceZ2,OGridLeak3D,beamLine,VFMCE,TpxClu -VFPPV -hitfilt"); // TString prodP08icAuAu9("DbV20080709 P2008 ITTF VFMCE -hitfilt"); // TString prodP08icAuAu200("DbV20070101 P2008 ITTF VFMCE -hitfilt"); // TString prodP08icdAu("DbV20080712 P2008 ITTF OSpaceZ2 OGridLeak3D beamLine, VFMCE TpxClu -VFMinuit -hitfilt"); TString prodP08iedAu("DbV20090213 P2008 ITTF OSpaceZ2 OGridLeak3D beamLine VFMCE TpxClu -VFMinuit -hitfilt"); TString prodP10iapp("DbV20091001 pp2009c TpcRS ITTF OSpaceZ2 OGridLeak3D beamLine, VFMCE TpcRS -VFMinuit -hitfilt"); TString geomP08ic("ry2008"); TString chain1Opt("in,magF,tpcDb,NoDefault,TpxRaw,-ittf,NoOutput"); // TString chain2Opt("NoInput,PrepEmbed,gen_T,geomT,sim_T,TpcRS,-ittf,-tpc_daq,nodefault"); TString chain2Opt("NoInput,PrepEmbed,gen_T,geomT,sim_T,ftpcT,trs,fss,-ittf,-tpc_daq,nodefault"); chain2Opt += " "; chain2Opt += geomP08ic; TString chain3Opt(""); if (prodName == "P08icpp") { chain3Opt = prodP08icpp; } else if (prodName == "P08iepp") { chain3Opt = prodP08iepp; } else if (prodName == "P08icAuAu9") { chain3Opt = prodP08icAuAu9; } else if (prodName == "P08icdAu") { chain3Opt = prodP08icdAu; } else if (prodName == "P08iedAu") { chain3Opt = prodP08iedAu; } else if (prodName == "P08icAuAu200") { chain3Opt = prodP08icAuAu200; } else if (prodName == "P10iapp") { chain3opt = prodP10iapp; } else { cout << "Choice prodName does not correspond to known chain. Processing impossible. " << endl; return; } chain3Opt += ",Embedding,TpcMixer,GeantOut,MiniMcMk,McAna,-in,NoInput,useInTracker"; chain3Opt += ","; chain3Opt += geomP08ic; // Dynamically link some shared libs gROOT->LoadMacro("bfc.C"); if (gClassTable->GetID("StBFChain") < 0) Load(); //______________Create the main chain object______________________________________ Chain = new StChain("Embedding"); //________________________________________________________________________________ bfc(-1,chain1Opt,daqfile); chain1 = chain; chain1->SetName("One"); Chain->cd(); //________________________________________________________________________________ bfc(-1,chain2Opt); chain2 = chain; chain2->SetName("Two"); Chain->cd(); #if 1 if (chain2->GetOption("TRS")) { StTrsMaker *trsMk = (StTrsMaker *) chain2->GetMaker("Trs"); if (! trsMk) { cout << "Cannot find Trs in chain2" << endl; return; } trsMk->setNormalFactor(1.32); trsMk->SetMode(0); } #endif //________________________________________________________________________________ gSystem->Load("StFtpcMixerMaker"); StFtpcMixerMaker *ftpcmixer = new StFtpcMixerMaker("FtpcMixer","daq","fss"); ftpcmixer->SetInput("Input1","StDAQReader"); ftpcmixer->SetInput("Input2","Event"); //________________________________________________________________________________ TString OutputFileName(gSystem->BaseName(daqfile)); OutputFileName.ReplaceAll("*",""); OutputFileName.ReplaceAll(".daq",""); // OutputFileName.Append("_emb.root"); OutputFileName.Append(".root"); bfc(-1,chain3Opt,0,OutputFileName); chain3 = chain; chain3->SetName("Three"); Chain->cd(); //________________________________________________________________________________ StTpcMixerMaker *mixer = (StTpcMixerMaker *) chain3->Maker("TpcMixer"); if( prodName == "P08icAuAu200") { mixer->SetInput("Input1","MixerEvent"); } else { mixer->SetInput("Input1","TpxRaw/.data/Event"); } mixer->SetInput("Input2","Trs/.const/Event"); Chain->cd(); #if 0 //............. begin of EMC embedding makers................ //.............. Add BEmc stuff here .................... gSystem->Load("StEmcSimulatorMaker"); gSystem->Load("StEmcMixerMaker"); gSystem->Load("StEEmcSimulatorMaker"); StMcEventMaker* mcEventMaker = new StMcEventMaker(); StEmcSimulatorMaker *bemcSim = new StEmcSimulatorMaker(); StEmcMixerMaker *bemcMixer = new StEmcMixerMaker(); chain3->AddAfter("emcRaw",bemcMixer); chain3->AddAfter("emcRaw",bemcSim); chain3->AddAfter("emcRaw",mcEventMaker); bemcMixer->SetDebug(0); // set it to 1 for more printouts // note, Barrel slow sim is always ON, said Adam //........... Add EEmc Stuff ( Simu, and Mixer) here .............. StEEmcFastMaker *eemcFastSim = new StEEmcFastMaker(); StEEmcMixerMaker *eemcMixer = new StEEmcMixerMaker(); /* position B+E EMC makers in the chain (order is reverse because 'After' is used - looks funny but is right) */ chain3->AddAfter("emcRaw",eemcMixer); chain3->AddAfter("emcRaw",eemcFastSim); eemcFastSim->SetEmbeddingMode(); // eemcFastSim->SetDebug(); // eemcMixer->SetDebug(); bool useEndcapSlowSim = true; if(useEndcapSlowSim) { // turn Endcap slow simu On/Off StEEmcSlowMaker *slowSim=new StEEmcSlowMaker(); chain3->AddAfter("EEmcFastSim",slowSim); slowSim->setEmbeddingMode(); } #endif //________________________________________________________________________________ { TDatime t; gMessMgr->QAInfo() << Form("Run is started at Date/Time %i/%i",t.GetDate(),t.GetTime()) << endm; } gMessMgr->QAInfo() << Form("Run on %s in %s",gSystem->HostName(),gSystem->WorkingDirectory()) << endm; gMessMgr->QAInfo() << Form("with %s", Chain->GetCVS()) << endm; // embedded particle set StPrepEmbedMaker *embMk = (StPrepEmbedMaker *) Chain->Maker("PrepEmbed"); if (! embMk) return; cout << "bfcMixer: Setting PID: "<<pid<<endl; embMk->SetTagFile(tagfile); // pTlow,ptHigh,etaLow,etaHigh,phiLow,phiHigh embMk->SetOpt( pt_low, pt_high, eta_low, eta_high, 0., 6.283185, type); // pid, mult embMk->SetPartOpt( pid,mult); // Default is no event selections embMk->SetSkipMode(kTRUE); // Make trigger and z-vertex cuts (only if SkipMode is true) // Trigger cut // Can put multiple trigger id's if ( !triggers.empty() ) { for(std::vector<Int_t>::iterator iter = triggers.begin(); iter != triggers.end(); iter++) { embMk->SetTrgOpt((*iter)) ; } } // z-vertex cuts embMk->SetZVertexCut(vzlow, vzhigh) ; TAttr::SetDebug(0); Chain->SetAttr(".Privilege",0,"*" ); //All makers are NOT priviliged Chain->SetAttr(".Privilege",1,"StBFChain::*" ); //StBFChain is priviliged Chain->SetAttr(".Privilege",1,"StIOInterFace::*" ); //All IO makers are priviliged Chain->SetAttr(".Privilege",1,"St_geant_Maker::*"); //It is also IO maker Chain->SetAttr(".Privilege",1,"StPrepEmbedMaker::*"); //It is also IO maker // Chain->SetDEBUG(0); if (Nevents < 0) return; Int_t iInit = Chain->Init(); if (iInit >= kStEOF) { Chain->FatalErr(iInit,"on init"); return; } StMaker *treeMk = Chain->GetMaker("outputStream"); Chain->EventLoop(Nevents,treeMk); gMessMgr->QAInfo() << "Run completed " << endm; gSystem->Exec("date"); }
//_____________________________________________________________________ void bfcMixer_pp2006( Int_t Nevents=10, Char_t *file1="star/data03/daq/2006/120/7120049/st_physics_adc_7120049_raw_1050001.daq", // probably ppLong 2006 run, NOT for real embedding - just for testing //Char_t *file1="st_zerobias_7118049_raw_1110001.daq",// contains 127 events, good foor real embedding // Char_t *file2="eleB.fzd", // one-particle events from Naresh Char_t *file2="mcpi0_hipt_run140_gid7_1000evts.fzd", Int_t useEndcapSlowSim=1 // note, Barrel slow sim is always ON, said Adam ){ TString path1="/"; //TString path2="/star/data04/sim/subbanly/electron2006/oneTrack2Keve/fzd/"; TString path2="/star/u/wzhang/links/gc2002/EEmc/embedData/fzd/"; // Dynamically link some shared libs if (gClassTable->GetID("StBFChain") < 0) Load(); // Create the main chain object chain = new StBFChain("Embedding"); StMaker *saveMk = 0; chain->SetFlags("-ittf,NoDefault"); // Create chain1 object chain1 = new StBFChain("One"); saveMk = chain1->cd(); chain1->SetFlags("in Physics NoDefault -ittf -trg"); //Akio said OK for '-trg'. chain1->Set_IO_Files(path1+file1); chain1->Load(); chain1->Instantiate(); saveMk->cd(); // Create chain2 object chain2 = new StBFChain("Two"); saveMk = chain2->cd(); chain2->SetFlags("fzin gen_T geomT sim_T tpc trs -tcl -tpt -PreVtx -tpc_daq -ittf "); chain2->Set_IO_Files(path2+file2); chain2->Load(); chain2->Instantiate(); St_geant_Maker *geantMk = chain2->GetMaker("geant"); if (geantMk) geantMk->SetMode(1); // Mixer mode - do not modify EvtHddr // do not rescale dEdx in TRS, it leads to wrong cluster formation, from Jamie saveMk->cd(); // Mixer for TPC gSystem->Load("StMixerMaker"); StMixerMaker *mixer = new StMixerMaker("Mixer","daq","trs"); chain1->SetInput("Input1","StDAQReader"); chain2->SetInput("Input2","Event"); mixer->writeFile("mixer.trs",Nevents); // Create chain3 object chain3 = new StBFChain("Three"); saveMk = chain3->cd(); // options for 2006pp, production=DbV20060915,pp2006b,ITTF,hitfilt chain3->SetFlags("Simu NoDefault NoInput onlraw -onlcl ry2006,tpc_daq,tpcI,svt_daq,SvtD,Physics,Idst,l0,Tree,evout l3onl fcf emcDY2 fpd trgd ZDCvtx useCDV ITTF tofDat -SvtIT MuDST -trg VFPPVnoCTB beamline GeantOut CMuDst dEdxY2 -EventQA"); // Note, do not freez the DB time stamp or you will not see the latest gains/peds/stat TString tt1=file1; TString tt2=file2; tt1.ReplaceAll(".daq",""); tt2.ReplaceAll(".fzd",""); TString OutputFileName=tt1+"_"+tt2+".root"; cout <<"BFC: Setting file output to: " <<OutputFileName.Data()<<endl; chain3->Set_IO_Files(0,OutputFileName.Data()); chain3->Load(); chain3->Instantiate(); //............. begin of EMC embedding makers................ //.............. Add BEmc stuff here .................... StMcEventMaker* mcEventMaker = new StMcEventMaker(); StEmcSimulatorMaker *bemcSim = new StEmcSimulatorMaker(); StEmcMixerMaker *bemcMixer = new StEmcMixerMaker(); chain3->AddAfter("emcRaw",bemcMixer); chain3->AddAfter("emcRaw",bemcSim); chain3->AddAfter("emcRaw",mcEventMaker); bemcMixer->SetDebug(0); // set it to 1 for more printouts // note, Barrel slow sim is always ON, said Adam //........... Add EEmc Stuff ( Simu, and Mixer) here .............. StEEmcFastMaker *eemcFastSim = new StEEmcFastMaker(); StEEmcMixerMaker *eemcMixer = new StEEmcMixerMaker(); /* position B+E EMC makers in the chain (order is reverse because 'After' is used - looks funny but is right) */ chain3->AddAfter("emcRaw",eemcMixer); chain3->AddAfter("emcRaw",eemcFastSim); eemcFastSim->SetEmbeddingMode(); // eemcFastSim->SetDebug(); // eemcMixer->SetDebug(); if(useEndcapSlowSim) { // turn Endcap slow simu On/Off StEEmcSlowMaker *slowSim=new StEEmcSlowMaker(); chain3->AddAfter("EEmcFastSim",slowSim); slowSim->setEmbeddingMode(); } //............. end of EMC embedding makers................ St_geant_Maker *geantMk = (St_geant_Maker *) chain->GetMaker("geant"); geantMk->SetActive(kTRUE); StMaker *tpcdaqMk = chain3->GetMaker("tpc_raw"); if(!tpcdaqMk ) { cout <<" Error: no tpc daq maker. End. "<<endl; return; } tpcdaqMk->SetMode(1); // Trs tpcdaqMk->SetInput("Event","MixerEvent"); saveMk->cd(); { TDatime t; printf ("QAInfo:Run is started at Date/Time%i/%i\n",t.GetDate(),t.GetTime()); } printf ("QAInfo:Run on %s in %s\n", gSystem->HostName(), gSystem->WorkingDirectory()); printf ("QAInfo: with %s\n", chain->GetCVS()); // Init the chain and all its makers if (Nevents >= 0) { Int_t iInit = chain->Init(); chain->ls(5); // list the final chain } // chain->SetDEBUG(); treeMk = chain->GetMaker("tree"); TBenchmark evnt; Int_t iMake = 0, i = 1, iBad = 0; StIOMaker *inpMk = (StIOMaker *)chain1->GetMaker("inputStream"); Int_t ncols, eventnumber, mult, skip=0, oldskip = 0, skiptest=0; cout <<"BFC - Entering Event Loop"<<endl; EventLoop: if (i <= Nevents && iMake != kStEOF && iMake != kStFatal) { evnt.Reset(); evnt.Start("QAInfo:"); chain->Clear(); iMake = chain->Make(i); if (treeMk && iMake == kStErr) {treeMk->Make(i); iBad++;} StEvtHddr *fEvtHddr = (StEvtHddr*)chain->GetDataSet("EvtHddr"); StEvtHddr *fEvtHddrDaq = (StEvtHddr*)chain1->GetDataSet("EvtHddr"); *fEvtHddr = *fEvtHddrDaq; // gSystem->Exec("ps ux"); evnt.Stop("QAInfo:"); // evnt->Show("QAInfo:"); printf ("QAInfo: Done with Event [no. %d/run %d/evt. %d/Date.Time%d.%d/sta %d] Real Time = %10.2f seconds Cpu Time = %10.2f seconds \n", i,chain->GetRunNumber(),chain->GetEventNumber(),chain->GetDate(), chain->GetTime(), iMake,evnt.GetRealTime("QAInfo:"),evnt.GetCpuTime("QAInfo:")); i++; goto EventLoop; } fflush(stdout); printf ("QAInfo:Run completed "); gSystem->Exec("date"); }
// // main function // void DoOneProcess(TString InputCfAName, TString ProcessName, float weight) { // // Get tree // TChain * chainA = new TChain("/configurableAnalysis/eventA"); TChain * chainB = new TChain("/configurableAnalysis/eventB"); chainA->Add(InputCfAName); chainB->Add(InputCfAName); InitializeA(chainA); InitializeB(chainB); // // histograms // TH1F *h1_result = new TH1F("h1_result","h1_result", 1, 0, 1); // // main event loop // Int_t nentries = (Int_t)chainA->GetEntries(); cout<<"The number of entries is: "<<nentries<<endl; // Progress tracking int i_permille_old = 0; TDatime DTStart; int StartDate = DTStart.GetDate(); int StartTime = DTStart.GetTime(); cout << "Start time : " << StartTime << endl; for(int i = 0; i<nentries; i++) { // Progress tracking begin -------------------------------- int i_permille = (int)floor(1000 * i / float(nentries)); TDatime DTCurrent; int CurrentDate = DTCurrent.GetDate(); int CurrentTime = DTCurrent.GetTime(); int TimeLaps = (CurrentDate-StartDate)*1000000+(CurrentTime-StartTime); int TimeToRun = (float)nentries/(float)i*TimeLaps; if (i_permille != i_permille_old) { // xterm magic from L. Vacavant and A. Cerri if (isatty(1)) { printf("\015\033[32m Processed :: \033[1m\033[31m%4.1f %%" "\033[0m\033[32m Expected processing time :: \033[1m\033[31m%i:%i:%i \033[0m\015", i_permille/10., (TimeToRun/10000)%100<60 ? (TimeToRun/10000)%100 : (TimeToRun/10000)%100-40, (TimeToRun/100)%100<60 ? (TimeToRun/100)%100 : (TimeToRun/100)%100-40, (TimeToRun%100)<60 ? (TimeToRun)%100 : (TimeToRun)%100-40 ); fflush(stdout); } i_permille_old = i_permille; } // Progress tracking end ---------------------------------- // get an entry of an event chainA->GetEntry(i); chainB->GetEntry(i); // // Core analysis // // Getting good muons vector<int> RA4MuonVeto; RA4MuonVeto.clear(); vector<int> RA4Muon = GetRA4Muon(RA4MuonVeto); // Getting good electrons vector<int> RA4ElecVeto; RA4ElecVeto.clear(); vector<int> RA4Elec = GetRA4Elec(RA4ElecVeto, "", 0, true); // Containers for B-tagged jets vector<int> LooseBJet; vector<int> MediumBJet; // HT double HT=-999.; // MJ vector<float> Vector_mj; // mj double MJ=-999.; // Getting good skinny jets vector<int> GoodJets_AK5PFclean = GetJets(RA4Muon,RA4Elec,RA4MuonVeto,RA4ElecVeto, HT,LooseBJet,MediumBJet, 2.4, 30, 0.3); for(int i=0; i<GoodJets_AK5PFclean.size(); i++) cout << event << " :: " << GoodJets_AK5PFclean.at(i) << endl; h1_result->Fill(0.5); /* // variables vector<float> Vector_mj; // mj float MJ=0; int Nfastjets=0; for(int ifastjet=0; ifastjet<(int)fastjets_AK5PF_px_->size(); ifastjet++) { // Number of jets float pT = TMath::Sqrt( fastjets_AK5PF_px_->at(ifastjet)*fastjets_AK5PF_px_->at(ifastjet) +fastjets_AK5PF_py_->at(ifastjet)*fastjets_AK5PF_py_->at(ifastjet)); float temp_mj = Getmj(fastjets_AK5PF_px_->at(ifastjet), fastjets_AK5PF_py_->at(ifastjet), fastjets_AK5PF_pz_->at(ifastjet), fastjets_AK5PF_energy_->at(ifastjet)); Vector_mj.push_back(temp_mj); if(Npv_ > 25) { h1_mj_fastjets_Npv26toInf->Fill(temp_mj); } else if(Npv_>15) { h1_mj_fastjets_Npv16to25->Fill(temp_mj); } else { h1_mj_fastjets_Npv0to15->Fill(temp_mj); } Nfastjets++; } // Get MJ MJ = GetMJ(Vector_mj); // fill histogram for MJ and Njets if(Npv_ > 25) { h1_njets_fastjets_Npv26toInf->Fill( TMath::Min((Float_t)Nfastjets,(Float_t)29.499) ); h1_MJ_fastjets_Npv26toInf->Fill(MJ); } else if(Npv_>15) { h1_njets_fastjets_Npv16to25->Fill( TMath::Min((Float_t)Nfastjets,(Float_t)29.499) ); h1_MJ_fastjets_Npv16to25->Fill(MJ); } else { h1_njets_fastjets_Npv0to15->Fill( TMath::Min((Float_t)Nfastjets,(Float_t)29.499) ); h1_MJ_fastjets_Npv0to15->Fill(MJ); } */ } // event loop cout << endl; cout << "... Looping events done" << endl; // // Write the result // TString ResultFileName = ProcessName+".root"; //TString ResultFileName = InputCfAName; //ResultFileName.ReplaceAll(".root", ""); //ResultFileName.ReplaceAll("/", "_"); //ResultFileName = "Result_"+ResultFileName+".root"; //ResultFileName.ReplaceAll("__", "_"); cout << "Writing " << ResultFileName << endl; TFile *ResultFile = new TFile(ResultFileName, "RECREATE"); gROOT->cd(); ResultFile->cd(); h1_result->SetDirectory(0); h1_result->Write(); ResultFile->Close(); TDatime DTEnd; int EndTime = DTEnd.GetTime(); cout << "End time : " << EndTime << endl; // cleanup delete chainA; delete chainB; delete ResultFile; }
//gStyle->SetTitleFontSize(0.2); //gStyle->SetTitleSize(0.8,"t"); gStyle->SetTitleH(0.22); gStyle->SetTitleW(0.4); gStyle->SetTitleX(0.25); gStyle->SetTitleY(1.020); gStyle->SetPadLeftMargin(0.2); gStyle->SetPadRightMargin(0.15); gStyle->SetPadTopMargin(0.18); gStyle->SetPadBottomMargin(0.2); //gStyle->SetLabelOffset(0.025,"Y"); //gStyle->SetStripDecimals(kFALSE); Int_t nn=20; TDatime tt; Int_t time=tt.GetTime(); Double_t xx[nn],yy[nn],ex[nn],ey[nn]; for(Int_t i=0;i<nn;i++){ xx[i]=10000.+i*10; yy[i]=time+i*60; //yy[i]=i*60; ex[i]=xx[i]/10.; ey[i]=0; } Int_t ncd=1, i=1; Int_t NCD=7; TGraphErrors *f1= new TGraphErrors(nn,xx,yy,ex,ey); f1->GetXaxis()->SetLabelSize(0.1); f1->GetYaxis()->SetLabelSize(0.1); f1->GetXaxis()->SetNdivisions(401,kFALSE); f1->GetYaxis()->SetNdivisions(-410,kFALSE);
//_____________________________________________________________________ void bfcMixer_TpcSvtSsd(const Int_t Nevents=500,Int_t isSvtIn=1, Int_t isSsdIn=1, const Char_t *daqfile="/star/rcf/test/daq/2007/113/8113044/st_physics_8113044_raw_1040042.daq", const Char_t *tagfile="/star/rcf/test/embedding/2007ProductionMinBias/FullField/P08if/2007/113/8113044/st_physics_8113044_raw_1040042.tags.root", const Double_t pt_low=0.1, const Double_t pt_high=5.0, const Double_t eta_low=-1.1, const Double_t eta_high=1.1, const Double_t vzlow=-175.0, const Double_t vzhigh=175.0, const Int_t pid=8, const Double_t mult = 100., const std::vector<Int_t> triggers = 0, const Char_t* prodName = "P08icAuAu", const Char_t* mode="flatpt" ) { // Separate DB timestamp to add it in both chain1 and chain3 TString DbVP06idpp("DbV20060729 "); TString DbVP07icCuCu("DbV20070518 "); TString DbVP08icAuAu("DbV20080418 "); // production chains for P06id - p+p 200 GeV (Run6) TString prodP06idpp("pp2006b ITTF OSpaceZ2 OGridLeak3D VFMCE -VFPPVnoCTB -hitfilt"); // production chain for P07ib // TString prodP07ib("P2005b DbV20070518 MakeEvent ITTF Iana ToF spt SsdIt SvtIt pmdRaw SCEbyE OGridLeak OShortR OSpaceZ2 ssd_daq");// KeepSvtHit hitfilt skip1row"); // production chain for P07ic - Cu+Cu 200 GeV (Run5) TString prodP07icCuCu("P2005b DbV20070518 MakeEvent ITTF ToF ssddat spt SsdIt SvtIt pmdRaw OGridLeak OShortR OSpaceZ2 KeepSvtHit skip1row VFMCE -VFMinuit -hitfilt"); // production chain for P08if // TString prodP08if("B2007g DbV20080418 adcOnly MakeEvent ITTF Iana ToF spt SsdIt SvtIt pmdRaw SCEbyE OShortR trgd Corr5 OSpaceZ2 ssd_daq KeepSvtHit -hitfilt VFMCE");// KeepSvtHit hitfilt skip1row"); // Production chain for P08ic Au+Au 200 GeV (Run7) TString prodP08icAuAu("B2007g ITTF adcOnly IAna KeepSvtHit VFMCE -hitfilt l3onl emcDY2 fpd ftpc trgd ZDCvtx svtIT ssdIT Corr5 -dstout"); TString geomP06id("ry2006"); TString geomP07ic("ry2005f"); TString geomP08ic("ry2007g"); // TString chain1Opt("in magF tpcDb adcOnly NoDefault -ittf NoOutput"); TString chain1Opt("in magF tpcDb NoDefault -ittf NoOutput"); TString chain2Opt("NoInput PrepEmbed gen_T geomT sim_T trs -ittf -tpc_daq nodefault"); TString chain3Opt(""); if( prodName == "P06idpp") { chain1Opt.Prepend(DbVP06idpp); chain2Opt += " "; chain2Opt += geomP06id; chain3Opt = prodP06idpp ; } else if( prodName == "P07ic" ){ chain1Opt.Prepend(DbVP07icCuCu); chain2Opt += " "; chain2Opt += geomP07ic; chain3Opt = prodP07icCuCu; } else if ( prodName == "P08icAuAu" ){ chain1Opt.Prepend(DbVP08icAuAu); chain2Opt += " "; chain2Opt += geomP08ic; chain3Opt = prodP08icAuAu ; } else{ cout << "Choice prodName does not correspond to known chain. Processing impossible. " << endl; return; } // chain3Opt += " Embedding onlraw GeantOut MiniMcMk McAna IdTruth -in NoInput,useInTracker EmbeddingShortCut"; // chain3Opt += " Embedding onlraw McEvent McEvOut GeantOut MiniMcMk McAna IdTruth -in NoInput,useInTracker -hitfilt EmbeddingShortCut"; chain3Opt += " TpcMixer Embedding onlraw McEvent McEvOut GeantOut MiniMcMk McAna IdTruth -in NoInput,useInTracker -hitfilt -TrsPileUp -TrsToF"; // chain3Opt += " Embedding onlraw McEvent McEvOut GeantOut IdTruth -in NoInput -hitfilt EmbeddingShortCut"; if (isSvtIn) chain3Opt += " SvtEmbed"; if (isSsdIn) { chain1Opt += ",ssddat"; chain2Opt += ",ssd,McEvent,-spt"; chain3Opt += ",SsdEmbed"; } if( prodName == "P06idpp") { chain3Opt.Prepend(DbVP06idpp); chain3Opt += " "; chain3Opt += geomP06id; } else if( prodName == "P07ic" ){ chain3Opt.Prepend(DbVP07icCuCu); chain3Opt += " "; chain3Opt += geomP07ic; } else if ( prodName == "P08icAuAu" ){ chain3Opt.Prepend(DbVP08icAuAu); chain3Opt += " "; chain3Opt += geomP08ic; } else{ cout << "Choice prodName does not correspond to known chain. Processing impossible. " << endl; return; } // Dynamically link some shared libs gROOT->LoadMacro("bfc.C"); if (gClassTable->GetID("StBFChain") < 0) Load(); //______________Create the main chain object______________________________________ Chain = new StChain("Embedding"); //________________________________________________________________________________ bfc(-1,chain1Opt,daqfile); chain1 = chain; chain1->SetName("One"); Chain->cd(); //________________________________________________________________________________ bfc(-1,chain2Opt); chain2 = chain; chain2->SetName("Two"); Chain->cd(); if (chain2->GetOption("TRS")){ StTrsMaker *trsMk = (StTrsMaker *) chain2->GetMaker("Trs"); if (! trsMk) { cout << "Cannot find Trs in chain2" << endl; return; } trsMk->setNormalFactor(1.05); trsMk->SetMode(0); } //________________________________________________________________________________ // gSystem->Load("StFtpcMixerMaker"); // StFtpcMixerMaker *ftpcmixer = new StFtpcMixerMaker("FtpcMixer","daq","trs"); //________________________________________________________________________________ TString OutputFileName(gSystem->BaseName(daqfile)); OutputFileName.ReplaceAll("*",""); OutputFileName.ReplaceAll(".daq",""); // OutputFileName.Append("_emb.root"); OutputFileName.Append(".root"); bfc(-1,chain3Opt,0,OutputFileName); chain3 = chain; chain3->SetName("Three"); Chain->cd(); Chain->cd(); //________________________________________________________________________________ { TDatime t; gMessMgr->QAInfo() << Form("Run is started at Date/Time %i/%i",t.GetDate(),t.GetTime()) << endm; } gMessMgr->QAInfo() << Form("Run on %s in %s",gSystem->HostName(),gSystem->WorkingDirectory()) << endm; gMessMgr->QAInfo() << Form("with %s", Chain->GetCVS()) << endm; // embedded particle set StPrepEmbedMaker *embMk = (StPrepEmbedMaker *) Chain->Maker("PrepEmbed"); if (! embMk) return; embMk->SetTagFile(tagfile); // pTlow,ptHigh,etaLow,etaHigh,phiLow,phiHigh embMk->SetOpt( pt_low, pt_high, eta_low, eta_high, 0., 6.283185, mode); // pid, mult embMk->SetPartOpt( pid,mult); // Set Skip mode (default is OFF) embMk->SetSkipMode(kFALSE) ; // Make trigger and z-vertex cuts (only if SkipMode is true) // Trigger cut // Can put multiple trigger id's if ( !triggers.empty() ){ for(std::vector<Int_t>::iterator iter = triggers.begin(); iter != triggers.end(); iter++){ embMk->SetTrgOpt((*iter)) ; } } // z-vertex cuts embMk->SetZVertexCut(vzlow, vzhigh) ; TAttr::SetDebug(0); Chain->SetAttr(".Privilege",0,"*" ); //All makers are NOT priviliged Chain->SetAttr(".Privilege",1,"StBFChain::*" ); //StBFChain is priviliged Chain->SetAttr(".Privilege",1,"StIOInterFace::*" ); //All IO makers are priviliged Chain->SetAttr(".Privilege",1,"St_geant_Maker::*"); //It is also IO maker Chain->SetAttr(".Privilege",1,"StPrepEmbedMaker::*"); //It is also IO maker StMaker *SsdEmbed = Chain->Maker("SsdEmbed"); if (SsdEmbed) { cout << "SsdEmbed has been found ----------------------------------------" << endl; SsdEmbed->SetInput("SsdRealData","One/.make/SpaStrip/.data/spa_strip"); SsdEmbed->SetInput("SsdSimuData","Two/.make/SpaStrip/.data/spa_strip"); StMaker *SsdPoint = Chain->Maker("SsdPoint"); if (SsdPoint) { cout << "SsdPoint has been found----------------------------------------" << endl; SsdPoint->SetInput("SpaStrip","SsdEmbed"); } } // Chain->SetDEBUG(0); if (Nevents < 0) return; Int_t iInit = Chain->Init(); if (iInit >= kStEOF) {Chain->FatalErr(iInit,"on init"); return;} StMaker *treeMk = Chain->GetMaker("outputStream"); Chain->EventLoop(Nevents,treeMk); gMessMgr->QAInfo() << "Run completed " << endm; gSystem->Exec("date"); }
//_____________________________________________________________________ void bfcMixer_TpcSvtSsd2005(const Int_t Nevents=100,Int_t isSvtIn=1, Int_t isSsdIn=1, const Char_t *daqfile="/star/rcf/test/daq/2005/051/st_physics_adc_6051006_raw_1050001.daq", const Char_t *tagfile="/star/rcf/test/embedding/cuProductionMinBias/FullField/P07ic/2005/051/st_physics_adc_6051006_raw_1050001.tags.root", const Double_t pt_low=0.1, const Double_t pt_high=5.0, const Double_t eta_low=-1.0, const Double_t eta_high=1.0, const Int_t pid=9, const Double_t mult = 0.1) { // production chain for P07ib TString prodP07ib("P2005b DbV20070518 MakeEvent ITTF Iana ToF spt SsdIt SvtIt pmdRaw SCEbyE OGridLeak OShortR OSpaceZ2 ssd_daq");// KeepSvtHit hitfilt skip1row"); TString geomP07ib("ry2005f"); TString chain1Opt("in magF tpcDb NoDefault -ittf NoOutput"); TString chain2Opt("NoInput PrepEmbed gen_T geomT sim_T trs -ittf -tpc_daq nodefault"); chain2Opt += " "; chain2Opt += geomP07ib; TString chain3Opt = prodP07ib; chain3Opt += " TpcMixer Embedding onlraw GeantOut MiniMcMk McAna IdTruth -in NoInput,useInTracker EmbeddingShortCut"; if (isSvtIn) chain3Opt += " SvtEmbed"; if (isSsdIn) { chain1Opt += ",ssddat"; chain2Opt += ",ssd,McEvent,-spt"; chain3Opt += ",SsdEmbed"; } chain3Opt += " "; chain3Opt += geomP07ib; // Dynamically link some shared libs gROOT->LoadMacro("bfc.C"); if (gClassTable->GetID("StBFChain") < 0) Load(); //______________Create the main chain object______________________________________ Chain = new StChain("Embedding"); //________________________________________________________________________________ bfc(-1,chain1Opt,daqfile); chain1 = chain; chain1->SetName("One"); Chain->cd(); //________________________________________________________________________________ bfc(-1,chain2Opt); chain2 = chain; chain2->SetName("Two"); Chain->cd(); if (chain2->GetOption("TRS")){ StTrsMaker *trsMk = (StTrsMaker *) chain2->GetMaker("Trs"); if (! trsMk) { cout << "Cannot find Trs in chain2" << endl; return; } trsMk->setNormalFactor(2.67); } //________________________________________________________________________________ // gSystem->Load("StFtpcMixerMaker"); // StFtpcMixerMaker *ftpcmixer = new StFtpcMixerMaker("FtpcMixer","daq","trs"); //________________________________________________________________________________ TString OutputFileName(gSystem->BaseName(daqfile)); OutputFileName.ReplaceAll("*",""); OutputFileName.ReplaceAll(".daq",""); // OutputFileName.Append("_emb.root"); OutputFileName.Append(".root"); bfc(-1,chain3Opt,0,OutputFileName); chain3 = chain; chain3->SetName("Three"); Chain->cd(); Chain->cd(); //________________________________________________________________________________ { TDatime t; gMessMgr->QAInfo() << Form("Run is started at Date/Time %i/%i",t.GetDate(),t.GetTime()) << endm; } gMessMgr->QAInfo() << Form("Run on %s in %s",gSystem->HostName(),gSystem->WorkingDirectory()) << endm; gMessMgr->QAInfo() << Form("with %s", Chain->GetCVS()) << endm; // embedded particle set StPrepEmbedMaker *embMk = (StPrepEmbedMaker *) Chain->Maker("PrepEmbed"); if (! embMk) return; embMk->SetTagFile(tagfile); // pTlow,ptHigh,etaLow,etaHigh,phiLow,phiHigh embMk->SetOpt( pt_low, pt_high, eta_low, eta_high, 0., 6.283185); // pid, mult embMk->SetPartOpt( pid,mult); TAttr::SetDebug(0); Chain->SetAttr(".Privilege",0,"*" ); //All makers are NOT priviliged Chain->SetAttr(".Privilege",1,"StBFChain::*" ); //StBFChain is priviliged Chain->SetAttr(".Privilege",1,"StIOInterFace::*" ); //All IO makers are priviliged Chain->SetAttr(".Privilege",1,"St_geant_Maker::*"); //It is also IO maker Chain->SetAttr(".Privilege",1,"StPrepEmbedMaker::*"); //It is also IO maker StMaker *SsdEmbed = Chain->Maker("SsdEmbed"); if (SsdEmbed) { cout << "SsdEmbed has been found ----------------------------------------" << endl; SsdEmbed->SetInput("SsdRealData","One/.make/SpaStrip/.data/spa_strip"); SsdEmbed->SetInput("SsdSimuData","Two/.make/SpaStrip/.data/spa_strip"); StMaker *SsdPoint = Chain->Maker("SsdPoint"); if (SsdPoint) { cout << "SsdPoint has been found----------------------------------------" << endl; SsdPoint->SetInput("SpaStrip","SsdEmbed"); } } // Chain->SetDEBUG(0); if (Nevents < 0) return; Int_t iInit = Chain->Init(); if (iInit >= kStEOF) {Chain->FatalErr(iInit,"on init"); return;} StMaker *treeMk = Chain->GetMaker("outputStream"); Chain->EventLoop(Nevents,treeMk); gMessMgr->QAInfo() << "Run completed " << endm; gSystem->Exec("date"); }
bool Exact_comparator::root_file_cmp (char *fn1, char *fn2) { TFile f1(fn1), f2(fn2); TIter next_1(f1.GetListOfKeys()), next_2(f2.GetListOfKeys()); TKey *k_1, *k_2; bool is_equal = true; char *obj_buf_1 = NULL, *obj_buf_2 = NULL; while (true) { k_1=(TKey*)next_1(); k_2=(TKey*)next_2(); // If there is no more keys if(!k_1 && !k_2) { break; } // If the size of two lists are not equal // then two root files are not equal if((k_1 && !k_2) || (!k_1 && k_2)) { is_equal = false; break; } if (!logic_compare(k_1, k_2)) { is_equal = false; break; } // compare buffer byte by byte Int_t obj_len = k_1->GetObjlen(); obj_buf_1 = read_obj_buf(&f1, k_1, obj_len); obj_buf_2 = read_obj_buf(&f2, k_2, obj_len); if (!cmp_obj_buf(obj_buf_1, obj_buf_2, obj_len)) { is_equal = false; break; } // compare the timestamp of two object const TDatime time_1 = k_1->GetDatime(), time_2 = k_2->GetDatime(); if((time_1.GetDate() != time_2.GetDate()) || (time_1.GetTime() != time_2.GetTime())) { is_equal = false; break; } } if(obj_buf_1 != NULL) { delete obj_buf_1; } if(obj_buf_2 != NULL) { delete obj_buf_2; } return is_equal; }
//_____________________________________________________________________ void bfcZ(const Int_t First, const Int_t Last, const Char_t *Chain="gstar Cy2b tfs -NoHits TpcHitFilter", const Char_t *infile=0, const Double_t zmin=-200, const Double_t zmax=-100, const Char_t *outfile=0, const Char_t *TreeFile=0){ gROOT->LoadMacro("bfc.C"); bfc(-1,Chain,infile,outfile,TreeFile); if (chain->GetOption("TpcHitFilter")) { StTpcHitFilterMaker *filtMk = (StTpcHitFilterMaker *) chain->GetMaker("tpc_hit_filter"); if (filtMk) { // St_tcl_Maker *tclMk= (St_tcl_Maker *) chain->GetMaker("tpc_hits"); if (zmin < 0 && zmax < 0) filtMk->WestOff(); if (zmin > 0 && zmax > 0) filtMk->EastOff(); filtMk->SetZrange(zmin,zmax); } } { TDatime t; printf ("QAInfo:Run is started at Date/Time %i/%i\n",t.GetDate(),t.GetTime()); printf ("QAInfo:Run on %s in %s\n", gSystem->HostName(), gSystem->WorkingDirectory()); printf ("QAInfo: with %s\n", chain->GetCVS()); } // Init the chain and all its makers Int_t iTotal = 0, iBad = 0; St_XDFFile *xdf_out = 0; TBenchmark evnt; Int_t iMake = 0, i = First; if (Last >= 0) { Int_t iInit = chain->Init(); if (iInit >= kStEOF) { chain->Fatal(iInit,"on init"); goto END; } StEvtHddr *hd = (StEvtHddr*)chain->GetDataSet("EvtHddr"); if (hd) hd->SetRunNumber(-2); // to be sure that InitRun calls at least once // skip if any if (First > 1) { if (chain->GetOption("fzin")) { geant = (St_geant_Maker *) chain->GetMaker("geant"); if (geant) { if (geant->IsActive()) geant->Skip(First-1); } } else { StIOMaker *inpMk = (StIOMaker *) chain->GetMaker("inputStream"); if (inpMk) {printf ("Skip %i Events\n",First-1);inpMk->Skip(First-1);} } } } xdf_out = chain->GetXdfOut(); if (chain->GetOption("Event")) evMk = (StEventMaker *) chain->GetMaker("StEventMaker"); treeMk = chain->GetMaker("OutputStream"); EventLoop: if (i <= Last && iMake != kStEOF && iMake != kStFatal) { evnt.Reset(); evnt.Start("QAInfo:"); chain->Clear(); iMake = chain->Make(i); if (iMake <kStEOF) { if (xdf_out){ St_DataSet *dstSet = chain->GetInputDS("dst"); if (dstSet) xdf_out->NextEventPut(dstSet); // xdf output } iTotal++; if (treeMk && iMake == kStErr) {treeMk->Make(i); iBad++;} // gSystem->Exec("ps ux"); evnt.Stop("QAInfo:"); // evnt.Show("QAInfo:"); printf ("QAInfo: Done with Event [no. %d/run %d/evt. %d/Date.Time %d.%d/sta %d] Real Time = %10.2f seconds Cpu Time = %10.2f seconds \n", i,chain->GetRunNumber(),chain->GetEventNumber(),chain->GetDate(), chain->GetTime(), iMake,evnt.GetRealTime("QAInfo:"),evnt.GetCpuTime("QAInfo:")); } i++; goto EventLoop; } END: fflush(stdout); printf ("QAInfo:Run completed "); gSystem->Exec("date"); if (evMk) Event = (StEvent *) chain->GetInputDS("StEvent"); { TDatime t; printf ("\nQAInfo:Run is finished at Date/Time %i/%i; Total events processed :%i and not completed: %i\n", t.GetDate(),t.GetTime(),iTotal,iBad); } }
void fitPtOverMCJLST(int mass = 125, int LHCsqrts = 7, int whichtype = 1, bool correctErrors = false, /* string changeParName = "", */ bool showErrorPDFs = false, string systString = "Default") // whichtype // 0 - gg Signal // 1 - VBF Signal // 2 - ZZ // 3 - ZX // 4 - ggZZ // 5 - WH // 6 - ZH // 7 - ttH { string changeParName = ""; if (systString == "Default") changeParName = "up"; string nameSample[8] = {"gg","vbf","zz","zx","ggzz","wh","zh","tth"}; float maxType[8] = {2.4,3.2,1.6,1.6,1.6,3.2,3.2,3.2}; float rebinType[8] = {1,2,1,1,4,10,10,40}; for (int t = 0; t < 8; t++) { if (mass > 150) maxType[t] = int(117.90*maxType[t]/sqrt(mass-10.91))/10.; } char fileToOpen[200]; sprintf(fileToOpen,"selRootFiles/PToverM_%s%d_SEL_%dTeV.root",nameSample[whichtype].c_str(),mass,LHCsqrts); // if (whichtype == 3) sprintf(fileToOpen,"PTOVERM_%s_SEL_allTeV.root",nameSample[whichtype].c_str()); RooRealVar* ptoverm = new RooRealVar("ptoverm","p_{T}/M^{4l}",0.,maxType[whichtype],"GeV/c"); TFile input(fileToOpen); // if (systString == "Mass" || systString == "Mela") { // sprintf(fileToOpen,"ptovermH_%sUp",systString.c_str()); // } else { sprintf(fileToOpen,"ptovermH_%s",systString.c_str()); //} TH1F* ptovermH = (TH1F*)input.Get(fileToOpen); if (rebinType[whichtype] > 1) ptovermH->Rebin(rebinType[whichtype]); if (maxType[whichtype] < ptovermH->GetBinLowEdge(ptovermH->GetNbinsX() + 1) - ptovermH->GetBinWidth(1)) { int theBin = ptovermH->FindBin(maxType[whichtype]); ptovermH->GetXaxis()->SetRange(1,theBin-1); } gROOT->ProcessLine(".L mytdrstyle.C"); gROOT->ProcessLine("setTDRStyle()"); // cout << endl << "Signal " << endl; ptoverm->setBins(ptovermH->GetNbinsX()); RooDataHist* rdh = new RooDataHist("rdh","Some dataset",RooArgList(*ptoverm),Import(*ptovermH,kFALSE)); // fit definitions // RooWorkspace *ws = new RooWorkspace("ws"); RooRealVar m("m","emme", 1.,0.01, 40.); RooRealVar n("n","enne", 0.93, 0.05, 15.); RooRealVar n2("n2","enne2", 0.75, 0.5, 15.); RooRealVar bb("bb","bibi",0.02, 0.000005, 20.0); RooRealVar T("T","tti",0.2,0.00000005,1.); RooRealVar bb2("bb2","bibi2",0.02, 0.0005, 10.0); RooRealVar fexp("fexp","f_exp",0.02, 0.0, 1.0); if (whichtype == 0) { if (LHCsqrts == 8) { m.setVal(3.319); // m.setConstant(kTRUE); n.setVal(0.7606); if (systString != "Default" || mass != 125) n.setConstant(kTRUE); n2.setVal(0.8061); n2.setConstant(kTRUE); bb.setVal(3.728); // bb.setConstant(kTRUE); T.setVal(0.00333); // T.setConstant(kTRUE); bb2.setVal(1.7172); // bb2.setConstant(kTRUE); fexp.setVal(0.002144); if (systString != "Default" || mass != 125) fexp.setConstant(kTRUE); } else { m.setVal(0.061); // m.setConstant(kTRUE); n.setVal(1.6141); if (systString == "Resummation" || systString == "TopMass") n.setConstant(kTRUE); n2.setVal(1.3294); n2.setConstant(kTRUE); bb.setVal(4.2761); // bb.setConstant(kTRUE); T.setVal(0.0361); // T.setConstant(kTRUE); bb2.setVal(1.6643); bb2.setConstant(kTRUE); fexp.setVal(0.0004); // fexp.setConstant(kTRUE); } } else if (whichtype == 1) { m.setVal(1.006); // m.setConstant(kTRUE); n.setVal(10.939); n.setConstant(kTRUE); n2.setVal(1.1448); n2.setConstant(kTRUE); bb.setVal(0.02048); bb.setConstant(kTRUE); T.setVal(0.16115); if (systString.find("Mela") != string::npos) T.setConstant(kTRUE); // T.setConstant(kTRUE); bb2.setVal(1.0024); bb2.setConstant(kTRUE); fexp.setVal(0.005); fexp.setConstant(kTRUE); if (mass > 300) { fexp.setVal(0.0); fexp.setConstant(kFALSE); } if (mass > 500) { bb2.setVal(5.0); // bb2.setConstant(kFALSE); } if (mass > 500) { bb.setVal(15.0); // bb.setConstant(kFALSE); } } else if (whichtype == 2) { if (LHCsqrts == 8) { m.setVal(1.0476); // m.setConstant(kTRUE); bb.setVal(3.3088); // if (mass != 140) bb.setConstant(kTRUE); n2.setVal(0.7146); n2.setConstant(kTRUE); n.setVal(0.9518); n.setConstant(kTRUE); bb2.setVal(100000.); bb2.setConstant(kTRUE); T.setVal(0.0021889); if (systString.find("Mela") != string::npos || mass != 140) T.setConstant(kTRUE); fexp.setVal(0.0); fexp.setConstant(kTRUE); } else { m.setVal(1.028); // m.setConstant(kTRUE); bb.setVal(2.91); // bb.setConstant(kTRUE); n2.setVal(0.7146); n2.setConstant(kTRUE); n.setVal(0.9518); n.setConstant(kTRUE); bb2.setVal(100000.); bb2.setConstant(kTRUE); T.setVal(0.002248); if (systString.find("Mela") != string::npos) T.setConstant(kTRUE); fexp.setVal(0.0); fexp.setConstant(kTRUE); } } else if (whichtype == 3) { m.setVal(1.411); // m.setConstant(kTRUE); n.setVal(3.4523); n.setConstant(kTRUE); n2.setVal(0.6910); n2.setConstant(kTRUE); bb.setVal(0.00039); // bb.setConstant(kTRUE); T.setVal(0.118); // T.setConstant(kTRUE); bb2.setVal(0.0224); bb2.setConstant(kTRUE); fexp.setVal(0.0); fexp.setConstant(kTRUE); } else if (whichtype == 4) { m.setVal(1.411); // m.setConstant(kTRUE); n.setVal(5.756); // n.setConstant(kTRUE); n2.setVal(0.8738); // n2.setConstant(kTRUE); bb.setVal(0.00039); // bb.setConstant(kTRUE); T.setVal(0.118); // T.setConstant(kTRUE); bb2.setVal(0.0224); bb2.setConstant(kTRUE); fexp.setVal(0.0); fexp.setConstant(kTRUE); } else if (whichtype == 5 && LHCsqrts == 8) { m.setVal(1.006); // m.setConstant(kTRUE); n.setVal(10.939); n.setConstant(kTRUE); n2.setVal(1.1448); n2.setConstant(kTRUE); bb.setVal(3.897); bb.setConstant(kTRUE); T.setVal(0.1009); // T.setConstant(kTRUE); bb2.setVal(1.0224); bb2.setConstant(kTRUE); fexp.setVal(0.01); fexp.setConstant(kTRUE); } else { // cout << "Entro qui" << endl; m.setVal(1.006); // m.setConstant(kTRUE); n.setVal(10.939); n.setConstant(kTRUE); n2.setVal(1.1448); n2.setConstant(kTRUE); bb.setVal(0.0129); bb.setConstant(kTRUE); T.setVal(0.1009); // T.setConstant(kTRUE); bb2.setVal(1.0224); bb2.setConstant(kTRUE); fexp.setVal(0.01); fexp.setConstant(kTRUE); } RooModifTsallis* rt3 = new RooModifTsallis("rt3","rt3",*ptoverm,m,n,n2,bb,bb2,T,fexp); // ws->import(*rt3); // fit RooFitResult* fit = rt3->fitTo(*rdh,Minos(0),Save(1),SumW2Error(kTRUE),NumCPU(1)); float mVal = m.getVal(); float nVal = n.getVal(); float n2Val = n2.getVal(); float bbVal = bb.getVal(); float bb2Val = bb2.getVal(); float fexpVal = fexp.getVal(); float TVal = T.getVal(); if (correctErrors) { // Tsallis errors not reliable, use toy MC TH1F* mHist = new TH1F("mHist","m",21,-0.5*mVal,0.5*mVal); TH1F* nHist = new TH1F("nHist","n",21,-0.2*nVal,0.2*nVal); TH1F* n2Hist = new TH1F("n2Hist","n2",21,-0.2*n2Val,0.2*n2Val); TH1F* bbHist = new TH1F("bbHist","bb",21,-0.2*bbVal,0.2*bbVal); TH1F* bb2Hist = new TH1F("bb2Hist","bb2",21,-0.2*bb2Val,0.2*bb2Val); TH1F* fexpHist = new TH1F("fexpHist","fexp",21,-0.2*fexpVal-0.000001,0.2*fexpVal+0.000001); TH1F* THist = new TH1F("THist","T",21,-0.5*TVal,0.5*TVal); mHist->GetXaxis()->SetTitle("m-m_{gen}"); nHist->GetXaxis()->SetTitle("n-n_{gen}"); n2Hist->GetXaxis()->SetTitle("n2-n2_{gen}"); bbHist->GetXaxis()->SetTitle("bb-bb_{gen}"); bb2Hist->GetXaxis()->SetTitle("bb2-bb2_{gen}"); THist->GetXaxis()->SetTitle("T-T_{gen}"); fexpHist->GetXaxis()->SetTitle("fexp-fexp_{gen}"); for (unsigned int iToy = 0; iToy < 200; iToy++) { cout << endl << "####" << endl; cout << "Generating toy experiment n. " << iToy+1 << endl; m.setVal(mVal); n.setVal(nVal); n2.setVal(n2Val); bb.setVal(bbVal); bb2.setVal(bb2Val); fexp.setVal(fexpVal); T.setVal(TVal); TDatime *now = new TDatime(); Int_t seed = now->GetDate() + now->GetTime(); cout << "RooFit Generation Seed = " << seed+iToy << endl; RooRandom::randomGenerator()->SetSeed(seed+iToy); cout << "####" << endl << endl; RooDataSet *dataToy = rt3->generate(RooArgSet(*ptoverm),ptovermH->GetEntries()); RooDataHist *dataToyH = new RooDataHist("dataToyH","toy",RooArgSet(*ptoverm),*dataToy); rt3->fitTo(*dataToyH,Minos(0),SumW2Error(kTRUE),NumCPU(1)); if (fit->floatParsFinal().find("m")) mHist->Fill(m.getVal()-mVal); if (fit->floatParsFinal().find("n")) nHist->Fill(n.getVal()-nVal); if (fit->floatParsFinal().find("n2")) n2Hist->Fill(n2.getVal()-n2Val); if (fit->floatParsFinal().find("bb")) bbHist->Fill(bb.getVal()-bbVal); if (fit->floatParsFinal().find("bb2")) bb2Hist->Fill(bb2.getVal()-bb2Val); if (fit->floatParsFinal().find("fexp")) fexpHist->Fill(fexp.getVal()-fexpVal); if (fit->floatParsFinal().find("T")) THist->Fill(T.getVal()-TVal); } TCanvas cant("cant","Test canvas",5.,5.,900.,500.); cant.Divide(4,2); cant.cd(1); mHist->Draw(); cant.cd(2); nHist->Draw(); cant.cd(3); n2Hist->Draw(); cant.cd(4); bbHist->Draw(); cant.cd(5); bb2Hist->Draw(); cant.cd(6); fexpHist->Draw(); cant.cd(7); THist->Draw(); // cant.SaveAs("figs/testToys.pdf"); cant.SaveAs("newfigs/testToys.pdf"); if (fit->floatParsFinal().find("m")) m.setError(mHist->GetRMS()); if (fit->floatParsFinal().find("n")) n.setError(nHist->GetRMS()); if (fit->floatParsFinal().find("n2")) n2.setError(n2Hist->GetRMS()); if (fit->floatParsFinal().find("bb")) bb.setError(bbHist->GetRMS()); if (fit->floatParsFinal().find("bb2")) bb2.setError(bb2Hist->GetRMS()); if (fit->floatParsFinal().find("fexp")) fexp.setError(fexpHist->GetRMS()); if (fit->floatParsFinal().find("T")) T.setError(THist->GetRMS()); } m.setVal(mVal); n.setVal(nVal); n2.setVal(n2Val); bb.setVal(bbVal); bb2.setVal(bb2Val); fexp.setVal(fexpVal); T.setVal(TVal); char fileToSave[200]; // if (changeParName != "") // sprintf(fileToSave,"text/paramsPTOverMCJLST_%s_%dTeV_%s_%s.txt",nameSample[whichtype].c_str(),LHCsqrts,systString.c_str(),changeParName.c_str()); // else sprintf(fileToSave,"text/paramsPTOverMCJLST_%s%d_%dTeV_%s.txt",nameSample[whichtype].c_str(),mass,LHCsqrts,systString.c_str()); ofstream os1(fileToSave); if (changeParName != "") { sprintf(fileToSave,"m%s",changeParName.c_str()); m.SetName(fileToSave); sprintf(fileToSave,"n%s",changeParName.c_str()); n.SetName(fileToSave); sprintf(fileToSave,"n2%s",changeParName.c_str()); n2.SetName(fileToSave); sprintf(fileToSave,"bb%s",changeParName.c_str()); bb.SetName(fileToSave); sprintf(fileToSave,"bb2%s",changeParName.c_str()); bb2.SetName(fileToSave); sprintf(fileToSave,"fexp%s",changeParName.c_str()); fexp.SetName(fileToSave); sprintf(fileToSave,"T%s",changeParName.c_str()); T.SetName(fileToSave); } (RooArgSet(m,n,n2,bb,bb2,fexp,T)).writeToStream(os1,false); os1.close(); RooRealVar mup("mup","emme", 1.,0.01, 30.); RooRealVar nup("nup","enne", 0.93, 0.5, 15.); RooRealVar n2up("n2up","enne2", 0.75, 0.5, 15.); RooRealVar bbup("bbup","bibi",0.02, 0.00005, 20.0); RooRealVar Tup("Tup","tti",0.2,0.00000005,1.); RooRealVar bb2up("bb2up","bibi2",0.02, 0.0005, 10.0); RooRealVar fexpup("fexpup","f_exp",0.02, 0.0, 1.0); RooModifTsallis* rt3up = new RooModifTsallis("rt3up","rt3up",*ptoverm,mup,nup,n2up,bbup,bb2up,Tup,fexpup); // ws->import(*rt3up); RooRealVar mdown("mdown","emme", 1.,0.01, 30.); RooRealVar ndown("ndown","enne", 0.93, 0.5, 15.); RooRealVar n2down("n2down","enne2", 0.75, 0.5, 15.); RooRealVar bbdown("bbdown","bibi",0.02, 0.00005, 20.0); RooRealVar Tdown("Tdown","tti",0.2,0.00000005,1.); RooRealVar bb2down("bb2down","bibi2",0.02, 0.0005, 10.0); RooRealVar fexpdown("fexpdown","f_exp",0.02, 0.0, 1.0); RooModifTsallis* rt3down = new RooModifTsallis("rt3down","rt3down",*ptoverm,mdown,ndown,n2down,bbdown,bb2down,Tdown,fexpdown); // ws->import(*rt3down); RooPlot *frame = ptoverm->frame(); char reducestr[300]; sprintf(reducestr,"ptoverm > %f && ptoverm < %f",ptoverm->getMin(),ptoverm->getMax()); rdh->plotOn(frame,DataError(RooAbsData::SumW2),Cut(reducestr)); static RooHist *hpull; float chi2 = 0.; if (changeParName == "") { sprintf(fileToSave,"text/paramsPTOverMCJLST_%s%d_%dTeV_Default.txt",nameSample[whichtype].c_str(),mass,LHCsqrts); ifstream is1(fileToSave); (RooArgSet(mup,nup,n2up,bbup,bb2up,fexpup,Tup)).readFromStream(is1,false); mdown.setVal(fabs(3*mup.getVal() - 2*m.getVal())); ndown.setVal(fabs(3*nup.getVal() - 2*n.getVal())); n2down.setVal(fabs(3*n2up.getVal() - 2*n2.getVal())); bbdown.setVal(fabs(3*bbup.getVal() - 2*bb.getVal())); Tdown.setVal(fabs(3*Tup.getVal() - 2*T.getVal())); bb2down.setVal(fabs(3*bb2up.getVal() - 2*bb2.getVal())); fexpdown.setVal(fabs(3*fexpup.getVal() - 2*fexp.getVal())); if (showErrorPDFs) { rt3->plotOn(frame,LineColor(kRed),LineStyle(kDashed),Normalization(rdh->sumEntries(),RooAbsReal::NumEvent)); hpull = frame->pullHist(); rt3up->plotOn(frame,LineColor(kBlue),Normalization(rdh->sumEntries(),RooAbsReal::NumEvent)); if (systString.find("Mela") == string::npos) rt3down->plotOn(frame,LineColor(kRed),LineStyle(kDashed),Normalization(rdh->sumEntries(),RooAbsReal::NumEvent)); } else { rt3->plotOn(frame,LineColor(kBlue),Normalization(rdh->sumEntries(),RooAbsReal::NumEvent)); hpull = frame->pullHist(); } } else { mup.setVal(m.getVal() + m.getError()); cout << "mup = " << mup.getVal() << endl; nup.setVal(n.getVal() + n.getError()); n2up.setVal(n2.getVal() + n2.getError()); bbup.setVal(bb.getVal() + bb.getError()); Tup.setVal(T.getVal() + T.getError()); bb2up.setVal(bb2.getVal() + bb2.getError()); fexpup.setVal(fexp.getVal() + fexp.getError()); mdown.setVal(m.getVal() - m.getError()); cout << "mdown = " << mdown.getVal() << endl; ndown.setVal(n.getVal() - n.getError()); n2down.setVal(n2.getVal() - n2.getError()); bbdown.setVal(bb.getVal() - bb.getError()); Tdown.setVal(T.getVal() - T.getError()); bb2down.setVal(bb2.getVal() - bb2.getError()); fexpdown.setVal(fexp.getVal() - fexp.getError()); rt3->plotOn(frame,LineColor(kBlue),Normalization(rdh->sumEntries(),RooAbsReal::NumEvent)); hpull = frame->pullHist(); if (showErrorPDFs) { rt3up->plotOn(frame,LineColor(kRed),LineStyle(kDashed),Normalization(rdh->sumEntries(),RooAbsReal::NumEvent)); rt3down->plotOn(frame,LineColor(kRed),LineStyle(kDashed),Normalization(rdh->sumEntries(),RooAbsReal::NumEvent)); } } double *ypulls = hpull->GetY(); unsigned int nBins = rdh->numEntries(); unsigned int nFullBins = 0; for (unsigned int i = 0; i < nBins; i++) { cout << "Pull of bin " << i << " = " << ypulls[i] << endl; if (fabs(ypulls[i]) < 5.0) chi2 += ypulls[i]*ypulls[i]; cout << "Partial chi2 = " << chi2 << endl; if (fabs(ypulls[i]) > 0.0001 && fabs(ypulls[i]) < 5.0) nFullBins++; } for (unsigned int i = 0; i < nBins; i++) { if (fabs(ypulls[i]) < 0.0001) ypulls[i] = 999.; hpull->SetPointError(i,0.,0.,0.,0.); } int nFitPar = fit->floatParsFinal().getSize() - 1; TCanvas can("can","The canvas",5.,5.,500.,900.); can.Divide(1,3); TLatex *t = new TLatex(); t->SetNDC(); t->SetTextAlign(22); t->SetTextSize(0.06); can.cd(1); gPad->SetBottomMargin(0.0); frame->Draw(); // gPad->SetLogy(); // Htest->Draw(); sprintf(fileToSave,"%s %d GeV at %d TeV",nameSample[whichtype].c_str(),mass,LHCsqrts); t->DrawLatex(0.6,0.8,fileToSave); can.cd(2); gPad->SetLogy(); gPad->SetTopMargin(0.0); frame->Draw(); RooPlot* pull = ptoverm->frame(Title("Pull Distribution")) ; pull->GetYaxis()->SetTitle("Pull"); /* pull->SetLabelSize(0.08,"XYZ"); pull->SetTitleSize(0.08,"XYZ"); pull->SetTitleOffset(0.6,"Y"); pull->SetTitleOffset(1.0,"X"); */ pull->addPlotable(hpull,"P") ; pull->SetMinimum(-6.); pull->SetMaximum(6.); can.cd(3); gPad->SetGridy(); pull->Draw(); sprintf(fileToSave,"#chi^{2}/n_{DoF} = %4.1f/%d",chi2,nFullBins - nFitPar); if (chi2 < 1000.) t->DrawLatex(0.80,0.86,fileToSave); // sprintf(fileToSave,"figs/fitPTOverMCJLST_%s%d_%dTeV_%s.pdf",nameSample[whichtype].c_str(),mass,LHCsqrts,systString.c_str()); sprintf(fileToSave,"newfigs/fitPTOverMCJLST_%s%d_%dTeV_%s.pdf",nameSample[whichtype].c_str(),mass,LHCsqrts,systString.c_str()); can.SaveAs(fileToSave); }