LCOV - code coverage report
Current view: top level - ITS/ITSbase - AliITSLoader.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 115 166 69.3 %
Date: 2016-06-14 17:26:59 Functions: 18 20 90.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             : #include <TClonesArray.h>
      19             : #include <TClass.h>
      20             : #include <TGeoManager.h>
      21             : #include <TTree.h>
      22             : 
      23             : #include "AliITSdigit.h"
      24             : #include "AliITSLoader.h"
      25             : #include "AliRunLoader.h"
      26             : #include "AliObjectLoader.h"
      27             : #include "AliITSInitGeometry.h"
      28             : #include "AliLog.h"
      29             : 
      30             : ///////////////////////////////////////////////////////////////////////////
      31             : // Loader for ITS
      32             : // it manages the I/O for:
      33             : // raw clusters, primary vertices
      34             : // V0 and cascade
      35             : // and tracks propagated to the origin
      36         118 : ClassImp(AliITSLoader)
      37             : 
      38             : /**********************************************************************/
      39          13 :   AliITSLoader::AliITSLoader():AliLoader(),
      40          65 : fGeom(0){
      41             :   // Default constructor
      42          26 : }
      43             : /*********************************************************************/
      44             : AliITSLoader::AliITSLoader(const Char_t *name,const Char_t *topfoldername):
      45           1 : AliLoader(name,topfoldername),
      46           5 : fGeom(0){
      47             :   //Constructor   
      48           4 :     AliDataLoader* rawClustersDataLoader = new AliDataLoader(
      49           4 :         fDetectorName + ".RawCl.root",GetDefaultRawClustersContainerName(),
      50             :         "Raw Clusters");
      51           1 :     fDataLoaders->Add(rawClustersDataLoader);
      52           1 :     rawClustersDataLoader->SetEventFolder(fEventFolder);
      53           2 :     rawClustersDataLoader->SetFolder(GetDetectorDataFolder());
      54             : 
      55           4 :     AliDataLoader* backTracksDataLoader =  new AliDataLoader(
      56           4 :         fDetectorName + ".BackTracks.root",GetDefaultBackTracksContainerName(),
      57             :         "Back Propagated Tracks");
      58           1 :     fDataLoaders->Add(backTracksDataLoader);
      59           1 :     backTracksDataLoader->SetEventFolder(fEventFolder);
      60           2 :     backTracksDataLoader->SetFolder(GetDetectorDataFolder());
      61             : 
      62           4 :     AliDataLoader* vertexDataLoader = new AliDataLoader(
      63           4 :         fDetectorName + ".Vertex.root",GetDefaultVerticesContainerName(),
      64             :         "Primary Vertices","O");
      65           1 :     fDataLoaders->Add(vertexDataLoader);
      66           1 :     vertexDataLoader->SetEventFolder(fEventFolder);
      67           2 :     vertexDataLoader->SetFolder(GetDetectorDataFolder());
      68             : 
      69           4 :     AliDataLoader* v0DataLoader = new AliDataLoader(
      70           4 :         fDetectorName + ".V0s.root",GetDefaultV0ContainerName(),"V0 Vertices");
      71           1 :     fDataLoaders->Add(v0DataLoader);
      72           1 :     v0DataLoader->SetEventFolder(fEventFolder);
      73           2 :     v0DataLoader->SetFolder(GetDetectorDataFolder());
      74             : 
      75           4 :     AliDataLoader* cascadeDataLoader = new AliDataLoader(
      76           4 :         fDetectorName + ".Cascades.root",GetDefaultCascadeContainerName(),
      77             :         "Cascades");
      78           1 :     fDataLoaders->Add(cascadeDataLoader);
      79           1 :     cascadeDataLoader->SetEventFolder(fEventFolder);
      80           2 :     cascadeDataLoader->SetFolder(GetDetectorDataFolder());
      81           2 : }
      82             : /**********************************************************************/
      83             : AliITSLoader::AliITSLoader(const Char_t *name,TFolder *topfolder): 
      84           1 :   AliLoader(name,topfolder),
      85           5 : fGeom(0){
      86             :   //ctor  
      87           4 :     AliDataLoader*  rawClustersDataLoader = new AliDataLoader(
      88           4 :         fDetectorName + ".RawCl.root",GetDefaultRawClustersContainerName(),
      89             :         "Raw Clusters"); 
      90           1 :     fDataLoaders->Add(rawClustersDataLoader);
      91           1 :     rawClustersDataLoader->SetEventFolder(fEventFolder);
      92           2 :     rawClustersDataLoader->SetFolder(GetDetectorDataFolder());
      93             : 
      94           4 :     AliDataLoader*  backTracksDataLoader =  new AliDataLoader(
      95           4 :         fDetectorName + ".BackTracks.root",GetDefaultBackTracksContainerName(),
      96             :         "Back Propagated Tracks");
      97           1 :     fDataLoaders->Add(backTracksDataLoader);
      98           1 :     backTracksDataLoader->SetEventFolder(fEventFolder);
      99           2 :     backTracksDataLoader->SetFolder(GetDetectorDataFolder());
     100             : 
     101           4 :     AliDataLoader* vertexDataLoader = new AliDataLoader(
     102           4 :         fDetectorName + ".Vertex.root",GetDefaultVerticesContainerName(),
     103             :         "Primary Vertices","O");
     104           1 :     fDataLoaders->Add(vertexDataLoader);
     105           1 :     vertexDataLoader->SetEventFolder(fEventFolder);
     106           2 :     vertexDataLoader->SetFolder(GetDetectorDataFolder());
     107             : 
     108           4 :     AliDataLoader* v0DataLoader = new AliDataLoader(
     109           4 :         fDetectorName + ".V0.root",GetDefaultV0ContainerName(),"V0 Vertices");
     110           1 :     fDataLoaders->Add(v0DataLoader);
     111           1 :     v0DataLoader->SetEventFolder(fEventFolder);
     112           2 :     v0DataLoader->SetFolder(GetDetectorDataFolder());
     113             : 
     114           4 :     AliDataLoader* cascadeDataLoader = new AliDataLoader(
     115           4 :         fDetectorName + ".Cascade.root",GetDefaultCascadeContainerName(),
     116             :         "Cascades");
     117           1 :     fDataLoaders->Add(cascadeDataLoader);
     118           1 :     cascadeDataLoader->SetEventFolder(fEventFolder);
     119           2 :     cascadeDataLoader->SetFolder(GetDetectorDataFolder());
     120           2 : }
     121             : 
     122             : 
     123             : /**********************************************************************/
     124          90 : AliITSLoader::~AliITSLoader(){
     125             :     //destructor
     126             :     AliDataLoader* dl = 0;
     127          15 :     UnloadRawClusters();
     128          15 :     dl = GetRawClLoader();
     129          15 :     fDataLoaders->Remove(dl);
     130             : 
     131          15 :     UnloadBackTracks();
     132          15 :     dl = GetBackTracksDataLoader();
     133          15 :     fDataLoaders->Remove(dl);
     134             : 
     135          15 :     UnloadVertices();
     136          15 :     dl = GetVertexDataLoader();
     137          15 :     fDataLoaders->Remove(dl);
     138             : 
     139          15 :     UnloadV0s();
     140          15 :     dl = GetV0DataLoader();
     141          15 :     fDataLoaders->Remove(dl);
     142             : 
     143          15 :     UnloadCascades();
     144          15 :     dl = GetCascadeDataLoader();
     145          15 :     fDataLoaders->Remove(dl);
     146             :   
     147          23 :     if(fGeom)delete fGeom;
     148          15 :     fGeom = 0;
     149          45 : }
     150             : /*
     151             : //----------------------------------------------------------------------
     152             : AliITS* AliITSLoader::GetITS(){
     153             :     // Returns the pointer to the ITS, kept on the file. A short cut metthod
     154             :     // Inputs:
     155             :     //    none.
     156             :     // Outputs:
     157             :     //    none.
     158             :     // Returns:
     159             :     //    Returns a pointer to the ITS, if not found returns 0.
     160             :     AliITS *its;
     161             : 
     162             :     if(gAlice){
     163             :         its = dynamic_cast<AliITS*> (gAlice->GetDetector(
     164             :             GetDetectorName().Data()));
     165             :         if(its) return its;
     166             :     } // end if gAlice
     167             :     AliRunLoader *rl=0;
     168             :     rl = GetRunLoader();
     169             :     if(!rl) return 0;
     170             :     AliRun *ar=0;
     171             :     ar = rl->GetAliRun();
     172             :     if(!ar) return 0;
     173             :     its = dynamic_cast<AliITS*> (ar->GetDetector(GetDetectorName().Data()));
     174             :     return its;
     175             : }
     176             : //----------------------------------------------------------------------
     177             : void AliITSLoader::SetupDigits(AliITS *its){
     178             :     // Sets up to store ITS Digits in side AliITS::fDtype TObjArray
     179             :     // Inputs:
     180             :     //    AliITS *its  Pointer to the ITS
     181             :     // Outputs:
     182             :     //    none.
     183             :     // Return:
     184             :     //    none.
     185             : 
     186             :     its->SetTreeAddressD(TreeD());
     187             : }
     188             : */
     189             : //----------------------------------------------------------------------
     190             : void AliITSLoader::SetupDigits(TObjArray *digPerDet,Int_t n,
     191             :                                const Char_t **digclass){
     192             :     // Sets up digPerDet to store ITS Digits.
     193             :     // Inputs:
     194             :     //    TObjArray *digPerDet   A pointer to a TObject Array size>=3.
     195             :     //    Int_t      n           The size of the TObjArray and digclass array
     196             :     //    Char_t     **digclass  Array of digit class names
     197             :     // Outputs:
     198             :     //    TObjArray *digPerDet   Setup and linked to the tree of digits
     199             :     // Return:
     200             :     //    none.
     201             :     Int_t i,m;
     202             :     TClonesArray *cl = 0;
     203             :     TTree *td = 0;
     204             :     TBranch *br = 0;
     205           0 :     Char_t branch[14];
     206           0 :     const Char_t *det[3] = {"SPD","SDD","SSD"};
     207             : 
     208           0 :     if(!digPerDet){
     209           0 :         Error("SetUpDigits","TObject Array digPerDet does not exist");
     210           0 :         return;
     211             :     } // end if
     212           0 :     m = digPerDet->GetSize();
     213           0 :     if(m<n){
     214           0 :         Error("SetUpDigits","TObject Array digPerDet=%p must have a size"
     215             :               " at least that of n=%d",digPerDet,n);
     216           0 :     } // end if
     217           0 :     if(m<3){
     218           0 :         Error("SetUpDigits","TObject Array digPerDet=%p must have a size >2",
     219             :               digPerDet);
     220           0 :         return;
     221             :     } // end if
     222           0 :     td = TreeD();
     223           0 :     for(i=0;i<n;i++){
     224           0 :         if(digPerDet->At(i)==0){ // set up TClones Array
     225           0 :             digPerDet->AddAt(new TClonesArray(digclass[i],1000),i);
     226           0 :             if(n==3) snprintf(branch,13,"ITSDigits%s",det[i]);
     227           0 :             else     snprintf(branch,13,"ITSDigits%d",i+1);
     228           0 :             br = td->GetBranch(branch);
     229           0 :             br->SetAddress(&((*digPerDet)[i]));
     230           0 :             continue; // do next one.
     231             :         } // end if
     232           0 :         cl =  dynamic_cast<TClonesArray*> (digPerDet->At(i));
     233           0 :         if(!cl && digPerDet->At(i)!=0){  // not a TClonesArray
     234           0 :             Error("SetUpDigits","TObject Array digPerDet-At(%d)=%p must be "
     235             :                   "zeroed or filled with TClonesArrays",i,digPerDet);
     236           0 :             return;
     237             :         } // end if
     238           0 :         if(!(cl->GetClass()->GetBaseClass(AliITSdigit::Class()))){
     239           0 :             Error("SetUPDigits","TClones array at digPerDet[%d}=%p must be"
     240           0 :                   "derived from AliITSdigit",i,digPerDet->At(i));
     241           0 :         } // end if
     242           0 :         cl->Clear();
     243           0 :         if(n==3) snprintf(branch,13,"ITSDigits%s",det[i]);
     244           0 :         else     snprintf(branch,13,"ITSDigits%d",i+1);
     245           0 :         br = td->GetBranch(branch);
     246           0 :         br->SetAddress(&((*digPerDet)[i]));
     247           0 :         continue;
     248             :     } // end for i
     249           0 : }
     250             : //---------------------------------------------------------------------
     251             : AliITSdigit * AliITSLoader::GetDigit(TObjArray *digPerDet,Int_t module,
     252             :                                      Int_t digit){
     253             :     // Gets the digit for for a specific detector type and module.
     254             :     // To be used in conjustion with Setupdigits(AliITS *its).
     255             :     // Inputs:
     256             :     //   TObjArray *digPereDet    Pointer to the Array of digits
     257             :     //   Int_t      module        Module number
     258             :     //   Int_t      digit         Digit number
     259             :     // Outputs:
     260             :     //   none.
     261             :     // Return:
     262             :     //   returns the pointer to the digit. if zero then last digit for that
     263             :     //   module.
     264             : 
     265           0 :     if(digPerDet==0){
     266           0 :         Error("GetDigit","digPerDet=%p, module=%d, digit=%d",
     267             :               digPerDet,module,digit);
     268           0 :         return 0;
     269             :     } // end if
     270           0 :     return 0;
     271           0 : }
     272             : /*
     273             : //---------------------------------------------------------------------
     274             : AliITSdigit * AliITSLoader::GetDigit(AliITS *its,Int_t module,Int_t digit){
     275             :     // Gets the digit for for a specific detector type and module.
     276             :     // To be used in conjustion with Setupdigits(AliITS *its).
     277             :     // Inputs:
     278             :     //   AliITS *its    Pointer to the ITS
     279             :     //   Int_t  module  Module number
     280             :     //   Int_t digit    Digit number
     281             :     // Outputs:
     282             :     //   none.
     283             :     // Return:
     284             :     //   returns the pointer to the digit. if zero then last digit for that
     285             :     //   module.
     286             :     //AliITSDetType *idtype;
     287             :     AliITSgeom *geom = its->GetITSgeom();
     288             :     Int_t idet = geom->GetModuleType(module);
     289             :     TClonesArray *digits;
     290             :  
     291             :     its->ResetDigits();
     292             :     TreeD()->GetEvent(module);
     293             :     digits = its->DigitsAddress(idet);
     294             :     if(digit>-1 && digit<digits->GetEntriesFast()){ // if in range.
     295             :         return (AliITSdigit*) digits->At(digit);
     296             :     } // end if
     297             :     return 0;
     298             : }
     299             : */
     300             : //----------------------------------------------------------------------
     301             : void AliITSLoader::MakeTree(Option_t *opt){
     302             :     // invokes AliLoader::MakeTree + specific ITS tree(s)
     303             :     // Valid options: H,S,D,R,T and C (C=raw clusters)
     304          28 :     AliLoader::MakeTree(opt);
     305          14 :     const char *oC = strstr(opt,"C");
     306          14 :     if (oC) MakeRawClustersContainer();
     307             : 
     308          14 :     const char *oB = strstr(opt,"B");
     309          14 :     if (oB) MakeBackTracksContainer();
     310             : 
     311          14 :     const char *oV0 = strstr(opt,"V0");
     312          14 :     if (oV0) MakeV0Container();
     313             : 
     314          14 :     const char *oX = strstr(opt,"X");
     315          14 :     if (oX) MakeCascadeContainer();
     316          14 : }
     317             : 
     318             : //----------------------------------------------------------------------
     319             : AliITSgeom* AliITSLoader::GetITSgeom(Bool_t force) {
     320             :   // retrieves the ITS geometry from file
     321       43893 :   if(fGeom && !force)return fGeom;
     322           3 :   if(fGeom && force){
     323           0 :     delete fGeom;
     324           0 :     fGeom = 0;
     325           0 :   }
     326           3 :   if(!gGeoManager){
     327           0 :     AliError("gGeoManager is a null pointer - ITS geometry not built");
     328           0 :     return fGeom;
     329             :   }
     330           3 :   AliITSInitGeometry initgeom;
     331           6 :   fGeom = initgeom.CreateAliITSgeom();
     332          15 :   AliDebug(1,"AliITSgeom object has been initialized from TGeo\n");
     333          15 :   AliDebug(1,Form("Geometry name: %s",(initgeom.GetGeometryName()).Data()));
     334           3 :   return fGeom;
     335       14636 : }
     336             : //______________________________________________________________________
     337             : void AliITSLoader::SetITSgeom(AliITSgeom *geom){
     338             :     // Replaces the AliITSgeom object read from file with the one
     339             :     // given.
     340             :     // Inputs:
     341             :     //   AliITSgeom *geom   The AliITSgeom object to replace the one
     342             :     //                      read from the file
     343             :     // Outputs:
     344             :     //   none.
     345             :     // Return:
     346             :     //   none.
     347             : 
     348           4 :     if(fGeom==geom) return; // Same do nothing
     349           2 :     if(fGeom) {
     350           2 :         delete fGeom;
     351           1 :         fGeom=0;
     352           1 :     }// end if
     353           2 :     fGeom=geom;
     354           4 : }
     355             : 
     356             : const TString& AliITSLoader::GetDefaultRawClustersContainerName() {
     357             :   //default for Raw Clusters container name
     358          10 :   static const TString kDefaultRawClustersContainerName = "TreeC";  
     359           2 :   return kDefaultRawClustersContainerName;
     360           0 : }
     361             : 
     362             : const TString& AliITSLoader::GetDefaultBackTracksContainerName() {
     363             :  //default for Back propag. tracks container name
     364          10 :   static const TString kDefaultBackTracksContainerName = "TreeB";   
     365           2 :   return kDefaultBackTracksContainerName;
     366           0 : }
     367             : 
     368             : const TString& AliITSLoader::GetDefaultVerticesContainerName() {
     369             :   //default for primary vertices container name
     370          10 :   static const TString kDefaultVerticesContainerName = "Vertex";     
     371           2 :   return kDefaultVerticesContainerName;
     372           0 : }
     373             : 
     374             : const TString& AliITSLoader::GetDefaultV0ContainerName() {
     375             :   //default for V0 container name
     376          10 :   static const TString kDefaultV0ContainerName = "V0";
     377           2 :   return kDefaultV0ContainerName;
     378           0 : }
     379             : 
     380             : const TString& AliITSLoader::GetDefaultCascadeContainerName() {
     381             :   //default fo cascade container name
     382          10 :   static const TString kDefaultCascadeContainerName = "Cascade";
     383           2 :   return kDefaultCascadeContainerName;
     384           0 : }

Generated by: LCOV version 1.11