]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUON.cxx
New digits structure, cathode planes are mixed in the same list (Christian)
[u/mrichter/AliRoot.git] / MUON / AliMUON.cxx
index 4b1d250619898a090c49eaf9379783b03fab2a53..4587d071c1abc525c066fde18024ac74f54e8e76 100644 (file)
 #include <TVector.h>
 #include <TVirtualMC.h>
 
-#include "AliConst.h" 
-#include "AliHeader.h"
-#include "AliHitMap.h"
+//#include "AliHeader.h"
 #include "AliLoader.h"
 #include "AliRunDigitizer.h"
 #include "AliMC.h"
 #include "AliRun.h"    
-#include "AliMUONLoader.h"
 #include "AliMUON.h"
 #include "AliMUONChamberTrigger.h"
 #include "AliMUONConstants.h"
-#include "AliMUONDigit.h"
-#include "AliMUONHit.h"
-#include "AliMUONHitMapA1.h"
-#include "AliMUONMerger.h"     
-#include "AliMUONPadHit.h"
+#include "AliMUONHit.h"        
 #include "AliMUONRawCluster.h"
 #include "AliMUONTransientDigit.h"
 #include "AliMUONTriggerCircuit.h"
+#include "AliMUONGeometryBuilder.h"
+#include "AliMUONCommonGeometryBuilder.h"
 #include "AliMUONVGeometryBuilder.h"   
+#include "AliMUONGeometryDEIndexing.h" 
+#include "AliMUONGeometrySegmentation.h"
 #include "AliMUONDigitizerv2.h"
 #include "AliMUONSDigitizerv1.h"
-
+#include "AliMUONRawData.h"
+#include "AliMUONFactoryV2.h"
+#include "AliLog.h"
 
 // Defaults parameters for Z positions of chambers
 // taken from values for "stations" in AliMUON::AliMUON
@@ -93,8 +92,10 @@ AliMUON::AliMUON()
     fMUONData(0),
     fSplitLevel(0),
     fChambers(0),
-    fGeometryBuilders(0),
     fTriggerCircuits(0),
+    fGeometryBuilder(0),
+    fSegmentationType(2),// set to 2 default wise new seg
+    fDEIndexing(0),
     fAccCut(kFALSE),
     fAccMin(0.),
     fAccMax(0.),   
@@ -104,7 +105,7 @@ AliMUON::AliMUON()
     fMaxDestepAlu(0.),
     fMaxIterPad(0),
     fCurIterPad(0),
-    fMerger(0)
+    fFactory(0)
 {
 // Default Constructor
 //
@@ -119,8 +120,10 @@ AliMUON::AliMUON(const char *name, const char *title)
     fMUONData(0),
     fSplitLevel(0),
     fChambers(0),
-    fGeometryBuilders(0),
     fTriggerCircuits(0),
+    fGeometryBuilder(0),
+    fSegmentationType(2),// set to 2 default wise new seg
+    fDEIndexing(0),
     fAccCut(kFALSE),
     fAccMin(0.),
     fAccMax(0.),   
@@ -130,22 +133,35 @@ AliMUON::AliMUON(const char *name, const char *title)
     fMaxDestepAlu(-1), // in the calculation of the tracking parameters
     fMaxIterPad(0),
     fCurIterPad(0),
-    fMerger(0)
+    fFactory(0)
 {
-//Begin_Html
-/*
-<img src="gif/alimuon.gif">
-*/
-//End_Html
 
   fIshunt =  0;
 
   SetMarkerColor(kRed);//
+    
+  // Geometry builder
+  fGeometryBuilder = new AliMUONGeometryBuilder(this);
+  
+  // Common geometry definitions
+  fGeometryBuilder
+    ->AddBuilder(new AliMUONCommonGeometryBuilder(this));
+
+  // Define the global transformation:
+  // Transformation from the old ALICE coordinate system to a new one:
+  // x->-x, z->-z 
+  TGeoRotation* rotGlobal 
+    = new TGeoRotation("rotGlobal", 90., 180., 90., 90., 180., 0.);
+  fGeometryBuilder
+    ->SetGlobalTransformation (TGeoCombiTrans(0., 0., 0., rotGlobal));
+
+  // Detection elements indexing
+  fDEIndexing = new AliMUONGeometryDEIndexing();
+
 //
 // Creating List of Chambers
     Int_t ch;
     fChambers = new TObjArray(AliMUONConstants::NCh());
-    fGeometryBuilders = new TObjArray(AliMUONConstants::NCh());
 
     // Loop over stations
     for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
@@ -167,8 +183,8 @@ AliMUON::AliMUON(const char *name, const char *title)
        //
        chamber->InitGeo(AliMUONConstants::DefaultChamberZ(ch));
        //          Set chamber inner and outer radius to default
-       chamber->SetRInner(AliMUONConstants::Dmin(st)/2);
-       chamber->SetROuter(AliMUONConstants::Dmax(st)/2);
+       chamber->SetRInner(AliMUONConstants::Dmin(st)/2.);
+       chamber->SetROuter(AliMUONConstants::Dmax(st)/2.);
        //
       } // Chamber stCH (0, 1) in 
     }     // Station st (0...)
