]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVE/EveDet/AliEveITSDigitsInfo.cxx
Update of the class ESDMuonFilter. New marcros for creating AOD with muon information...
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveITSDigitsInfo.cxx
index 491a70d77992fc6e77fc268152049dd5992d8275..31394b6db6b8ef4a36e91c70c3303205ad781d93 100644 (file)
@@ -7,22 +7,41 @@
  * full copyright notice.                                                 *
  **************************************************************************/
 
-#include <TMath.h>
-#include <TVector3.h>
+#include "AliEveITSDigitsInfo.h"
+#include <EveBase/AliEveEventManager.h>
 
-#include <TEveTreeTools.h>
-#include <TEveTrans.h>
+#include <AliITS.h>
+#include <AliITSInitGeometry.h>
+#include <AliITSgeomTGeo.h>
+#include <AliITSsegmentationSPD.h>
+#include <AliITSsegmentationSDD.h>
+#include <AliITSsegmentationSSD.h>
+#include <AliITSDDLModuleMapSDD.h>
 
-#include "AliEveITSDigitsInfo.h"
 #include <AliITSCalibrationSDD.h>
 #include <AliITSdigit.h>
 #include <AliITSdigitSPD.h>
 
+#include <AliCDBEntry.h>
+#include <AliCDBManager.h>
+
 #include <AliRawReader.h>
 #include <AliITSRawStreamSPD.h>
 #include <AliITSRawStreamSDD.h>
 #include <AliITSRawStreamSSD.h>
 
+#include <TGeoMatrix.h>
+#include <TEveTrans.h>
+//#include <TClonesArray.h>
+
+#include <TMath.h>
+#include <TVector3.h>
+
+//==============================================================================
+//==============================================================================
+// AliEveITSModuleSelection
+//==============================================================================
+
 //______________________________________________________________________________
 //
 // Helper for selecting a range of ITS modules by type, layer, phi and
@@ -42,6 +61,11 @@ AliEveITSModuleSelection::AliEveITSModuleSelection():
 }
 
 
+//==============================================================================
+//==============================================================================
+// AliEveITSDigitsInfo
+//==============================================================================
+
 //______________________________________________________________________________
 //
 // Stores ITS geometry information and event-data in format suitable
@@ -56,8 +80,11 @@ AliEveITSDigitsInfo::AliEveITSDigitsInfo() :
   TEveRefCnt(),
   fSPDmap(), fSDDmap(), fSSDmap(),
   fTree (0),
-  fGeom (0),
-  fSegSPD(0), fSegSDD(0), fSegSSD(0)
+  fSegSPD     (0), fSegSDD     (0), fSegSSD     (0),
+  fDDLMapSDD  (0),
+  fSPDMinVal  (0), fSSDMinVal  (0), fSDDMinVal  (0),
+  fSPDMaxVal  (0), fSSDMaxVal  (0), fSDDMaxVal  (0),
+  fSPDHighLim (0), fSDDHighLim (0), fSSDHighLim (0)
 {
   // Default constructor.
 
@@ -70,12 +97,9 @@ void AliEveITSDigitsInfo::InitInternals()
   // module-id to transformation-matrix mapping and segmentation
   // classes and data-structures.
 
-  static const TEveException eH("AliEveITSDigitsInfo::InitInternals ");
+  static const TEveException kEH("AliEveITSDigitsInfo::InitInternals ");
 
-  fGeom = new AliITSgeom();
-  fGeom->ReadNewFile("$REVESYS/alice-data/ITSgeometry.det");
-  if (fGeom == 0)
-    throw(eH + "can not load ITS geometry \n");
+  AliEveEventManager::AssertGeometry();
 
   SetITSSegmentation();
 
@@ -124,6 +148,22 @@ void AliEveITSDigitsInfo::InitInternals()
   fSSDScale[2] = 9;
   fSSDScale[3] = 20;
   fSSDScale[4] = 30;
+  
+  fDDLMapSDD = new AliITSDDLModuleMapSDD();
+  AliCDBManager *man       = AliCDBManager::Instance();
+  AliCDBEntry   *ddlMapSDD = man->Get("ITS/Calib/DDLMapSDD");
+  ddlMapSDD->SetOwner(kTRUE);
+  if (!ddlMapSDD) {
+    AliWarning("SDD DDL map file retrieval from OCDB failed! - Use default DDL map");
+  } else {
+    AliITSDDLModuleMapSDD *ddlsdd = (AliITSDDLModuleMapSDD*)ddlMapSDD->GetObject();
+    if (!ddlsdd) {
+      AliWarning("SDD DDL map object not found in OCDB file! - Use default DDL map");
+    } else {
+      fDDLMapSDD->SetDDLMap(ddlsdd);
+    }
+  }
+  delete ddlMapSDD;
 }
 
 /******************************************************************************/
