//______________________________________________________________________________ void Export() { Char_t tmp[256]; Char_t tstamp[256]; // load CaLib gSystem->Load("libCaLib.so"); // get time-stamp UInt_t day, month, year; UInt_t hour, min; TTimeStamp t; t.GetDate(kFALSE, 0, &year, &month, &day); t.GetTime(kFALSE, 0, &hour, &min); sprintf(tstamp, "%d-%02d-%02d_%02d.%02d", year, month, day, hour, min); //// export CaLib data //sprintf(tmp, "backup_Dec_07_%s.root", tstamp); //TCMySQLManager::GetManager()->Export(tmp, 0, -1, "LD2_Dec_07"); // //// export CaLib data //sprintf(tmp, "backup_Feb_09_%s.root", tstamp); //TCMySQLManager::GetManager()->Export(tmp, 0, -1, "LD2_Feb_09"); //// export CaLib data //sprintf(tmp, "backup_May_09_%s.root", tstamp); //TCMySQLManager::GetManager()->Export(tmp, 0, -1, "LD2_May_09"); // //// export CaLib data //sprintf(tmp, "backup_MC_Dec_07_%s.root", tstamp); //TCMySQLManager::GetManager()->Export(tmp, 0, -1, "LD2_MC_Dec_07"); // //// export CaLib data //sprintf(tmp, "backup_MC_Feb_09_%s.root", tstamp); //TCMySQLManager::GetManager()->Export(tmp, 0, -1, "LD2_MC_Feb_09"); // //// export CaLib data //sprintf(tmp, "backup_MC_May_09_%s.root", tstamp); //TCMySQLManager::GetManager()->Export(tmp, 0, -1, "LD2_MC_May_09"); // export CaLib data sprintf(tmp, "backup_Apr_09_%s.root", tstamp); TCMySQLManager::GetManager()->Export(tmp, 0, -1, "LH2_Apr_09"); // export CaLib data sprintf(tmp, "backup_MC_Apr_09_%s.root", tstamp); TCMySQLManager::GetManager()->Export(tmp, 0, -1, "LH2_MC_Apr_09"); gSystem->Exit(0); }
void plotAtriRunStatistics(char *baseName, Int_t runLow, Int_t runHigh, Int_t numWeeks){ chain = new TChain("runStatsTree"); char fileName[256]; for(Int_t runNo=runLow;runNo<=runHigh;runNo++){ sprintf(fileName, "%s_run%i.root", baseName, runNo); printf("Adding %s\n", fileName); chain->Add(fileName); } chain->SetBranchAddress("stationId", &stationId); chain->GetEntry(0); getGraphs(); TTimeStamp *timeThen = new TTimeStamp(); timeThen->Add(-7*24*60*60*numWeeks); makePlots(timeThen->GetSec()); }
TString changetime(TString timea, int shift) { TString y,m,d,h,min,s,newtime; int year,month,day,hour,minute,second; y+=timea(0,4); cout<<"year "<<y<<endl; m+=timea(4,2); cout<<"month "<<m<<endl; d+=timea(6,2); cout<<"day "<<d<<endl; h+=timea(9,2); cout<<"hour "<<h<<endl; min+=timea(11,2); cout<<"minute "<<min<<endl; s+=timea(13,2); cout<<"second "<<s<<endl; TTimeStamp tstamp; tstamp.Set(y.Atoi(),m.Atoi(),d.Atoi(),h.Atoi(),min.Atoi(),s.Atoi(),0,1,shift); newtime += tstamp.AsString("yyyy-mm-dd HH:mm:ss"); return newtime; }
void makePlots(time_t then){ TTimeStamp *timeThen = new TTimeStamp(then); TTimeStamp *timeNow = new TTimeStamp(); //Calibration Pulser and Forced trigger rate canCalForceRate = new TCanvas("canCalForceRate"); canCalForceRate->cd(); grCalForceRate = new TMultiGraph(); grCalForceRate->SetName("grCalForceRate"); char title[100]; sprintf(title, "ARA0%i - Event Rate", stationId); grCalForceRate->SetTitle(title); grCalForceRate->Add(grCPURate, "l"); grCalForceRate->Add(grCalPulserRate, "l"); grCalForceRate->Draw("a"); grCalForceRate->GetXaxis()->SetTitle("Time"); grCalForceRate->GetXaxis()->SetRangeUser(timeThen->GetSec(), timeNow->GetSec()); grCalForceRate->GetXaxis()->SetTimeDisplay(1); grCalForceRate->GetXaxis()->SetTimeFormat("%d %B %F1970-01-01"); grCalForceRate->GetYaxis()->SetTitle("Rate (Hz)"); legCalForceRate = new TLegend(0.85,0.75,1,0.9); legCalForceRate->AddEntry(grCalPulserRate, "CalPulser Rate", "l"); legCalForceRate->AddEntry(grCPURate, "Min-Bias Rate", "l"); legCalForceRate->SetFillColor(0); legCalForceRate->Draw(); //Total and RF0 Rate canTotalRate = new TCanvas("canTotalRate"); canTotalRate->cd(); grTotalRate = new TMultiGraph(); grTotalRate->SetName("grTotalRate"); char title[100]; sprintf(title, "ARA0%i - Event Rate", stationId); grTotalRate->SetTitle(title); grTotalRate->Add(grEventRate, "l"); grTotalRate->Add(grRF0Rate, "l"); grTotalRate->Draw("a"); grTotalRate->GetXaxis()->SetTitle("Time"); grTotalRate->GetXaxis()->SetRangeUser(timeThen->GetSec(), timeNow->GetSec()); grTotalRate->GetXaxis()->SetTimeDisplay(1); grTotalRate->GetXaxis()->SetTimeFormat("%d %B %F1970-01-01"); grTotalRate->GetYaxis()->SetTitle("Rate (Hz)"); legTotalRate = new TLegend(0.85,0.75,1,0.9); legTotalRate->AddEntry(grRF0Rate, "Deep Trigger Rate", "l"); legTotalRate->AddEntry(grEventRate, "Total Rate", "l"); legTotalRate->SetFillColor(0); legTotalRate->Draw(); //All - Total, RF0 Calpulser and RF0 rates canAll = new TCanvas("canAllRate"); canAll->cd(); grAllRate = new TMultiGraph(); grAllRate->SetName("grAllRate"); char title[100]; sprintf(title, "ARA0%i - Event Rate", stationId); grAllRate->SetTitle(title); grAllRate->Add(grEventRate, "l"); grAllRate->Add(grRF0Rate, "l"); grAllRate->Add(grCalPulserRate, "l"); // grAllRate->Add(grCPURate, "l"); grAllRate->Draw("a"); grAllRate->GetXaxis()->SetTitle("Time"); grAllRate->GetXaxis()->SetRangeUser(timeThen->GetSec(), timeNow->GetSec()); grAllRate->GetXaxis()->SetTimeDisplay(1); grAllRate->GetXaxis()->SetTimeFormat("%d %B %F1970-01-01"); grAllRate->GetYaxis()->SetTitle("Rate (Hz)"); legAllRate = new TLegend(0.85,0.75,1,0.9); legAllRate->AddEntry(grRF0Rate, "Deep Trigger Rate", "l"); legAllRate->AddEntry(grEventRate, "Total Rate", "l"); legAllRate->AddEntry(grCalPulserRate, "CalPulser Rate", "l"); // legAllRate->AddEntry(grCPURate, "Min-Bias Rate", "l"); legAllRate->SetFillColor(0); legAllRate->Draw(); }
/** * Factory: DD4hep_ConditionExample_stress * * \author M.Frank * \version 1.0 * \date 01/12/2016 */ static int condition_example (Detector& description, int argc, char** argv) { string input; int num_iov = 10, num_runs = 10; bool arg_error = false; for(int i=0; i<argc && argv[i]; ++i) { if ( 0 == ::strncmp("-input",argv[i],4) ) input = argv[++i]; else if ( 0 == ::strncmp("-iovs",argv[i],4) ) num_iov = ::atol(argv[++i]); else if ( 0 == ::strncmp("-runs",argv[i],4) ) num_runs = ::atol(argv[++i]); else arg_error = true; } if ( arg_error || input.empty() ) { /// Help printout describing the basic command line interface cout << "Usage: -plugin <name> -arg [-arg] \n" " name: factory name DD4hep_AlignmentExample1 \n" " -input <string> Geometry file \n" " -iovs <number> Number of parallel IOV slots for processing. \n" " -runs <number> Number of collision loads to be performed. \n" "\tArguments given: " << arguments(argc,argv) << endl << flush; ::exit(EINVAL); } // First we load the geometry description.fromXML(input); /******************** Initialize the conditions manager *****************/ ConditionsManager manager = installManager(description); const IOVType* iov_typ = manager.registerIOVType(0,"run").second; if ( 0 == iov_typ ) { except("ConditionsPrepare","++ Unknown IOV type supplied."); } /******************** Now as usual: create the slice ********************/ shared_ptr<ConditionsContent> content(new ConditionsContent()); shared_ptr<ConditionsSlice> slice(new ConditionsSlice(manager,content)); Scanner(ConditionsKeys(*content,INFO),description.world()); Scanner(ConditionsDependencyCreator(*content,DEBUG),description.world()); TStatistic cr_stat("Creation"), acc_stat("Access"); /******************** Populate the conditions store *********************/ // Have 10 run-slices [11,20] .... [91,100] size_t total_created = 0; for(int i=0; i<num_iov; ++i) { TTimeStamp start; IOV iov(iov_typ, IOV::Key(1+i*10,(i+1)*10)); ConditionsPool* iov_pool = manager.registerIOV(*iov.iovType, iov.key()); // Create conditions with all deltas. Use a generic creator int count = Scanner().scan(ConditionsCreator(*slice, *iov_pool, DEBUG), description.world()); TTimeStamp stop; cr_stat.Fill(stop.AsDouble()-start.AsDouble()); printout(INFO,"Example", "Setup %ld conditions for IOV:%s [%8.3f sec]", count, iov.str().c_str(), stop.AsDouble()-start.AsDouble()); total_created += count; } // ++++++++++++++++++++++++ Now compute the conditions for each of these IOVs TRandom3 random; ConditionsManager::Result total; for(int i=0; i<num_runs; ++i) { TTimeStamp start; unsigned int rndm = 1+random.Integer(num_iov*10); IOV req_iov(iov_typ,rndm); // Attach the proper set of conditions to the user pool ConditionsManager::Result res = manager.prepare(req_iov,*slice); TTimeStamp stop; total += res; acc_stat.Fill(stop.AsDouble()-start.AsDouble()); // Now compute the tranformation matrices printout(INFO,"Prepare","Total %ld conditions (S:%6ld,L:%6ld,C:%6ld,M:%ld) of type %s [%8.3f sec]", res.total(), res.selected, res.loaded, res.computed, res.missing, req_iov.str().c_str(), stop.AsDouble()-start.AsDouble()); } printout(INFO,"Statistics","+======= Summary: # of IOV: %3d # of Runs: %3d ===========================", num_iov, num_runs); printout(INFO,"Statistics","+ %-12s: %11.5g +- %11.4g RMS = %11.5g N = %lld", cr_stat.GetName(), cr_stat.GetMean(), cr_stat.GetMeanErr(), cr_stat.GetRMS(), cr_stat.GetN()); printout(INFO,"Statistics","+ %-12s: %11.5g +- %11.4g RMS = %11.5g N = %lld", acc_stat.GetName(), acc_stat.GetMean(), acc_stat.GetMeanErr(), acc_stat.GetRMS(), acc_stat.GetN()); printout(INFO,"Statistics","+ Accessed a total of %ld conditions (S:%6ld,L:%6ld,C:%6ld,M:%ld). Created:%ld", total.total(), total.selected, total.loaded, total.computed, total.missing, total_created); printout(INFO,"Statistics","+========================================================================="); // All done. return 1; }
TProof * my_run(TProof * p, unsigned num, double from, double to) { if(p != NULL) TProof * p = TProof::Open("localhost"); TString sel = "TMySelector.cpp"; unsigned u; double tfrom, tto, sum, rres; double step = (to - from) / num; char pname[1024]; int nanosec; time_t sec; double tm[2]; TTimeStamp tst; // ############################################################################ for(u = 0, tfrom = from, tto = step; u < num; u++, tfrom += step, tto += step) { sprintf(pname, "from_%u", u); p->SetParameter(pname, tfrom); sprintf(pname, "to_%u", u); p->SetParameter(pname, tto); } sec = tst.GetSec(); nanosec = tst.GetNanoSec(); p->Process(sel, u); for(u = 0, sum = 0; u < num; u++) { sprintf(pname, "res_%u", u); sum += ((TParameter<Double_t> *) p->GetOutputList()->FindObject(pname))->GetVal(); } tst.Set(); tm[0] = tst.GetSec() - sec + 1 + (tst.GetNanoSec() - nanosec) / 1000000000.0; // ############################################################################ tst.Set(); sec = tst.GetSec(); nanosec = tst.GetNanoSec(); for(rres = 0, step = (to - from) / (num * 10000); from < to; from += step) rres += TMySelector::fun(from) * step; tst.Set(); tm[1] = tst.GetSec() - sec + 1 + (tst.GetNanoSec() - nanosec) / 1000000000.0; // ############################################################################ printf("\nРезультат:\n\n\tПараллельно = %lf (время: %lf секунд)\n\tПоследовательно = %lf (время: %lf секунд)\n\tАбсолютное отклонение = %lf\n\n", sum, tm[0], rres, tm[1], fabs(sum - rres)); return p; }
int main() { TTimeStamp timestamp; timestamp.Set(); Int_t revisionNumber = 0; // // Reading XML // ROMEString xmlFileName = "$(ROMESYS)/.revision.xml"; gSystem->ExpandPathName(xmlFileName); auto_ptr<ROMEXML> xmlIn(new ROMEXML()); if(xmlIn->OpenFileForPath(xmlFileName.Data())) { ROMEString revisionString; ROMEString path; path = "Entry"; Int_t nEntry = xmlIn->NumberOfOccurrenceOfPath(path.Data()); Int_t iEntry; vector<ROMEString> user(nEntry + 1); vector<ROMEString> host(nEntry + 1); vector<ROMEString> directory(nEntry + 1); vector<ROMEString> lastcompile(nEntry + 1); Bool_t foundIdenticalEntry = kFALSE; auto_ptr<UserGroup_t> userInfo(gSystem->GetUserInfo()); user[nEntry] = userInfo->fUser; host[nEntry] = gSystem->HostName(); directory[nEntry] = "$(ROMESYS)"; gSystem->ExpandPathName(directory[nEntry]); lastcompile[nEntry] = timestamp.AsString(); path.SetFormatted("Revision"); xmlIn->GetPathValue(path,revisionString); for(iEntry = 0; iEntry < nEntry; iEntry++) { path.SetFormatted("Entry[%d]/User", iEntry + 1); xmlIn->GetPathValue(path,user[iEntry]); path.SetFormatted("Entry[%d]/Host", iEntry + 1); xmlIn->GetPathValue(path,host[iEntry]); path.SetFormatted("Entry[%d]/Directory", iEntry + 1); xmlIn->GetPathValue(path,directory[iEntry]); path.SetFormatted("Entry[%d]/LastCompile", iEntry + 1); xmlIn->GetPathValue(path,lastcompile[iEntry]); if (user[iEntry] == user[nEntry] && host[iEntry] == host[nEntry] && directory[iEntry] == directory[nEntry]) { lastcompile[iEntry] = lastcompile[nEntry]; foundIdenticalEntry = kTRUE; } } // // Writing XML // if ( // Ryu user[nEntry] == "sawada" || user[nEntry] == "ryu" || // Matthias user[nEntry] == "schneebeli_m" || user[nEntry] == "egger_j" || // Shuei user[nEntry] == "shuei" || user[nEntry] == "yamada" || #if 0 // Meg user[nEntry] == "meg" || user[nEntry] == "Administrator" || #endif 0) { ROMEXML::SuppressWritingDate(); auto_ptr<ROMEXML> xmlOut(new ROMEXML()); xmlOut->OpenFileForWrite(xmlFileName); xmlOut->SetTranslate(0); xmlOut->WriteElement("Revision", revisionString.Data()); for(iEntry = 0; iEntry < nEntry; iEntry++) { xmlOut->StartElement("Entry"); xmlOut->WriteElement("User", user[iEntry].Data()); xmlOut->WriteElement("Host", host[iEntry].Data()); xmlOut->WriteElement("Directory", directory[iEntry].Data()); xmlOut->WriteElement("LastCompile", lastcompile[iEntry].Data()); xmlOut->EndElement(); } if (!foundIdenticalEntry) { xmlOut->StartElement("Entry"); xmlOut->WriteElement("User", user[nEntry].Data()); xmlOut->WriteElement("Host", host[nEntry].Data()); xmlOut->WriteElement("Directory", directory[nEntry].Data()); xmlOut->WriteElement("LastCompile", lastcompile[nEntry].Data()); xmlOut->EndElement(); } xmlOut->EndDocument(); } ParseSVNKeyword(revisionString); revisionNumber = revisionString.ToInteger(); } else { cerr<<"Error: Revision number in include/ROMEVersion.h will not be correct."<<endl; revisionNumber = 0; } ROMEString hfile = "$(ROMESYS)/include/"; gSystem->ExpandPathName(hfile); hfile.AppendFormatted("ROMEVersion.h"); // // Reading ROMEVersion.h // ROMEString fileBuffer; ifstream originalFile(hfile.Data()); if (originalFile.good()) { fileBuffer.ReadFile(originalFile); } originalFile.close(); // // Writing ROMEVersion.h // ROMEString buffer; // cout << "9" << endl; // current time UInt_t year; UInt_t month; UInt_t day; UInt_t hour; UInt_t min; UInt_t sec; timestamp.Set(); timestamp.GetDate(kTRUE, 0, &year, &month, &day); timestamp.GetTime(kTRUE, 0, &hour, &min, &sec); // prepare new file. buffer.Resize(0); buffer.AppendFormatted("#ifndef ROMEVersion\n"); buffer.AppendFormatted("#define ROMEVersion\n"); buffer.AppendFormatted("\n"); buffer.AppendFormatted("/* Version information automatically generated by installer. */\n"); buffer.AppendFormatted("\n"); buffer.AppendFormatted("/*\n"); buffer.AppendFormatted(" * These macros can be used in the following way:\n"); buffer.AppendFormatted(" *\n"); buffer.AppendFormatted(" * #if ROME_VERSION_CODE >= ROME_VERSION(2,5)\n"); buffer.AppendFormatted(" * # include <newheader.h>\n"); buffer.AppendFormatted(" * #else\n"); buffer.AppendFormatted(" * # include <oldheader.h>\n"); buffer.AppendFormatted(" * #endif\n"); buffer.AppendFormatted(" *\n"); buffer.AppendFormatted("*/\n"); buffer.AppendFormatted("\n"); buffer.AppendFormatted("#define ROME_RELEASE \"%d.%d\"\n", romeMajor, romeMinor); buffer.AppendFormatted("#define ROME_REVISION_CODE %d\n", revisionNumber); buffer.AppendFormatted("#define ROME_STABLE %d\n", isStableVersion); /* buffer.AppendFormatted("#define ROME_RELEASE_DATE \"%s %2d %d\"\n", monthName[month], day, year); buffer.AppendFormatted("#define ROME_RELEASE_TIME \"%02d:%02d:%02d\"\n", hour, min, sec); */ buffer.AppendFormatted("#define ROME_VERSION_CODE %d\n", GetROMEVersion(romeMajor, romeMinor)); buffer.AppendFormatted("#define ROME_VERSION(a,b) (((a) << 8) + (b))\n"); buffer.AppendFormatted("\n"); buffer.AppendFormatted("#endif\n"); // write file if (fileBuffer != buffer) { ofstream versionH(hfile.Data()); if (!versionH.good()) { cerr<<"failed to open "<<hfile<<" for write."<<endl; return 1; } versionH<<buffer.Data(); versionH.close(); } return 0; }