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

From: Venkatesh Kaushik <venkat.kaushik_at_cern.ch>
Date: Wed, 6 Apr 2011 20:49:04 +0200


Actually it should be
if((*it).c_str() != agnTimeGap::agnName) { //no match }

Venkatesh Kaushik wrote:
> Hi Arthur,
> Since its a pointer to a vector of strings you can
> try something like
> for(std::vector<std::string>::iterator it = Source_Name->begin(); it
> != Source_Name->end(); ++it ) {
> if( *it == agnTimeGap::agnName) { // no match ;}
> else { // matched! ; }
> }
> Cheers,
> Venkat
>
> 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 - 20:49:12 CEST

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