Problem adding TCut to TList

Hi rooters,
I have a strange problem with a TList.

I wrote the following very simple macro:

#include “TFile.h”
#include “TList.h”
#include “TCut.h”
#include “TCutG.h”
#include “TTree.h”
#include “TString.h”
#include “TCollection.h”
TCut detA = new TCut(“DetA”,“ModuleID==0”);
TList
myCutList = new TList();
myCutList->Add(detA);
myCutList->Print();

but when I try to load it with:

.L macro.C

I get the following errors:

root [0] .L Session.C
In file included from input_line_8:1:
/home/mimmi/Session.C:16:1: error: unknown type name ‘myCutList’
myCutList->Add(detA);
^
/home/mimmi/Session.C:16:10: error: cannot use arrow operator on a type
myCutList->Add(detA);
^
/home/mimmi/Session.C:17:1: error: unknown type name ‘myCutList’
myCutList->Add(particle);
^
/home/mimmi/Session.C:17:10: error: cannot use arrow operator on a type
myCutList->Add(particle);
^
/home/mimmi/Session.C:18:1: error: unknown type name ‘myCutList’
myCutList->Add(testPulses);
^
/home/mimmi/Session.C:18:10: error: cannot use arrow operator on a type
myCutList->Add(testPulses);
^
/home/mimmi/Session.C:19:1: error: unknown type name ‘myCutList’
myCutList->Print();
^
/home/mimmi/Session.C:19:10: error: cannot use arrow operator on a type
myCutList->Print();
^

The strange thing is that if I copy&paste each single line fron the macro to the root interactive session, everything works fine!

Can anyone help me?

Thanks in advance!


ROOT Version: 6.10/08
Platform, compiler: Linux Fedora 4.13.16-100.fc25.x86_64, gcc version 6.4.1


Try the following macro:

macro.C (288 Bytes)

$ root
   ------------------------------------------------------------------
  | Welcome to ROOT 6.15/01                      http://root.cern.ch |
  |                                     (c) 1995-2018, The ROOT Team |
  | Built for macosx64                                               |
  | From heads/master@v6-13-04-50-ga9da30b440, May 14 2018, 09:01:20 |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'       |
   ------------------------------------------------------------------

root [0] .x macro.C
Collection name='TList', class='TList', size=1
 OBJ: TCut	DetA	ModuleID==0
root [1] 
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.