Re: std::vector<std::string>*

From: Arthur E. Snyder <snyder_at_slac.stanford.edu>
Date: Wed, 6 Apr 2011 12:04:03 -0700


Hi All,

I got the following to compile:

   if(agnTimeGap::agnName!="") {

     cout << "name:" << agnName << endl;
     //    cout << "source:" << *Source_Name << endl;
     cout << "this source:" << *(const char*)Source_Name << endl;
     if(*agnTimeGap::agnName.Data()!=*(const char*)Source_Name) return kTRUE;
     cout << "got it" << endl;

   }

However it doesn't work; the print out looks like this:

set up for linux

name:J0457.0-2325
this source:È

Perhaps |Source_Name| is not loaded properly by |MakeSelector|?

  std::vector<std::string> *Source_Name;   Branch *b_Source_Name; //!

Source_Name = 0; <--- this is different from the usual, like because |Source_Name| is pointer to |vector| of strings rather than the usual variables themselves ..

fChain->SetBranchAddress("Source_Name", &Source_Name, &b_Source_Name);

It's passing pointer-to-pointer |&Source_Name| to |SetBranchAddress| followed by pointer to pointer to point (|&b_Source_Name)|

Is that ok?

A.E. Snyder, Group ?                         \!c*p?/
SLAC Mail Stop #95                          ((.   .))
Box 4349                                        |
Stanford, Ca, USA, 94309                      '\|/`
e-mail:snyder_at_slac.stanford.edu                 o
phone:650-926-2701                              _
http://www.slac.stanford.edu/~snyder          BaBar
FAX:707-313-0250                          Collaboration
                                                 &
                                            Fermi/GLAST



On Wed, 6 Apr 2011, Arthur E. Snyder wrote:

>
> In recent verions of fermi/glast n-tuples a string variable has been added
> of the form:
>
> vector<string>* Source_Name
>
> I had some instructions for dealing with tup->Draw("var","cut"). These
> work, and I can, e.g., compare |Source_Name| to a |TString| in the cut.
>
> However, when I try to the same thing in a selector (made with
> |tup->MakeSelector| it fails to compile.
>
> Code fragment is:
>
> if(agnTimeGap::agnName!="") {
> cout << "name:" << agnName << endl;
> // cout << "source:" << *Source_Name << endl;
> if(agnTimeGap::agnName!=Source_Name) return kTRUE;
> cout << "got it" << endl;
> }
>
> which is like the 'code' as it appears in |Draw|.
>
> The error message is
>
> /afs/slac.stanford.edu/u/ek/snyder/glast/root/./agnTimeGap.cc:95: error:
> invalid conversion from `std::vector<std::string,
> std::allocator<std::string> >*' to `char'
> /afs/slac.stanford.edu/u/ek/snyder/glast/root/./agnTimeGap.cc:95: error:
> initializing argument 1 of `TString::TString(char)'
>
> Putting a * in front of |Source_Name| produces a different error.
>
> So how am I supposed to compare at |TString| to a |vector<string>*|?
>
> --Thanks, Arthur S.
>
>
>
> A.E. Snyder, Group ? \!c*p?/
> SLAC Mail Stop #95 ((. .))
> Box 4349 |
> Stanford, Ca, USA, 94309 '\|/`
> e-mail:snyder_at_slac.stanford.edu o
> phone:650-926-2701 _
> http://www.slac.stanford.edu/~snyder BaBar
> FAX:707-313-0250 Collaboration
> &
> Fermi/GLAST
>
>
>
Received on Wed Apr 06 2011 - 21:04:11 CEST

This archive was generated by hypermail 2.2.0 : Wed Apr 06 2011 - 23:50:01 CEST