Bool TApplication::TApplicationState_Bootup::OnBegin(TRefRef PreviousMode) { TApplication* pApp = GetStateMachine<TApplication>(); // TODO: // gr: if this fails (e.g. no logo asset) skip onto next mode Bool bSuccess = CreateIntroScreen(); if(!bSuccess) return FALSE; // Subscribe to the asset manager TLMessaging::g_pEventChannelManager->SubscribeTo(this, "Asset", "OnAssetChanged"); // TODO: // Setup language // Setup Audio - language specific // Load Text - language specific // Setup global settings // Obtain list of files to load at startup pApp->GetPreloadFiles(m_PreloadFiles); if(m_PreloadFiles.GetSize() > 0) { // Request the load of the assets for ( s32 i=m_PreloadFiles.GetLastIndex(); i>=0; i-- ) TLAsset::LoadAsset( m_PreloadFiles[i], FALSE ); } return TStateMode::OnBegin(PreviousMode); }
void UIAccelerometer::addDelegate(UIAccelerometerDelegate* pDelegate) { UIAccelerometerHandler* pHandler = UIAccelerometerHandler::handlerWithDelegate(pDelegate); if (pHandler) { m_pDelegates->addObject(pHandler); if (!m_pSensor) { m_pSensor = TCOM_Sensors_DataType_Client::GetInstance(); if (m_pSensor) { m_pSensor->StartUp(); m_pSensor->SetDelay(TG3_SENSOR_DELAY_FASTEST); TApplication* pApp = TApplication::GetCurrentApplication(); TWindow* pWnd = pApp->GetActiveWindow(); m_pSensor->SetWindowCtrlId(pWnd->GetWindowHwndId(), 0); m_pSensor->Activate(TG3_SENSOR_TYPE_ACCELEROMETER, TRUE); } else { CCLOG("cocos2d: The Accelerometer Sensor Open failed"); } } } }
int main(int argc, char *argv[]) { TApplication *a = new TApplication("app", &argc, argv); TCanvas *c1 = makegraph(); a->Run(); return 0; }
// /// Called by EvHelp() to activate the help file with the help context ID. // void THelpFileManager::ActivateHelp(TWindow* /*window*/, int helpFileContextId, uint helpCmd) { if (helpCmd == HELP_INDEX || helpCmd == HELP_CONTENTS) helpCmd = HELP_FINDER; TApplication* app = TYPESAFE_DOWNCAST(this, TApplication); #if !defined(NO_HTMLHELP) if(UseHTMLHelp){ if (app) HelpState = ToBool(HtmlHelp(app->GetMainWindow(), GetHelpFile().c_str(), helpCmd, helpFileContextId) != 0); else HelpState = ToBool(HtmlHelp(0, GetHelpFile().c_str(), helpCmd, helpFileContextId) != 0); } else{ #endif if (app) HelpState = ToBool(app->GetMainWindow()->WinHelp(GetHelpFile().c_str(), helpCmd, helpFileContextId)); else HelpState = ToBool(::WinHelp(0, GetHelpFile().c_str(), helpCmd, helpFileContextId)); #if !defined(NO_HTMLHELP) } #endif }
int main(int argc, char **argv) { TApplication app; app.Run(); return 0; }
int main(int argc, char *argv[]) { TApplication *a = new TApplication("app", &argc, argv); analysis(); a->Run(); return 0; }
Boolean CCEGLView::Create(int nWidthInPoints, int nHeightInPoints) { // record the window size in points m_tSizeInPoints.SetWidth(nWidthInPoints); m_tSizeInPoints.SetHeight(nHeightInPoints); // get the screen size TApplication* pApp = TApplication::GetCurrentApplication(); Int32 nWidth = pApp->GetScreenWidth(); Int32 nHeight = pApp->GetScreenHeight(); // calculate the factor and the rect of viewport m_fScreenScaleFactor = MIN((float)nWidth / nWidthInPoints, (float)nHeight / nHeightInPoints); int viewPortW = (int)(m_tSizeInPoints.Width() * m_fScreenScaleFactor); int viewPortH = (int)(m_tSizeInPoints.Height() * m_fScreenScaleFactor); m_rcViewPort.SetX((nWidth - viewPortW) / 2); m_rcViewPort.SetY((nHeight - viewPortH) / 2); m_rcViewPort.SetWidth(viewPortW); m_rcViewPort.SetHeight(viewPortH); Boolean bRet = TWindow::Create(&TRectangle(0, 0, nWidth, nHeight)); if (bRet) { s_pMainWindow = this; } return bRet; }
int main(int argc, char **argv) { parseOptions(argc,argv); TApplication *theApp; if ( interactive ) theApp = new TApplication("App", &argc, argv); else gROOT->SetBatch(); Bs2KstKst::MultiDimCutOpt *cutOpt = new Bs2KstKst::MultiDimCutOpt(); // set run type if ( runType == "all" ) { cutOpt->setRunAll(true); } else if ( runType == "2011" ) { cutOpt->setRunAll(false); cutOpt->setRun2011(true); } else if ( runType == "2012" ) { cutOpt->setRunAll(false); cutOpt->setRun2012(true); } else { cerr << "ERROR - no such runType: " << runType << endl; exit(1); } // setup files cutOpt->setup( infname , outfname, cachefile ); // set mis id type cutOpt->setMisIdType( misIdType ); if ( loadFromCachce ) { cutOpt->loadWorkspace(); } else { cutOpt->makeInitialDatasets(); //cutOpt->loadDatasetsFromFile( "root/MultiDimCutDatasets.root" ); cutOpt->makePDFs(); cutOpt->plotShapes(); } if ( ! makeCache ) { cutOpt->setScanPoints1D( scanPoints1D ); cutOpt->setScanPoints2D( scanPoints2D ); if ( bdtOnly ) cutOpt->runBDTOptOnly( fomType ); else cutOpt->runSimple( fomType ); } cutOpt->save(); if ( interactive ) { cout << "Exit with Ctrl+c" << endl; theApp->Run(); } }
int main(int argc, char** argv) { //TRint* myapp = new TRint("kaliveda", &argc, argv, NULL, 0); TApplication* myapp = new TApplication("myapp", &argc, argv); new KVSimDirGUI; myapp->Run(); return 0; }
// This is the standard "main" of C++ starting a ROOT application int main ( int argc , char ** argv ) { gROOT-> Reset() ; TApplication app ( "Root Application" , &argc , argv ) ; StandaloneApplication ( app.Argc(), app.Argv() ) ; app.Run () ; exit(0); return 0 ; }
void TApplication::TApplicationState_ExitGame::OnEnd(TRefRef NextMode) { // Destroy (game specific) TGame object TApplication* pApp = GetStateMachine<TApplication>(); pApp->DestroyGame(); return TStateMode::OnEnd(NextMode); }
int main(int argc, char *argv[]) { ArgumentParser parser; parser.addArgument("-i", "--input", 1, false); parser.parse(argc, argv); TApplication *myapp = new TApplication("App", &argc, argv); fit(parser.retrieve<string>("i")); myapp->Run(); }
// Enter Game transitional state Bool TApplication::TApplicationState_EnterGame::OnBegin(TRefRef PreviousMode) { // TODO: // Begin transition // Create (gamespecific) TGame object TApplication* pApp = GetStateMachine<TApplication>(); if ( !pApp->CreateGame() ) return FALSE; return TStateMode::OnBegin(PreviousMode); }
// /// Responds to a menu item selection. // void TRecentFiles::CmFile(uint id) { TApplication* app = TYPESAFE_DOWNCAST(this, TApplication); TFrameWindow* window = app ? app->GetMainWindow() : 0; if (window) { // Foward menu selection command to specified target // window->SendMessage(MruMessage, id, 0); } }
const char* getDiffResolutionPath(const char *pszPath) { CCString *pRet = new CCString(pszPath); pRet->autorelease(); do { TApplication* pApp = TApplication::GetCurrentApplication(); CC_BREAK_IF(!pApp); // get the Resolution int nScreenWidth = pApp->GetScreenWidth(); int nScreenHeight = pApp->GetScreenHeight(); // it's default resolution, do nothing CC_BREAK_IF(nScreenWidth == 320 && nScreenHeight == 480); if (nScreenWidth == 480 && nScreenHeight == 800) { // it's WVGA CC_BREAK_IF(pRet->m_sString.find("@WVGA") != -1); std::string filePathWithoutExtension = pszPath; std::string extension = ""; std::string filePath = pszPath; int nExPos = filePath.find_last_of("."); if (nExPos != -1) { filePathWithoutExtension = filePath.substr(0, nExPos); extension = filePath.substr(nExPos); } // new path, add "@WVGA" before the extension pRet->m_sString = filePathWithoutExtension + "@WVGA" + extension; // not find the resource of new path,use the original path if (! isResourceExist(pRet->m_sString.c_str())) { pRet->m_sString = filePath; } } else { // not support resolution CCAssert(0, "it's not supportted resolution."); } } while (0); return pRet->m_sString.c_str(); }
void GenerateTimingHistogram(){ TApplication *fApp = new TApplication("Test", NULL, NULL); //Scintillator::SetStartingId(-1); ScintillatorPlane topPlane(2,8,-105.,false,"TopPlane"); ScintillatorPlane bottomPlane(2,8,105.,false,"BottomPlane"); int nxbins = 8; int xlow = 0; int xhigh = 8; int nybins = 8; int ylow = 0; int yhigh = 8; Channel *trig = 0; Channel *ch1 = 0; Channel *ch2 = 0; TCanvas *c2 = new TCanvas("c2", "Timing-Info", 200, 10, 700, 500); c2->Divide(1, 1); c2->cd(1); Tree t("3476.root", "BSC_DATA_TREE"); int numOfEvents = t.GetNumOfEvents(); // TH1F *hTrig = new TH1F("hTrig","TEST",100,20000,21000); TH2F *h2d = new TH2F("h2d", "Timing", nxbins, xlow, xhigh, nybins, ylow, yhigh); std::vector<Tracking::Scintillator*> scintPlane1 = topPlane.GetScintillatorPlane(); std::vector<Tracking::Scintillator*> scintPlane2 = bottomPlane.GetScintillatorPlane(); for (int evNo = 0; evNo < numOfEvents; evNo++) { for (int i = 0; i < scintPlane1.size(); i++) { ch1 = t.GetEntry(scintPlane1[i]->GetName(), evNo); if (ch1->size()) { for (int j = 0; j < scintPlane2.size(); j++) { ch2 = t.GetEntry(scintPlane2[j]->GetName(), evNo); if(ch2->size()) h2d->Fill(i, j); } } } } //h2d->Draw(); h2d->Draw("LEGO2"); fApp->Run(); h2d->Print(); // TFile f("hTrig.root","recreate"); //Open file, then write histo to it. TFile::Open("hTrig.root", "RECREATE"); h2d->Write(); c2->Modified(); c2->Update(); }
void TMustEnterValidator::Error(TWindow *owner) { string msgTmpl; TApplication* app = GetApplicationObject(); msgTmpl = app->LoadString(IDS_VALMUSTENTER).c_str(); char* msg = new char[msgTmpl.length() + 10 + 10 + 1]; sprintf(msg, msgTmpl.c_str()); if (owner) owner->MessageBox(msg, app->GetName(), MB_ICONEXCLAMATION|MB_OK); else ::MessageBox(0, msg, app->GetName(), MB_ICONEXCLAMATION|MB_OK|MB_TASKMODAL); delete [] msg; }
int main(int argc, char* argv[]) { std::string temp_str = std::to_string(atoi(argv[1])); temp_str += ".root"; TApplication *fApp = new TApplication("Test", NULL, NULL); Tracking::Tree::instance()->ReadTree(temp_str.c_str(), "BSC_DATA_TREE", 0); Detector *rpc1 = new GlassRpc(2, "FirstGlassRpc", 120, 31); Detector *rpc2 = new GlassRpc(4, "SecondGlassRpc", 150, 31); Tomography::SetupManager::instance()->Register(rpc1); Tomography::SetupManager::instance()->Register(rpc2); rpc1->GetX_Y_And_ClusterHistograms(); rpc1->GetStripProfile(); rpc2->GetX_Y_And_ClusterHistograms(); rpc2->GetStripProfile(); fApp->Run(); }
int main(int argc, char *argv[]){ // int argcb; // char **argvb; TApplication *app = new TApplication("app", &argc, argv); TH1::AddDirectory(kFALSE);//avoid name overwrites but could cause other memory histogram issues // h->SetDirectory(0); for the current histogram h TCanvas * can_view = new TCanvas("can_view", "can_view", 800, 800); gStyle->SetOptStat(0); can_view->cd(); exp_core experiment(150); add_S3(experiment,30); experiment.draw_phi(true);//"true" adds colour cout<<endl<<"/////////////////////////////////////////////////////////////////////////"<<endl; app->Run(); return 0; }
TRef TApplication::TApplicationState_Bootup::Update(float Timestep) { SyncBool TimelineUpdate = SyncFalse; if(m_pTimelineInstance) TimelineUpdate = m_pTimelineInstance->Update(Timestep); if ( m_SkipBootup || (GetModeTime() > BOOTUP_TIME_MIN) && ArePreloadFilesLoaded() && (TimelineUpdate == SyncFalse) ) { TApplication* pApp = GetStateMachine<TApplication>(); // If we have a front end mode then go to the front end mode, otherwise drop into the enter game mode if(pApp->HasMode("FrontEnd")) return "FrontEnd"; else return "EnterGame"; } // Wait for preload files to be loaded and the min time return TRef(); };
void TScientificLowerValidator::Error(TWindow *owner) { string msgTmpl; TApplication* app = GetApplicationObject(); switch(validator_type) { case INCLUSIVE: msgTmpl = app->LoadString(IDS_VALBELOWINCLLIMIT).c_str(); break; case EXCLUSIVE: msgTmpl = app->LoadString(IDS_VALBELOWEXCLLIMIT).c_str(); break; } char* msg = new char[msgTmpl.length() + 10 + 10 + 1]; sprintf(msg, msgTmpl.c_str(), min); if (owner) owner->MessageBox(msg, app->GetName(), MB_ICONEXCLAMATION|MB_OK); else ::MessageBox(0, msg, app->GetName(), MB_ICONEXCLAMATION|MB_OK|MB_TASKMODAL); delete [] msg; }
// /// Deactivates the help. // void THelpFileManager::DeactivateHelp() { TApplication* app = TYPESAFE_DOWNCAST(this, TApplication); #if !defined(NO_HTMLHELP) if(UseHTMLHelp){ if (app) HtmlHelp(app->GetMainWindow(), GetHelpFile().c_str(), HELP_QUIT, 0); else HtmlHelp(0, GetHelpFile().c_str(), HELP_QUIT, 0); } else{ #endif if (app) app->GetMainWindow()->WinHelp(GetHelpFile().c_str(), HELP_QUIT, 0); else ::WinHelp(0, GetHelpFile().c_str(), HELP_QUIT, 0); #if !defined(NO_HTMLHELP) } #endif }
//g++ allDataPrint.cpp `root-config --cflags --glibs` int main(int argc, char** argv) #endif { int colore = 2; TMultiGraph *mg = new TMultiGraph("potenziale","Potenziali"); cout<<"Carico i dati\n"; ifstream filenames("infonamelist.txt"); string filename = "settings.set"; if(argc>1) filename = argv[1]; //carico il file di impostazioni, per ricompilare meno spesso while(!filenames.eof()){ string fname; filenames >> fname;//fname non deve contenere spazi e ".txt" if(fname.find(".set")==string::npos) fname+=".set"; if(fname!=".set"){ impostazioni info("gauss.set", fname.c_str(),filename.c_str()); cout << fname << ":" << endl; int ns = info.NL(), skip = info.spaceSkip(); double step = info.spaceStep(); TGraph *gV = new TGraph(); int j=0; for(int i=0;i<ns;i+=skip){ double x = i*step; gV->SetPoint(j++,x,info.potenziale(i)); } gV->SetTitle(("Potenziale per " +fname).c_str()); gV->SetLineColor(colore++); mg->Add(gV); } } TCanvas c1("c1","Confronto Potenziali",600,450); // c1.Divide(2,1); //c1.cd(1); // merr->Draw("apl"); mg->Draw("apl"); c1.BuildLegend(); /* c1.cd(2); merr->Draw("apl"); c1.BuildLegend(); */ #ifndef __CINT__ theApp.Run(true); return 0; #endif }
//g++ allDataPrint.cpp `root-config --cflags --glibs` int main(int argc, char** argv) #endif { TCanvas c3("c3","Grafico",640,512); TCanvas c1("c1","Confronto",1280,512); c1.Divide(2,1); preparedraw myData (argv[1], // preparedraw::doMax | preparedraw::doFh | preparedraw::doSh | preparedraw::doErr); TGraph2D *g = myData.data(); TGraph *gb = myData.firsthalf();//before TGraph *ga = myData.secondhalf();//after TGraph *gerrs = myData.errs(); // TGraph *maxs = myData.maximum(); c3.cd(); g->GetXaxis()->SetTitle("X"); g->GetYaxis()->SetTitle("T"); //g->Draw("cont1"); g->Draw("pcol"); //g->Draw(); //grafo.Draw("surf1"); cout<<"Disegno i grafici\n"; TMultiGraph *mg = new TMultiGraph("integrali","Integrali prima e dopo la barriera"); ga->SetLineColor(2); mg->Add(gb); mg->Add(ga); c1.cd(1); mg->Draw("apl"); gerrs->SetTitle("Andamento degli errori"); c1.cd(2); gerrs->Draw("apl"); #ifndef __CINT__ theApp.Run(true); return 0; #endif }
//g++ allDataPrint.cpp `root-config --cflags --glibs` int main(int argv, char** argc) #endif { /* TCanvas c("c","Real",640,512); TGraph2D *grafo = new TGraph2D("out.txt"); grafo->Draw("pcol"); TCanvas c2("c2","Imaginary",640,512); TGraph2D *Cgrafo = new TGraph2D("iout.txt"); Cgrafo->Draw("pcol");*/ TCanvas c3("c3","Norm",640,512); TGraph2D *Ngrafo = new TGraph2D(argc[1]); Ngrafo->Draw("pcol"); //grafo.Draw("surf1"); #ifndef __CINT__ theApp.Run(true); return 0; #endif }
//---------------------------------------------------------------------------// //Main Method //---------------------------------------------------------------------------// int main(int argc, char** argv) { TApplication *App = new TApplication("Application",(Int_t*)&argc, argv); TCanvas *Canvas = new TCanvas("canvas", "Canvas", 640, 640); // Set up ROOT as we require. SetupROOT(); // Get list of files to run over. TString fileName("/storage/epp2/phseaj/exercise/basket_2010b.list"); std::ifstream inputFile(fileName.Data(), ios::in); // Declare a TChain for the TGlobalPID module TChain *gRecon = new TChain("ReconDir/Global"); TChain *gGenVtx = new TChain("TruthDir/Vertices"); // Check if the file exists. if (!inputFile.is_open()){ std::cout << "ERROR: File prod4 files not found!" << std::endl; std::cout << " - This file should contain a list of all data files to be processed." << std::endl; return 0; } else{ std::string curFileName; // Add the input files to the TChains. //only doing 10 of the basket files, revert to while to do whole run // while(getline(inputFile,curFileName)){ for(int l = 0; l<10; l++){ if(getline(inputFile,curFileName)){ gRecon->Add(curFileName.c_str()); gGenVtx->Add(curFileName.c_str()); } } } std::cout << "Got input file(s)." << std::endl; //Setup access to the Recon tree int NPIDs(0); // This variable counts the number of particles per event int NVtxFGD1(0), NVtxFGD2(0); // Declare a TClonesArray to hold objects of type TGlobalPID TClonesArray *globalPIDs = new TClonesArray("ND::TGlobalReconModule::TGlobalPID",50); TClonesArray *VtxFGD1 = new TClonesArray("ND::TTruthVerticesModule::TTruthVertex",50); TClonesArray *VtxFGD2 = new TClonesArray("ND::TTruthVerticesModule::TTruthVertex",50); // Associate the right branch in the TTree to the right local variable gRecon->SetBranchAddress("NPIDs",&NPIDs); gRecon->SetBranchAddress("PIDs",&globalPIDs); gGenVtx->SetBranchAddress("VtxFGD1", &VtxFGD1); gGenVtx->SetBranchAddress("NVtxFGD1", &NVtxFGD1); gGenVtx->SetBranchAddress("VtxFGD2", &VtxFGD2); gGenVtx->SetBranchAddress("NVtxFGD2", &NVtxFGD2); //check that truthdir and recon have the same number of entries if(gRecon->GetEntries() != gGenVtx->GetEntries()) cout<<"not equal entries, probably wrong"<<endl; // Loop over the entries in the TChain. //======================================================== // Declare Graphs n stuff here //======================================================== //adding tclones arrays for use with detectors Int_t NTPCs; TClonesArray *TPC; Int_t NFDGs; TClonesArray *FDG; Int_t NECALs; TClonesArray *ECAL; Int_t NPODs; TClonesArray *POD; Int_t NSMRDs; TClonesArray *SMRD; //adding a 2d graph general purpose, change titles each time! TH1D *graph1 = new TH1D("graph1","Momenta of TPC PIDs from FDGs", 100, -50.0 , 50.0); Int_t ninteract(0), nfgd(0),nfgdqes(0),fgdqesneu(0); //======================================================== // end Declare Graphs n stuff here //======================================================== // Loop over the entries in the TChain. (only 1/1000 of whole entries atm) for(unsigned int i = 0; i < gRecon->GetEntries()/10; ++i) { if((i+1)%10000 == 0) std::cout << "Processing event: " << (i+1) << std::endl; //display status every 10,000 th entry // Get an entry for the Recon tree gRecon->GetEntry(i); gGenVtx->GetEntry(i); ND::TGlobalReconModule::TGlobalPID *gTrack = NULL; //added new loop for truth vertex gGenVtx->GetEntry(i); for (int j=0; j<NPIDs; j++) { // Get a specific track from the TClonesArray gTrack = (ND::TGlobalReconModule::TGlobalPID*)globalPIDs->At(j); //get truevertex (in example, also gets trueparticle, can add in later) ND::TTrueVertex vtx = gTrack->TrueParticle.Vertex; //get position lorrentz vector TLorentzVector vec = vtx.Position; ninteract++; if(ABS(vec.X())<832.2 && ABS(vec.Y()-55)<832.2 && ((vec.Z()>123.45&&vec.Z()<446.95)||(vec.Z()>1481.45&&vec.Z()<1807.95))){ //is it in one of the FGDs? nfgd++; if(vtx.ReactionCode.find("Weak[NC],QES;",0)!=-1){ unsigned long det; det = gTrack->Detectors; string detstr; stringstream stream; stream << det; detstr = stream.str(); if(detstr.find("1",0)||detstr.find("2",0)||detstr.find("3",0)){ graph1->Fill((Double_t)gTrack->FrontMomentum); } nfgdqes++; } } TClonesArray *TPCObjects = new TClonesArray("ND::TGlobalReconModule::TTPCObject",gTrack->NTPCs); ND::TGlobalReconModule::TObject *tpcTrack = NULL; for ( int k = 0 ; k < gTrack->NTPCs; k++) { tpcTrack = (ND::TGlobalReconModule::TObject*) TPCObjects->At(k); //now we can access variables through tpcTrack->PullEle for example } } } // End loop over events //plotting bits at the end :D graph1->Draw(); App->Run(); return 0; }
int main(int argc, char *argv[]) { zmq::context_t zmq_ctx(1); zmq::socket_t zmq_sub(zmq_ctx, ZMQ_SUB); zmq::message_t event; DAQ::FzEvent ev; std::string hostname, port; std::string url; // handling of command line parameters po::options_description desc("\nFazia Spy - allowed options"); desc.add_options() ("help", "produce help message") ("host", po::value<std::string>(), "FzDAQ publisher hostname to contact") ("port", po::value<std::string>(), "[optional] FzDAQ publisher port (default: 5563)") ("single", "[optional] single shot, dump first acquired event to screen") ("adc", "[optional] acquire only ADC from BLOCK") ("block", po::value<unsigned int>(), "BLOCK card number to spy (default: 0) (if specify only BLOCK a total view will be plotted)") ("fee", po::value<unsigned int>(), "FRONTEND card number to spy [0...7] (default: 0)") ("tel", po::value<unsigned int>(), "TELESCOPE to spy [0 => A , 1 => B] (default: 0)") ; po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); if (vm.count("help")) { std::cout << desc << "\n"; return 0; } if (vm.count("host")) { hostname = vm["host"].as<std::string>(); } else { std::cout << "ERROR: host missing" << std::endl; return -1; } if (vm.count("port")) { port = vm["port"].as<std::string>(); } else { port = "5563"; } url = "tcp://" + hostname + ":" + port; std::cout << "connect to: " << url << std::endl; try { zmq_sub.connect(url.c_str()); } catch(zmq::error_t zmq_err) { std::cout << "ERROR: connection failed - " << zmq_err.what() << std::endl; return -1; } zmq_sub.setsockopt(ZMQ_SUBSCRIBE, "", 0); if (vm.count("single")) { zmq_sub.recv(&event); if(ev.ParseFromArray(event.data(), event.size()) == true) { std::cout << "parsing succedeed ! - event size = " << event.size() << std::endl; dumpOnScreen(&ev); } return 0; } if(vm.count("block")) { nblk = vm["block"].as<unsigned int>(); } else { nblk = 0; } total = true; if(vm.count("adc")) { adc = true; total = false; } if(vm.count("fee")) { nfee = vm["fee"].as<unsigned int>(); if( (nfee > 7) || (nfee < 0) ) { std::cout << "ERROR: FRONTEND card number out of range" << std::endl; return -1; } total = false; } if(vm.count("tel")) { ntel = vm["tel"].as<unsigned int>(); if( (ntel > 1) || (ntel < 0) ) { std::cout << "ERROR: TELESCOPE number out of range" << std::endl; return -1; } total = false; } if(adc) std::cout << "starting FAZIA SPY GUI interface for: " << "B" << nblk << " ADC channel" << std::endl; else std::cout << "starting FAZIA SPY GUI interface for: " << "B" << nblk << "-" << "F" << nfee << "-" << "T" << ntel << std::endl; TApplication* rootapp = new TApplication("FAZIA SPY GUI", &argc, argv); //theCanvas is allocated for the life of the program: Double_t w = 1024; Double_t h = 768; theCanvas = new TCanvas("theCanvas", "the Canvas", w, h); theCanvas->SetWindowSize(w + (w - theCanvas->GetWw()), h + (h - theCanvas->GetWh())); if(total) { for(int i=0; i<8; i++) { // for each Frontend Card for(int j=0; j<2; j++) { // for each Telescope totHistograms[(i*12)+DAQ::FzData::QH1+(j*6)] = new TH1F("QH1", "QH1", 1024, 0, 1024); totHistograms[(i*12)+DAQ::FzData::I1+(j*6)] = new TH1F("I1", "I1", 500, 0, 500); totHistograms[(i*12)+DAQ::FzData::QL1+(j*6)] = new TH1F("QL1", "QL1", 1024, 0, 1024); totHistograms[(i*12)+DAQ::FzData::Q2+(j*6)] = new TH1F("Q2", "Q2", 1024, 0, 1024); totHistograms[(i*12)+DAQ::FzData::I2+(j*6)] = new TH1F("I2", "I2", 500, 0, 500); totHistograms[(i*12)+DAQ::FzData::Q3+(j*6)] = new TH1F("Q3", "Q3", 1024, 0, 1024); } } // create the sub pads: theCanvas->Divide(12, 8); // draw the histograms once for(int i=0; i<8; i++) { // for each Frontend Card for(int j=0; j<2; j++) { // for each Telescope for(int k=0; k<6; k++) { std::cout << "index = " << (i*12)+k+(j*6) << std::endl; theCanvas->cd((i*12)+k+(j*6)+1); totHistograms[(i*12)+k+(j*6)]->SetMaximum(8500); totHistograms[(i*12)+k+(j*6)]->SetMinimum(-8500); totHistograms[(i*12)+k+(j*6)]->Draw(); } } } } else { if(adc) { adcHistogram = new TH1F("ADC", "ADC", 150, 0, 150); adcHistogram->SetMaximum(8000); adcHistogram->SetMinimum(8000); phHistogram = new TH1F("Phase", "Phase", 100000, 0, 360); // create the sub pads: theCanvas->Divide(2, 1); theCanvas->cd(1); adcHistogram->Draw(); theCanvas->cd(2); phHistogram->Draw(); } else { // telHistograms[i] are allocated for the life of the program: telHistograms[DAQ::FzData::QH1] = new TH1F("QH1", "QH1", 1024, 0, 1024); telHistograms[DAQ::FzData::I1] = new TH1F("I1", "I1", 500, 0, 500); telHistograms[DAQ::FzData::QL1] = new TH1F("QL1", "QL1", 1024, 0, 1024); telHistograms[DAQ::FzData::Q2] = new TH1F("Q2", "Q2", 1024, 0, 1024); telHistograms[DAQ::FzData::I2] = new TH1F("I2", "I2", 500, 0, 500); telHistograms[DAQ::FzData::Q3] = new TH1F("Q3", "Q3", 1024, 0, 1024); // create the sub pads: theCanvas->Divide(2, 3); // draw the histograms once for (int i=0; i<TEL_HIST_NUM; i++) { theCanvas->cd(i+1); telHistograms[i]->SetMaximum(8500); telHistograms[i]->SetMinimum(-8500); telHistograms[i]->Draw(); } telHistograms[DAQ::FzData::QH1]->SetMaximum(8000); telHistograms[DAQ::FzData::QH1]->SetMinimum(-8000); telHistograms[DAQ::FzData::QL1]->SetMaximum(8000); telHistograms[DAQ::FzData::QL1]->SetMinimum(-8000); } } theCanvas->cd(0); theCanvas->Update(); // create two threads for filling and displsaying telHistograms[i]. if ((connecthistogramfill(&zmq_sub)) == 0) printf("successfully started thread to fill histogram..\n"); if ((connectdisplayupdate(NULL)) == 0) printf("successfully started thread to update the display..\n"); rootapp->Run(); return 0; // never reached }
int main(int argc, char *argv[]){ // int argcb; // char **argvb; TApplication *app = new TApplication("app", &argc, argv); TH1::AddDirectory(kFALSE);//avoid name overwrites but could cause other memory histogram issues // h->SetDirectory(0); for the current histogram h double worldsize=80; exp_core experiment(worldsize); // // Set the option you wish to run // int control =0; // 0 = EVERYTHING // 1 = geometry // 2 = Rutherford // 3 = Decay position // 4 = Distribution hits // 5 = Draw events for real time viewing bool save_text=true;//saves terminal output but no terminal output until completion // // Set the target // double density_targ=1.55; double density_back=19.32; target tharget(20,40,1000,180.0,0,10000,79,197); experiment.set_targ(tharget); // // Set the beam // double ebeam=120; //MeV experiment.set_beam(18,36,ebeam); // // Input your physics // double excited_Z=34; double excited_A=70; double initial_state_MeV = 1.4; double transition_keV = 200; bool excited_beam_like=false; double halflife=0.003;//in ns string dist="";// leave blank for a uniform distribution // // Setup Detectors // int config=0; // 0 normal, 1 stopper, 2 old int S3=1; // 0 off, 1 S3 simple, 2 S3 rings , 3 pin double overr=0; // mm >0 non-default S3 / pin position //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////// END OF USER INPUT //////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// double t_d=0.2,t_u=0.35*pi; ///////// First we sort output files //////// // Create the names stringstream ss; ss<<"outputs/SPICE_"<<experiment.channelnames(experiment.get_BZ(),experiment.get_BA()); ss<<"_"<<experiment.channelnames(experiment.get_TZ(),experiment.get_TA()); if(tharget.backing_thickness>0) ss<<"_"<<experiment.channelnames(tharget.backing_Z,tharget.backing_A)<<"_backed"; ss<<"_"<<ebeam<<"MeV"; string file_title=ss.str(); // Check if the root file exists already bool exist=false; TFile* outfile= new TFile((file_title+".root").c_str(),"READ"); if(outfile->IsOpen()){exist=true;outfile->Close();delete outfile;} // Open the file root file to right, whether or not it exists outfile= new TFile((file_title+".root").c_str(),"UPDATE");//Open an existing file for writing. If no file exists, it is created. gROOT->cd();// // This code is for capturing the terminal output std::streambuf *psbuf, *backup; std::ofstream filestr; if(save_text){ // Append if the root file is being if(exist){filestr.open(file_title+".txt",std::ofstream::app);filestr<<endl<<"/////// APPEND //////"<<endl;} //appended else filestr.open(file_title+".txt"); backup = std::cout.rdbuf(); // back up cout's streambuf psbuf = filestr.rdbuf(); // get file's streambuf std::cout.rdbuf(psbuf); // assign streambuf to cout } // Create the canvas that is used as an inbetween for the whole program TCanvas * can_view = new TCanvas("can_view", "can_view", 1200, 600); gStyle->SetOptStat(0); can_view->cd(); ///////////////////////////////////////////////////// ////////////////// Draw Geometry //////////////////// ///////////////////////////////////////////////////// // This loop outputs graphics of the chosen detector geography if(control==0||control==1){spice_auto_setup(experiment,config,S3,overr); if(!outfile->GetDirectory("Geometry"))outfile->mkdir("Geometry"); gROOT->cd(); can_view->cd();can_view->Clear(); experiment.draw_exp(); outfile->cd("Geometry"); can_view->SetName("3Dview");can_view->Write("3Dview",TObject::kOverwrite); gROOT->cd(); can_view->cd();can_view->Clear(); experiment.draw_exp(2); outfile->cd("Geometry"); can_view->SetName("side_view");can_view->Write("side_view",TObject::kOverwrite); gROOT->cd(); can_view->cd();can_view->Clear(); experiment.draw_exp(3); outfile->cd("Geometry"); can_view->SetName("beam_view");can_view->Write("beam_view",TObject::kOverwrite); gROOT->cd(); can_view->cd();can_view->Clear(); experiment.draw_phi(); outfile->cd("Geometry"); can_view->SetName("theta_view");can_view->Write("theta_view",TObject::kOverwrite); gROOT->cd(); } ///////////////////////////////////////////////////// //////// Calculate Rutherford and Kinematics //////// ///////////////////////////////////////////////////// // This loop calculates the basic beam target kinematics and Rutherford scattering rates if(control==0||control==2){spice_auto_setup(experiment,config,S3,overr); //experiment.set_rutherford();//sets reaction experiment.set_elastic(); can_view->Clear(); can_view->Divide(2); can_view->cd(1); experiment.set_ruthmask(t_d,t_u,true,false);// Cut down on wasted simulations by only focusing on the region of interest experiment.draw_hit_pattern_2D(1,1000000,1,1,0); ((TH2D*)gPad->GetPrimitive("Hit_Map_copy"))->SetTitle("Target"); can_view->cd(2); experiment.set_ruthmask(t_d,t_u,false,true); experiment.draw_hit_pattern_2D(1,1000000,1,0,1); ((TH2D*)gPad->GetPrimitive("Hit_Map_copy"))->SetTitle("Beam"); outfile->cd(); can_view->SetName("Hit_map_rutherford");can_view->Write("Hit_map_rutherford",TObject::kOverwrite); gROOT->cd(); can_view->Clear();can_view->cd(); experiment.draw_primary_kinematics(); outfile->cd(); can_view->SetName("Kinematics");can_view->Write("Kinematics",TObject::kOverwrite); gROOT->cd(); experiment.auto_rutherford_OTT(100000,true); if(S3==2){spice_auto_setup(experiment,config,1,overr);experiment.auto_rutherford_OTT(100000,true);} } ///////////////////////////////////////////////////// ////// Experimental Interaction and Detection /////// ///////////////////////////////////////////////////// // This loop calculates data for the reaction of interest // if(control==0||control==3||control==4||control==5){ if(excited_Z<0||excited_A<0){ if(excited_beam_like){ experiment.set_reco(experiment.get_BZ(),experiment.get_BA()); }else{ experiment.set_elastic(); } }else{ experiment.set_reco(excited_Z,excited_A); } // Now we set the target interaction and decay information experiment.set_target_interaction(2);//E^2 is a reasonably approximation for most of our stuff experiment.set_E_star(initial_state_MeV); experiment.set_ICE(transition_keV); // experiment.density_targ=density_targ;// experiment.density_back=density_back; if(halflife>0) experiment.set_halflife_ns(halflife,density_targ,density_back); // Can set the densities directly as well //set some distribution if(dist.size()>0){ experiment.set_primary_dist(dist); }else{ //experiment.set_uniform(t_d,t_u); TFormula fot("fot","sin(x)"); experiment.set_primary_dist(&fot);//using this one so we can use the same masking for both } if(excited_beam_like)experiment.reverse_primary_dist();//because distribution defined for beam like by default but RECOIL is excited experiment.set_implant_escape(-1); //SET THIS so things dont escape when they go wack into things int z=2;// Detector number of the first heavy ion detector if(S3==2)z++;// If S3, skip the PCB. PCBs left out for the diodes in spice_auto_setup ////////////////////////////// ////// FINISHED SET UP /////// ////////////////////////////// experiment.print_reaction(); experiment.print_target(); experiment.print_decay(); // experiment.print_detectables(); outfile->cd(); experiment.dist_target_KE_beam.Write("KE_though_target",TObject::kOverwrite); gROOT->cd(); if(control==0||control==3){spice_auto_setup(experiment,config,S3,overr); experiment.basic_decay_check(100000); // Draw the target and decay things // quite important to check things are set and working right can_view->Clear();can_view->Divide(2); can_view->cd(1); experiment.draw_decay_Z(0,true,10); can_view->cd(2); experiment.draw_target_interaction(0,true); outfile->cd(); can_view->SetName("Ungated_Decay_Position");can_view->Write("Ungated_Decay_Position",TObject::kOverwrite); gROOT->cd(); for(int i=z;i<experiment.detN();i++){ //set only the daughter recoil as valid in the S3 or pins experiment.set_valid_part(i,0,0,1,0); } string n=experiment.channelnames(experiment.get_D1Z(),experiment.get_D1A())+"_Gated_Decay_Position"; experiment.mask_manual(t_d,t_u,true,false);//saves on wasted computation can_view->Clear();can_view->Divide(2); can_view->cd(1); experiment.draw_decay_Z(1,true,10); can_view->cd(2); experiment.draw_target_interaction(1,true); outfile->cd(); can_view->SetName(n.c_str());can_view->Write(n.c_str(),TObject::kOverwrite); gROOT->cd(); for(int i=z;i<experiment.detN();i++){ //set only the ejectile as valid in the S3 or pins experiment.set_valid_part(i,0,1,0,0); } string N=experiment.channelnames(experiment.get_EZ(),experiment.get_EA())+"_Gated_Decay_Position"; experiment.mask_manual(t_d,t_u,false,true);//saves on wasted computation can_view->Clear();can_view->Divide(2); can_view->cd(1); experiment.draw_decay_Z(1,true,10); can_view->cd(2); experiment.draw_target_interaction(1,true); outfile->cd(); can_view->SetName(N.c_str());can_view->Write(N.c_str(),TObject::kOverwrite); gROOT->cd(); } // Distribution hit loops if(control==0||control==4){spice_auto_setup(experiment,config,S3,overr); can_view->Clear(); can_view->cd(); experiment.mask_manual(t_d,t_u,true,true); double ra=experiment.manual_primary_dist_hist.Integral();//Ask what fraction we have masked too, as unmask integral = 1 // Print a basic output of fractions of hits cout<<endl<<endl<<"Multiply by fraction "<<ra; experiment.basic_hit_count(100000,true,1,1,0,0); string r=experiment.channelnames(experiment.get_RZ(),experiment.get_RA()); string e=experiment.channelnames(experiment.get_EZ(),experiment.get_EA()); experiment.manual_primary_dist_hist.SetLineWidth(2); TH1D full; // Get theta CM for different hit conditions // Fetch the manual CM distribution histogram and the speed masked one // We want to show the mask so we know we havent cut it too small can_view->Clear(); can_view->Divide(2); can_view->cd(1); experiment.mask_manual(t_d,t_u,true,false);//saves on wasted computation full=experiment.manual_primary_dist_store; ra=experiment.manual_primary_dist_hist.Integral();//Ask what fraction we have masked too, as unmask integral = 1 full.SetTitle(("CM_theta_dist_"+r+"_gated").c_str()); //Get theta CM for different hit condition TH1D recoh=experiment.theta_hist(500000,true,1,0,0,0); recoh.SetLineColor(2); recoh.Scale(ra*(full.GetBinWidth(1)/recoh.GetBinWidth(1)));//Some basic scaling to match distribution histogram full.DrawCopy(); experiment.manual_primary_dist_hist.DrawCopy("same"); recoh.DrawCopy("same"); can_view->cd(2); experiment.mask_manual(t_d,t_u,false,true);//saves on wasted computation full=experiment.manual_primary_dist_store; ra=experiment.manual_primary_dist_hist.Integral(); full.SetTitle(("CM_theta_dist_"+e+"_gated").c_str()); TH1D ejech=experiment.theta_hist(500000,true,0,1,0,0); ejech.SetLineColor(2); ejech.Scale(ra*(full.GetBinWidth(1)/ejech.GetBinWidth(1))); full.DrawCopy(); experiment.manual_primary_dist_hist.DrawCopy("same"); ejech.DrawCopy("same"); outfile->cd(); can_view->SetName("CM_angles");can_view->Write("CM_angles",TObject::kOverwrite); gROOT->cd(); can_view->Clear(); can_view->Divide(2); can_view->cd(1); experiment.mask_manual(t_d,t_u,true,false);//saves on wasted computation experiment.draw_hit_pattern_2D(1,500000,1,1,0); ((TH2D*)gPad->GetPrimitive("Hit_Map_copy"))->SetTitle(r.c_str()); can_view->cd(2); experiment.mask_manual(t_d,t_u,false,true);//saves on wasted computation experiment.draw_hit_pattern_2D(1,500000,1,0,1); ((TH2D*)gPad->GetPrimitive("Hit_Map_copy"))->SetTitle(e.c_str()); outfile->cd(); can_view->SetName("Hit_map_ditribution");can_view->Write("Hit_map_ditribution",TObject::kOverwrite); gROOT->cd(); can_view->Clear(); can_view->cd(); experiment.mask_manual(t_d,t_u,true,true);//saves on wasted computation experiment.auto_E_theta(500000,1,1,1); outfile->cd(); can_view->SetName("Theta_E");can_view->Write("Theta_E",TObject::kOverwrite); gROOT->cd(); } if(control==5){spice_auto_setup(experiment,config,S3,overr); can_view->Clear(); can_view->cd(); experiment.draw_hits_3D(2); } } // // // Next we spend 20 seconds drawing events so that if something is very wrong it can be corrected // // We set multiplicity=1 so it will only show us S3 good events // experiment.draw_hits_3D(2,1,true,0.5,1,true,20); // //draw_hits_3D(projection,hit_multiplicity,obstructions,display_time,refresh_rate,draw_misses,run_time) // // // if(save_text){ std::cout.rdbuf(backup); // restore cout's original streambuf filestr.close(); string x; ifstream inFile(file_title+".txt"); while (getline(inFile,x)){ cout << x << endl ; } inFile.close(); outfile->cd(); TMacro mac((file_title+".txt").c_str()); mac.Write("terminal.txt",TObject::kOverwrite); } outfile->Close(); cout<<endl<<"/////////////////////////////////////////////////////////////////////////"<<endl; app->Run(); return 0; }
int main(int argc, char**argv) { const char* infile2 = "/data1/rgerosa/L3_Weight/PromptSkim_Single_Double_Electron_recoFlag/EB/Even_WZAnalysis_PromptSkim_W-DoubleElectron_FT_R_42_V21B_Z_noEP.root"; const char* infile3 = "/data1/rgerosa/L3_Weight/PromptSkim_Single_Double_Electron_recoFlag/EB/Odd_WZAnalysis_PromptSkim_W-DoubleElectron_FT_R_42_V21B_Z_noEP.root"; int evalStat = 1; int inputLoops = 25; const int nLoops = inputLoops; // Set style options gROOT->Reset(); gROOT->SetStyle("Plain"); gStyle->SetPadTickX(1); gStyle->SetPadTickY(1); gStyle->SetOptTitle(1); gStyle->SetOptStat(1110); gStyle->SetOptFit(0); gStyle->SetFitFormat("6.3g"); gStyle->SetPalette(1); gStyle->SetTextFont(42); gStyle->SetTextSize(0.05); gStyle->SetTitleFont(42, "xyz"); gStyle->SetTitleSize(0.05); gStyle->SetLabelFont(42, "xyz"); gStyle->SetLabelSize(0.05); gStyle->SetTitleXOffset(0.8); gStyle->SetTitleYOffset(1.1); gROOT->ForceStyle(); if ( evalStat && (!infile2 || !infile3 )) { cout << " No input files to evaluate statistical precision specified !" << endl; return -1; } cout << "Making calibration plots for: " << infile2 << endl; TApplication* theApp = new TApplication("Application", &argc, argv); char hname[100]; TF1 *fgaus = new TF1("fgaus", "gaus", -10, 10); TF1 *pol0_0 = new TF1("pol0_0", "pol1", 0, 20); TF1 *pol0_1 = new TF1("pol0_1", "pol1", 20, 40); TF1 *pol0_2 = new TF1("pol0_2", "pol1", 40, 60); TF1 *pol0_3 = new TF1("pol0_3", "pol1", 60, 85); TFile *f2 = new TFile(infile2); TFile *f3 = new TFile(infile3); TH2F *hcmap2[nLoops]; TH2F *hcmap3[nLoops]; TGraphErrors *statprecision_vs_ieta[nLoops]; TGraphErrors *statprecision_vs_loop[4]; int ipoint = 0; for ( int ietaregion = 0; ietaregion < 4; ietaregion++) { statprecision_vs_loop[ietaregion] = new TGraphErrors(); statprecision_vs_loop[ietaregion]->SetMarkerStyle(20); statprecision_vs_loop[ietaregion]->SetMarkerSize(1); statprecision_vs_loop[ietaregion]->SetMarkerColor(kBlue + 2); if (ietaregion == 0) statprecision_vs_loop[ietaregion]->SetTitle("i#eta < 20"); if (ietaregion == 1) statprecision_vs_loop[ietaregion]->SetTitle("20 < i#eta < 40"); if (ietaregion == 2) statprecision_vs_loop[ietaregion]->SetTitle("40 < i#eta < 60"); if (ietaregion == 3) statprecision_vs_loop[ietaregion]->SetTitle("60 < i#eta < 85"); } for ( int iLoop = 0; iLoop < nLoops; iLoop++ ) { sprintf(hname, "h2_%d_hC_scale_EB", iLoop); hcmap2[iLoop] = (TH2F*)f2->Get(hname); hcmap3[iLoop] = (TH2F*)f3->Get(hname); TH1F *hstatprecision[171]; for (int jbin = 1; jbin < hcmap2[iLoop]-> GetNbinsY() + 1; jbin++) { float etaring = hcmap2[iLoop]-> GetYaxis()->GetBinCenter(jbin); sprintf(hname, "hstatprecision_ring_ieta%02f_%d", etaring, iLoop); hstatprecision[jbin - 1] = new TH1F(hname, hname, 150, -0.5, 0.5); for (int ibin = 1; ibin < hcmap2[iLoop]-> GetNbinsX() + 1; ibin++) { float ic1 = hcmap2[iLoop]->GetBinContent(ibin, jbin); float ic2 = hcmap3[iLoop]->GetBinContent(ibin, jbin); if (ic1 > 0 && ic1 < 2 && ic1 != 1 && ic2 > 0 && ic2 < 2 && ic2 != 1) { hstatprecision[jbin - 1]->Fill((ic1 - ic2) / (ic1 + ic2)); // sigma (diff/sum) gives the stat. precision on teh entire sample } } } statprecision_vs_ieta[iLoop] = new TGraphErrors(); statprecision_vs_ieta[iLoop]->SetMarkerStyle(20); statprecision_vs_ieta[iLoop]->SetMarkerSize(1); statprecision_vs_ieta[iLoop]->SetMarkerColor(kRed + 2); int n = 0; for (int i = 1; i < hcmap2[iLoop]-> GetNbinsY() + 1; i++) { float etaring = hcmap2[iLoop]-> GetYaxis()->GetBinCenter(i); if (int(etaring) == 0) continue; if ( hstatprecision[i - 1]->GetEntries() == 0) continue; float e = 0.5 * hcmap2[iLoop]-> GetYaxis()->GetBinWidth(i); fgaus->SetParameter(1, 1); fgaus->SetParameter(2, hstatprecision[i - 1]->GetRMS()); fgaus->SetRange(-5 * hstatprecision[i - 1]->GetRMS(), 5 * hstatprecision[i - 1]->GetRMS()); hstatprecision[i - 1]->Fit("fgaus", "QR"); statprecision_vs_ieta[iLoop]-> SetPoint(n, etaring, fgaus->GetParameter(2)); statprecision_vs_ieta[iLoop]-> SetPointError(n, e, fgaus->GetParError(2)); n++; } statprecision_vs_ieta[iLoop]->Fit("pol0_0", "QR"); statprecision_vs_ieta[iLoop]->Fit("pol0_1", "QR"); statprecision_vs_ieta[iLoop]->Fit("pol0_2", "QR"); statprecision_vs_ieta[iLoop]->Fit("pol0_3", "QR"); statprecision_vs_loop[0]->SetPoint(ipoint, iLoop + 1, pol0_0->GetParameter(0) + pol0_0->GetParameter(1) * 10); statprecision_vs_loop[0]->SetPointError(ipoint, 0.5, sqrt(pol0_0->GetParError(0)*pol0_0->GetParError(0) + pol0_0->GetParError(1)*pol0_0->GetParError(1))); statprecision_vs_loop[1]->SetPoint(ipoint, iLoop + 1, pol0_1->GetParameter(0) + pol0_1->GetParameter(1) * 30); statprecision_vs_loop[1]->SetPointError(ipoint, 0.5, sqrt(pol0_1->GetParError(0)*pol0_1->GetParError(0) + pol0_1->GetParError(1)*pol0_1->GetParError(1))); statprecision_vs_loop[2]->SetPoint(ipoint, iLoop + 1, pol0_2->GetParameter(0) + pol0_2->GetParameter(1) * 50); statprecision_vs_loop[2]->SetPointError(ipoint, 0.5, sqrt(pol0_0->GetParError(0)*pol0_2->GetParError(0) + pol0_2->GetParError(1)*pol0_2->GetParError(1))); statprecision_vs_loop[3]->SetPoint(ipoint, iLoop + 1, pol0_3->GetParameter(0) + pol0_3->GetParameter(1) * 72.5); statprecision_vs_loop[3]->SetPointError(ipoint, 0.5, sqrt(pol0_3->GetParError(0)*pol0_3->GetParError(0) + pol0_3->GetParError(1)*pol0_3->GetParError(1))); ipoint++; } //----------------------------------------------------------------- //--- Draw plots //----------------------------------------------------------------- TCanvas *c[nLoops]; TCanvas *c2[4]; TFile * out = new TFile ("StatPrecEB.root", "RECREATE"); // --- plot 5 : statistical precision vs ieta for ( int iLoop = 0; iLoop < nLoops; iLoop++ ) { sprintf(hname, "cstat_%d", iLoop); c[iLoop] = new TCanvas(hname, hname); c[iLoop]->SetGridx(); c[iLoop]->SetGridy(); statprecision_vs_ieta[iLoop]->GetHistogram()->GetYaxis()-> SetRangeUser(0.0001, 0.07); statprecision_vs_ieta[iLoop]->GetHistogram()->GetXaxis()-> SetRangeUser(-85, 85); statprecision_vs_ieta[iLoop]->GetHistogram()->GetYaxis()-> SetTitle("#sigma((c_{P}-c_{D})/(c_{P}+c_{D}))"); statprecision_vs_ieta[iLoop]->GetHistogram()->GetXaxis()-> SetTitle("i#eta"); statprecision_vs_ieta[iLoop]->Draw("ap"); if(iLoop == nLoops - 1) { out->cd(); statprecision_vs_ieta[iLoop]->SetName("gr_stat_prec"); statprecision_vs_ieta[iLoop]->Write(); } } for ( int ietaregion = 0; ietaregion < 4; ietaregion++ ) { sprintf(hname, "ietaregion_%d", ietaregion); c2[ietaregion] = new TCanvas(hname, hname); c2[ietaregion]->SetGridx(); c2[ietaregion]->SetGridy(); statprecision_vs_loop[ietaregion]->GetHistogram()->GetYaxis()-> SetRangeUser(0., 0.04); statprecision_vs_loop[ietaregion]->GetHistogram()->GetXaxis()-> SetRangeUser(0, nLoops + 1); statprecision_vs_loop[ietaregion]->GetHistogram()->GetYaxis()-> SetTitle("Statistical precision"); statprecision_vs_loop[ietaregion]->GetHistogram()->GetXaxis()-> SetTitle("n#circ iteration"); statprecision_vs_loop[ietaregion]->Draw("ap"); } theApp->Run(); return 0; }
int main (int argc, char **argv) { /// Mc Ntuplas TString input = Form("/data1/rgerosa/NTUPLES_FINAL_CALIB/MC/WJetsToLNu_DYJetsToLL_7TeV-madgraph-tauola_Fall11_All.root"); /// MC Calibration result E/p TString input2 = Form("/data1/rgerosa/L3_Weight/MC_WJets/EB_Z_recoFlag/WJetsToLNu_DYJetsToLL_7TeV-madgraph-tauola_Fall11_Z_noEP.root"); TApplication* theApp = new TApplication("Application",&argc, argv); TFile *f = new TFile(input,""); TTree *inputTree = (TTree*)f->Get("ntu"); TFile *f2 = new TFile(input2,""); TH2F *h_scale_EB = (TH2F*)f2->Get("h_scale_EB"); TH2F *hcmap = (TH2F*) h_scale_EB->Clone("hcmap"); hcmap -> Reset("ICEMS"); hcmap -> ResetStats(); /// Taking infos std::vector<float>* ele1_recHit_E=0; std::vector<float>* ele2_recHit_E=0; std::vector<int>* ele1_recHit_hashedIndex=0; std::vector<int>* ele2_recHit_hashedIndex=0; std::vector<int>* ele1_recHit_flag=0; std::vector<int>* ele2_recHit_flag=0; float ele1_E_true,ele2_E_true; float ele1_tkP,ele2_tkP; int ele1_isEB, ele2_isEB; float ele1_fbrem,ele2_fbrem; int isW, isZ; inputTree->SetBranchAddress("ele1_recHit_E", &ele1_recHit_E); inputTree->SetBranchAddress("ele2_recHit_E", &ele2_recHit_E); inputTree->SetBranchAddress("ele1_recHit_hashedIndex", &ele1_recHit_hashedIndex); inputTree->SetBranchAddress("ele2_recHit_hashedIndex", &ele2_recHit_hashedIndex); inputTree->SetBranchAddress("ele1_recHit_flag", &ele1_recHit_flag); inputTree->SetBranchAddress("ele2_recHit_flag", &ele2_recHit_flag); inputTree->SetBranchAddress("ele1_E_true", &ele1_E_true); inputTree->SetBranchAddress("ele2_E_true", &ele2_E_true); inputTree->SetBranchAddress("ele1_tkP", &ele1_tkP); inputTree->SetBranchAddress("ele2_tkP", &ele2_tkP); inputTree->SetBranchAddress("ele1_isEB", &ele1_isEB); inputTree->SetBranchAddress("ele2_isEB", &ele2_isEB); inputTree->SetBranchAddress("ele1_fbrem", &ele1_fbrem); inputTree->SetBranchAddress("ele2_fbrem", &ele2_fbrem); inputTree->SetBranchAddress("isW", &isW); inputTree->SetBranchAddress("isZ", &isZ); TProfile2D* mapMomentum = new TProfile2D("mapMomentum","mapMomentum",360,0,360,170,-85,85); TProfile2D* mapfbrem = new TProfile2D("mapfbrem","mapfbrem",360,0,360,170,-85,85); /// Make fbrem and p/ptrue map cycling on MC --> all the events for(Long64_t i=0; i< inputTree->GetEntries(); i++) { inputTree->GetEntry(i); if (!(i%100000))std::cerr<<i; if (!(i%10000)) std::cerr<<"."; if (ele1_isEB == 1 && (isW==1 || isZ==1)) { double E_seed=0; int seed_hashedIndex, iseed; for (unsigned int iRecHit = 0; iRecHit < ele1_recHit_E->size(); iRecHit++ ) { if(ele1_recHit_E -> at(iRecHit) > E_seed && ele1_recHit_flag->at(iRecHit) < 4 ) /// control if this recHit is good { seed_hashedIndex=ele1_recHit_hashedIndex -> at(iRecHit); iseed=iRecHit; E_seed=ele1_recHit_E -> at(iRecHit); ///! Seed search } } int eta_seed = GetIetaFromHashedIndex(seed_hashedIndex); int phi_seed = GetIphiFromHashedIndex(seed_hashedIndex); if(ele1_tkP>0 && ele1_E_true>0 && abs(ele1_tkP/ele1_E_true)<2. && abs(ele1_tkP/ele1_E_true)>0.5) mapMomentum->Fill(phi_seed,eta_seed,abs(ele1_tkP/ele1_E_true)); mapfbrem->Fill(phi_seed,eta_seed,abs(ele1_fbrem)); } if (ele2_isEB == 1 && isZ==1) { double E_seed=0; int seed_hashedIndex, iseed; for (unsigned int iRecHit = 0; iRecHit < ele2_recHit_E->size(); iRecHit++ ) { if(ele2_recHit_E -> at(iRecHit) > E_seed && ele2_recHit_flag->at(iRecHit) < 4 ) /// control if this recHit is good { seed_hashedIndex=ele2_recHit_hashedIndex -> at(iRecHit); iseed=iRecHit; E_seed=ele2_recHit_E -> at(iRecHit); ///! Seed search } } int eta_seed = GetIetaFromHashedIndex(seed_hashedIndex); int phi_seed = GetIphiFromHashedIndex(seed_hashedIndex); if(ele2_tkP>0 && ele2_E_true>0 && abs(ele2_tkP/ele2_E_true)<2. && abs(ele2_tkP/ele2_E_true)>0.5) mapMomentum->Fill(phi_seed,eta_seed,abs(ele2_tkP/ele2_E_true)); mapfbrem->Fill(phi_seed,eta_seed,abs(ele2_fbrem)); } } /// Map of IC normalized in eta rings std::vector< std::pair<int,int> > TT_centre ; TT_centre.push_back(std::pair<int,int> (58,49)); TT_centre.push_back(std::pair<int,int> (53,109)); TT_centre.push_back(std::pair<int,int> (8,114)); TT_centre.push_back(std::pair<int,int> (83,169)); TT_centre.push_back(std::pair<int,int> (53,174)); TT_centre.push_back(std::pair<int,int> (63,194)); TT_centre.push_back(std::pair<int,int> (83,224)); TT_centre.push_back(std::pair<int,int> (73,344)); TT_centre.push_back(std::pair<int,int> (83,358)); TT_centre.push_back(std::pair<int,int> (-13,18)); TT_centre.push_back(std::pair<int,int> (-18,23)); TT_centre.push_back(std::pair<int,int> (-8,53)); TT_centre.push_back(std::pair<int,int> (-3,63)); TT_centre.push_back(std::pair<int,int> (-53,128)); TT_centre.push_back(std::pair<int,int> (-53,183)); TT_centre.push_back(std::pair<int,int> (-83,193)); TT_centre.push_back(std::pair<int,int> (-74,218)); TT_centre.push_back(std::pair<int,int> (-8,223)); TT_centre.push_back(std::pair<int,int> (-68,303)); TT_centre.push_back(std::pair<int,int> (-43,328)); /// Mean over phi corrected skipping dead channel for (int iEta = 1 ; iEta < h_scale_EB->GetNbinsY()+1; iEta ++) { float SumIC = 0; int numIC = 0; for(int iPhi = 1 ; iPhi < h_scale_EB->GetNbinsX()+1 ; iPhi++) { bool isGood = CheckxtalIC(h_scale_EB,iPhi,iEta); bool isGoodTT = CheckxtalTT(iPhi,iEta,TT_centre); if(isGood && isGoodTT) { SumIC = SumIC + h_scale_EB->GetBinContent(iPhi,iEta); numIC ++ ; } } //fede: skip bad channels and bad TTs for (int iPhi = 1; iPhi< h_scale_EB->GetNbinsX()+1 ; iPhi++) { if(numIC==0 || SumIC==0) continue; bool isGood = CheckxtalIC(h_scale_EB,iPhi,iEta); bool isGoodTT = CheckxtalTT(iPhi,iEta,TT_centre); if (!isGood || !isGoodTT) continue; hcmap->SetBinContent(iPhi,iEta,h_scale_EB->GetBinContent(iPhi,iEta)/(SumIC/numIC)); } } /// ratio map TH2F* ratioMap = (TH2F*) hcmap -> Clone("ratioMap"); ratioMap->Reset(); for( int i =0 ; i<hcmap->GetNbinsX() ; i++){ for( int j=0; j<hcmap->GetNbinsY() ; j++){ if(hcmap->GetBinContent(i,j)!=0 && mapMomentum->GetBinContent(i,j)!=0) ratioMap->SetBinContent(i+1,j+1,mapMomentum->GetBinContent(i,j)/hcmap->GetBinContent(i,j)); } } /// Profile along phi taking into account dead channels TGraphErrors *coeffEBp = new TGraphErrors(); TGraphErrors *coeffEBm = new TGraphErrors(); for (int iPhi =1; iPhi< hcmap->GetNbinsX()+1 ; iPhi++){ double SumEBp =0, SumEBm=0; double iEBp=0, iEBm=0; for(int iEta = 1; iEta<hcmap->GetNbinsY()+1 ; iEta++){ if(hcmap->GetBinContent(iPhi,iEta)==0)continue; if(iEta>85) {SumEBp=SumEBp+mapMomentum->GetBinContent(iPhi,iEta)/hcmap->GetBinContent(iPhi,iEta); iEBp++;} else{ SumEBm=SumEBm+mapMomentum->GetBinContent(iPhi,iEta)/hcmap->GetBinContent(iPhi,iEta); iEBm++;} } coeffEBp->SetPoint(iPhi-1,iPhi-1,SumEBp/iEBp); coeffEBm->SetPoint(iPhi-1,iPhi-1,SumEBm/iEBm); } TFile* outputGraph = new TFile("output/GraphFor_P_Correction.root","RECREATE"); outputGraph->cd(); coeffEBp->Write("coeffEBp"); coeffEBm->Write("coeffEBm"); outputGraph->Close(); gROOT->Reset(); gROOT->SetStyle("Plain"); gStyle->SetPadTickX(1); gStyle->SetPadTickY(1); gStyle->SetOptTitle(1); gStyle->SetOptStat(0); gStyle->SetOptFit(0); gStyle->SetFitFormat("6.3g"); gStyle->SetPalette(1); gStyle->SetTextFont(42); gStyle->SetTextSize(0.05); gStyle->SetTitleFont(42,"xyz"); gStyle->SetTitleSize(0.05); gStyle->SetLabelFont(42,"xyz"); gStyle->SetLabelSize(0.05); gStyle->SetTitleXOffset(0.8); gStyle->SetTitleYOffset(1.1); gROOT->ForceStyle(); TCanvas* c1 = new TCanvas("mapMomentum","mapMomentum",1); c1->cd(); mapMomentum->GetXaxis()->SetTitle("#phi"); mapMomentum->GetXaxis()->SetNdivisions(20); c1->SetGridx(); mapMomentum->GetYaxis()->SetTitle("#eta"); mapMomentum->GetZaxis()->SetRangeUser(0.7,1.3); mapMomentum->Draw("colz"); TCanvas* c2 = new TCanvas("mapfbrem","mapfbrem",1); c2->cd(); mapfbrem->GetXaxis()->SetTitle("#phi"); mapfbrem->GetYaxis()->SetTitle("#eta"); mapfbrem->GetXaxis()->SetNdivisions(20); c2->SetGridx(); mapfbrem->GetZaxis()->SetRangeUser(0.,0.7); mapfbrem->Draw("colz"); TCanvas* c3 = new TCanvas("ratioMap","ratioMap",1); c3->cd(); ratioMap->GetXaxis()->SetTitle("#phi"); ratioMap->GetYaxis()->SetTitle("#eta"); ratioMap->GetXaxis()->SetNdivisions(20); c3->SetGridx(); ratioMap->GetZaxis()->SetRangeUser(0.7,1.3); ratioMap->Draw("colz"); TCanvas* c4 = new TCanvas("coeffEB","coeffEB",1); c4->cd(); coeffEBp->GetXaxis()->SetTitle("#phi"); coeffEBp->GetYaxis()->SetTitle("p/p_{true}"); coeffEBp -> SetMarkerStyle(20); coeffEBp -> SetMarkerSize(1); coeffEBp -> SetMarkerColor(kRed+1); coeffEBp -> SetLineColor(kRed+1); c4->SetGridx(); c4->SetGridy(); ratioMap->Draw("ap"); coeffEBm->GetXaxis()->SetTitle("#phi"); coeffEBm->GetYaxis()->SetTitle("p/p_{true}"); coeffEBm -> SetMarkerStyle(20); coeffEBm -> SetMarkerSize(1); coeffEBm -> SetMarkerColor(kBlue+1); coeffEBm -> SetLineColor(kBlue+1); coeffEBm->Draw("ap same"); theApp->Run(); return 0; }