直方图C ++(根)代码中的错误 [英] Error in histogram C++ (root) code

查看:67
本文介绍了直方图C ++(根)代码中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C ++(root)中有这行代码:



  void  TMTrackAnalyzer :: beginJob()
{
edm :: Service< TFileService> FS;

dirs_.insert(std :: pair< ObjectType,TFileDirectory *>(InputData,fs-> mkdir( InputData)));

}





基本上填充直方图,设置直方图,标签和标题的范围。实际上我在这个函数中填充了更多的直方图,但为了简单起见我只放了一个。对于他们每个人,我都会遇到这些错误:



预期在''之前的' - ''''''''''''''''''''''''''''''''''''''''''''''''''' '令牌



这些是指(和,在InputData之前和之后.InputData是我想要保存直方图的目录。有谁知道出了什么问题在这里?谢谢!



我的尝试:



我试图谷歌类似但没有找到任何东西,我不知道该怎么做

解决方案

你的 std :: pair 构造错误。您可能希望使用 std :: make_pair 或在传递给 dirs_.insert之前使用变量名明显地创建它(未经测试):

 std :: pair< ObjectType,TFileDirectory *> mypair(InputData,fs-> mkdir(  InputData))); 
dirs_.insert (mypair);



另见 pair :: pair - C ++参考 [ ^ ]


I have this line of code in C++ (root):

void TMTrackAnalyzer::beginJob()
{
          edm::Service<TFileService> fs;
                                                                                                   
          dirs_.insert(std::pair< ObjectType, TFileDirectory* >(InputData, fs->mkdir("InputData") ) );
                                                    
}



which basically fills a histogram, sets the range of the histogram, label and title. Actually I fill more histograms in this function, but I put here just one for simplicity. And for each of them I get these errors:

expected primary-expression before '(' token
expected primary-expression before ',' token

These refer to the ( and , before and after InputData. InputData is the directory where I want to save the histograms. Do anyone has any idea what is wrong here? Thank you!

What I have tried:

I tried to google something similar but haven't found anything and I am not sure what to do

解决方案

Your std::pair construction is wrong. You probably want to use std::make_pair or create it explicitely using a variable name before passing to dirs_.insert (untested):

std::pair< ObjectType, TFileDirectory* > mypair (InputData, fs->mkdir("InputData") ) );
dirs_.insert(mypair);


See also pair::pair - C++ Reference[^].


这篇关于直方图C ++(根)代码中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