Hi Everyone,
I’m trying to read two trees in the same file with TTreeReader. In one of the trees there is a TString branch that I want to use to make a selection, so I wanted to use the CompareTo() function of the TString, but I can’t make it work…
So here is what I’m doing:
#include <iostream>
#include "TFile.h"
#include "TTreeReader.h"
void rd53aCorrelation ( ) {
TFile *file = TFile::Open ( "telescopeData.root" ) ;
TTreeReader dutReader ( "dutData", file ) ;
TTreeReader telReader ( "cluster3DTree", file ) ;
// Declare telescope values
TTreeReaderValue<TString> myM3226( telReader, "modName") ;
TTreeReaderValue<Int_t> telEvent( telReader, "event" ) ;
TTreeReaderValue<Double_t> telY( telReader, "y" ) ;
// Declare dut values
TTreeReaderValue<Int_t> dutEvent( dutReader, "trigNumber") ;
TTreeReaderValue<Int_t> rowDUT( dutReader, "row") ;
TH2D *corr = new TH2D("corr", "Correlation between RD53A and M3226", 480, -3., 3., 200, -0.8, 0.8);
// Now we loop
while ( telReader.Next() ) {
if ( *myM3226.CompareTo("M3226") != 0 ) {
while ( dutReader.Next() ) {
if ( *telEvent < *dutEvent ) break ;
if ( *telEvent != *dutEvent ) continue ;
else if ( *telEvent == *dutEvent ) {
//corr->Fill( (Double_t)( *rowDUT * 0.005-0.5), *telY );
std::cout << *rowDUT << std::endl;
}//end else
}//end while
}//end if m3226
}//end whil
corr->Draw("colz");
}//end void
The problem is with the line where I compare the TString to see if it matches “M3226”. There I get the error:
/Users/nikkie/cernbox/myWork/telescope/rd53aOctober2018/dataAnalysis/rd53aCorrelation.cc:27:18: error: no member named 'CompareTo' in 'TTreeReaderValue<TString>'; did you mean to use '->' instead of '.'?
if ( *myM3226.CompareTo("M3226") != 0 ) {
^
->
/Users/nikkie/cernbox/myWork/telescope/rd53aOctober2018/dataAnalysis/rd53aCorrelation.cc:27:10: error: indirection requires pointer operand ('int' invalid)
if ( *myM3226.CompareTo("M3226") != 0 ) {
I used the arrow as well to get rid of the first error but I can never get rid of the second one.
Does anybody know what I’m doing wrong?
Cheers,
Nikkie
_ROOT Version: 6.14/04
_Platform: MacOS Mojave
_Compiler: XCode