Problem with TTreeReaderArray: Cannot determine the type

Hi all,

I’m trying to make some more compact code, i.e. avoiding the need to have multiple declarations such as:

 TTreeReaderArray< Int_t > stationEtas0 (myReader, "MissedHitStationEtaForLevel0");
 TTreeReaderArray< Int_t > stationEtas1 (myReader, "MissedHitStationEtaForLevel1");
 TTreeReaderArray< Int_t > stationEtas2 (myReader, "MissedHitStationEtaForLevel2");

by re-writing as follows:

 TFile *file = TFile::Open("/Users/emoyse/Documents/MuonTruthSummary.root");
 const Int_t nLevels = 3;
 TH2F *etaPhi[nLevels];
 TH2F *stations[nLevels];
 
 TTreeReaderArray< Int_t >* stationEtas[nLevels];
 TTreeReaderArray< Int_t >* stationPhis[nLevels];
  
 TTreeReader myReader("MuonTruthSummaryTree", file);
 for (UInt_t level=0 ; level<nLevels ; ++level){
   TString levelText = TString::UItoa(level,10);
   
   etaPhi[level] = new TH2F("etaPhi"+levelText,"Missed hits - "+levelText,20,-10,10, 50,0, 50 ); // Will change this once I get eta/phi conversions working.
   stations[level] = new TH2F("stations"+levelText,"Missed hits - "+levelText,5,0,5, 8,0, 8 ); 
   
   stationEtas[level] = new TTreeReaderArray< Int_t >(myReader, "MissedHitStationEtaForLevel"+levelText);
   stationPhis[level] = new TTreeReaderArray< Int_t >(myReader, "MissedHitStationPhiForLevel"+levelText);
 }
 
 while (myReader.Next()) {
   // std::cout<<"size(): "<<stationEtas->size()<<std::endl;
   for (UInt_t level=0 ; level<nLevels ; ++level){   
     for (UInt_t index = 0; index<stationEtas[level]->GetSize() ; ++index){
       TTreeReaderArray< Int_t >* test1 = stationEtas[level];
       std::cout<<" eta: "<<(*test1)[index]<<std::endl;
     }
   }
 }

I guess I’m doing something wrong though, as when I try to run this I get:

[quote]Error in <CreateContentProxy()>: Cannot determine the type contained in the collection of branch MissedHitStationEtaForLevel0. That’s weird - please report!
[/quote]

I can’t see what the problem is … does anyone have an idea?

Thanks!

Ok, changing

 TTreeReaderArray< Int_t >* stationEtas[nLevels];

to:

 TTreeReaderValue< std::vector< Int_t > >* stationEtas[nLevels];

fixes the problem. Is there a bug with the Array? Or was I doing something wrong?

Hi Rooters,

I have been having issues with TTreeReader, which I think are related to the issues raised in this post. I have setup TTreeReader to retrieve a branch, and then fill a histogram with the information stored in this branch.

32   TTreeReaderArray<Int_t> NPV201(Reader1, "NPV");
33   TTreeReaderArray<Float_t> zVertex201(Reader1, "zRecoVertex");
34   TTreeReaderArray<Float_t> calibMass201(Reader1, "jet_akt10LCTopoTrimmedPtFrac5SmallR20_calib_m");
36   TTreeReaderArray<Float_t> width201(Reader1, "jet_akt10LCTopoTrimmedPtFrac5SmallR20_width");
37   TTreeReaderArray<Float_t> area201(Reader1, "jet_akt10LCTopoTrimmedPtFrac5SmallR20_activearea");
 ....
 [Histos are defined here]
 81   while (Reader1.Next()) {
 82 
 83    
 84     for (Int_t iJet = 0; iJet < calibMass201.GetSize(); ++ iJet) {

 89       mass_vs_Width_201->Fill(calibMass201.At(iJet), width201.At(iJet));
 90       mass_vs_area_201->Fill(calibMass201.At(iJet), area201.At(iJet));
 ...
    	}
     }

When I run, I get an error:

Error in <CreateContentProxy()>: Cannot determine the type contained in the collection of branch jet_akt10LCTopoTrimmedPtFrac5SmallR20_calib_m. That's weird - please report

This is the same error which has been previously reported. I haven’t yet found an adequate solution to this problem. I have also tried the suggestion in this post of changing TTreeReaderArray<Float_T> to TTreeReaderValue<std::vector<Float_t>>, but this isn’t going to work since I need to use an Array to access GetSize() and At(). Does anybody know if there is a fix in TTreeReader which removes this issue, if it is a bug?

Thanks in advance!

Hi,

What is the content of the TTree? Can you either post the ROOT file or at least the result of yourtree->Print(); ?

Cheers,
Philippe.

Hi Philippe,

The root file is too large to attach, but the content of the CollectionTree is: RunNumber, EventNumber, mu, NPV, ttbarEventCat, zRecoVertex (the types of these leaves are successfully found by the reader), then the remaining leaves are of the form jet_akt10LCTopoTrimmedPtFrac5SmallR20_*, for example * = uncalib_m, uncalib_pt, calib_m, calib_pt, trkmass etc. These are all contain jet information.

Hi,

Can you put the file somewhere where I can access it? /afs/… or a web server etc?

Cheers, Axel.

Hi,

I’ve put the two root files I want to use here: /afs/cern.ch/user/m/mnelson/public/forAxel.