]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliAODEvent.cxx
ReadFromTree: option for reconnection of tree added.
[u/mrichter/AliRoot.git] / STEER / AliAODEvent.cxx
index 9cdb7915b2613dc14cefde44be2bc84b0cbbcc03..1ed88d1cb3160cc28a20d9600d430f2edfb5aa3d 100644 (file)
@@ -205,7 +205,7 @@ void  AliAODEvent::MakeEntriesReferencable()
     //
     TIter next(fAODObjects);
     TObject* obj;
-    while (obj = next())
+    while ((obj = next()))
     {
        if(obj->InheritsFrom("TCollection"))
            {
@@ -332,6 +332,47 @@ void AliAODEvent::ClearStd()
   fPmdClusters   ->Clear();
 }
 
+//_________________________________________________________________
+Int_t AliAODEvent::GetPHOSClusters(TRefArray *clusters) const
+{
+  // fills the provided TRefArray with all found phos clusters
+  
+  clusters->Clear();
+  
+  AliAODCaloCluster *cl = 0;
+  for (Int_t i = 0; i < GetNCaloClusters() ; i++) {
+    
+    if ( (cl = GetCaloCluster(i)) ) {
+      if (cl->IsPHOSCluster()){
+       clusters->Add(cl);
+       //AliDebug(1,Form("IsPHOS cluster %d Size: %d \n",i,clusters->GetEntriesFast()));
+      }
+    }
+  }
+  return clusters->GetEntriesFast();
+}
+
+//_________________________________________________________________
+Int_t AliAODEvent::GetEMCALClusters(TRefArray *clusters) const
+{
+  // fills the provided TRefArray with all found emcal clusters
+
+  clusters->Clear();
+
+  AliAODCaloCluster *cl = 0;
+  for (Int_t i = 0; i < GetNCaloClusters(); i++) {
+
+    if ( (cl = GetCaloCluster(i)) ) {
+      if (cl->IsEMCALCluster()){
+       clusters->Add(cl);
+       //AliDebug(1,Form("IsEMCAL cluster %d Size: %d \n",i,clusters->GetEntriesFast()));
+      }
+    }
+  }
+  return clusters->GetEntriesFast();
+}
+
+
 //______________________________________________________________________________
 Int_t AliAODEvent::GetMuonTracks(TRefArray *muonTracks) const
 {
@@ -350,9 +391,9 @@ Int_t AliAODEvent::GetMuonTracks(TRefArray *muonTracks) const
 }
 
 
-void AliAODEvent::ReadFromTree(TTree *tree)
+void AliAODEvent::ReadFromTree(TTree *tree, Option_t* opt /*= ""*/)
 {
-  // connects aod event to tree
+  // Connects aod event to tree
   
   if(!tree){
     Printf("%s %d AliAODEvent::ReadFromTree() Zero Pointer to Tree \n",(char*)__FILE__,__LINE__);
@@ -367,12 +408,12 @@ void AliAODEvent::ReadFromTree(TTree *tree)
   if(aodEvent){
     // Check if already connected to tree
     TList* connectedList = (TList*) (tree->GetUserInfo()->FindObject("AODObjectsConnectedToTree"));
-    if (connectedList) {
-      // If connected use the connected list if objects
-      fAODObjects->Delete();
-      fAODObjects = connectedList;
-      GetStdContent(); 
-      return;
+    if (connectedList && (strcmp(opt, "reconnect"))) {
+       // If connected use the connected list if objects
+       fAODObjects->Delete();
+       fAODObjects = connectedList;
+       GetStdContent(); 
+       return;
     }
     // Connect to tree
     // prevent a memory leak when reading back the TList
@@ -403,7 +444,7 @@ void AliAODEvent::ReadFromTree(TTree *tree)
                printf("Get list of object from tree %d !!\n", objL->GetEntries());
                TIter nextobject(objL);
                TObject* obj =  0;
-               while(obj = nextobject())
+               while((obj = nextobject()))
                {
                    printf("Adding object from friend %s !\n", obj->GetName());
                    fAODObjects->Add(obj);
@@ -419,7 +460,6 @@ void AliAODEvent::ReadFromTree(TTree *tree)
     while((el=(TNamed*)next())){
       TString bname(el->GetName());
       // check if branch exists under this Name
-      printf("Trying to connect branch %s\n", bname.Data());
       TBranch *br = tree->GetTree()->GetBranch(bname.Data());
       if(br){
        tree->SetBranchAddress(bname.Data(),fAODObjects->GetObjectRef(el));
@@ -476,6 +516,6 @@ void AliAODEvent::AssignIDtoCollection(TCollection* col)
     // written by a subsequent process.
     TIter next(col);
     TObject* obj;
-    while (obj = next())
+    while ((obj = next()))
        TProcessID::AssignID(obj);
 }