@@ -133,16 +173,15 @@ AliEveITSDigitsInfo:: ~AliEveITSDigitsInfo()
   // Destructor.
   // Deletes the data-maps and the tree.
 
-  map<Int_t, TClonesArray*>::iterator j;
-  for(j = fSPDmap.begin(); j != fSPDmap.end(); ++j)
+  std::map<Int_t, TClonesArray*>::iterator j;
+  for (j = fSPDmap.begin(); j != fSPDmap.end(); ++j)
     delete j->second;
-  for(j = fSDDmap.begin(); j != fSDDmap.end(); ++j)
+  for (j = fSDDmap.begin(); j != fSDDmap.end(); ++j)
     delete j->second;
-  for(j = fSSDmap.begin(); j != fSSDmap.end(); ++j)
+  for (j = fSSDmap.begin(); j != fSSDmap.end(); ++j)
     delete j->second;
-
+  delete fDDLMapSDD;
   delete fSegSPD; delete fSegSDD; delete fSegSSD;
-  delete fGeom;
   delete fTree;
 }
 
@@ -161,7 +200,8 @@ void AliEveITSDigitsInfo::ReadRaw(AliRawReader* raw, Int_t mode)
   // Read raw-data into internal structures. AliITSdigit is used to
   // store raw-adata for all sub-detectors.
 
