String on a ttree

Dear all,

I’m using a ttree to read a csv file in which a column is composed by strings. I need those strings to make some if statements. However, the tree reads only 9 characters and the required string has 12 characters. There is some way to increased the number os characters on the tree?

Code:

void dataRead(){ //TString chamber, int numDate, TString datemeas
   
    // Tree for read date from a csc file.
    TTree *tree = new TTree("Data for scan","Data from csv file"); 
    // Method to read the file .csv with two variables.
   
    tree->ReadFile("Current_Scan_AllData_2019_03_13.csv","CHAMBER_NAME_CMSSW/C,d1/C,d2/C,d3/C,vmon/D,imon/D",',');
    // Variables to put on the tree branch.
    double current, voltage;
    char chamb, date;
    // Setting the branch address with those variables.
    tree->SetBranchAddress("CHAMBER_NAME_CMSSW", &chamb);
    tree->SetBranchAddress("d1", &date);
    tree->SetBranchAddress("imon", &current);
    tree->SetBranchAddress("vmon", &voltage);
........
}

kind regards,


_ROOT Version: 6.19/01
Platform: Ubuntu 20.04
Compiler: gcc 9.3.0


You need something like: char chamb[100], date[100];

And use “:” (not “,”) to separate the branch elements in ReadFile:

    tree->ReadFile("Current_Scan_AllData_2019_03_13.csv","CHAMBER_NAME_CMSSW/C:d1/C:d2/C:d3/C:vmon/D:imon/D",',');

Hi guys,

thank you for the response, but I got the same result =/

Attach your “.csv” file for inspection.

Current_Scan_AllData_2019_03_13.zip (420 Bytes)

I don’t get any problem (except for the first line of your “.csv” file which you should remove or add a “#” character in the beginning).

That’s weird, I can fill the tree but the names are cutted.

e.g: The name “RE+4_R2_CH04” appears as RE+4_R2_C when I do tree->Scan().

Cheers,

tree->Scan("*", "", "colsize=20");