void mySelector::SlaveTerminate() { // The SlaveTerminate() function is called after all entries or objects // have been processed. When running with PROOF SlaveTerminate() is called // on each slave server. cout<<"-------------End of Slave Job----------------"<<endl; tNow.Set();tNow.Print(); cout<<"Number of Event: "<<fNumberOfEvents<<", elapsed time: "<<tNow.Convert()-tBegin.Convert()<<"seconds,rate: "<<float(fNumberOfEvents)/(tNow.Convert()-tBegin.Convert())<<endl; }
void MySelector::SlaveTerminate() { // The SlaveTerminate() function is called after all entries or // objects have been processed. When running with PROOF // SlaveTerminate() is called on each slave server. // some statistics at end of job printf("\n *==* ---------- End of Slave Job ---------- "); tNow.Set(); tNow.Print(); printf( "Number of Events: %i, elapsed time: %i sec, rate: %g evts/sec\n" ,fNumberOfEvents, tNow.Convert()-tBegin.Convert(), float(fNumberOfEvents)/(tNow.Convert()-tBegin.Convert()) ); }
Bool_t KVDataSetManager::CheckCacheStatus() { //We check the status of the available datasets cache file. //We return kTRUE if the file exists & was last modified //less than fMaxCacheTime seconds ago. TString fullpath; Info("KVDataSetManager::CheckCacheStatus", "Checking for available datasets cache file..."); if( KVBase::SearchKVFile( KVBase::GetWORKDIRFilePath(fCacheFileName), fullpath ) ){ // file exists - how old is it ? FileStat_t file_info; gSystem->GetPathInfo( fullpath.Data(), file_info ); TDatime file_date( file_info.fMtime ); TDatime now; UInt_t file_age = now.Convert() - file_date.Convert(); Info("KVDataSetManager::CheckCacheStatus", "...file found. It is %u seconds old", file_age); if( file_age < fMaxCacheTime ) { Info("KVDataSetManager::CheckCacheStatus", "Using cached file"); return kTRUE; } else Info("KVDataSetManager::CheckCacheStatus", "File is too old (max time=%u). Update will be performed.", fMaxCacheTime); } else Info("KVDataSetManager::CheckCacheStatus", "...no file found"); return kFALSE; }
void seism() { TStopwatch sw; sw.Start(); //set time offset TDatime dtime; gStyle->SetTimeOffset(dtime.Convert()); TCanvas *c1 = new TCanvas("c1","Time on axis",10,10,1000,500); c1->SetFillColor(42); c1->SetFrameFillColor(33); c1->SetGrid(); Float_t bintime = 1; //one bin = 1 second. change it to set the time scale TH1F *ht = new TH1F("ht","The ROOT seism",10,0,10*bintime); Float_t signal = 1000; ht->SetMaximum( signal); ht->SetMinimum(-signal); ht->SetStats(0); ht->SetLineColor(2); ht->GetXaxis()->SetTimeDisplay(1); ht->GetYaxis()->SetNdivisions(520); ht->Draw(); for (Int_t i=1;i<2300;i++) { //======= Build a signal : noisy damped sine ====== Float_t noise = gRandom->Gaus(0,120); if (i > 700) noise += signal*sin((i-700.)*6.28/30)*exp((700.-i)/300.); ht->SetBinContent(i,noise); c1->Modified(); c1->Update(); gSystem->ProcessEvents(); //canvas can be edited during the loop } printf("Real Time = %8.3fs, Cpu Time = %8.3fs\n",sw.RealTime(),sw.CpuTime()); }
void KVINDRAOnlineDataAnalyser::PrintControlRate() { TDatime nowtime; int time_passed = nowtime.Convert() - fStart.Convert(); if (time_passed < 1.0) { fEventsRefresh *= 2; return; } // check time - we aim for a 5 second refresh fEventsRefresh *= 5. / time_passed; // minimum 5 events fEventsRefresh = TMath::Max(fEventsRefresh, 5); Float_t acq_rate = (1.0 * (events - last_events)) / (1.0 * time_passed); printf("Events read = %d <=> Control rate = %f /sec.\n", events, acq_rate); last_events = events; fStart.Set(); if (fDumpEvents) fRunFile->GetFiredDataParameters()->ls(); }
void candleplot() { gStyle->SetTimeOffset(0); TRandom *rand = new TRandom(); TDatime *dateBegin = new TDatime(2010,1,1,0,0,0); TDatime *dateEnd = new TDatime(2011,1,1,0,0,0); TH2I *h1 = new TH2I("h1","Machine A + B",12,dateBegin->Convert(),dateEnd->Convert(),1000,0,1000); TH2I *h2 = new TH2I("h2","Machine B",12,dateBegin->Convert(),dateEnd->Convert(),1000,0,1000); h1->GetXaxis()->SetTimeDisplay(1); h1->GetXaxis()->SetTimeFormat("%m/%y"); h1->GetXaxis()->SetTitle("Date [month/year]"); float Rand; for (int i = dateBegin->Convert(); i < dateEnd->Convert(); i+=86400*30) { for (int j = 0; j < 1000; j++) { Rand = rand->Gaus(500+sin(i/10000000.)*100,50); h1->Fill(i,Rand); Rand = rand->Gaus(500+sin(i/11000000.)*100,70); h2->Fill(i,Rand); } } h1->SetBarWidth(0.4); h1->SetBarOffset(-0.25); h1->SetFillColor(kYellow); h1->SetFillStyle(1001); h2->SetBarWidth(0.4); h2->SetBarOffset(0.25); h2->SetLineColor(kRed); h2->SetFillColor(kGreen); TCanvas *c1 = new TCanvas(); h1->Draw("candle2"); h2->Draw("candle3 same"); gPad->BuildLegend(0.78,0.695,0.980,0.935,"","f"); }
{ gROOT->Reset(); TDatime da(2011,01,01,12,00,00); gStyle->SetTimeOffset(da.Convert()); ct = new TCanvas("ct","Time on axis"); ht2 = new TH1F("ht2","ht2",365,0.,365.*86400); for (Int_t i=1;i<365;i++) { ht2->SetBinContent(i,i); } ct->cd(2); ht2->GetXaxis()->SetLabelSize(0.04); ht2->GetXaxis()->SetTimeDisplay(1); ht2->GetXaxis()->SetNdivisions(12); ht2->GetXaxis()->SetTimeFormat("%d\/%m\/%y"); ht2->Draw(); }
int main(Int_t argc,char **argv) { TApplication *TheApp = new TApplication("theApp",&argc,argv); // problem with the two commandline args getting in conflict // this programs plots a signal over time // // Create time stamp // Let's see what we get a starting point TDatime dtime; gStyle->SetTimeOffset(dtime.Convert()); TCanvas *c1 = new TCanvas("c1","Time on axis",10,10,1000,500); c1->SetFillColor(42); c1->SetFrameFillColor(33); c1->SetGrid(); c1->cd(); Float_t bintime = 1; //one bin = 1 second. change it to set the time scale TH1F *ht = new TH1F("ht","The Noisy Signal",10,0,10*bintime); Float_t signal = 1000; ht->SetMaximum(signal); ht->SetMinimum(-signal); ht->SetStats(0); ht->SetLineColor(2); ht->GetXaxis()->SetTimeDisplay(1); ht->GetYaxis()->SetNdivisions(520); ht->Draw(); TF1 *f1 = new TF1("f1","gaus",-5,5); TCanvas *c2 = new TCanvas(); c2->cd(); f1->Draw(); for (Int_t i=1;i<20000;i++) { // wait for 1 second //sleep(1); //cout<<"tick \n"; //======= Build a signal : noisy damped sine ====== //Float_t noise = f1->GetRandom(); Float_t noise = i/10; cout<<noise<<"\n"; if (i > 700) noise += signal*sin((i-700.)*6.28/30)*exp((700.-i)/300.); ht->SetBinContent(i,noise); ht->GetXaxis()->SetRange(i-50,i+50); /* if(i==50){ c1->Clear(); ht->Draw(); c1->Update(); } else{ */ c1->Modified(); c1->Update(); //} gSystem->ProcessEvents(); //canvas can be edited during the loop } TheApp->Run(); TheApp->Terminate(); return 1; }
void adcAnalyzer::Begin(TTree * /*tree*/) { TString option = GetOption(); triggerTime = 0; nEvent = 0; // Tool initializations //spectralAnalyzer = new TSpectrum(); // Output file outFile = new TFile("adcHistograms.root", "RECREATE"); for (int i = 0; i < 8; ++i) outFile->mkdir(Form("ADC_CH%i", i), Form("ADC_CH%i", i)); // Histogram initializations TH1::SetDefaultSumw2(kTRUE); h1_ADCSpectrumCombined = new TH1D("h1_ADCSpectrumCombined", "ADC spectrum (all channels);ADC counts;N_{events}", 255, 0., 255.); h1_TriggerTime = new TH1D("h1_TriggerTime", "Turn clock time", 100, 0., 100.); for (unsigned i = 0; i < 8; ++i) { outFile->cd(Form("ADC_CH%i", i)); p1_RateVsTime[i] = new TProfile(Form("p1_RateVsTime_%i", i), Form("Rate vs time (channel %i);time;rate", i), (time_f.Convert() - time_i.Convert())/2, time_i.Convert(), time_f.Convert()); h1_ADCSpectrum[i] = new TH1D(Form("h1_ADCSpectrum_%i", i), Form("ADC spectrum (channel %i);ADC counts;N_{events}", i), 130, -40.5, 90.5); h1_Baseline[i] = new TH1D(Form("h1_Baseline_%i", i), Form("ADC baseline (channel %i);ADC counts;N_{events}", i), 255, 0.5, 255.5); h1_PeakValue[i] = new TH1D(Form("h1_PeakValue_%i", i), Form("Signal peak (channel %i);ADC counts;N_{events}", i), 100, 0.5, 100.5); h1_TimeOverShoot[i] = new TH1D(Form("h1_TimeOverShoot_%i", i), Form("Time in overshoot (channel %i);time (ns);N_{events}", i), 500, 0.5, 4000.5); h1_TimeOverShootPO[i] = new TH1D(Form("h1_TimeOverShootPO_%i", i), Form("Time in overshoot per orbit (channel %i);time (ns);N_{events}", i), 750, 0.5, 12000.5); h1_TimeOverThresh[i] = new TH1D(Form("h1_TimeOverThresh_%i", i), Form("Time over threshold (channel %i);time (ns); nEvents", i), 250, 0.5, 2000.5); h1_TimeOverThreshPO[i] = new TH1D(Form("h1_TimeOverThreshPO_%i", i), Form("Time over threshold per orbit (channel %i);time (ns); nEvents", i), 625, 0.5, 10000.5); h1_HitsVsTime[i] = new TH1D(Form("h1_HitsVsTime_%i", i), Form("ADC Channel %i;time (ns);N_{hits}", i), 11250, 0., 89000); h1_HitsPerOrbit[i] = new TH1D(Form("h1_HitsPerOrbit_%i", i), Form("ADC Channel %i;N_{hits};N_{orbits}", i), 800, -0.5, 799.5); h1_EffectiveDeadtime[i] = new TH1D(Form("h1_EffectiveDeadtime_%i", i), Form("ADC Channel %i;t_{OT+OS};N_{hits}", i), 600, 0.5, 6000.5); h2_PulseHeightVsTOT[i] = new TH2D(Form("h2_PulseHeightVsTOT_%i", i), Form("pulse height vs. TOT (channel %i);time (ns); h_{pulse} (ADC counts)", i), 250, 0.5, 2000.5, 80, 0.5, 80.5); h2_OSHeightVsTOT[i] = new TH2D(Form("h2_OSHeightVsTOT_%i", i), Form("overshoot height vs. TOT (channel %i);time (ns); h_{pulse} (ADC counts)", i), 250, 0.5, 2000.5, 40, 0.5, 40.5); h2_TOSVsTOT[i] = new TH2D(Form("h2_TOSVsTOT_%i", i), Form("TOS vs. TOT (channel %i);TOT (ns); TOS", i), 250, 0.5, 2000.5, 500, 0.5, 4000.5); outFile->GetDirectory(Form("ADC_CH%i", i))->mkdir("Orbit scans", "Orbit Scans"); for (unsigned j = 0; j < 20; ++j) { outFile->cd(Form("ADC_CH%i/Orbit scans", i)); p1_ADCVsTime[i][j] = new TProfile(Form("p1_ADCVsTime_%i_%i", i, j), Form("ADC Channel %i (acquisition %i);time (ns);ADC counts", i, 50*j), 22500, 0., 90000, 0., 255.); } } }
void makeStripCharts(const Char_t* ratefn, const Char_t* voltfn, const Char_t* outtag, const Char_t* statfn=0, // def 0 for backwards compatibility const Float_t zoomDays=7.0, const Bool_t finFromData=kFALSE) { // finFromData = true => max of time axis determined by last data point // = false => determined by time at which the script is run gSystem->Setenv("TZ","UTC"); gStyle->SetTimeOffset(0); gStyle->SetOptStat(0); ratef = TFile::Open(ratefn); if ( (ratef==0) || (ratef->IsZombie()) ) { Error("makeStripCharts","Could not open [%s]",ratefn); } else { gERvsT = dynamic_cast<TGraph*>(ratef->Get("gERvsT")); } voltf = TFile::Open(voltfn); if ( (voltf==0) || (voltf->IsZombie()) ) { Error("makeStripCharts","Could not open [%s]",voltfn); } else { gVolt = dynamic_cast<TGraph*>(voltf->Get("gVolt")); gCurr = dynamic_cast<TGraph*>(voltf->Get("gCurr")); } if (statfn!=0) { statf = TFile::Open(statfn); if ( (statf!=0) && (statf->IsZombie()==kFALSE) ) { gStERvsT = dynamic_cast<TGraph*>(statf->Get("gStERvsT")); gStVvsT = dynamic_cast<TGraph*>(statf->Get("gStVvsT")); gStCvsT = dynamic_cast<TGraph*>(statf->Get("gStCvsT")); } if (gERvsT==0) { gERvsT = gStERvsT; } if (gVolt==0) { gVolt = gStVvsT; } if (gCurr==0) { gCurr = gStCvsT; } } if ( (gERvsT!=0) && (gVolt!=0) && (gCurr!=0) ) { setStyle(gERvsT, kRate); setStyle(gVolt, kVolt); setStyle(gCurr, kCurr); if (gStVvsT!=0) { setStyle(gStVvsT, kStVolt); } if (gStCvsT!=0) { setStyle(gStCvsT, kStCurr); } // assume gERvsT is ordered Double_t start = (gERvsT->GetX())[0]; Double_t fin = (gERvsT->GetX())[(gERvsT->GetN())-1]; if (gStERvsT!=0) { setStyle(gStERvsT, kStRate); // gStERvsT not ordered Double_t sst, sfn; getStartFinFrom(*gStERvsT, sst, sfn); if (sst<start) { start = sst; } if (sfn>fin) { fin = sfn; } } if (finFromData==kFALSE) { const TDatime now; fin = now.Convert(); } Int_t tbins(100); Double_t tmin(0), tmax(1); TSnMath::GetNiceDateAxisFor(start, fin, tbins, tmin, tmax); TH2F* hrd = new TH2F("hrd", gERvsT->GetTitle(), tbins, tmin, tmax, rbins, rmin, rmax); TH2F* hvd = new TH2F("hvd", gVolt->GetTitle(), tbins, tmin, tmax, vbins, vmin, vmax); TH2F* hzd = new TH2F("hzd", gVolt->GetTitle(), tbins, tmin, tmax, zbins, zmin, zmax); TH2F* hcd = new TH2F("hcd", gCurr->GetTitle(), tbins, tmin, tmax, cbins, cmin, cmax); setTimeDisp(*hrd); setTimeDisp(*hvd); setTimeDisp(*hzd); setTimeDisp(*hcd); c1 = new TCanvas("c1","c1",cwid,chit); c1->Divide(1,4); c1->cd(1); hrd->Draw("axis"); if (gStERvsT!=0) { gStERvsT->Draw(grphDrawOpt); } gERvsT->Draw(grphDrawOpt); c1->GetPad(1)->SetLogy(); c1->GetPad(1)->SetGridx(); c1->cd(2); hzd->Draw("axis"); if (gStVvsT!=0) { gStVvsT->Draw(grphDrawOpt); } gVolt->Draw(grphDrawOpt); c1->GetPad(2)->SetGridx(); c1->cd(3); hvd->Draw("axis"); if (gStVvsT!=0) { gStVvsT->Draw(grphDrawOpt); } gVolt->Draw(grphDrawOpt); c1->GetPad(3)->SetGridx(); c1->cd(4); hcd->Draw("axis"); if (gStCvsT!=0) { gStCvsT->Draw(grphDrawOpt); } gCurr->Draw(grphDrawOpt); c1->GetPad(4)->SetGridx(); c1->cd(); c1->Update(); c1->Print(Form("%s.root",outtag)); c1->Print(Form("%s.gif",outtag)); TSnMath::GetNiceDateAxisFor( fin - (zoomDays*kSecPerDay), fin, tbins, tmin, tmax); TH2F* hrz = new TH2F("hrz", gERvsT->GetTitle(), tbins, tmin, tmax, rbins, rmin, rmax); TH2F* hvz = new TH2F("hvz", gVolt->GetTitle(), tbins, tmin, tmax, zbins, zmin, zmax); TH2F* hzz = new TH2F("hzz", gVolt->GetTitle(), tbins, tmin, tmax, vbins, vmin, vmax); TH2F* hcz = new TH2F("hcz", gCurr->GetTitle(), tbins, tmin, tmax, cbins, cmin, cmax); setTimeDisp(*hrz, 515); setTimeDisp(*hvz, 515); setTimeDisp(*hzz, 515); setTimeDisp(*hcz, 515); c2 = new TCanvas("c2","c2",cwid,chit); c2->Divide(1,4); c2->cd(1); hrz->Draw("axis"); if (gStERvsT!=0) { gStERvsT->Draw(grphDrawOpt); } gERvsT->Draw(grphDrawOpt); c2->GetPad(1)->SetLogy(); c2->GetPad(1)->SetGridx(); c2->cd(2); hvz->Draw("axis"); if (gStVvsT!=0) { gStVvsT->Draw(grphDrawOpt); } gVolt->Draw(grphDrawOpt); c2->GetPad(2)->SetGridx(); c2->cd(3); hzz->Draw("axis"); if (gStVvsT!=0) { gStVvsT->Draw(grphDrawOpt); } gVolt->Draw(grphDrawOpt); c2->GetPad(3)->SetGridx(); c2->cd(4); hcz->Draw("axis"); if (gStCvsT!=0) { gStCvsT->Draw(grphDrawOpt); } gCurr->Draw(grphDrawOpt); c2->GetPad(4)->SetGridx(); c2->cd(); c2->Update(); c2->Print(Form("%s.now.root",outtag)); c2->Print(Form("%s.now.gif",outtag)); } else { Error("makeStripCharts","Could not get graphs"); } }
void makeSBWcharts(const Char_t* sbgfn, const Char_t* outtag, const Float_t zoomDays=7.0, const Bool_t drawMinMax=kFALSE, const Bool_t finFromData=kFALSE) { // finFromData = true => max of time axis determined by last data point // = false => determined by time at which the script is run gROOT->Reset(); gSystem->Setenv("TZ","UTC"); gStyle->SetTimeOffset(0); gStyle->SetOptStat(0); TH1::AddDirectory(kTRUE); sbgf = TFile::Open(sbgfn); if ( (sbgf==0) || (sbgf->IsZombie()) ) { Error("makeSBWcharts","Could not open [%s]",sbgfn); } gMaxTemp = dynamic_cast<TGraph*>(sbgf->Get("gMaxTemp")); gMinTemp = dynamic_cast<TGraph*>(sbgf->Get("gMinTemp")); gMaxGust = dynamic_cast<TGraph*>(sbgf->Get("gMaxGust")); gCTemp = dynamic_cast<TGraph*>(sbgf->Get("gCTemp")); gAveWind = dynamic_cast<TGraph*>(sbgf->Get("gAveWind")); const TDatime dnow; const UInt_t now = dnow.Convert(); Double_t start(0), fin(0); Int_t tbins(100); Double_t tmin(0), tmax(1); c1 = new TCanvas("c1","c1",cwid,static_cast<Int_t>(chit/2.0)); c1->Divide(1,2); TLegend* mleg=0, * wleg=0; TLine* tzline=0; if (drawMinMax) { mleg = new TLegend(.258,.742,.410,.993); mleg->SetFillColor(0); mleg->SetBorderSize(1); wleg = new TLegend(.244,.794,.444,.993); wleg->SetFillColor(0); wleg->SetBorderSize(1); } if (gCTemp!=0) { setStyle(gCTemp, kCTemp); // get time scale from CTemp (only) getStartFinFrom(*gCTemp, start, fin); if (finFromData==kFALSE) { fin = now; } TSnMath::GetNiceDateAxisFor(start, fin, tbins, tmin, tmax); TH2F* htd = new TH2F("htd", gCTemp->GetTitle(), tbins, tmin, tmax, mbins, mmin, mmax); setTimeDisp(*htd); tzline = new TLine(tmin, 0, tmax, 0); tzline->SetLineColor(kBlack); tzline->SetLineWidth(1); tzline->SetLineStyle(2); c1->cd(1); htd->Draw("axis"); tzline->Draw(); gCTemp->Draw(grphDrawOpt); c1->GetPad(1)->SetGridx(); c1->GetPad(1)->SetGridy(); if (drawMinMax) { mleg->AddEntry(newDumHistForLegend(gCTemp), "Temp", "fp"); if (gMaxTemp!=0) { setStyle(gMaxTemp, kMaxTemp); gMaxTemp->Draw(grphDrawOpt); mleg->AddEntry(newDumHistForLegend(gMaxTemp), "Max Temp", "fp"); } if (gMinTemp!=0) { setStyle(gMinTemp, kMinTemp); gMinTemp->Draw(grphDrawOpt); mleg->AddEntry(newDumHistForLegend(gMinTemp), "Min Temp", "fp"); } mleg->Draw(); } // use time scale from temp if (gAveWind!=0) { setStyle(gAveWind, kAveWind); TH2F* hwd = new TH2F("hwd", gAveWind->GetTitle(), tbins, tmin, tmax, wbins, wmin, wmax); setTimeDisp(*hwd); c1->cd(2); hwd->Draw("axis"); gAveWind->Draw(grphDrawOpt); c1->GetPad(2)->SetGridx(); c1->GetPad(2)->SetGridy(); if (drawMinMax) { wleg->AddEntry(newDumHistForLegend(gAveWind), "Wind Speed", "fp"); if (gMaxGust!=0) { setStyle(gMaxGust, kMaxGust); gMaxGust->Draw(grphDrawOpt); wleg->AddEntry(newDumHistForLegend(gMaxGust), "Max Gust", "fp"); } wleg->Draw(); } } } c1->cd(); c1->Update(); c1->Print(Form("%s.root",outtag)); c1->Print(Form("%s.gif",outtag)); c2 = new TCanvas("c2","c2",cwid,static_cast<Int_t>(chit/2.0)); c2->Divide(1,2); TSnMath::GetNiceDateAxisFor( fin - (zoomDays*kSecPerDay), fin, tbins, tmin, tmax); if (gCTemp!=0) { c2->cd(1); TH2F* htz = new TH2F("htz", gCTemp->GetTitle(), tbins, tmin, tmax, mbins, mmin, mmax); setTimeDisp(*htz, 515); htz->Draw("axis"); gCTemp->Draw(grphDrawOpt); tzline->DrawLine(tmin, 0, tmax, 0); c2->GetPad(1)->SetGridx(); c2->GetPad(1)->SetGridy(); if (drawMinMax) { if (gMaxTemp!=0) { gMaxTemp->Draw(grphDrawOpt); } if (gMinTemp!=0) { gMinTemp->Draw(grphDrawOpt); } mleg->Draw(); } if (gAveWind!=0) { TH2F* hwz = new TH2F("hwz", gAveWind->GetTitle(), tbins, tmin, tmax, wbins, wmin, wmax); setTimeDisp(*hwz, 515); c2->cd(2); hwz->Draw("axis"); gAveWind->Draw(grphDrawOpt); c2->GetPad(2)->SetGridx(); c2->GetPad(2)->SetGridy(); if (drawMinMax) { if (gMaxGust!=0) { gMaxGust->Draw(grphDrawOpt); } wleg->Draw(); } } } c2->cd(); c2->Update(); c2->Print(Form("%s.now.root",outtag)); c2->Print(Form("%s.now.gif",outtag)); // cleanup delete sbgf; delete gMaxTemp; delete gMinTemp; delete gCTemp; delete gMaxGust; delete gAveWind; delete c1; delete c2; delete tzline; if (drawMinMax) { delete mleg; delete wleg; } }