@@ -186,21 +202,16 @@ AliMUON::AliMUON(const AliMUON& rMUON)
 {
 // Protected copy constructor
 
-  Fatal("AliMUONMergerModule", "Not implemented.");
+  AliFatal("Not implemented.");
 }
 
 //____________________________________________________________________
 AliMUON::~AliMUON()
 {
 // Destructor
-  if(fDebug) printf("%s: Calling AliMUON destructor !!!\n",ClassName());
+  AliDebug(1,"Calling AliMUON destructor");
   fIshunt  = 0;
-  if (fMerger) delete fMerger;
 
-  if (fGeometryBuilders){
-    fGeometryBuilders->Delete();
-    delete fGeometryBuilders;
-  }
   if (fChambers){
     fChambers->Delete();
     delete fChambers;
@@ -210,6 +221,9 @@ AliMUON::~AliMUON()
     delete fTriggerCircuits;
   }
   delete fMUONData;
+  delete fGeometryBuilder;
+  delete fDEIndexing;
+  delete fFactory; 
 }
 
 //________________________________________________________________________
@@ -219,7 +233,7 @@ AliMUON& AliMUON::operator = (const AliMUON& rhs)
 
   if (this == &rhs) return *this;
 
-  Fatal("operator=", "Not implemented.");
+  AliFatal("Not implemented.");
     
   return *this;  
 }
@@ -230,19 +244,26 @@ void AliMUON::AddGeometryBuilder(AliMUONVGeometryBuilder* geomBuilder)
 // Adds the geometry builder to the list
 // ---
 
-  fGeometryBuilders->Add(geomBuilder);
+  fGeometryBuilder->AddBuilder(geomBuilder);
 }
+
 //____________________________________________________________________
 void AliMUON::BuildGeometry()
 {
 // Geometry for event display
-//   for (Int_t i=0; i<7; i++) {
-//     for (Int_t j=0; j<2; j++) {
-//       Int_t id=2*i+j+1;
-//       this->Chamber(id-1).SegmentationModel(1)->Draw("eventdisplay");
-//     }
-//   }
+
+  if (!fSegmentationType) {
+    AliFatal("No Segmentation Type defined.");
+    return;
+  }
+
+
+//     for (Int_t i = 0; i < AliMUONConstants::NCh(); i++)     
+//       this->Chamber(i).SegmentationModel2(1)->Draw("eventdisplay");// to be check !
+     
+  
 }
+
 //__________________________________________________________________
 void  AliMUON::SetTreeAddress()
 {
@@ -260,15 +281,6 @@ void  AliMUON::SetTreeAddress()
   fHits = GetMUONData()->Hits(); // Added by Ivana to use the methods FisrtHit, NextHit of AliDetector    
 }
 
