]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSvSPD02.cxx
MC-dependent part of AliRun extracted in AliMC (F.Carminati)
[u/mrichter/AliRoot.git] / ITS / AliITSvSPD02.cxx
index 9ee2a57287c03867298b1ab8ab708f4cce234fb7..583207e73bae522289d2c8a3ec4397c72fa2500f 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.1  2002/12/05 20:07:25  nilsen
-Adding new SPD 2002 test-beam geometry, with Config file (setup for testing,
-50 pions in one event and not 50 events with one pion).
+/* $Id$ */
 
-*/
 #include <Riostream.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -51,18 +46,19 @@ Adding new SPD 2002 test-beam geometry, with Config file (setup for testing,
 #include "AliITSgeomSDD.h"
 #include "AliITSgeomSSD.h"
 #include "AliITSDetType.h"
-#include "AliITSresponseSPD.h"
+#include "AliITSresponseSPDdubna.h"
 #include "AliITSresponseSDD.h"
 #include "AliITSresponseSSD.h"
 #include "AliITSsegmentationSPD.h"
 #include "AliITSsegmentationSDD.h"
 #include "AliITSsegmentationSSD.h"
-#include "AliITSsimulationSPD.h"
+#include "AliITSsimulationSPDdubna.h"
 #include "AliITSsimulationSDD.h"
 #include "AliITSsimulationSSD.h"
 #include "AliITSClusterFinderSPD.h"
 #include "AliITSClusterFinderSDD.h"
 #include "AliITSClusterFinderSSD.h"
+#include "AliMC.h"
 
 
 ClassImp(AliITSvSPD02)
@@ -127,7 +123,7 @@ AliITSvSPD02::AliITSvSPD02(const char *title) : AliITS("ITS", title){
     strncpy(fWrite,fEuclidGeomDet,60);
 }
 //______________________________________________________________________
