LCOV - code coverage report
Current view: top level - ITSMFT/MFT/MFTbase - AliMFTHalfDiskSegmentation.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 104 1.0 %
Date: 2016-06-14 17:26:59 Functions: 1 14 7.1 %

          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             : /// \class AliMFTHalfDiskSegmentation
      20             : ///
      21             : /// Class for the description of the structure a Half-Disk
      22             : ///
      23             : // author Raphael Tieulent <raphael.tieulent@cern.ch>
      24             : //-----------------------------------------------------------------------------
      25             : #include "TClonesArray.h"
      26             : 
      27             : #include "AliLog.h"
      28             : #include "AliMFTConstants.h"
      29             : #include "AliMFTHalfDiskSegmentation.h"
      30             : #include "AliMFTGeometry.h"
      31             : 
      32             : /// \cond CLASSIMP
      33          14 : ClassImp(AliMFTHalfDiskSegmentation);
      34             : /// \endcond
      35             : 
      36             : 
      37             : //====================================================================================================================================================
      38             : /// Default constructor
      39             : AliMFTHalfDiskSegmentation::AliMFTHalfDiskSegmentation():
      40           0 :   AliMFTVSegmentation(),
      41           0 :   fNLadders(0),
      42           0 :   fLadders(NULL)
      43           0 : {
      44             : 
      45             : 
      46           0 : }
      47             : 
      48             : //====================================================================================================================================================
      49             : /// Constructor
      50             : /// \param [in] uniqueID UInt_t: Unique ID of the Half-Disk to build
      51             : AliMFTHalfDiskSegmentation::AliMFTHalfDiskSegmentation(UInt_t uniqueID):
      52           0 :   AliMFTVSegmentation(),
      53           0 :   fNLadders(0),
      54           0 :   fLadders(NULL)
      55           0 : {
      56             : 
      57             :   // constructor
      58           0 :   SetUniqueID(uniqueID);
      59             : 
      60           0 :   AliDebug(1,Form("Start Creating Half-Disk UniqueID = %d",GetUniqueID()));
      61             :   
      62           0 :   AliMFTGeometry * mftGeom = AliMFTGeometry::Instance();
      63             :   
      64           0 :   SetName(Form("MFT_D_%d_%d",mftGeom->GetHalfMFTID(GetUniqueID()), mftGeom->GetHalfDiskID(GetUniqueID()) ));
      65             :   
      66           0 :   fLadders  = new TClonesArray("AliMFTLadderSegmentation");
      67           0 :   fLadders -> SetOwner(kTRUE);
      68             :   
      69             :   
      70             :   
      71           0 : }
      72             : 
      73             : //====================================================================================================================================================
      74             : /// Copy Constructor
      75             : AliMFTHalfDiskSegmentation::AliMFTHalfDiskSegmentation(const AliMFTHalfDiskSegmentation& input):
      76           0 :   AliMFTVSegmentation(input),
      77           0 :   fNLadders(input.fNLadders)
      78           0 : {
      79             :   
      80             :   // copy constructor
      81           0 :   if(input.fLadders)  fLadders  = new TClonesArray(*(input.fLadders));
      82           0 :   else   fLadders  = new TClonesArray("AliMFTLadderSegmentation");
      83           0 :   fLadders -> SetOwner(kTRUE);
      84             : 
      85           0 : }
      86             : 
      87             : //====================================================================================================================================================
      88             : 
      89           0 : AliMFTHalfDiskSegmentation::~AliMFTHalfDiskSegmentation() {
      90             : 
      91           0 :   Clear("");
      92             : 
      93           0 : }
      94             : 
      95             : //====================================================================================================================================================
      96             : /// Clear the TClonesArray holding the ladder segmentations
      97             : 
      98             : void AliMFTHalfDiskSegmentation::Clear(const Option_t* /*opt*/) {
      99             : 
     100           0 :   if (fLadders) fLadders->Delete();
     101           0 :   delete fLadders; 
     102           0 :   fLadders = NULL;
     103             : 
     104           0 : }
     105             : 
     106             : 
     107             : //====================================================================================================================================================
     108             : /// Creates the Ladders on this half-Disk based on the information contained in the XML file
     109             : void AliMFTHalfDiskSegmentation::CreateLadders(TXMLEngine* xml, XMLNodePointer_t node)
     110             : {
     111             :   Int_t iladder;
     112             :   Int_t nsensor;
     113           0 :   Double_t pos[3];
     114           0 :   Double_t ang[3]={0.,0.,0.};
     115             : 
     116           0 :   TString nodeName = xml->GetNodeName(node);
     117           0 :   if (!nodeName.CompareTo("ladder")) {
     118           0 :     XMLAttrPointer_t attr = xml->GetFirstAttr(node);
     119           0 :     while (attr!=0) {
     120           0 :       TString attrName = xml->GetAttrName(attr);
     121           0 :       TString attrVal  = xml->GetAttrValue(attr);
     122           0 :       if(!attrName.CompareTo("iladder")){
     123           0 :         iladder = attrVal.Atoi();
     124           0 :         if (iladder>=GetNLadders() || iladder<0) {
     125           0 :           AliFatal(Form(" Wrong Ladder number :  %d ",iladder));
     126             :         }
     127             : 
     128             :       } else
     129           0 :         if(!attrName.CompareTo("nsensor")){
     130           0 :           nsensor = attrVal.Atoi();
     131           0 :         } else
     132           0 :           if(!attrName.CompareTo("xpos")){
     133           0 :             pos[0] = attrVal.Atof();
     134           0 :           } else
     135           0 :             if(!attrName.CompareTo("ypos")){
     136           0 :               pos[1] = attrVal.Atof();
     137           0 :             } else
     138           0 :               if(!attrName.CompareTo("zpos")){
     139           0 :                 pos[2] = attrVal.Atof();
     140           0 :               } else
     141           0 :                 if(!attrName.CompareTo("phi")){
     142           0 :                   ang[0] = attrVal.Atof();
     143           0 :                 } else
     144           0 :                   if(!attrName.CompareTo("theta")){
     145           0 :                     ang[1] = attrVal.Atof();
     146           0 :                   } else
     147           0 :                     if(!attrName.CompareTo("psi")){
     148           0 :                       ang[2] = attrVal.Atof();
     149           0 :                     } else{
     150           0 :                 AliError(Form(" Unknwon Attribute name %s ",xml->GetAttrName(attr)));
     151             :               }
     152             :       
     153           0 :       attr = xml->GetNextAttr(attr);
     154           0 :     }
     155             :     
     156             :     Int_t plane = -1;
     157             :     Int_t ladderID=iladder;
     158           0 :     if( iladder < GetNLadders()/2) {
     159             :       plane = 0;
     160           0 :     } else {
     161             :       plane = 1;
     162             :       // ladderID -= GetNLadders()/2;
     163             :     }
     164             :     
     165             : //    if ((plane==0 && pos[2]<0.) || (plane==1 && pos[2]>0.))
     166             : //      AliFatal(Form(" Wrong Z Position or ladder number ???  :  z= %f ladder id = %d",pos[2],ladderID));
     167             : 
     168           0 :     AliMFTGeometry * mftGeom = AliMFTGeometry::Instance();
     169             : 
     170           0 :     UInt_t ladderUniqueID = mftGeom->GetObjectID(AliMFTGeometry::kLadderType,
     171           0 :                                                  mftGeom->GetHalfMFTID(GetUniqueID()),
     172           0 :                                                  mftGeom->GetHalfDiskID(GetUniqueID()),
     173             :                                                  ladderID);
     174             : 
     175             : //    UInt_t ladderUniqueID = (AliMFTGeometry::kLadderType<<13) +  (((GetUniqueID()>>9) & 0xF)<<9) + (plane<<8) + (ladderID<<3);
     176             : 
     177             :     
     178           0 :     AliMFTLadderSegmentation * ladder = new AliMFTLadderSegmentation(ladderUniqueID);
     179           0 :     ladder->SetNSensors(nsensor);
     180           0 :     ladder->SetPosition(pos);
     181           0 :     ladder->SetRotationAngles(ang);
     182             : 
     183             :     /// @todo : In the XML geometry file, the position of the top-left corner of the chip closest to the pipe is given in the Halfdisk coordinate system.
     184             :     /// Need to put in the XML file the position of the ladder coordinate center
     185             :     // Find the position of the corner of the flex which is the ladder corrdinate system center.
     186             :     
     187           0 :     pos[0] = -AliMFTConstants::kSensorSideOffset;
     188           0 :     pos[1] = -AliMFTConstants::kSensorTopOffset - AliMFTConstants::kSensorHeight;
     189           0 :     pos[2] = -AliMFTConstants::kFlexThickness - AliMFTConstants::kSensorThickness;
     190           0 :     Double_t master[3];
     191           0 :     ladder->GetTransformation()->LocalToMaster(pos, master);
     192           0 :     ladder->SetPosition(master);
     193           0 :     AliDebug(2,Form("Creating Ladder %2d with %d Sensors at the position (%.2f,%.2f,%.2f) with angles (%.2f,%.2f,%.2f) and ID = %d",iladder,nsensor,master[0],master[1],master[2],ang[0],ang[1],ang[2], ladderUniqueID ) );
     194             : 
     195             :     
     196           0 :     ladder->CreateSensors();
     197             : 
     198           0 :     new ((*fLadders)[iladder]) AliMFTLadderSegmentation(*ladder);
     199           0 :     delete ladder;
     200             : 
     201             :     //GetLadder(iladder)->Print();
     202             : 
     203             :     
     204           0 :   }
     205             :   
     206             :   // display all child nodes
     207           0 :   XMLNodePointer_t child = xml->GetChild(node);
     208           0 :   while (child!=0) {
     209           0 :     CreateLadders(xml, child);
     210           0 :     child = xml->GetNext(child);
     211             :   }
     212           0 : }
     213             : 
     214             : 
     215             : 
     216             : //==================================================================================================================
     217             : /// Returns the number of sensors on the Half-Disk
     218             : Int_t AliMFTHalfDiskSegmentation::GetNChips() {
     219             : 
     220             :   Int_t nChips = 0;
     221             : 
     222           0 :   for (Int_t iLadder=0; iLadder<fLadders->GetEntries(); iLadder++) {
     223             : 
     224           0 :     AliMFTLadderSegmentation *ladder = (AliMFTLadderSegmentation*) fLadders->At(iLadder);
     225           0 :     nChips += ladder -> GetNSensors();
     226             : 
     227             :   }
     228             : 
     229           0 :   return nChips;
     230             : 
     231             : }
     232             : 
     233             : //==================================================================================================================
     234             : /// Print out Half-Disk information
     235             : /// \param [in] opt "l" or "ladder" -> The ladder information will be printed out as well
     236             : 
     237             : void AliMFTHalfDiskSegmentation::Print(Option_t* opt){
     238             : 
     239           0 :   AliInfo(Form("Half-Disk %s (Unique ID = %d)",GetName(),GetUniqueID()));
     240           0 :   GetTransformation()->Print();
     241           0 :   AliInfo(Form("N Ladders = %d",fNLadders));
     242           0 :   if(opt && (strstr(opt,"ladder")||strstr(opt,"l"))){
     243           0 :     for (int i=0; i<GetNLadders(); i++)  GetLadder(i)->Print(opt);
     244             :     
     245           0 :   }
     246           0 : }

Generated by: LCOV version 1.11