Draw() or Scan(): Cutting on a std::vector<string> bra

Good morning,

I created a TTree with one branch containing a std::vector.

this branch is called “channels” and contain strings like “jjjj”.

I can write it fine, and looking at this branch with TBrowser, I found the methods to read it content, like in:

or

SUSYTree->Scan("jetPt:channels.data()","jetPt>100")
***********************************************
*    Row   * Instance *     jetPt * channels. *
***********************************************
*        0 *        0 * 305.10269 *      jjjj *
*        1 *        0 * 314.94259 *      jjjj *
*        2 *        0 * 327.89904 *      jjjj *
*        3 *        0 * 160.29873 *      jjjj *
***********************************************
==> 4 selected entries
(Long64_t)4

But I get an error when I try to cut on this string value, like this:

SUSYTree->Scan("jetPt:channels.data()", "channels.data() == jjjj" )
Error in <TTreeFormula::Compile>:  Bad numerical expression : "jjjj"
Error in <TTreeFormula::Compile>: Both operands of the operator == have to be either numbers or strings
(Long64_t)(-1)

May you help me?

Thanks a lot,

and have a nice day!

Ric.

[/code]

Sorry, I forgot to mention that I’m using ROOT 5.18 (ATLAS Athena)

Thanks,

Ric.

Hi,

This has been fixed in the head of the svn trunk (revision 26117) and will be part of the 5.21/06 release.

Cheers,
Philippe.

Ok, thanks a lot.

And have a nice evening :slight_smile:

Ric.

Sorry for bothering you again with this.

I downloaded and compiled the head version, but I still cannot cut on branches containing std::vector< std::strings> (as I described above):

ROOT 5.21/05 (trunk@26187, Nov 14 2008, 11:39:28 on linux)
root [2] SUSYTree->Scan("jetPt:channels.data()")
***********************************************
*    Row   * Instance *     jetPt * channels. *
***********************************************
*        0 *        0 * 305.10269 *      jjjj *
*        0 *        1 * 158.11608 *           *
*        0 *        2 * 140.56155 *           *
*        0 *        3 *  74.01828 *           *
*        1 *        0 * 314.94259 *        jj *
*        1 *        1 * 213.57994 *      jjjj *
*        1 *        2 * 123.22430 *           *
*        1 *        3 * 57.146205 *           *
*        1 *        4 * 25.615610 *           *
*        2 *        0 * 327.89904 *        jj *
*        2 *        1 * 249.17918 *      jjjj *
*        2 *        2 * 144.92178 *           *
*        2 *        3 * 51.341476 *           *
*        2 *        4 * 49.671630 *           *
*        2 *        5 * 42.564464 *           *
*        2 *        6 * 23.709358 *           *
*        3 *        0 * 160.29873 *      jjjj *
*        3 *        1 * 122.61026 *           *
*        3 *        2 * 112.81999 *           *
*        3 *        3 * 86.671241 *           *
*        3 *        4 * 27.753007 *           *
***********************************************
(Long64_t)21
root [3] SUSYTree->Scan("jetPt:channels.data()","jetPt>100")
***********************************************
*    Row   * Instance *     jetPt * channels. *
***********************************************
*        0 *        0 * 305.10269 *      jjjj *
*        1 *        0 * 314.94259 *        jj *
*        1 *        1 * 213.57994 *      jjjj *
*        2 *        0 * 327.89904 *        jj *
*        2 *        1 * 249.17918 *      jjjj *
*        3 *        0 * 160.29873 *      jjjj *
***********************************************
==> 6 selected entries
(Long64_t)6
root [4] SUSYTree->Scan("jetPt:channels.data()","channels.data() == jjjj")
Error in <TTreeFormula::Compile>:  Bad numerical expression : "jjjj"

Many thanks for your help,

Ric.

Hi,

TrySUSYTree->Scan("jetPt:channels")
andSUSYTree->Scan("jetPt:channels","channels == jjjj");

Cheers,
Philippe.

Good morning Philippe,

and thanks a lot for your help.

I tried as you suggested, but I still get errors, unfortunately:

root [4] SUSYTree->Scan("jetPt:channels","jetPt>100")
***********************************************
*    Row   * Instance *     jetPt *  channels *
***********************************************
*        0 *        0 * 305.10269 *      jjjj *
*        0 *        1 * 158.11608 *       jjj *
*        1 *        0 * 262.49447 *       jjj *
*        2 *        0 * 314.94259 *      jjjj *
*        2 *        1 * 213.57994 *        jj *
*        2 *        2 * 123.22430 *       jjj *
*        3 *        0 * 327.89904 *      jjjj *
*        3 *        1 * 249.17918 *        jj *
*        3 *        2 * 144.92178 *       jjj *
*        4 *        0 * 672.52795 *       jjj *
*        5 *        0 * 160.29873 *      jjjj *
*        5 *        1 * 122.61026 *       jjj *
***********************************************
==> 12 selected entries
(Long64_t)12
root [5] SUSYTree->Scan("jetPt:channels","channels == jjjj");
Error in <TTreeFormula::Compile>:  Bad numerical expression : "jjjj"

I’m using the revision: trunk@26187

Thanks again,

Ric.

I can usually get this to work (with TStrings, haven’t tried std::strings) by escaping the quotes:

root [5] SUSYTree->Scan("jetPt:channels","channels == \"jjjj\"");

or

root [5] SUSYTree->Scan("jetPt:channels","channels.data() == \"jjjj\"");

HTH,
~Ben Loer

Hi Ben,

thanks a lot! Escaping the quotes works fine, even with std::strings :slight_smile:

and both with “.data()” or not.

root [3] SUSYTree->Scan("jetPt:channels","channels.data() == \"jjjj\"");
***********************************************
*    Row   * Instance *     jetPt *  channels *
***********************************************
*        0 *        0 * 305.10269 *      jjjj *
*        2 *        0 * 314.94259 *      jjjj *
*        3 *        0 * 327.89904 *      jjjj *
*        5 *        0 * 160.29873 *      jjjj *
***********************************************
==> 4 selected entries
root [4] SUSYTree->Scan("jetPt:channels","channels == \"jj\"");
***********************************************
*    Row   * Instance *     jetPt *  channels *
***********************************************
*        2 *        1 * 213.57994 *        jj *
*        3 *        1 * 249.17918 *        jj *
***********************************************
==> 2 selected entries

Thanks a lot again :slight_smile:

Ric.