Protection added.
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 30 Apr 2008 08:14:59 +0000 (08:14 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 30 Apr 2008 08:14:59 +0000 (08:14 +0000)
ZDC/AliZDCQADataMakerSim.cxx

index 1eff68a..37b32f0 100644 (file)
@@ -170,23 +170,27 @@ void AliZDCQADataMakerSim::MakeHits(TTree * hitTree)
     return;\r
   } else {\r
       char** add = (char**) (branch->GetAddress());\r
-      fHits = (TClonesArray*)(*add);\r
-\r
-    Int_t ntracks = (Int_t) hitTree->GetEntries();\r
-    //printf("\n\t *** no.track %d\n",ntracks);\r
-    if (ntracks<=0) return;\r
-    //\r
-    for(Int_t itrack=0; itrack<ntracks; itrack++){\r
-\r
-      branch->GetEntry(itrack);\r
-      //\r
-      //printf("\t *** track %d",itrack);\r
-      //hits->Print("");\r
-      //printf("\n");\r
+      if (add) {\r
+         fHits = (TClonesArray*)(*add);\r
+      } else {\r
+         if (!fHits) fHits = new TClonesArray("AliZDCHit", 1000);\r
+         branch->SetAddress(&fHits);\r
+      }\r
+      Int_t ntracks = (Int_t) hitTree->GetEntries();\r
+      //printf("\n\t *** no.track %d\n",ntracks);\r
+      if (ntracks<=0) return;\r
       //\r
-      MakeHits(); \r
-      fHits->Clear();\r
-    }    \r
+      for(Int_t itrack=0; itrack<ntracks; itrack++){\r
+         \r
+         branch->GetEntry(itrack);\r
+         //\r
+         //printf("\t *** track %d",itrack);\r
+         //hits->Print("");\r
+         //printf("\n");\r
+         //\r
+         MakeHits(); \r
+         fHits->Clear();\r
+      }          \r
   }\r
 }\r
 \r
@@ -207,8 +211,12 @@ void AliZDCQADataMakerSim::MakeDigits(TTree *digitTree )
       return;\r
    } \r
    char** add = (char**) (branch->GetAddress());\r
-   fDigit = (AliZDCDigit*)(*add);\r
-\r
+   if (add) {\r
+       fDigit = (AliZDCDigit*)(*add);\r
+   } else {\r
+       if (!fDigit) fDigit = new AliZDCDigit();\r
+       branch->SetAddress(&fDigit);\r
+   }\r
    \r
    Int_t ndig = digitTree->GetEntries();\r
    \r