-// Make Kine tree and creates branch for writing particles
-//
- TBranch *branch=0;
- // Make Kinematics Tree
- char hname[30];
-// printf("\n MakeTree called %d", event);
- if (!fTreeK) {
- sprintf(hname,"TreeK%d",event);
- fTreeK = new TTree(hname,"Kinematics");
- // Create a branch for particles
- branch = fTreeK->Branch("Particles", "TParticle", &fParticleBuffer, 4000);
- fTreeK->Write(0,TObject::kOverwrite);
- }
+// Creates branch for writing particles
+//
+ if (AliLoader::GetDebug()) Info("ConnectTree","Connecting TreeK");
+ if (fTreeK == 0x0)
+ {
+ if (TreeK() == 0x0)
+ {
+ Fatal("ConnectTree","Parameter is NULL");//we don't like such a jokes
+ return;
+ }
+ return;//in this case TreeK() calls back this method (ConnectTree)
+ //tree after setting fTreeK, the rest was already executed
+ //it is safe to return now
+ }
+
+ // Create a branch for particles
+
+ if (AliLoader::GetDebug())
+ Info("ConnectTree","Tree name is %s",fTreeK->GetName());
+
+ if (fTreeK->GetDirectory())
+ {
+ if (AliLoader::GetDebug())
+ Info("ConnectTree","and dir is %s",fTreeK->GetDirectory()->GetName());
+ }
+ else
+ Warning("ConnectTree","DIR IS NOT SET !!!");
+
+ TBranch *branch=fTreeK->GetBranch(AliRunLoader::fgkKineBranchName);
+ if(branch == 0x0)
+ {
+ branch = fTreeK->Branch(AliRunLoader::fgkKineBranchName, "TParticle", &fParticleBuffer, 4000);
+ if (AliLoader::GetDebug()) Info("ConnectTree","Creating Branch in Tree");
+ }
+ else
+ {
+ if (AliLoader::GetDebug()) Info("ConnectTree","Branch Found in Tree");
+ branch->SetAddress(&fParticleBuffer);
+ }
+ if (branch->GetDirectory())
+ {
+ if (AliLoader::GetDebug())
+ Info("ConnectTree","Branch Dir Name is %s",branch->GetDirectory()->GetName());
+ }
+ else
+ Warning("ConnectTree","Branch Dir is NOT SET");