LCOV - code coverage report
Current view: top level - BCM - AliBCM.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 87 1.1 %
Date: 2016-06-14 17:26:59 Functions: 1 15 6.7 %

          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             : //  Beam Condition Monitor BCM                                               //
      21             : //                                                                           //
      22             : //  andreas.morsch@cern.ch                                                   // 
      23             : ///////////////////////////////////////////////////////////////////////////////
      24             :  
      25             : #include <TClonesArray.h>
      26             : #include <TGeoCompositeShape.h>
      27             : #include <TGeoGlobalMagField.h>
      28             : #include <TGeoManager.h>
      29             : #include <TGeoMaterial.h>
      30             : #include <TGeoMatrix.h>
      31             : #include <TGeoMedium.h>
      32             : #include <TGeoPgon.h>
      33             : #include <TGeoVolume.h>
      34             : #include <TGeoXtru.h>
      35             : #include <TVirtualMC.h>
      36             : 
      37             : #include "AliBCM.h"
      38             : #include "AliBCMHit.h"
      39             : #include "AliBCMLoader.h"
      40             : #include "AliMagF.h"
      41             : #include "AliRun.h"
      42             : #include "AliMC.h"
      43             : #include "AliLog.h"
      44             :  
      45          12 : ClassImp(AliBCM)
      46             : 
      47             :  
      48             : //_____________________________________________________________________________
      49             : AliBCM::AliBCM():
      50           0 :     AliDetector(),
      51           0 :     fVolId(0)
      52           0 : {
      53             :   //
      54             :   // Default constructor for BCM
      55             :   //
      56           0 : }
      57             :  
      58             : //_____________________________________________________________________________
      59             : AliBCM::AliBCM(const char *name, const char *title): 
      60           0 :     AliDetector(name,title),
      61           0 :     fVolId(0)  
      62           0 : {
      63             : //
      64             : //  Constructor
      65           0 :     fHits  = new TClonesArray("AliBCMHit");
      66           0 :     fNhits = 0;    
      67           0 :     gAlice->GetMCApp()->AddHitList(fHits);
      68           0 : }
      69             : AliBCM::~AliBCM()
      70           0 : {  
      71             :     // Destructor
      72           0 :     if(fHits)      delete fHits;
      73           0 : }
      74             : 
      75             : void AliBCM::StepManager()
      76             : {
      77             : //
      78             : // Step Manager for ALICE Beam Condition Monitor
      79             : //    
      80             : 
      81             :     static Float_t edepT;    
      82             :     static Double_t xh[4] = {0., 0., 0., 0.};
      83             :     Float_t edep = 0.;
      84           0 :     Int_t   copy = -1; 
      85             :     
      86             :     
      87           0 :     if (TVirtualMC::GetMC()->TrackCharge() && 
      88           0 :         TVirtualMC::GetMC()->CurrentVolID(copy) == fVolId) {
      89             :         // Charged particle inside sensitive volume
      90             :         //
      91             :         // Entering
      92           0 :         if (TVirtualMC::GetMC()->IsTrackEntering()) {
      93           0 :             edepT = 0.;
      94           0 :             TVirtualMC::GetMC()->TrackPosition(xh[0],xh[1],xh[2]);
      95           0 :             xh[3] = TVirtualMC::GetMC()->TrackTime();
      96           0 :         }
      97             :         
      98             :         //
      99             :         // Any step
     100           0 :         if ((edep = TVirtualMC::GetMC()->Edep()) > 0.) {
     101           0 :             Double_t x[3];   
     102           0 :             TVirtualMC::GetMC()->TrackPosition(x[0],x[1],x[2]); 
     103           0 :             edepT += edep;
     104           0 :         }
     105             :         //
     106             :         // Exiting 
     107           0 :         if(TVirtualMC::GetMC()->IsTrackExiting()||TVirtualMC::GetMC()->IsTrackStop()||TVirtualMC::GetMC()->IsTrackDisappeared())
     108             :         {
     109           0 :             Int_t track = gAlice->GetMCApp()->GetCurrentTrackNumber();
     110           0 :             TClonesArray &lhits = *fHits;
     111           0 :             Int_t ic = copy + 10;
     112           0 :             if (xh[2] < 0.) ic+=10;
     113           0 :             new(lhits[fNhits++]) AliBCMHit(1, track, xh, ic, edepT);
     114           0 :         }
     115             :     }
     116             : 
     117             :     
     118           0 : }
     119             : 
     120             : //_____________________________________________________________________________
     121             : void AliBCM::CreateGeometry()
     122             : {
     123             :     //
     124             :     // Create geometry for BCM
     125             :     //
     126             :     
     127             :     //
     128             :     // Top volume 
     129           0 :     TGeoVolume* top      = gGeoManager->GetVolume("ALIC");
     130             :     // Media 
     131           0 :     TGeoMedium* medPCD   = gGeoManager->GetMedium("BCM_PCD");
     132             :     // Rotations
     133           0 :     TGeoRotation* rotxz   = new TGeoRotation("rotxz" ,  270.,   0., 90.,  90., 180., 0.);
     134           0 :     TGeoRotation* rot000  = new TGeoRotation("rot000",   90.,   0., 90.,  90.,   0., 0.);
     135           0 :     TGeoRotation* rot090  = new TGeoRotation("rot090",   90.,  90., 90., 180.,   0., 0.);
     136           0 :     TGeoRotation* rot180  = new TGeoRotation("rot180",   90., 180., 90., 270.,   0., 0.);
     137           0 :     TGeoRotation* rot270  = new TGeoRotation("rot270",   90., 270., 90.,   0.,   0., 0.);
     138             :     //
     139             :     const Float_t kWidth     = 1.00;
     140             :     const Float_t kThickness = 0.05;
     141             :     const Float_t rBCM       = 7.;
     142             :     
     143             :     
     144           0 :     TGeoBBox*   shBCMpcd = new TGeoBBox(kWidth/2., kWidth/2., kThickness/2.);
     145           0 :     TGeoVolume* voBCMpcd = new TGeoVolume("BCMpcd", shBCMpcd, medPCD);
     146           0 :     TGeoVolumeAssembly* voBCM = new TGeoVolumeAssembly("BCM");
     147             :     
     148           0 :     voBCM->AddNode(voBCMpcd, 1, new TGeoCombiTrans(+rBCM, 0.    , 0., rot000));
     149           0 :     voBCM->AddNode(voBCMpcd, 2, new TGeoCombiTrans(0.   , +rBCM , 0., rot090));
     150           0 :     voBCM->AddNode(voBCMpcd, 3, new TGeoCombiTrans(-rBCM, 0.,     0., rot180));
     151           0 :     voBCM->AddNode(voBCMpcd, 4, new TGeoCombiTrans(0.   , -rBCM , 0., rot270));
     152             :     
     153           0 :     top->AddNode(voBCM, 1, new TGeoTranslation(0., 0., 1561.));
     154           0 :     top->AddNode(voBCM, 2, new TGeoCombiTrans(0., 0., -1908., rotxz));
     155             :     
     156           0 : }
     157             : 
     158             : //_____________________________________________________________________________
     159             : void AliBCM::CreateMaterials()
     160             : {
     161             :   //
     162             :   // Create materials for BCM
     163             :   //
     164             :   // Polycristalline Diamond
     165             :     Float_t rho  = 3.53;
     166           0 :     Float_t absl = 86.3 / rho;
     167           0 :     Float_t radl = 42.7 / rho;
     168             :     //
     169             :     Float_t epsil  = .001;   // Tracking precision, 
     170             :     Float_t stemax = -1.;    // Maximum displacement for multiple scat 
     171             :     Float_t tmaxfd = -20. ;  // Maximum angle due to field deflection 
     172             :     Float_t deemax = -.01;   // Maximum fractional energy loss, DLS 
     173             :     Float_t stmin  = -.8;
     174           0 :     Int_t   isxfld = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ();
     175           0 :     Float_t sxmgmx = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max();
     176             : 
     177           0 :     AliMaterial(1, "PCD", 12.011, 6., rho, radl, absl);
     178             :     //
     179           0 :     AliMedium(1, "PCD", 1, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
     180           0 : }
     181             : 
     182             : //_____________________________________________________________________________
     183             : void AliBCM::Init()
     184             : {
     185             :     //
     186             :     // Initialise BCM magnet after it has been built
     187             :     //
     188             :   Int_t i;
     189             :   //
     190           0 :   if(AliLog::GetGlobalDebugLevel()>0) {
     191           0 :     printf("\n%s: ",ClassName());
     192           0 :     for(i=0;i<35;i++) printf("*");
     193           0 :     printf(" BCM_INIT ");
     194           0 :     for(i=0;i<35;i++) printf("*");
     195           0 :     printf("\n%s: ",ClassName());
     196           0 :     for(i=0;i<80;i++) printf("*");
     197           0 :     printf("\n");
     198           0 :   }
     199             : 
     200             :     //
     201             :     // Here the BCM initialisation code (if any!)
     202           0 :     fVolId =  TVirtualMC::GetMC()->VolId("BCMpcd");
     203           0 : }
     204             : 
     205             : void AliBCM::MakeBranch(Option_t* option)
     206             : {
     207             : //Create Tree branches for the BCM
     208             :     
     209             :   const Int_t kBufSize = 4000;
     210           0 :   const char *cH = strstr(option,"H");
     211             : //  const char *cD = strstr(option,"D");
     212             : //  const char *cR = strstr(option,"R");
     213             : //  const char *cS = strstr(option,"S");
     214             : 
     215           0 :   if(cH && fLoader->TreeH() && (fHits == 0x0)){
     216           0 :       fHits  = new TClonesArray("AliBCMHit");
     217           0 :       fNhits = 0;    
     218           0 :       MakeBranchInTree(fLoader->TreeH(), "BCM" ,&fHits ,kBufSize, 0);
     219           0 :   }
     220           0 :   AliDetector::MakeBranch(option);
     221           0 : }
     222             : 
     223             : void AliBCM::SetTreeAddress()
     224             : {
     225             :   // Set branch address
     226             : 
     227           0 :     if (fLoader->TreeH() && fHits==0x0)
     228           0 :         fHits   = new TClonesArray("AliBCMHit",  4000);
     229           0 :     AliDetector::SetTreeAddress();
     230           0 : }
     231             : 
     232             : //_____________________________________________________________________________
     233             : AliLoader* AliBCM::MakeLoader(const char* topfoldername)
     234             : { 
     235             :   //
     236             :   // Builds BCM getter (AliLoader type)
     237           0 :   AliDebug(1,Form("Creating AliBCMLoader, Top folder is %s ",topfoldername));
     238           0 :   fLoader = new AliBCMLoader(GetName(),topfoldername);
     239           0 :   return fLoader;
     240           0 : }

Generated by: LCOV version 1.11