-//____________________________________________________________________
-void AliMUON::SetPadSize(Int_t id, Int_t isec, Float_t p1, Float_t p2)
-{
-// Set the pad size for chamber id and cathode isec
-    Int_t i=2*(id-1);
-    ((AliMUONChamber*) fChambers->At(i))  ->SetPadSize(isec,p1,p2);
-    ((AliMUONChamber*) fChambers->At(i+1))->SetPadSize(isec,p1,p2);
-}
-
 //___________________________________________
 void AliMUON::SetChambersZ(const Float_t *Z)
 {
@@ -320,6 +332,7 @@ void AliMUON::SetMaxAdc(Int_t id, Int_t p1)
     ((AliMUONChamber*) fChambers->At(i))->SetMaxAdc(p1);
     ((AliMUONChamber*) fChambers->At(i+1))->SetMaxAdc(p1);
 }
+
 //__________________________________________________________________
 void AliMUON::SetMaxStepGas(Float_t p1)
 {
@@ -344,26 +357,6 @@ void AliMUON::SetMaxDestepAlu(Float_t p1)
 // Set maximum step size in Alu
   fMaxDestepAlu=p1;
 }
-//___________________________________________________________________
-void AliMUON::SetAcceptance(Bool_t acc, Float_t angmin, Float_t angmax)
-{
-// Set acceptance cuts 
-  fAccCut=acc;
-  fAccMin=angmin*TMath::Pi()/180;
-  fAccMax=angmax*TMath::Pi()/180;
-  Int_t ch;
-  if (acc) {
-    for (Int_t st = 0; st < AliMUONConstants::NCh() / 2; st++) {
-      // Loop over 2 chambers in the station
-      for (Int_t stCH = 0; stCH < 2; stCH++) {
-       ch = 2 * st + stCH;
-       //         Set chamber inner and outer radius according to acceptance cuts
-       Chamber(ch).SetRInner(TMath::Abs(AliMUONConstants::DefaultChamberZ(ch)*TMath::Tan(fAccMin)));
-       Chamber(ch).SetROuter(TMath::Abs(AliMUONConstants::DefaultChamberZ(ch)*TMath::Tan(fAccMax)));
-      } // chamber loop
-    } // station loop
-  }
-}
 
 //____________________________________________________________________
 Float_t  AliMUON::GetMaxStepGas() const
@@ -396,8 +389,17 @@ Float_t  AliMUON::GetMaxDestepAlu() const
   
   return fMaxDestepAlu;
 }
+
+//____________________________________________________________________
+ void  AliMUON::SetAlign(Bool_t align)
+{
+ // Sets option for alignement to geometry builder
+   fGeometryBuilder->SetAlign(align);
+}   
+    
 //____________________________________________________________________
-void   AliMUON::SetSegmentationModel(Int_t id, Int_t isec, AliSegmentation *segmentation)
+void   AliMUON::SetSegmentationModel(Int_t id, Int_t isec, AliMUONGeometrySegmentation*  segmentation)
 {
 // Set the segmentation for chamber id cathode isec
     ((AliMUONChamber*) fChambers->At(id))->SetSegmentationModel(isec, segmentation);
@@ -426,15 +428,6 @@ void AliMUON::SDigits2Digits()
 
 // write TreeD here 
 
-    if (!fMerger) {
-      if (gAlice->GetDebug()>0) {
-       cerr<<"AliMUON::SDigits2Digits: create default AliMUONMerger "<<endl;
-       cerr<<" no merging, just digitization of 1 event will be done"<<endl;
-      }
-      fMerger = new AliMUONMerger();
-    }
-    fMerger->Init();
-    fMerger->Digitise();
     char hname[30];
     //    sprintf(hname,"TreeD%d",fLoader->GetHeader()->GetEvent());
     fLoader->TreeD()->Write(hname,TObject::kOverwrite);
@@ -456,51 +449,32 @@ void AliMUON::Hits2SDigits()
   }
   fLoader->UnloadHits();
 }
