LCOV - code coverage report
Current view: top level - ACORDE/ACORDEsim - AliACORDE.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 64 101 63.4 %
Date: 2016-06-14 17:26:59 Functions: 9 15 60.0 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : /* $Id$ */
      17             : 
      18             : ///////////////////////////////////////////////////////////////////////////////
      19             : //                                                                           //
      20             : //  Cosmic Rays ALICE Trigger                                                //
      21             : //  This class contains the basic functions for the Cosmic Ray ALICE         //
      22             : //  detector. Functions specific to one particular geometry are              //
      23             : //  contained in the derived classes                                         //
      24             : //
      25             : // Begin_Html
      26             : /*
      27             : <img src="picts/AliACORDEClass.gif">
      28             : </pre>
      29             : <p>The responsible person for this module is
      30             : <a href="mailto:Enrique.Gamez.Flores@cern.ch">Enrique Gamez Flores</a>.
      31             : </font>
      32             : <pre>
      33             : */
      34             : //End_Html
      35             : //             
      36             : //
      37             : //                                                                           //
      38             : ///////////////////////////////////////////////////////////////////////////////
      39             : 
      40             : #include <TClonesArray.h>
      41             : #include <TGeoGlobalMagField.h>
      42             : #include <TGeoManager.h>
      43             : #include <TStopwatch.h>
      44             : #include <TTree.h>
      45             : #include <TVirtualMC.h>
      46             : 
      47             : #include "AliACORDE.h"
      48             : #include "AliMagF.h"
      49             : #include "AliRun.h"
      50             : #include "AliACORDERawData.h"
      51             : #include "AliACORDERawStream.h"
      52             : 
      53          12 : ClassImp(AliACORDE)
      54             : 
      55             : //_____________________________________________________________________________
      56             : AliACORDE::AliACORDE()
      57          12 :   : AliDetector(),
      58          12 :     fCreateCavern(0),
      59          12 :     f4CentralModulesGeometry(0)
      60          36 : {
      61             :   //
      62             :   // Default constructor
      63             :   //
      64          12 : }
      65             :  
      66             : //_____________________________________________________________________________
      67             : AliACORDE::AliACORDE(const char *name, const char *title)
      68           1 :   : AliDetector(name, title),
      69           1 :     fCreateCavern(kFALSE),
      70           1 :     f4CentralModulesGeometry(kTRUE)
      71             : 
      72           3 : {
      73             :   //
      74             :   // Standard constructor
      75           1 : }
      76             : 
      77             : //_____________________________________________________________________________
      78             : AliACORDE::~AliACORDE()
      79           0 : {
      80             :   //
      81             :   // Default destructor
      82             :   //
      83          26 : }
      84             : 
      85             : //_____________________________________________________________________________
      86             : void AliACORDE::CreateMaterials()
      87             : {
      88             :   // Magnatic field inside the pit
      89           2 :   Int_t   isxfld = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ();
      90           1 :   Float_t sxmgmx = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max();
      91             : 
      92             :   //Magnetic field above the Magnet.
      93             :   Int_t xfield = 0;   // no Magnetic field.
      94             :   Float_t xfieldm = 0;
      95             :   Float_t xepsil = 0.1; // Tracking precission in cm. obove the pit
      96             : 
      97             :   // --- Define the various materials for GEANT --- 
      98             :   Float_t epsil, stmin, tmaxfd, deemax, stemax;
      99             :   //
     100             :   //     Aluminum 
     101           1 :   AliMaterial(9,  "ALUMINIUM0$", 26.98, 13., 2.7, 8.9, 37.2);
     102             :   //  AliMaterial(29, "ALUMINIUM1$", 26.98, 13., 2.7, 8.9, 37.2);
     103             :   //AliMaterial(49, "ALUMINIUM2$", 26.98, 13., 2.7, 8.9, 37.2);
     104             :   //
     105             :   //     Iron 
     106             :   //AliMaterial(10, "IRON0$    ", 55.85, 26., 7.87, 1.76, 17.1);
     107             :   //AliMaterial(30, "IRON1$    ", 55.85, 26., 7.87, 1.76, 17.1);
     108             :   //AliMaterial(50, "IRON2$    ", 55.85, 26., 7.87, 1.76, 17.1);
     109             :   //
     110             :   //     Air 
     111           1 :   Float_t as[] = { 12.0107, 14.0067,   15.9994,  39.948 };
     112           1 :   Float_t zs[] = {  6.,      7.,       8.,       18. };
     113           1 :   Float_t ws[] = { 0.000124, 0.755267, 0.231781, 0.012827 }; 
     114             :   Double_t density      = .00120479;
     115           1 :   AliMixture(15, "AIR0$", as, zs, density, 4, ws);
     116             : 
     117             :   //AliMaterial(15, "AIR0$     ", 14.61, 7.3, .001205, 30423.24, 67500.);
     118             :   //AliMaterial(35, "AIR1$     ", 14.61, 7.3, .001205, 30423.24, 67500.);
     119             :   //AliMaterial(55, "AIR2$     ", 14.61, 7.3, .001205, 30423.24, 67500.);
     120             :   //AliMaterial(75, "AIR3$     ", 14.61, 7.3, .001205, 30423.24, 67500.);
     121             :   //AliMaterial(95, "AIR4$     ", 14.61, 7.3, .001205, 30423.24, 67500.);
     122             : 
     123             : 
     124             :   // Scintillator material polystyrene 
     125           1 :   Float_t aP[2] = {12.011, 1.00794};
     126           1 :   Float_t zP[2] = {6.0, 1.0};
     127           1 :   Float_t wP[2] = {1.0, 1.0};
     128             :   Float_t dP = 1.032;
     129           1 :   AliMixture(13, "Polystyrene$", aP, zP, dP, -2, wP);
     130             :   // Subalpine Molasse over the ALICE hall. 
     131           1 :   Float_t aMolasse[10] = { 1., 12.01, 15.994, 22.99, 24.305, 26.98, 28.086, 39.1, 40.08, 55.85 };
     132           1 :   Float_t zMolasse[10] = {1., 6., 8., 11., 12., 13., 14., 19., 20., 26.};
     133           1 :   Float_t wMolasse[10] = {0.008, 0.043, 0.485, 0.007, 0.042, 0.037, 0.215, 0.023, 0.1, 0.04};
     134             :   Float_t dMolasse = 2.40;
     135           1 :   AliMixture(24, "Molasse$", aMolasse, zMolasse, 2*dMolasse, 10, wMolasse); // correction to density of molasse alpine newDen=2*dmolasse
     136             : 
     137             :   // **************** 
     138             :   //     Defines tracking media parameters. 
     139             :   //     Les valeurs sont commentees pour laisser le defaut 
     140             :   //     a GEANT (version 3-21, page CONS200), f.m. 
     141             :   epsil  = .001;  // Tracking precision, Inside the pit
     142             :   stemax = -1.;   // Maximum displacement for multiple scattering 
     143             :   tmaxfd = -20.;  // Maximum angle due to field deflection 
     144             :   deemax = -.3;   // Maximum fractional energy loss, DLS 
     145             :   stmin  = -.8;
     146             :   // *************** 
     147             : 
     148             :   Float_t atmaxfd = 10.;
     149             :   Float_t adeemax = -0.1;
     150             :   Float_t aepsil = 0.1;
     151             :   Float_t astmin = -10.;
     152             : 
     153             :   //
     154             :   //    Aluminum 
     155           1 :   AliMedium(9,  "ALU_C0          ",  9, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
     156             :   // AliMedium(29, "ALU_C1          ", 29, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
     157             :   //AliMedium(49, "ALU_C2          ", 49, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
     158             :   //
     159             :   //    Iron 
     160             :   //AliMedium(10, "FE_C0           ", 10, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
     161             :   //AliMedium(30, "FE_C1           ", 30, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
     162             :   //AliMedium(50, "FE_C2           ", 50, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
     163             :   //
     164             :   //    Air 
     165           1 :   AliMedium(15, "AIR_C0          ", 15, 0, isxfld, sxmgmx, atmaxfd, stemax, adeemax, aepsil, astmin);
     166             :   // AliMedium(35, "AIR_C1          ", 35, 0, isxfld, sxmgmx, atmaxfd, stemax, adeemax, aepsil, astmin);
     167             :   //AliMedium(55, "AIR_C2          ", 55, 0, isxfld, sxmgmx, atmaxfd, stemax, adeemax, aepsil, astmin);
     168             :   //AliMedium(75, "AIR_C4          ", 75, 0, isxfld, sxmgmx, atmaxfd, stemax, adeemax, aepsil, astmin);
     169             :   //AliMedium(95, "AIR_C5          ", 95, 0, isxfld, sxmgmx, atmaxfd, stemax, adeemax, aepsil, astmin);
     170             : 
     171             : 
     172             : 
     173             :   // The scintillator of the CPV made of Polystyrene 
     174             :   // scintillator -> idtmed[1112]
     175             :   //AliMedium(12 , "CPV scint.0     ", 13, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
     176           1 :   AliMedium(13 , "CPV scint.1     ", 13, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
     177             :   //AliMedium(14 , "CPV scint.2     ", 13, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
     178             : 
     179             :   //     Molasse -> idtmed[1123]
     180           1 :   AliMedium(24 , "Molasse         ", 24, 0, xfield, xfieldm, tmaxfd, stemax, deemax, xepsil, stmin);
     181             : 
     182             :   // Concrete, in case if we need to put hte shafts by ourselves.
     183             : 
     184           1 :   Float_t aconc[10] = { 1.,12.01,15.994,22.99,24.305,26.98,28.086,39.1,40.08,55.85 };
     185           1 :   Float_t zconc[10] = { 1.,6.,8.,11.,12.,13.,14.,19.,20.,26. };
     186           1 :   Float_t wconc[10] = { .01,.001,.529107,.016,.002,.033872,.337021,.013,.044,.014 };
     187             : 
     188           1 :   AliMixture(17, "CONCRETE$", aconc, zconc, 2.35, 10, wconc);
     189             :   //    Concrete 
     190           1 :   AliMedium(17, "CC_C0            ", 17, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
     191             :   //  AliMedium(27, "CC_C1            ", 17, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin); // MX24
     192             :   //AliMedium(37, "CC_C2            ", 17, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin); // PM25
     193             :   //AliMedium(47, "CC_C3            ", 17, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin); // PGC2
     194             : 
     195           1 : }
     196             : 
     197             : //_____________________________________________________________________________
     198             : void AliACORDE::SetTreeAddress()
     199             : {
     200             : 
     201             :   TBranch *branch;
     202         298 :   char branchname[20];
     203         149 :   snprintf(branchname,19,"%s",GetName());
     204             :   // Branch address for hit tree
     205         149 :   TTree *treeH = fLoader->TreeH();
     206         149 :   if (treeH ) {
     207          24 :     branch = treeH->GetBranch(branchname);
     208          47 :     if (branch) branch->SetAddress(&fHits);
     209             :   }
     210         149 : }
     211             : 
     212             : //_____________________________________________________________________________
     213             : void AliACORDE::MakeBranch(Option_t* opt)
     214             : {
     215             :   //
     216             :   // Initializes the branches of the ACORDE inside the trees written
     217             :   // for each event.
     218             :   //
     219           0 :   const char* oH = strstr(opt, "H");
     220           0 :   if ( fLoader->TreeH() && oH && (fHits == 0x0) ) {
     221           0 :     fHits = new TClonesArray("AliACORDEhit", 1000);
     222           0 :     fNhits = 0;
     223           0 :   }
     224           0 :   AliDetector::MakeBranch(opt);
     225           0 : }
     226             : 
     227             : AliLoader* AliACORDE::MakeLoader(const char* topfoldername)
     228             : { 
     229             :  
     230           4 :   AliDebug(1,Form("Creating AliACORDELoader, Top folder is %s ",
     231             :                   topfoldername));
     232           3 :   fLoader = new AliACORDELoader(GetName(),topfoldername);
     233           1 :   return fLoader;
     234           0 : }
     235             : 
     236             : 
     237             : AliDigitizer* AliACORDE::CreateDigitizer(AliDigitizationInput* digInput) const
     238             : {
     239             :   //
     240             :   //
     241           3 :   return new AliACORDEDigitizer(digInput);
     242           0 : }
     243             : 
     244             : void AliACORDE::Digits2Raw()
     245             : {
     246             :   // Produce Raw data starting from digits
     247             :   // 1. Get digits
     248             :   // 2. From digits get an array with the state of the modules
     249             :   // 3. Unload digits
     250             :   // 4. Write raw data
     251             : 
     252             :   // 1. Get digits
     253             : 
     254             :   // 1.1 Get detector, load digits and set branch
     255           8 :   AliACORDE* acorde = (AliACORDE*)gAlice->GetDetector("ACORDE");
     256           4 :   fLoader->LoadDigits("READ");
     257           4 :   TTree* treeD = fLoader->TreeD();
     258           4 :   if (!treeD) {
     259           0 :     Error("Digits2Raw", "no digits tree");
     260           0 :     return;
     261             :   }
     262           8 :   TClonesArray *adigits = new TClonesArray ("AliACORDEdigit", 1000);
     263           4 :   treeD->GetBranch("ACORDEdigit")->SetAddress(&adigits);
     264             :   // 1.2 Get first entry (there is always only one)
     265           4 :   acorde->ResetDigits();
     266           4 :   treeD->GetEvent(0);
     267             :   
     268             :   // 2. From digits get an array with the state of the modules
     269             :   // 2.1 Define and initialize the array
     270           4 :   Bool_t Modules[60];
     271         488 :   for (Int_t i=0;i<60;i++) Modules[i]= kFALSE;
     272             :   // 2.2 Loop over all digits
     273           4 :   Int_t ndig = adigits->GetEntriesFast();
     274           8 :   for (Int_t idig=0;idig<ndig;idig++) {
     275             :     // 2.3 set the array entry for each digit
     276           0 :     AliACORDEdigit* digit = (AliACORDEdigit*) adigits->At(idig);
     277           0 :     Int_t mod = digit->GetModule();
     278           0 :     Modules[mod]=kTRUE;
     279             :   } 
     280             :   // 3. Unload digits
     281           4 :   fLoader->UnloadDigits();
     282             : 
     283             :   // 4. Write raw data
     284           4 :   AliACORDERawData rawdata;
     285           4 :   rawdata.WriteACORDERawData(Modules,(ndig > 1));
     286           8 : }
     287             : 
     288             : //_____________________________________________________________________________
     289             : Bool_t AliACORDE::Raw2SDigits(AliRawReader* rawReader)
     290             : {
     291             :   //
     292             :   // Reads the raw data stream and exracts the digits
     293             :   //
     294             :   // Input:
     295             :   //         rawReader : pointer to the current AliRawReader
     296             :   // Output:
     297             :   //
     298             :   // Created:      31 Jan 2008  Mario Sitta
     299             :   //
     300           0 :   TStopwatch timer;
     301           0 :   timer.Start();
     302             : 
     303           0 :   if(!fLoader) {
     304           0 :     AliError("no ACORDE loader found");
     305           0 :     return kFALSE;
     306             :   }
     307             : 
     308           0 :   TTree* treeD  = fLoader->TreeD();
     309           0 :   if(!treeD) {
     310           0 :       fLoader->MakeTree("D");
     311           0 :       treeD = fLoader->TreeD();
     312           0 :   }
     313             :         
     314           0 :   AliACORDEdigit  digit;
     315           0 :   AliACORDEdigit* pdigit = &digit;
     316             :   const Int_t kBufferSize = 4000;
     317             :    
     318           0 :   treeD->Branch("ACORDE", "AliACORDEdigit",  &pdigit, kBufferSize);
     319             : 
     320             :   //  rawReader->Reset();
     321           0 :   AliACORDERawStream* rawStream  = new AliACORDERawStream(rawReader);    
     322             :      
     323           0 :   if (!rawStream->Next()) return kFALSE; // No ACORDE data found
     324             :   /*  
     325             :   for(Int_t i=0; i<64; i++) {
     326             :       new(pdigit) AliACORDEdigit(i, (Int_t)rawStream->GetADC(i), (Int_t)rawStream->GetTime(i)); 
     327             :       treeD->Fill();
     328             :   }
     329             :   */ 
     330           0 :   fLoader->WriteDigits("OVERWRITE");
     331           0 :   fLoader->UnloadDigits();   
     332             :         
     333           0 :   delete rawStream;
     334             : 
     335           0 :   timer.Stop();
     336           0 :   timer.Print();
     337             : 
     338           0 :   return kTRUE;
     339           0 : }
     340             : 
     341             : //_____________________________________________________________________________

Generated by: LCOV version 1.11