Rudimentary merging added.
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 12 Aug 2013 12:37:42 +0000 (12:37 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 12 Aug 2013 12:37:42 +0000 (12:37 +0000)
STEER/STEER/AliTransportMonitor.cxx
STEER/STEER/AliTransportMonitor.h

index 506859714b0b0c6dc588d4b6136869e257bab2f4..b86eff3816cc61e73b497583554c568ec5257663 100644 (file)
@@ -114,6 +114,27 @@ PMonData &AliTransportMonitor::AliTransportMonitorVol::GetPMonData(Int_t pdg)
   return *data;
 }
 
+void AliTransportMonitor::AliTransportMonitorVol::Merge(AliTransportMonitorVol* volM) 
+{
+  // Merging
+  fTotalTime = (fTotalTime + volM->GetTotalTime());
+  if (fTimeRZ && volM->GetHistogram()) {
+    fTimeRZ->Add(volM->GetHistogram()); 
+  } else if (volM->GetHistogram()) {
+    fTimeRZ = (TH2F*)(volM->GetHistogram()->Clone());
+  }
+
+  Int_t ntypes = volM->GetNtypes();
+  Int_t ntypes2 = GetNtypes();
+  for (Int_t i = 0; i < ntypes; i++) {
+    Int_t pdg = volM->GetPDG(i);
+    //PMonData &data  = GetPMonData(pdg);
+    //PMonData &dataM = volM->GetPMonData(pdg);
+    //data.fEdt  += dataM.fEdt;
+    //data.fTime += dataM.fTime;
+  }
+}
+
 ClassImp(AliTransportMonitor)
 
 //______________________________________________________________________________
@@ -283,7 +304,21 @@ void AliTransportMonitor::Export(const char *fname)
   file->Write();
   file->Close();
 }  
-
+//______________________________________________________________________________
+void AliTransportMonitor::Merge(AliTransportMonitor* mergeMon)
+{
+  // merge with monitor 
+  Int_t n = fVolumeMon->GetEntriesFast();
+  TObjArray* mergeVols = mergeMon->GetVolumes();
+  fTotalTime = 0;
+  for (Int_t i = 0; i < n; i++)
+    {
+      AliTransportMonitorVol *volMon1 = (AliTransportMonitorVol*)fVolumeMon->At(i);      
+      AliTransportMonitorVol *volMon2 = (AliTransportMonitorVol*)mergeVols->At(i);      
+      volMon1->Merge(volMon2);
+      fTotalTime += (volMon1->GetTotalTime());
+    }
+}
 //______________________________________________________________________________
 AliTransportMonitor *AliTransportMonitor::Import(const char *fname)
 {
index 7300016cefa0d440f09f9f0897d51a76bf95392f..a28e4b1f6d995a0605d83255b0d08b80c8f0da48 100644 (file)
 #include "TStopwatch.h"
 #endif
 
+#ifndef ROOT_TH2F
+#include "TH2F.h"
+#endif
+
 // Class that can be plugged in the simulation to monitor transport timing per 
 // particle for each geometry volume.
 //
 //  andrei.gheata@cern.ch 
 
-class TH2F;
 
 
 //______________________________________________________________________________
@@ -34,6 +37,7 @@ public:
       Double_t      fEdt;        // Energy * dt integral
       Double_t      fTime;       // Total transport time for the particle in this volume
       AliPMonData() : fPDG(0), fEdt(0), fTime(0) {}
+      void          Merge(AliPMonData* pdata) {fTime = 0.5*(fTime+pdata->fTime); fEdt = 0.5 * (fEdt+pdata->fEdt);}
       virtual ~AliPMonData() {}
       ClassDef(AliPMonData, 1)     // Basic monitoring info structure
     };   
@@ -51,6 +55,8 @@ public:
     Double_t        GetEmed(Int_t itype) const {return (fTotalTime>0)?fPData[itype].fEdt/fTotalTime : 0.;}
     Int_t           GetPDG(Int_t itype)  const {return fPData[itype].fPDG;}
     TH2F           *GetHistogram() const {return fTimeRZ;}
+    AliPMonData    *GetPMonData(Int_t itype) const {AliPMonData obj = fPData[itype]; return &obj;} 
+    void            Merge(AliTransportMonitorVol* volM);
     private:
       AliPMonData  &GetPMonData(Int_t pdg);
       AliTransportMonitorVol(const AliTransportMonitorVol& other) : TNamed(other), fNtypes(0), fTotalTime(0), fPData(0), fTimeRZ(0), fParticles() {}
@@ -84,6 +90,8 @@ public:
   void              Start();
   void              Stop();
   void              Export(const char *fname);
+  TObjArray*        GetVolumes() const {return fVolumeMon;}
+  void              Merge(AliTransportMonitor* mergeMon);
   static AliTransportMonitor *Import(const char *fname);
 private:
   Double_t          fTotalTime;  // Total simulation time