+//_____________________________________________________________________
+void AliMUON::Digits2Raw()
+{
+  // convert digits of the current event to raw data
+  AliMUONRawData* rawData;
+
+  rawData = new AliMUONRawData(fLoader);
+  if (!rawData->WriteRawData()) AliInfo("pb writting raw data");
+  delete rawData;
+  return;
+}
 //_______________________________________________________________________
 AliLoader* AliMUON::MakeLoader(const char* topfoldername)
 { 
 //builds standard getter (AliLoader type)
 //if detector wants to use castomized getter, it must overload this method
 
- if (GetDebug())
-   Info("MakeLoader",
-        "Creating standard getter for detector %s. Top folder is %s.",
-         GetName(),topfoldername);
+ AliDebug(1,Form("Creating standard getter for detector %s. Top folder is %s.",
+         GetName(),topfoldername));
  fLoader   = new AliLoader(GetName(),topfoldername);
  fMUONData = new AliMUONData(fLoader,GetName(),GetName()); 
  fMUONData->SetSplitLevel(fSplitLevel);
  return fLoader;
 }
 //_______________________________________________________________________
-AliMUONPadHit* AliMUON::FirstPad(AliMUONHit*  hit, TClonesArray *clusters) 
-{
-// to be removed
-    // Initialise the pad iterator
-    // Return the address of the first padhit for hit
-    TClonesArray *theClusters = clusters;
-    Int_t nclust = theClusters->GetEntriesFast();
-    if (nclust && hit->PHlast() > 0) {
-       fMaxIterPad=hit->PHlast();
-       fCurIterPad=hit->PHfirst();
-       return (AliMUONPadHit*) clusters->UncheckedAt(fCurIterPad-1);
-    } else {
-       return 0;
-    }
-}
-//_______________________________________________________________________
-AliMUONPadHit* AliMUON::NextPad(TClonesArray *clusters) 
-{
-  // To be removed
-// Get next pad (in iterator) 
-//
-    fCurIterPad++;
-    if (fCurIterPad <= fMaxIterPad) {
-       return (AliMUONPadHit*) clusters->UncheckedAt(fCurIterPad-1);
-    } else {
-       return 0;
-    }
-}
-//_______________________________________________________________________
 
 AliMUONRawCluster *AliMUON::RawCluster(Int_t ichamber, Int_t icathod, Int_t icluster)
 {
@@ -521,41 +495,4 @@ AliMUONRawCluster *AliMUON::RawCluster(Int_t ichamber, Int_t icathod, Int_t iclu
     return  mRaw;
 }
 //________________________________________________________________________
-void   AliMUON::SetMerger(AliMUONMerger* merger)
-{
-// Set pointer to merger 
-    fMerger = merger;
-}
-//________________________________________________________________________
-AliMUONMerger*  AliMUON::Merger()
-{
-// Return pointer to merger
-    return fMerger;
-}
-//________________________________________________________________________
-void AliMUON::RemapTrackHitIDs(Int_t* map)
-{
-// Remaps the track numbers in the hits arrays, so that they correspond
-// to the entry indices in the Kine tree.
-// The correspondance is not direct. To get the real index into the Kine tree
-// compute the particle index as follows:
-//
-//   num_primaries = AliStack::GetNprimary();
-//   num_tracks = AliStack::GetNtracks();
-//   track = AliMUONHit::Track()
-//
-//   if (track < num_primaries)
-//       particleindex = track + num_tracks - num_primaries;
-//   else
-//       particleindex = track - num_primaries;
-       
-       // Remap the track numbers based on the specified map.
-       AliMUONData* data = GetMUONData();
-       TClonesArray* hits = data->Hits();
-       for (Int_t i = 0; i < hits->GetEntriesFast(); i++)
-       {
-               AliMUONHit* hit = static_cast<AliMUONHit*>( hits->At(i) );
-               hit->SetTrack( map[hit->Track()] );
-       };
-};