-AliITSvSPD02::AliITSvSPD02(const AliITSvSPD02 &source){
+AliITSvSPD02::AliITSvSPD02(const AliITSvSPD02 &source) : AliITS(source){
     ////////////////////////////////////////////////////////////////////////
     //     Copy Constructor for ITS SPD test beam 2002 version 1.
     // This class is not to be copied. Function only dummy.
@@ -479,23 +475,24 @@ void AliITSvSPD02::InitAliITSgeom(){
        return;
     } // end if
     cout << "Reading Geometry transformation directly from Geant 3." << endl;
-    const Int_t nlayers = 2;
+    const Int_t ltypess = 2;
+    const Int_t nlayers = 5;
     const Int_t ndeep = 5;
-    Int_t itsGeomTreeNames[nlayers][ndeep],lnam[20],lnum[20];
+    Int_t itsGeomTreeNames[ltypess][ndeep],lnam[20],lnum[20];
     Int_t nlad[nlayers],ndet[nlayers];
     Double_t t[3],r[10];
     Float_t  par[20],att[20];
     Int_t    npar,natt,idshape,imat,imed;
     AliITSGeant3Geometry *ig = new AliITSGeant3Geometry();
-    Int_t mod,lay,lad,det,i,j,k;
-    Char_t names[nlayers][ndeep][4];
-    Int_t itsGeomTreeCopys[nlayers][ndeep];
-    Char_t *namesA[nlayers][ndeep] = {
+    Int_t mod,typ,lay,lad,det,cpy,i,j,k;
+    Char_t names[ltypess][ndeep][4];
+    Int_t itsGeomTreeCopys[ltypess][ndeep];
+    Char_t *namesA[ltypess][ndeep] = {
      {"ALIC","ITSV","ITEL","IMB0","IMBS"}, // lay=1
      {"ALIC","ITSV","IDET","ITS0","ITST"}};// Test SPD
-    Int_t itsGeomTreeCopysA[nlayers][ndeep]= {{1,1,4,1,1},// lay=1
+    Int_t itsGeomTreeCopysA[ltypess][ndeep]= {{1,1,4,1,1},// lay=1
                                              {1,1,1,1,1}};//lay=2 TestSPD
-    for(i=0;i<nlayers;i++)for(j=0;j<ndeep;j++){
+    for(i=0;i<ltypess;i++)for(j=0;j<ndeep;j++){
        for(k=0;k<4;k++) names[i][j][k] = namesA[i][j][k];
        itsGeomTreeCopys[i][j] = itsGeomTreeCopysA[i][j];
     } // end for i,j
@@ -504,47 +501,33 @@ void AliITSvSPD02::InitAliITSgeom(){
     // tree its self.
     cout << "Reading Geometry informaton from Geant3 common blocks" << endl;
     for(i=0;i<20;i++) lnam[i] = lnum[i] = 0;
-    for(i=0;i<nlayers;i++)for(j=0;j<ndeep;j++) 
-       itsGeomTreeNames[i][j] = ig->StringToInt(names[i][j]);
-    mod = 0;
-    for(i=0;i<nlayers;i++){
-       k = 1;
-       for(j=0;j<ndeep;j++) if(itsGeomTreeCopys[i][j]!=0)
-           k *= TMath::Abs(itsGeomTreeCopys[i][j]);
-       mod += k;
-    } // end for i
-
+    for(i=0;i<ltypess;i++)for(j=0;j<ndeep;j++) 
+        strncpy((char*) &itsGeomTreeNames[i][j],names[i][j],4);
+    // itsGeomTreeNames[i][j] = ig->StringToInt(names[i][j]);
+    mod = 5;
     if(fITSgeom!=0) delete fITSgeom;
-    nlad[0]=20;nlad[1]=40;nlad[2]=14;nlad[3]=22;nlad[4]=34;nlad[5]=38;
-    ndet[0]=4;ndet[1]=4;ndet[2]=6;ndet[3]=8;ndet[4]=22;ndet[5]=25;
-    fITSgeom = new AliITSgeom(0,6,nlad,ndet,mod);
-    mod = -1;
-    for(lay=1;lay<=nlayers;lay++){
-       for(j=0;j<ndeep;j++) lnam[j] = itsGeomTreeNames[lay-1][j];
-       for(j=0;j<ndeep;j++) lnum[j] = itsGeomTreeCopys[lay-1][j];
-       switch (lay){
-       case 1: case 2: // layers 1 and 2 are a bit special
-           lad = 0;
-           for(j=1;j<=itsGeomTreeCopys[lay-1][4];j++){
-               lnum[4] = j;
-               for(k=1;k<=itsGeomTreeCopys[lay-1][5];k++){
-                   lad++;
-                   lnum[5] = k;
-                   for(det=1;det<=itsGeomTreeCopys[lay-1][6];det++){
-                       lnum[6] = det;
-                       mod++;
-                       ig->GetGeometry(ndeep,lnam,lnum,t,r,idshape,npar,natt,
-                                       par,att,imat,imed);
-                       fITSgeom->CreatMatrix(mod,lay,lad,det,kSPD,t,r);
-                       if(!(fITSgeom->IsShapeDefined((Int_t)kSPD)))
-                             fITSgeom->ReSetShape(kSPD,
-                                         new AliITSgeomSPD425Short(npar,par));
-                   } // end for det
-               } // end for k
-            } // end for j
-           break;
-       } // end switch
-    } // end for lay
+    nlad[0]=1;nlad[1]=1;nlad[2]=1;nlad[3]=1;nlad[4]=1;
+    ndet[0]=1;ndet[1]=1;ndet[2]=1;ndet[3]=1;ndet[4]=1;
+    fITSgeom = new AliITSgeom(0,nlayers,nlad,ndet,mod);
+    for(typ=1;typ<=ltypess;typ++){
+       for(j=0;j<ndeep;j++) lnam[j] = itsGeomTreeNames[typ-1][j];
+       for(j=0;j<ndeep;j++) lnum[j] = itsGeomTreeCopys[typ-1][j];
+       lad = 1;
+       det = 1;
+       for(cpy=1;cpy<=itsGeomTreeCopys[typ-1][2];cpy++){
+           lnum[2] = cpy;
+           lay = cpy;
+           if(cpy>2 && typ==1) lay = cpy +1;
+           if(typ==2) lay = 3;
+           mod = lay-1;
+           ig->GetGeometry(ndeep,lnam,lnum,t,r,idshape,npar,natt,par,att,
+                           imat,imed);
+           fITSgeom->CreatMatrix(mod,lay,lad,det,kSPD,t,r);
+           if(!(fITSgeom->IsShapeDefined((Int_t)kSPD)))
+               fITSgeom->ReSetShape(kSPD,
+                                    new AliITSgeomSPD425Short(npar,par));
+       } // end for cpy
+    } // end for typ
     return;
 }
 //______________________________________________________________________
@@ -598,8 +581,12 @@ void AliITSvSPD02::SetDefaults(){
 
     //SPD
     iDetType=DetType(kSPD);
-    s0 = (AliITSgeomSPD*) fITSgeom->GetShape(kSPD);// Get shape info. Do it this way for now.
-    AliITSresponse *resp0=new AliITSresponseSPD();
+    // Get shape info. Do it this way for now.
+    s0 = (AliITSgeomSPD*) fITSgeom->GetShape(kSPD);
+    AliITSresponse *resp0=new AliITSresponseSPDdubna();
+    ((AliITSresponseSPDdubna*)resp0)->SetNoiseParam();
+    resp0->SetTemperature();
+    resp0->SetDistanceOverVoltage();
     SetResponseModel(kSPD,resp0);
     AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
     seg0->SetDetSize(s0->GetDx()*2.*kconv, // base this on AliITSgeomSPD
@@ -624,6 +611,14 @@ void AliITSvSPD02::SetDefaults(){
 //    SetSimulationModel(kSPD,new AliITSsimulationSPD(seg0,resp0));
 //    iDetType->ReconstructionModel(new AliITSClusterFinderSPD());
 
+    SetResponseModel(kSDD,new AliITSresponseSDD());
+    SetSegmentationModel(kSDD,new AliITSsegmentationSDD());
+    DetType(kSDD)->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
+
+    SetResponseModel(kSSD,new AliITSresponseSSD());
+    SetSegmentationModel(kSSD,new AliITSsegmentationSSD());
+    DetType(kSSD)->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
+
     if(kNTYPES>3){
        Warning("SetDefaults",
                "Only the four basic detector types are initialised!");
@@ -631,6 +626,70 @@ void AliITSvSPD02::SetDefaults(){
     return;
 }
 //______________________________________________________________________
+void AliITSvSPD02::SetDefaultSimulation(){
+    // sets the default simulation.
+    // Inputs:
+    //      none.
+    // Outputs:
+    //      none.
+    // Return:
+    //      none.
+
+    AliITSDetType *iDetType;
+    AliITSsimulation *sim;
+    iDetType=DetType(0);
+    sim = iDetType->GetSimulationModel();
+    if (!sim) {
+        AliITSsegmentation *seg0=
+            (AliITSsegmentation*)iDetType->GetSegmentationModel();
+        AliITSresponse *res0 = (AliITSresponse*)iDetType->GetResponseModel();
+        AliITSsimulationSPDdubna *sim0=new AliITSsimulationSPDdubna(seg0,res0);
+        SetSimulationModel(0,sim0);
+    }else{ // simulation exists, make sure it is set up properly.
+        ((AliITSsimulationSPDdubna*)sim)->Init(
+            (AliITSsegmentationSPD*) iDetType->GetSegmentationModel(),
+            (AliITSresponseSPDdubna*) iDetType->GetResponseModel());
+//        if(sim->GetResponseModel()==0) sim->SetResponseModel(
+//            (AliITSresponse*)iDetType->GetResponseModel());
+//        if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
+//            (AliITSsegmentation*)iDetType->GetSegmentationModel());
+    } // end if
+    iDetType=DetType(1);
+    sim = iDetType->GetSimulationModel();
+    if (!sim) {
+        AliITSsegmentation *seg1=
+            (AliITSsegmentation*)iDetType->GetSegmentationModel();
+        AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
+        AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
+        SetSimulationModel(1,sim1);
+    }else{ // simulation exists, make sure it is set up properly.
+        ((AliITSsimulationSDD*)sim)->Init(
+            (AliITSsegmentationSDD*) iDetType->GetSegmentationModel(),
+            (AliITSresponseSDD*) iDetType->GetResponseModel());
+//        if(sim->GetResponseModel()==0) sim->SetResponseModel(
+//            (AliITSresponse*)iDetType->GetResponseModel());
+//        if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
+//            (AliITSsegmentation*)iDetType->GetSegmentationModel());
+    } //end if
+    iDetType=DetType(2);
+    sim = iDetType->GetSimulationModel();
+    if (!sim) {
+        AliITSsegmentation *seg2=
+            (AliITSsegmentation*)iDetType->GetSegmentationModel();
+        AliITSresponse *res2 = (AliITSresponse*)iDetType->GetResponseModel();
+        AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
+        SetSimulationModel(2,sim2);
+    }else{ // simulation exists, make sure it is set up properly.
+        ((AliITSsimulationSSD*)sim)->Init(
+            (AliITSsegmentationSSD*) iDetType->GetSegmentationModel(),
+            (AliITSresponseSSD*) iDetType->GetResponseModel());
+//        if(sim->GetResponseModel()==0) sim->SetResponseModel(
+//            (AliITSresponse*)iDetType->GetResponseModel());
+//        if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
+//            (AliITSsegmentation*)iDetType->GetSegmentationModel());
+    } // end if
+}
+//______________________________________________________________________
 void AliITSvSPD02::DrawModule(){
     ////////////////////////////////////////////////////////////////////////
     //     Draw a shaded view of the ITS SPD test beam version 1.
@@ -687,7 +746,7 @@ void AliITSvSPD02::StepManager(){
        copy = fTrackReferences->GetEntriesFast();
        TClonesArray &lTR = *fTrackReferences;
        // Fill TrackReference structure with this new TrackReference.
-       new(lTR[copy]) AliTrackReference(gAlice->CurrentTrack(),gMC);
+       new(lTR[copy]) AliTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
     } // if Outer ITS mother Volume
     if(!(this->IsActive())){
        return;
@@ -709,17 +768,18 @@ void AliITSvSPD02::StepManager(){
     // Fill hit structure.
     if(!(gMC->TrackCharge())) return;
     id = gMC->CurrentVolID(copy);
-    if(id==fIdSens[0]){
-       vol[0] = vol[1] = 1; // Layer, ladder
+    if(id==fIdSens[0]){  // Volume name "IMBS"
+       vol[2] = vol[1] = 1; // Det, ladder
        id = gMC->CurrentVolOffID(2,copy);
        //detector copy in the ladder = 1<->4  (ITS1 < I101 < I103 < I10A)
-       vol[2] = copy; // detector
-    } else if(id == fIdSens[1]){
-       vol[0] = 1; // layer
-       vol[1] = 2; // ladder
+       vol[0] = copy; // Lay
+       if(copy>2) vol[0]++;
+    } else if(id == fIdSens[1]){ // Volume name "ITST"
+       vol[0] = 3; // layer
+       vol[1] = 1; // ladder
        id = gMC->CurrentVolOffID(2,copy);
        //detector copy in the ladder = 1<->4  (ITS2 < I1D1 < I1D3 < I20A)
-       vol[2] = copy;  // detector
+       vol[2] = 1;  // detector
     } else return; // end if
     //
     gMC->TrackPosition(position);
@@ -728,9 +788,10 @@ void AliITSvSPD02::StepManager(){
     if(gMC->IsTrackEntering()){
        position0 = position;
        stat0 = vol[3];
+       return;
     } // end if IsEntering
     // Fill hit structure with this new hit only for non-entrerance hits.
-    else new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->CurrentTrack(),vol,
+    else new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,
                                        gMC->Edep(),gMC->TrackTime(),position,
                                        position0,momentum);
     //