Create a "character string" branch in a TTree

Hi,

I try to insert a branch with type “character string” in a TTree but I don’t store what I want in this branch. I’d like to do something like

studymc = new TTree(“studymc”,“TTree from StudyMC.cpp”);
studymc->Branch(“nTfired”, &nTfired, “nTfired/I”);
studymc->Branch(“Tfired”, &Tfired, “Tfired[nTfired]/C”);

with in the corresponding header :
int nTfired;
Char_t Tfired[200];

to store an array of “character string” for each event processed. “nTfired” is the number of triggers fired for each event processed and I’d like to store the name of all the fired triggers (“Tfired”) for each event.
I tried several possibilities for the type of Tfired (Char_t, char_t*, Char_t [200], …) but without success.

I have to admit I don’t understand how to deal with this kind of variables (need to use 2D array, use Char_t*,…?) so any help would be much appreciated.

thanks a lot for any reply,

vincent

Hi Vincent,
the best would probably be to do the following:

[code]TClonesArray* caTfired=new TClonesArray(“TObjString”);

studymc = new TTree(“studymc”,“TTree from StudyMC.cpp”);
studymc->Branch(“nTfired”, &caTfired);

for (Int_t entry=0; entry<…; entry++) {
Int_t nFired=…; // set the number of fired triggers
for (Int_t iFired=0; iFired<nFired<iFired++) {
// get the iFired-th trigger name
const char* tName=framework->get_triggernam(iFired);
new ((*caTfired)[iFired]) TObjString(tName);
}
studymc->Fill();
caTfired->Clear();
}[/code]
or, even simpler, you can use a std::vector, if you’re using ROOT >= v4.02: std::vector<std::string> vecTfired; std::vector<std::string>* pVecTfired=&vecTFired; studymc = new TTree("studymc","TTree from StudyMC.cpp"); studymc->Branch("nTfired", &pVecTfired);
Cheers, Axel.