-  if ((mode & 1) || (mode & 2)){
+  if ((mode & 1) || (mode & 2))
+  {
     AliITSRawStreamSPD inputSPD(raw);
     TClonesArray* digits = 0;
     while (inputSPD.Next())
@@ -187,15 +227,14 @@ void AliEveITSDigitsInfo::ReadRaw(AliRawReader* raw, Int_t mode)
     raw->Reset();
   }
 
-  if ((mode & 4) || (mode & 8)){
+  if ((mode & 4) || (mode & 8))
+  {
     AliITSRawStreamSDD input(raw);
+    input.SetDDLModuleMap(fDDLMapSDD);
     TClonesArray* digits = 0;
     while (input.Next())
     {
       Int_t module = input.GetModuleID();
-      Int_t anode  = input.GetAnode();
-      Int_t time   = input.GetTime();
-      Int_t signal = input.GetSignal();
 
       if (input.IsNewModule())
       {
@@ -204,17 +243,23 @@ void AliEveITSDigitsInfo::ReadRaw(AliRawReader* raw, Int_t mode)
          fSDDmap[module] = digits = new TClonesArray("AliITSdigit", 0);
       }
 
-      AliITSdigit* d = new ((*digits)[digits->GetEntriesFast()]) AliITSdigit();
-      d->SetCoord1(anode);
-      d->SetCoord2(time);
-      d->SetSignal(signal);
-
+      if (input.IsCompletedModule()==kFALSE)
+      {
+       Int_t anode  = input.GetAnode()+input.GetChannel()*AliITSsegmentationSDD::GetNAnodesPerHybrid();
+       Int_t time   = input.GetTime();
+       Int_t signal = input.GetSignal();
+       AliITSdigit* d = new ((*digits)[digits->GetEntriesFast()]) AliITSdigit();
+       d->SetCoord1(anode);
+       d->SetCoord2(time);
+       d->SetSignal(signal);
+      }
       // printf("SDD: %d %d %d %d\n",module,anode,time,signal);
     }
     raw->Reset();
   }
 
-  if ((mode & 16) || (mode & 32)){
+  if ((mode & 16) || (mode & 32))
+  {
     AliITSRawStreamSSD input(raw);
     TClonesArray* digits = 0;
     while (input.Next())
@@ -224,7 +269,9 @@ void AliEveITSDigitsInfo::ReadRaw(AliRawReader* raw, Int_t mode)
       Int_t strip   = input.GetStrip();
       Int_t signal  = input.GetSignal();
 
-      if (input.IsNewModule())
+      // !!!! IsNewModule() is false in the beginning of the stream, so we also
+      // !!!! check for digits == 0. Should be fixed in SSD stream.
+      if (input.IsNewModule() || digits == 0)
       {
        digits = fSSDmap[module];
        if (digits == 0)
@@ -250,7 +297,7 @@ void AliEveITSDigitsInfo::SetITSSegmentation()
   // data-structures.
 
   // SPD
-  fSegSPD = new AliITSsegmentationSPD(fGeom);
+  fSegSPD = new AliITSsegmentationSPD("TGeo");
 
   Int_t m;
   Float_t fNzSPD=160;
@@ -273,10 +320,12 @@ void AliEveITSDigitsInfo::SetITSSegmentation()
   }
 
   // SDD
-  fSegSDD = new AliITSsegmentationSDD(fGeom);
+  fSegSDD = new AliITSsegmentationSDD("TGeo");
+  // !!!! Set default drift speed, eventually need to get it from CDB.
+  fSegSDD->SetDriftSpeed(7.3);
 
   // SSD
-  fSegSSD = new AliITSsegmentationSSD(fGeom);
+  fSegSSD = new AliITSsegmentationSSD("TGeo");
 }
 
 /******************************************************************************/
@@ -290,7 +339,7 @@ TClonesArray* AliEveITSDigitsInfo::GetDigits(Int_t mod, Int_t subdet)
     case 0:
     {
       TClonesArray* digitsSPD = 0;
-      map<Int_t, TClonesArray*>::iterator i = fSPDmap.find(mod);
+      std::map<Int_t, TClonesArray*>::iterator i = fSPDmap.find(mod);
       if (i == fSPDmap.end()) {
        if (fTree) {
          TBranch* br =  fTree->GetBranch("ITSDigitsSPD");
@@ -309,7 +358,7 @@ TClonesArray* AliEveITSDigitsInfo::GetDigits(Int_t mod, Int_t subdet)
     case 1:
     {
       TClonesArray* digitsSDD = 0;
-      map<Int_t, TClonesArray*>::iterator i = fSDDmap.find(mod);
+      std::map<Int_t, TClonesArray*>::iterator i = fSDDmap.find(mod);
       if (i == fSDDmap.end()) {
        if (fTree) {
          TBranch* br =  fTree->GetBranch("ITSDigitsSDD");
@@ -328,7 +377,7 @@ TClonesArray* AliEveITSDigitsInfo::GetDigits(Int_t mod, Int_t subdet)
     case 2:
     {
       TClonesArray* digitsSSD = 0;
-      map<Int_t, TClonesArray*>::iterator i = fSSDmap.find(mod);
+      std::map<Int_t, TClonesArray*>::iterator i = fSSDmap.find(mod);
       if (i == fSSDmap.end()) {
        if (fTree) {
          TBranch* br =  fTree->GetBranch("ITSDigitsSSD");
@@ -364,39 +413,32 @@ void AliEveITSDigitsInfo::GetModuleIDs(AliEveITSModuleSelection* sel,
   {
     case 0:
       idx0 = 0;
-      idx1 = fGeom->GetLastSPD();
+      idx1 = AliITSgeomTGeo::GetModuleIndex(3, 1, 1) - 1;
       break;
     case 1:
-      idx0 = fGeom->GetLastSPD()+1;
-      idx1 = fGeom->GetLastSDD();
+      idx0 = AliITSgeomTGeo::GetModuleIndex(3, 1, 1);
+      idx1 = AliITSgeomTGeo::GetModuleIndex(5, 1, 1) - 1;
       break;
     case 2:
-      idx0 = fGeom->GetLastSDD()+1;
-      idx1 = fGeom->GetLastSSD();
+      idx0 = AliITSgeomTGeo::GetModuleIndex(5, 1, 1);
+      idx1 = AliITSgeomTGeo::GetNModules() - 1;
       break;
     default:
       idx1 = 0;
-      idx1 = fGeom->GetLastSSD();
+      idx1 = AliITSgeomTGeo::GetNModules() - 1;
       break;
   }
 
-  TVector3 v;
-  Double_t x[9];
-  Int_t lay, lad, det;
+  TVector3  v;
   TEveTrans mx;
-  for (Int_t id = idx0; id<idx1; ++id)
+  Int_t     lay, lad, det;
+  for (Int_t id = idx0; id < idx1; ++id)
   {
-    fGeom->GetModuleId(id, lay, lad, det);
+    AliITSgeomTGeo::GetModuleId(id, lay, lad, det);
     if (sel->GetLayer() == lay || sel->GetLayer() == -1)
     {
       // check data from matrix
-      mx.UnitTrans();
-      fGeom->GetRotMatrix(id, x);
-      mx.SetBaseVec(1, x[0], x[3], x[6]);
-      mx.SetBaseVec(2, x[1], x[4], x[7]);
-      mx.SetBaseVec(3, x[2], x[5], x[8]);
-      fGeom->GetTrans(id, x);
-      mx.SetBaseVec(4, x);
+      mx.SetFrom(*AliITSgeomTGeo::GetMatrix(id));
       mx.GetPos(v);
       if (v.Phi()   <= sel->GetMaxPhi()   && v.Phi()   >= sel->GetMinPhi()   &&
          v.Theta() <= sel->GetMaxTheta() && v.Theta() >= sel->GetMinTheta())
@@ -415,7 +457,9 @@ void AliEveITSDigitsInfo::Print(Option_t* ) const
 
   printf("*********************************************************\n");
   printf("SPD module dimension (%f,%f)\n",           fSegSPD->Dx()*0.0001, fSegSPD->Dz()*0.0001);
-  printf("SPD first,last module:: %d,%d\n",          fGeom->GetStartSPD(), fGeom->GetLastSPD() );
+  printf("SPD first,last module: %d, %d\n",
+        AliITSgeomTGeo::GetModuleIndex(1,1,1), 
+        AliITSgeomTGeo::GetModuleIndex(3,1,1) - 1);
   printf("SPD num cells per module (x::%d,z::%d)\n", fSegSPD->Npx(), fSegSPD->Npz());
   Int_t iz = 0, ix = 0;
   printf("SPD dimesion of (%d,%d) in pixel(%f,%f)\n",   ix, iz, fSegSPD->Dpx(ix), fSegSPD->Dpz(iz));
@@ -424,14 +468,18 @@ void AliEveITSDigitsInfo::Print(Option_t* ) const
 
   printf("*********************************************************\n");
   printf("SDD module dimension (%f,%f)\n",           fSegSDD->Dx()*0.0001, fSegSDD->Dz()*0.0001);
-  printf("SDD first,last module:: %d,%d\n",          fGeom->GetStartSDD(), fGeom->GetLastSDD());
+  printf("SDD first,last module: %d, %d\n",
+        AliITSgeomTGeo::GetModuleIndex(3,1,1),
+        AliITSgeomTGeo::GetModuleIndex(5,1,1) - 1);
   printf("SDD num cells per module (x::%d,z::%d)\n", fSegSDD->Npx(), fSegSDD->Npz());
   printf("SDD dimesion of pixel are (%f,%f)\n",      fSegSDD->Dpx(1)*0.001, fSegSDD->Dpz(1)*0.001);
 
   Float_t ap, an;
   printf("*********************************************************\n");
   printf("SSD module dimension (%f,%f)\n",  fSegSSD->Dx()*0.0001, fSegSSD->Dz()*0.0001);
-  printf("SSD first,last module:: %d,%d\n", fGeom->GetStartSSD(), fGeom->GetLastSSD() );
+  printf("SSD first, last module: %d, %d\n",
+        AliITSgeomTGeo::GetModuleIndex(5,1,1),
+        AliITSgeomTGeo::GetNModules() - 1);
   printf("SSD strips in module %d\n",       fSegSSD->Npx());
   printf("SSD strip sizes are (%f,%f)\n",   fSegSSD->Dpx(1), fSegSSD->Dpz(1));
   fSegSSD->SetLayer(5);  fSegSSD->Angles(ap,an);