本文整理汇总了C++中TString::Atof方法的典型用法代码示例。如果您正苦于以下问题:C++ TString::Atof方法的具体用法?C++ TString::Atof怎么用?C++ TString::Atof使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TString
的用法示例。
在下文中一共展示了TString::Atof方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnCharacters
void TBDataParser::OnCharacters(const char *characters)
{
if(_currentElement != NULL && !strcmp(_currentElement->Data(),"vector")) {
TString *string = new TString(characters);
TObjArray *values = string->Tokenize(", ");
for(Int_t i = 0; i < values->GetEntries(); i++) {
TObjString *object = (TObjString *) values->At(i);
TString value = object->GetString().ReplaceAll("\n", "").ReplaceAll("\t", "").ReplaceAll(" ", "").ReplaceAll("\0", "");
if(value.IsFloat()) {
_vector->Fill(value.Atof());
}
}
if(_vectorsStack->GetEntries() == 1) {
_motherVecEntries = _vector->GetEntries();
} else if(_currentMethod != NULL && !strcmp(_currentMethod->Data(),"all")) {
for(Int_t i = 1; i < _motherVecEntries; i++) {
TObjString *object = (TObjString *) values->First();
TString value = object->GetString().ReplaceAll("\n", "").ReplaceAll("\t", "").ReplaceAll(" ", "").ReplaceAll("\0", "");
if(value.IsFloat())
_vector->Fill(value.Atof());
}
}
values->Delete();
}
}
示例2: GetEtaBin
TCollection* GetEtaBin(TObject* o, Double_t& etaMin, Double_t& etaMax)
{
const char* re = "[pm][0-9]*d[0-9]*_[pm][0-9]*d[0-9]*";
TRegexp check(re);
if (!o->IsA()->InheritsFrom(TCollection::Class())) {
// Warning("GetEtaBin", "Don't know how to deal with %s - a %s",
// o->GetName(), o->ClassName());
return 0;
}
TString oN(o->GetName());
if (oN.Index(check) == kNPOS) {
// Warning("GetEtaBin", "Collection %s does not match %s",
// oN.Data(), re);
return 0;
}
Int_t ul = oN.Index("_");
TString sMin = oN(0, ul);
TString sMax = oN(ul+1, oN.Length()-ul-1);
sMin.ReplaceAll("p", "+");
sMin.ReplaceAll("m", "-");
sMin.ReplaceAll("d", ".");
sMax.ReplaceAll("p", "+");
sMax.ReplaceAll("m", "-");
sMax.ReplaceAll("d", ".");
etaMin = sMin.Atof();
etaMax = sMax.Atof();
return static_cast<TCollection*>(o);
}
示例3: transferxSecFromTextToROOT
void transferxSecFromTextToROOT(std::string inputStr="xSec_T3G.txt"){
ifstream fin(inputStr.c_str());
char line[200];
TFile *xSecProspinoFile =0;
TH1D *xSecProspino =0;
int minMom = 1000000, maxMom = 0;
int nBins = 0;
std::vector<int> momVec; std::vector<double> xSecVec, xSecErrVec;
while( fin.getline(line, 200) ){
TString lineT(line);
if( lineT.Contains("Interactions") ) continue;
TObjArray *vlist = lineT.Tokenize(" ");
int nEntries = vlist->GetEntries();
int mMom;
double xSec =0, xSecRelErr =0;
for(int ie=0; ie<nEntries; ie++){
TObjString* perObj = dynamic_cast<TObjString*>(vlist->At(ie));
TString perStr = perObj->GetString();
if( ie==0 ){
mMom = perStr.Atoi();
if( minMom > mMom ) minMom = mMom;
if( maxMom < mMom ) maxMom = mMom;
}
if( ie==1 ) xSec = perStr.Atof();
if( ie==2 ) xSecRelErr = perStr.Atof();
}
nBins ++;
momVec.push_back(mMom); xSecVec.push_back(xSec); xSecErrVec.push_back(xSec*xSecRelErr/100.);
// std::cout<<"mMom : "<<mMom<<" xSec : "<<xSec<<" xSecRelErr : "<<xSecRelErr<<std::endl;
}
double divBin = 1.0*(maxMom - minMom)/(nBins-1);
double lowMom = minMom-divBin/2.0, highMom = maxMom+divBin/2.0;
std::cout<<"nBins : "<<nBins<<" minMom : "<<minMom<<" maxMom : "<<maxMom<<" divBin : "<<divBin<<" lowMom : "<<lowMom<<" highMom : "<<highMom<<std::endl;
TString rootStrT(inputStr);
rootStrT.ReplaceAll("txt", "root");
std::cout<<"root file : "<<rootStrT<<std::endl;
xSecProspinoFile = new TFile(rootStrT, "RECREATE");
if( rootStrT.Contains("T1") ) xSecProspino = new TH1D("gluino_xsection", "gluino_xsection", nBins, lowMom, highMom);
if( rootStrT.Contains("T2") ) xSecProspino = new TH1D("squark_xsection", "squark_xsection", nBins, lowMom, highMom);
if( rootStrT.Contains("T3G") ) xSecProspino = new TH1D("stop_xsection", "stop_xsection", nBins, lowMom, highMom);
for(int iv=0; iv<(int)momVec.size(); iv++){
double mMom = (double)momVec[iv];
int ib = xSecProspino->FindFixBin(mMom);
xSecProspino->SetBinContent(ib, xSecVec[iv]);
xSecProspino->SetBinError(ib, xSecErrVec[iv]);
}
// xSecProspino->Write();
xSecProspinoFile->Write(); xSecProspinoFile->Close();
}
示例4: get_sample_name
TString get_sample_name(TString name)
{
TObjArray* arr = name.Tokenize(".");
TString out = ((TObjString*)arr->At(arr->GetEntries()-2))->GetString();
out.ReplaceAll("_JER_up", "");
out.ReplaceAll("_JER_down", "");
out.ReplaceAll("_JEC_up", "");
out.ReplaceAll("_JEC_down", "");
out.ReplaceAll("_PU_down", "");
out.ReplaceAll("_PU_up", "");
out.ReplaceAll("_LJets_up", "");
out.ReplaceAll("_LJets_down", "");
out.ReplaceAll("_BJets_up", "");
out.ReplaceAll("_BJets_down", "");
out.ReplaceAll("_MuonSF_down", "");
out.ReplaceAll("_MuonSF_up", "");
out.ReplaceAll("_BJets_down", "");
out.ReplaceAll("_BJets_down", "");
out.ReplaceAll("_matching_down", "");
out.ReplaceAll("_matching_up", "");
out.ReplaceAll("_scale_down", "");
out.ReplaceAll("_scale_up", "");
out.ToLower();
out.ReplaceAll("dyjets_50toinf", "zlight");
out.ReplaceAll("dyjets", "zlight");
out.ReplaceAll("dy", "zlight");
out.ReplaceAll("wjets_bflavor", "wb");
out.ReplaceAll("wjets_cflavor", "wc");
out.ReplaceAll("wjets_lflavor", "wlight");
//out.ReplaceAll("tt", "ttbar");
if (out.Contains("zp")){
TString temp = out;
temp.ReplaceAll("zp","");
temp.ReplaceAll("p", ".");
TObjArray* arr2 = temp.Tokenize("w");
TString nom = ((TObjString*)arr2->At(1))->GetString();
TString denom = ((TObjString*)arr2->At(0))->GetString();
cout << "nom = " << nom << " denom = " << denom << endl;
Int_t p = (100*nom.Atof())/denom.Atof();
cout << "p = " << p << endl;
out = TString::Format("zp %d w %d p",denom.Atoi(), p);
out.ReplaceAll(" ", "");
}
return out;
}
示例5:
float *getwq(TH1 *h) {
TString delim = "_";
TString hn = h->GetName();
TObjArray *tokens = hn.Tokenize(delim);
TObjString *wstro = (TObjString*)tokens->At(1);
TObjString *qstro = (TObjString*)tokens->At(2);
TString wstr = wstro->GetString();
TString qstr = qstro->GetString();
double wval = wstr.Atof();
double qval = qstr.Atof();
float *ret = new float[2];
ret[0] = wval;
ret[1] = qval;
delete tokens;
return ret;
}
示例6: parseWeight
void bcut::parseWeight(TString wgt){
cutTypes_.push_back(kFloat);
fWeights_.push_back(NULL);
fvWeights_.push_back(NULL);
indWeights_.push_back(-1);
constWeights_.push_back(1.);
if(wgt=="weight") fWeights_.back() = &baby_base::weight;
else if(wgt=="w_lumi") fWeights_.back() = &baby_base::w_lumi;
else if(wgt=="w_pu") fWeights_.back() = &baby_base::w_pu;
else if(wgt=="w_lep") fWeights_.back() = &baby_base::w_lep;
else if(wgt=="w_fs_lep") fWeights_.back() = &baby_base::w_fs_lep;
else if(wgt=="w_toppt") fWeights_.back() = &baby_base::w_toppt;
else if(wgt=="w_btag") fWeights_.back() = &baby_base::w_btag;
else if(wgt=="eff_trig") fWeights_.back() = &baby_base::eff_trig;
else if(wgt.Contains("[")){ // if weight is a vector element
TString index_s(wgt);
wgt.Remove(wgt.Index("["), wgt.Length());
index_s.Remove(0, index_s.Index("[")+1);
index_s.Remove(index_s.Index("]"), index_s.Length());
indWeights_.back() = index_s.Atoi();
cutTypes_.back() = kvFloat;
if(wgt=="w_pdf") fvWeights_.back() = &baby_base::w_pdf;
else if(wgt=="sys_pdf") fvWeights_.back() = &baby_base::sys_pdf;
else if(wgt=="sys_isr") fvWeights_.back() = &baby_base::sys_isr;
else if(wgt=="sys_mur") fvWeights_.back() = &baby_base::sys_mur;
else if(wgt=="sys_muf") fvWeights_.back() = &baby_base::sys_muf;
else if(wgt=="sys_murf") fvWeights_.back() = &baby_base::sys_murf;
else if(wgt=="sys_trig") fvWeights_.back() = &baby_base::sys_trig;
else if(wgt=="sys_lep") fvWeights_.back() = &baby_base::sys_lep;
else if(wgt=="sys_fs_lep") fvWeights_.back() = &baby_base::sys_fs_lep;
else if(wgt=="sys_bctag") fvWeights_.back() = &baby_base::sys_bctag;
else if(wgt=="sys_fs_bctag") fvWeights_.back() = &baby_base::sys_fs_bctag;
else if(wgt=="sys_udsgtag") fvWeights_.back() = &baby_base::sys_udsgtag;
else if(wgt=="sys_fs_udsgtag") fvWeights_.back() = &baby_base::sys_fs_udsgtag;
else {
cout<<"Weight \""<<wgt<<" not defined. Add it to bcut::parseWeight in bcut.cpp"<<endl;
exit(0);
}
}else if(wgt.Atof()>0) {
constWeights_.back() = wgt.Atof();
cutTypes_.back() = kConst;
} else {
cout<<"Weight \""<<wgt<<" not defined. Add it to bcut::parseWeight in bcut.cpp"<<endl;
exit(0);
}
}
示例7: calculate_balance
void TExpenser::calculate_balance() {
fBalanceXMLParser -> selectMainNode();
fBalanceXMLParser -> selectNode("entry");
TString balance = fBalanceXMLParser -> getNodeContent("amount");
fBalanceXMLParser -> selectNode("date");
TString balance_year = fBalanceXMLParser -> getNodeContent("year");
TString balance_month = fBalanceXMLParser -> getNodeContent("month");
fLastStatusLabel -> SetText(balance_month+"/"+balance_year+": " + balance + " eur");
// now calculate the current balance (last - expenses since the last)
TDatime time;
fXMLParser->selectMainNode();
fXMLParser->selectNode("expense");
Double_t expenses_since_last_status = 0;
while (fXMLParser->getCurrentNode() != 0) {
XMLNodePointer_t current_node = fXMLParser->getCurrentNode();
fXMLParser -> selectNode("date");
TString year = fXMLParser -> getNodeContent("year");
TString month = fXMLParser -> getNodeContent("month");
fXMLParser -> setCurrentNode(current_node);
bool year_more_recent = (year.Atoi() > balance_year.Atoi());
bool year_same = (year.Atoi() == balance_year.Atoi());
bool month_more_recent = (month.Atoi()>=balance_month.Atoi());
bool expense_more_recent_than_balance = (year_more_recent || (year_same && month_more_recent));
if ( expense_more_recent_than_balance && fXMLParser -> getNodeContent("withdrawn") == "Yes" ) {
expenses_since_last_status += fXMLParser -> getNodeContent("amount").Atof();
}
fXMLParser->selectNextNode("expense");
}
// calculate total income since last balance
fIncomeXMLParser->selectMainNode();
fIncomeXMLParser->selectNode("entry");
Double_t income_since_last_status = 0;
while (fIncomeXMLParser->getCurrentNode() != 0) {
XMLNodePointer_t current_node = fIncomeXMLParser->getCurrentNode();
fIncomeXMLParser -> selectNode("date");
TString year = fIncomeXMLParser -> getNodeContent("year");
TString month = fIncomeXMLParser -> getNodeContent("month");
fIncomeXMLParser -> setCurrentNode(current_node);
if ( ( (month.Atoi()>=balance_month.Atoi()) && (year.Atoi()==balance_year.Atoi()) ) || (year.Atoi()>balance_year.Atoi()) ) {
income_since_last_status += fIncomeXMLParser -> getNodeContent("amount").Atof();
}
fIncomeXMLParser->selectNextNode("entry");
}
Double_t new_balance = balance.Atof() - expenses_since_last_status + income_since_last_status;
fCurrentStatusLabel -> SetText(toStr(time.GetDay())+"/"+toStr(time.GetMonth())+"/"+toStr(time.GetYear())+": " + toStr(new_balance,2) + " eur");
}
示例8: CalcLednicR
Double_t CalcLednicR(Double_t zr, Double_t zt, Double_t v)
{
TString cmd = Form("echo '%0.5f,%0.5f,%0.5f'", zr, zt, v);
cmd+= " | ./lednic_input.exe";
Printf("%s", cmd.Data());
cmd = gSystem->GetFromPipe(cmd.Data());
if (!cmd.IsFloat()) {
Printf("Problem with program 'lednic_input.exe'");
return 0;
}
return cmd.Atof();
}
示例9: processBinString
void AnalysisConfig::processBinString(vector<pair<float,float> >& binSet, string& inputString)
{
binSet.clear();
// Define a regex expression to use to match strings of (float, float) format and a size variable to pass as the size of the resulting match.
TRegexp numPairRegex("\\(-?[0-9]+\\.?[0-9]?,-?[0-9]+\\.?[0-9]?\\)");
int* matchLength = new int;
// Get list of bin strings from input string.
vector<string> binStrings;
getListFromString(inputString, binStrings);
// Extract number information from list of bin strings (Should have format: (i,j) ).
for(auto& binStr : binStrings)
{
// Check if the bin string is a formatted properly.
*matchLength = 0;
if(numPairRegex.Index(binStr, matchLength) != 0 || (unsigned int)(*matchLength) != binStr.length())
{ // If the regex expression doesn't find itself in the string *OR* the matched string isn't the full length of the input string...
cout << " ERROR (AnalysisConfig::processBinString)\n: Bin string does not have (p,q) format: " << binStr << endl << endl;
return; // KICK
}
float binMin, binMax;
TString numStr = "";
string::iterator it=binStr.begin()+1;
// Extract bin minimum value
do{ numStr+=*(it++); } while( it != binStr.end() && *it != ',');
binMin = numStr.Atof();
// Extract bin maximum value
numStr = ""; it++; // Reset bin number string and move past the comma
do{ numStr+=*(it++); } while( it != binStr.end() && *it != ')');
binMax = numStr.Atof();
// Add pair to bin set.
binSet.push_back({binMin, binMax});
}
}
示例10: WriteAsciiFile
Int_t KVRTGIDManager::WriteAsciiFile ( const Char_t * filename, const TCollection *selection, Bool_t update )
{
// Write identification functions in file 'filename'.
// If selection=0 (default), write all grids.
// If update=true, call UpdateListFromIDGridManager() before writing
// If selection!=0, write only grids in list.
// Returns number of functions written in file.
if( update ) UpdateListFromIDGridManager();
if( !fIDGlobalList ){
Warning("KVRTGIDManager::WriteAsciiFile","No listed identification functions to write");
return 0;
}
ofstream tgidfile ( filename );
if( !tgidfile.is_open() ){
Error("KVRTGIDManager::WriteAsciiFile","No write permission for file %s", filename);
return 0;
}
const TCollection *list_tgid = ( selection ? selection : fIDGlobalList );
TIter next ( list_tgid );
KVTGID *tgid = NULL;
Int_t n_saved = 0;
while ( ( tgid = (KVTGID *)next() ) ) {
// Not write a KVTGID copy
TString tmp = tgid->GetTitle();
if(tmp.Contains("COPY")){
tmp.Remove(0, tmp.Index("0x"));
KVTGID *tmp_tgid = reinterpret_cast<KVTGID *>((Int_t)tmp.Atof());
Warning("KVRTGIDManager::WriteAsciiFile","The function %s (%s, %p) is not written because it is a copy of %s (%s, %p)"
, tgid->GetName(), tgid->ClassName(), tgid
, tmp_tgid->GetName(), tmp_tgid->ClassName(), tmp_tgid);
continue;
}
tgid->WriteToAsciiFile ( tgidfile );
Info( "KVRTGIDManager::WriteAsciiFile", "%s (%s, %p) saved", tgid->GetName(), tgid->ClassName(), tgid );
n_saved++;
}
tgidfile.close();
return n_saved;
}
示例11: AddTask_HadronicCocktailMC
void AddTask_HadronicCocktailMC(Int_t particleFlag = 0, Bool_t runLightOutput = kFALSE, TString maxyset = "0.8") {
Double_t maxy = maxyset.Atof();
maxy /= 100; // needed to enable subwagon feature on grid
// ================== GetAnalysisManager ===============================
AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
if (!mgr) {
Error("AddTask_HadronicCocktailMC", "No analysis manager found.");
return ;
}
// ================== GetInputEventHandler =============================
AliVEventHandler *inputHandler=mgr->GetInputEventHandler();
AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
//================================================
//========= Add task to the ANALYSIS manager =====
//================================================
// find input container
AliAnalysisTaskHadronicCocktailMC *task=NULL;
task = new AliAnalysisTaskHadronicCocktailMC(Form("HadronicCocktailMC_%1.2f",maxy));
task->SetMaxY(maxy);
task->SetLightOutput(runLightOutput);
task->SetAnalyzedParticle(particleFlag); // switch to run: 0 - pi0, 1 - eta, 2 - pi+-
TString analyzedParticle = "";
if (particleFlag==0) analyzedParticle = "pi0";
else if (particleFlag==1) analyzedParticle = "eta";
else if (particleFlag==2) analyzedParticle = "pi+-";
//connect containers
AliAnalysisDataContainer *coutput =
mgr->CreateContainer(Form("HadronicCocktailMC_%s_%1.2f",analyzedParticle.Data(),maxy), TList::Class(), AliAnalysisManager::kOutputContainer, Form("%s:HadronicCocktailMC",AliAnalysisManager::GetCommonFileName()));
mgr->AddTask(task);
mgr->ConnectInput(task,0,cinput);
mgr->ConnectOutput(task,1,coutput);
return;
}
示例12: getsipm
Int_t getsipm( Char_t *start_datetime, Char_t *end_datetime )
{
TSQLServer *serv = TSQLServer::Connect("pgsql://phnxdb1.phenix.bnl.gov/daq", "phnxrc", "");
// Create the sql query
TString sql = "SELECT EXTRACT(EPOCH FROM read_datetime)::INT AS read_timestamp,current FROM sipm WHERE read_datetime >= \'";
sql += start_datetime;
sql += "\' AND read_datetime < \'";
sql += end_datetime;
sql += "\'";
std::cout << "sql query: " << sql << std::endl;
TSQLResult *res;
res = serv->Query(sql);
// Extract the result of the query into vectors
Int_t nrows = res->GetRowCount();
Int_t nfields = res->GetFieldCount();
std::cout << "rows: " << nrows << " columns: " << nfields << std::endl;
TString fieldname;
TString field;
TSQLRow *row;
// std::vector<double> read_timestamp;
// std::vector<double> read_current;
for (Int_t i = 0; i < nrows; i++) {
row = res->Next();
for (Int_t j = 0; j < nfields; j++) {
fieldname = TString( res->GetFieldName(j) );
field = TString( row->GetField(j) );
// std::cout << "fieldname: " << fieldname << " field: " << field << std::endl;
if ( fieldname == "read_timestamp" ) read_time_sipm[0].push_back( field.Atof() );
if ( fieldname.Contains( "current" ) ) sipm_current[0].push_back( field.Atof() );
}
}
return nrows;
}
示例13: Proc_hYW
void ProcYields::Proc_hYW(){
Info("Proc_hYW()", "");
TDirectory* dirhYW = _fout->mkdir("hYW");
TH1F* hYW[nVARSET];
TDirectory* dirVarset=NULL;
for(Int_t iVarset=0;iVarset<nVARSET;iVarset++){
Info("Proc_hYW()","Varset = Varset%d", iVarset+1);
dirVarset=dirhYW->mkdir(TString::Format("Varset%d",iVarset+1));
dirVarset->cd();
hYW[iVarset] = new TH1F("hYW","hYW", _user.nWbins, _user.Wmin, _user.Wmax);
hYW[iVarset]->SetXTitle("W[GeV]");
//!Loop over Q2W dirs, get h5Ds and their yields
TIter nextkey(_fout->GetListOfKeys());
TKey *key;
while (key = (TKey*)nextkey()) {
TString Q2Wdirname = key->GetName();
if(Q2Wdirname.EqualTo("hYW_Dir") || Q2Wdirname.EqualTo("hYW"))continue;
Info("Proc_hYW()","Q2Wdir = %s", Q2Wdirname.Data());
TString wrange = Q2Wdirname.Tokenize("_")->At(1)->GetName();
TString wlow = wrange.Tokenize(",")->At(0)->GetName();
wlow.Remove(0,1); //remove "["
//Float_t w = wlow.Atof();
Double_t w = wlow.Atof();
sprintf(_hname, "%s/hY5D/Varset%d/hY5D_FULL", Q2Wdirname.Data(),iVarset+1);
THnSparse* hY5D_FULL = (THnSparse*)_fout->Get(_hname);
if (hY5D_FULL == NULL) cout <<"could not get h5D" << endl;
//Float_t yield = getIntegral(hY5D_FULL);
Double_t yield = getIntegral(hY5D_FULL);
//hYW[iVarset]->Fill(w, yield);
hYW[iVarset]->SetBinContent(hYW[iVarset]->FindBin(w+_intrinsic.Wbinw), yield);
Info("Proc_hYW()","W = %f, bin# = %d, yield = %f\n", w, hYW[iVarset]->FindBin(w+_intrinsic.Wbinw), yield);
}
}
Info("Proc_hYW()", "done\n");
}
示例14: BuildGridForAllTGID
void KVRTGIDManager::BuildGridForAllTGID(const Char_t *idtype, Double_t xmin, Double_t xmax, Int_t ID_min, Int_t ID_max, Int_t npoints, Bool_t logscale){
// Build a grid (KVTGIDGrid) for all the identification functions
// of the global list. The new grids are automatically loaded in
// gIDGridManager and are visible in the Grid Manager GUI.
// If a function is already associated to a grid then a new grid
// is not built. No grid is built for copies of KVTGID's made in
// the method ReadAsciiFile(...).
//
// Inputs: idtype - type of the identification for which the
// grids will be built (CI-SI, SI-CSI, CI-CSI,
// SI75-SILI, ...). By default, all grids are
// built
// xmin
// xmax
// ID_min
// ID_max
// npoints
// logscale - see KVTGIDGrid::Generate(...)
if( !fIDGlobalList ) return;
// First make a sublist of TGID found in object inheriting
// from KVTGIDGrid in gIDGridManager
TList tgid_list;
GetTGIDfromIDGridManager(&tgid_list);
KVIDGridManager *gm = gIDGridManager;
KVList *grid_list = NULL;
if(gm){
grid_list = gm->GetGrids();
grid_list->Disconnect("Modified()",gm,"Modified()");
}
// If the TGID of the global list is not in the sublist then
// build grid
TIter next(fIDGlobalList);
Bool_t IDtypeOK = strcmp(idtype,"");
KVTGID *tgid = NULL;
while( (tgid = (KVTGID *)next()) ){
if(tgid_list.FindObject(tgid)) continue;
if(IDtypeOK){
KVBase *idt = NULL;
TSeqCollection *idt_list = (TSeqCollection* )GetIDTelescopesForTGID(tgid);
if(!idt_list) continue;
if( !(idt = (KVBase *)idt_list->First()) ) continue;
SafeDelete(idt_list);
if( strcmp(idtype,idt->GetLabel()) ) continue;
}
// Not built grid for a KVTGID copy
TString tmp = tgid->GetTitle();
if(tmp.Contains("COPY")){
tmp.Remove(0, tmp.Index("0x"));
KVTGID *tmp_tgid = reinterpret_cast<KVTGID *>((Int_t)tmp.Atof());
Warning("KVRTGIDManager::BuildGridForAllTGID","No grid built for %s (%s, %p) because it is a copy of %s (%s, %p)"
, tgid->GetName(), tgid->ClassName(), tgid
, tmp_tgid->GetName(), tmp_tgid->ClassName(), tmp_tgid);
continue;
}
KVTGIDGrid *grid = new KVTGIDGrid(tgid);
grid->SetOnlyZId((Bool_t)tgid->GetZorA());
if(tgid->GetZorA()) grid->SetMassFormula(tgid->GetMassFormula());
grid->Generate(xmax, xmin, ID_min, ID_max, npoints, logscale);
Info("KVRTGIDManager::BuildGridForAllTGID","grid built from its TGID function %s (%s, %p)"
, tgid->GetName(), tgid->ClassName(), tgid);
}
if( grid_list ) grid_list->Connect("Modified()","KVIDGridManager",gm,"Modified()");
gm->Modified();
}
示例15: getradmon
Int_t getradmon( Char_t *start_datetime, Char_t *end_datetime )
{
TSQLServer *serv = TSQLServer::Connect("pgsql://phnxdb0.phenix.bnl.gov/daq", "phnxrc", "");
// Create the sql query
TString columns = "id, EXTRACT(EPOCH FROM read_datetime)::INT AS read_timestamp, channel, i_n_set, i_n, v_n, i_k_set, i_k, v_k, i_s_set, i_s, v_s, i_r_set, i_r, v_r";
TString sql = "SELECT ";
sql += columns;
sql += " FROM radmon WHERE read_datetime>=\'";
sql += start_datetime;
sql += "\' AND read_datetime<=\'";
sql += end_datetime;
sql += "\'";
sql += " AND ABS( (i_r/i_r_set) - 1.0 ) < 0.01";
sql += " AND ABS( (i_s/i_s_set) - 1.0 ) < 0.01";
sql += " AND ABS( (i_n/i_n_set) - 1.0 ) < 0.01";
sql += " AND v_n > 0.4 AND v_n < 2.0";
// key
sql += " AND v_r < 20.0 AND v_s < 20.0";
// sql += " AND v_r < 50.0 AND v_s < 50.0";
sql += ";";
cout << "sql query: " << sql << endl;
TSQLResult *res;
res = serv->Query(sql);
// Extract the result of the query into vectors
Int_t nrows = res->GetRowCount();
Int_t nfields = res->GetFieldCount();
cout << "rows: " << nrows << " columns: " << nfields << endl;
TString fieldname;
TString field;
TSQLRow *row;
Int_t channel = 0;
Double_t read_timestamp;
Double_t v_k = 0.0, v_n = 0.0, v_s = 0.0, v_r = 0.0;
Double_t i_k = 0.0, i_n = 0.0, i_s = 0.0, i_r = 0.0;
// zero point and temperature correction for radfet
// Run 14 after 373780 May 28, 2014
// Double_t a0[nsensor] = { 3.923, 7.513, 5.395, 6.038, 4.140, 3.306, 3.263 };
// Beginning of Run 15 Jan 14, 2015
// Double_t a0[nsensor] = { 3.971, 7.871, 5.645, 7.566, 3.322, 3.108, 3.214 };
// after adding CAN 1 and CAN 2 2015.04.15
// Double_t a0[nsensor] = { 3.971, 7.871, 5.645, 7.566, 3.322, 3.108, 3.214, 3.274, 3.643 };
Double_t a0[nsensor] = { 3.36, 3.36, 3.36, 3.36, 3.36, 3.36, 3.36, 3.36, 3.36 };
// Here's at the beginning of Run 14 in January
// Double_t a0[nsensor] = { 3.78, 6.74, 4.94, 3.40, 3.45, 3.306, 3.263 };
// zero point correction for Si detector
// Run 14 after 373780 May 28, 2014
// Double_t s0[nsensor] = { 4.290, 7.220, 6.250, 2.694, 2.050, 1.054, 1.051 };
// Begining of Run 15 Jan 14, 2015
// Double_t s0[nsensor] = { 4.326, 7.078, 6.208, 3.349, 1.108, 1.048, 1.058 };
// after adding CAN 1 and CAN 2 2015.04.15
// Double_t s0[nsensor] = { 4.326, 7.078, 6.208, 3.349, 1.108, 1.048, 1.058, 1.046, 1.048 };
// Here's the beginning of Run 14 in January
// Double_t s0[nsensor] = { 3.60, 6.20, 5.26, 1.16, 1.18, 1.054, 1.051 };
Double_t s0[nsensor] = { 1.05, 1.05, 1.05, 1.05, 1.05, 1.05, 1.05, 1.05, 1.05 };
for ( channel = 0; channel < nsensor; channel++ ) {
V_s[channel].clear();
V_r[channel].clear();
R_n[channel].clear();
T_n[channel].clear();
R_k[channel].clear();
R_r[channel].clear();
read_time[channel].clear();
V_r_corrected[channel].clear();
V_s_corrected[channel].clear();
dose_r[channel].clear();
dose_s[channel].clear();
rs_ratio[channel].clear();
}
Double_t v_r_c = 0.0;
Double_t v_s_c = 0.0;
for (Int_t i = 0; i < nrows; i++) {
row = res->Next();
for (Int_t j = 0; j < nfields; j++) {
fieldname = TString( res->GetFieldName(j) );
field = TString( row->GetField(j) );
// Extract all columns of each row
// std::cout << "fieldname: " << fieldname << " field: " << field << std::endl;
if ( fieldname == "read_timestamp" ) read_timestamp = field.Atof();
if ( fieldname == "channel" ) channel = field.Atoi();
if ( fieldname == "v_k" ) v_k = field.Atof();
if ( fieldname == "v_n" ) v_n = field.Atof();
if ( fieldname == "v_s" ) v_s = field.Atof();
if ( fieldname == "v_r" ) v_r = field.Atof();
if ( fieldname == "i_k" ) i_k = field.Atof();
//.........这里部分代码省略.........