LCOV - code coverage report
Current view: top level - PMD/PMDsim - AliPMD.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 93 140 66.4 %
Date: 2016-06-14 17:26:59 Functions: 11 24 45.8 %

          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             : //                                                                           //
      21             : //  Photon Multiplicity Detector                                             //
      22             : //  This class contains the basic functions for the Photon Multiplicity      //
      23             : //  Detector. Functions specific to one particular geometry are              //
      24             : //  contained in the derived classes                                         //
      25             : //                                                                           //
      26             : //Begin_Html
      27             : /*
      28             : <img src="picts/AliPMDClass.gif">
      29             : </pre>
      30             : <br clear=left>
      31             : <font size=+2 color=red>
      32             : <p>The responsible person for this module is
      33             : <a href="mailto:sub@vecdec.veccal.ernet.in">Subhasis Chattopadhyay</a>.
      34             : </font>
      35             : <pre>
      36             : */
      37             : //End_Html
      38             : //                                                                           //
      39             : ///////////////////////////////////////////////////////////////////////////////
      40             : 
      41             : #include <TBRIK.h>
      42             : #include <TClonesArray.h>
      43             : #include <TGeometry.h>
      44             : #include <TNode.h>
      45             : #include <TTree.h>
      46             : #include <TVirtualMC.h>
      47             : 
      48             : #include "AliLog.h"
      49             : #include "AliLoader.h" 
      50             : #include "AliPMDLoader.h" 
      51             : #include "AliPMD.h"
      52             : #include "AliRun.h"
      53             : #include "AliMC.h"
      54             : #include "AliPMDDigitizer.h"
      55             : #include "AliPMDhit.h"
      56             : #include "AliPMDDDLRawData.h"
      57             : #include "AliPMDRawToSDigits.h"
      58             :   
      59          12 : ClassImp(AliPMD)
      60             :  
      61             : //_____________________________________________________________________________
      62          12 : AliPMD::AliPMD()
      63          36 : {
      64             :   //
      65             :   // Default constructor
      66             :   //
      67          12 :   fIshunt     = 0;
      68          12 :   fPar[0]     = 1.;
      69          12 :   fPar[1]     = 1.;
      70          12 :   fPar[2]     = 0.8;
      71          12 :   fPar[3]     = 0.02;
      72          12 :   fIn[0]      = 6.;
      73          12 :   fIn[1]      = 20.;
      74          12 :   fIn[2]      = 600.;
      75          12 :   fIn[3]      = 27.;
      76          12 :   fIn[4]      = 27.;
      77          12 :   fGeo[0]     = 0.;
      78          12 :   fGeo[1]     = 0.2;
      79          12 :   fGeo[2]     = 4.;
      80          12 :   fPadSize[0] = 0.8;
      81          12 :   fPadSize[1] = 1.0;
      82          12 :   fPadSize[2] = 1.2;
      83          12 :   fPadSize[3] = 1.5;
      84          12 :   fNumPads[0] = 0;
      85          12 :   fNumPads[1] = 0;
      86          12 :   fNumPads[2] = 0;
      87          12 :   fNumPads[3] = 0;
      88          12 : }
      89             :  
      90             : //_____________________________________________________________________________
      91             : AliPMD::AliPMD(const char *name, const char *title)
      92           1 :   : AliDetector(name,title)
      93           3 : {
      94             :   //
      95             :   // Default constructor
      96             :   //
      97             : 
      98             :   // 
      99             :   // Allocate the array of hits
     100           3 :   fHits   = new TClonesArray("AliPMDhit",  405);
     101           1 :   gAlice->GetMCApp()->AddHitList(fHits);
     102             : 
     103             : 
     104           1 :   fIshunt =  0;
     105             :   
     106           1 :   fPar[0]     = 1.;
     107           1 :   fPar[1]     = 1.;
     108           1 :   fPar[2]     = 0.8;
     109           1 :   fPar[3]     = 0.02;
     110           1 :   fIn[0]      = 6.;
     111           1 :   fIn[1]      = 20.;
     112           1 :   fIn[2]      = 600.;
     113           1 :   fIn[3]      = 27.;
     114           1 :   fIn[4]      = 27.;
     115           1 :   fGeo[0]     = 0.;
     116           1 :   fGeo[1]     = 0.2;
     117           1 :   fGeo[2]     = 4.;
     118           1 :   fPadSize[0] = 0.8;
     119           1 :   fPadSize[1] = 1.0;
     120           1 :   fPadSize[2] = 1.2;
     121           1 :   fPadSize[3] = 1.5;
     122           1 :   fNumPads[0] = 0;
     123           1 :   fNumPads[1] = 0;
     124           1 :   fNumPads[2] = 0;
     125           1 :   fNumPads[3] = 0;
     126           1 : }
     127             : 
     128             : AliLoader* AliPMD::MakeLoader(const char* topfoldername)
     129             : {
     130             :   // Makes PMD Loader
     131             :  
     132           4 :   fLoader = new AliPMDLoader(GetName(),topfoldername);
     133             :  
     134           1 :   if (fLoader)
     135             :     {
     136           3 :       AliDebug(100,"Success");
     137             :     }
     138             :   else
     139             :     {
     140           0 :       AliError("Failure");
     141             :     }
     142             : 
     143           1 :   return fLoader;
     144           0 : }
     145             : 
     146             : AliPMD::~AliPMD()
     147           0 : {
     148             :   //
     149             :   // Destructor
     150             :   //
     151          26 : }
     152             : 
     153             : //_____________________________________________________________________________
     154             : void AliPMD::AddHit(Int_t track, Int_t *vol, Float_t *hits)
     155             : {
     156             :   //
     157             :   // Add a PMD hit
     158             :   //
     159        1150 :   TClonesArray &lhits = *fHits;
     160             :   AliPMDhit *newcell, *curcell;
     161             :   //  printf("PMD++ Adding energy %f, prim %d, vol %d %d %d %d %d %d %d %d\n",
     162             :   // hits[3],gAlice->GetPrimary(track-1),vol[0],vol[1],vol[2],vol[3],
     163             :   // vol[4],vol[5],vol[6],vol[7]);
     164             : 
     165         575 :   newcell = new AliPMDhit(fIshunt, track, vol, hits);
     166             : 
     167       29088 :   for (Int_t i=0; i<fNhits; i++) {
     168             :     //
     169             :     // See if this cell has already been hit
     170       13836 :     curcell=(AliPMDhit*) lhits[i];
     171       13836 :     if (*curcell==*newcell) {
     172             : //        printf("Cell with same numbers found\n") ; curcell->Print();
     173         206 :       *curcell = *curcell+*newcell;
     174             : //        printf("Cell after addition\n") ; curcell->Print();
     175         206 :       delete newcell;
     176         103 :       return;
     177             :     }
     178             :   }
     179         472 :   new(lhits[fNhits++]) AliPMDhit(newcell);
     180         944 :   delete newcell;
     181        1047 : }
     182             :  
     183             : //_____________________________________________________________________________
     184             : void AliPMD::SetPAR(Float_t p1, Float_t p2, Float_t p3,Float_t p4)
     185             : {
     186             :   //
     187             :   // Set PMD parameters
     188             :   //
     189           0 :   fPar[0] = p1;
     190           0 :   fPar[1] = p2;
     191           0 :   fPar[2] = p3;
     192           0 :   fPar[3] = p4;
     193           0 : }
     194             :  
     195             : //_____________________________________________________________________________
     196             : void AliPMD::SetIN(Float_t p1, Float_t p2, Float_t p3,Float_t p4,Float_t p5)
     197             : {
     198             :   //
     199             :   // Set PMD parameters
     200             :   //
     201           0 :   fIn[0] = p1;
     202           0 :   fIn[1] = p2;
     203           0 :   fIn[2] = p3;
     204           0 :   fIn[3] = p4;
     205           0 :   fIn[4] = p5;
     206           0 : }
     207             :  
     208             : //_____________________________________________________________________________
     209             : void AliPMD::SetGEO(Float_t p1, Float_t p2, Float_t p3)
     210             : {
     211             :   //
     212             :   // Set geometry parameters
     213             :   //
     214           0 :   fGeo[0] = p1;
     215           0 :   fGeo[1] = p2;
     216           0 :   fGeo[2] = p3;
     217           0 : }
     218             :  
     219             : //_____________________________________________________________________________
     220             : void AliPMD::SetPadSize(Float_t p1, Float_t p2, Float_t p3,Float_t p4)
     221             : {
     222             :   //
     223             :   // Set pad size
     224             :   //
     225           0 :   fPadSize[0] = p1;
     226           0 :   fPadSize[1] = p2;
     227           0 :   fPadSize[2] = p3;
     228           0 :   fPadSize[3] = p4;
     229           0 : }
     230             :  
     231             : //_____________________________________________________________________________
     232             : void AliPMD::StepManager()
     233             : {
     234             :   //
     235             :   // Called at every step in PMD
     236             :   //
     237           0 : }
     238             : 
     239             : void AliPMD::MakeBranch(Option_t* option)
     240             : {
     241             :     // Create Tree branches for the PMD
     242             :     
     243           8 :     const char *cH = strstr(option,"H");
     244          12 :     if (cH && fLoader->TreeH() && (fHits == 0x0))
     245           0 :       fHits   = new TClonesArray("AliPMDhit",  405);
     246             :     
     247           4 :     AliDetector::MakeBranch(option);
     248           4 : }
     249             : 
     250             : 
     251             : void AliPMD::SetTreeAddress()
     252             : {
     253             :   // Set branch address
     254             : 
     255         340 :     if (fLoader->TreeH() && fHits==0x0)
     256           4 :       fHits   = new TClonesArray("AliPMDhit",  405);
     257             :       
     258         155 :     AliDetector::SetTreeAddress();
     259         155 : }
     260             : 
     261             : void AliPMD::SetCpvOff()
     262             : {
     263             :   // Set the CPV plane off
     264           0 : }
     265             : void AliPMD::SetPreOff()
     266             : {
     267             :   // Set the Preshower plane off
     268             : 
     269           0 : }
     270             : void AliPMD::SetModuleOff(Int_t /*imodule*/)
     271             : {
     272             :   // Set the desired module off
     273             : 
     274           0 : }
     275             : 
     276             : //____________________________________________________________________________
     277             : void AliPMD::Hits2SDigits()  
     278             : { 
     279             : // create summable digits
     280             : 
     281           2 :   AliRunLoader* runLoader = fLoader->GetRunLoader(); 
     282           1 :   AliPMDDigitizer* pmdDigitizer = new AliPMDDigitizer;
     283           3 :   pmdDigitizer->OpengAliceFile(fLoader->GetRunLoader()->GetFileName().Data(),
     284             :                                "HS");
     285           1 :   pmdDigitizer->SetZPosition(361.5);
     286             : 
     287          10 :   for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
     288           4 :     pmdDigitizer->Hits2SDigits(iEvent);
     289             :   }
     290           1 :   fLoader->UnloadHits();
     291           1 :   fLoader->UnloadSDigits();
     292           2 :   delete pmdDigitizer;
     293           1 : }
     294             : //____________________________________________________________________________
     295             : void AliPMD::SDigits2Digits()  
     296             : { 
     297             :   // creates sdigits to digits
     298           0 : }
     299             : //____________________________________________________________________________
     300             : void AliPMD::Hits2Digits()  
     301             : { 
     302             : // create digits
     303             : 
     304           0 :   AliRunLoader* runLoader = fLoader->GetRunLoader(); 
     305           0 :   AliPMDDigitizer* pmdDigitizer = new AliPMDDigitizer;
     306           0 :   pmdDigitizer->OpengAliceFile(fLoader->GetRunLoader()->GetFileName().Data(),
     307             :                                "HD");
     308           0 :   pmdDigitizer->SetZPosition(361.5);
     309             : 
     310           0 :   for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
     311           0 :     pmdDigitizer->Hits2Digits(iEvent);
     312             :   }
     313           0 :   fLoader->UnloadHits();
     314           0 :   fLoader->UnloadDigits();
     315           0 :   delete pmdDigitizer;
     316             : 
     317           0 : }
     318             : // ---------------------------------------------------------------------------
     319             : AliDigitizer* AliPMD::CreateDigitizer(AliDigitizationInput* digInput) const
     320             : { 
     321           3 :   return new AliPMDDigitizer(digInput);
     322           0 : }
     323             : // ---------------------------------------------------------------------------
     324             : void AliPMD::Digits2Raw()
     325             : { 
     326             : // convert digits of the current event to raw data
     327             : 
     328           8 :   fLoader->LoadDigits();
     329           4 :   TTree* digits = fLoader->TreeD();
     330           4 :   if (!digits) {
     331           0 :     AliError("No digits tree");
     332           0 :     return;
     333             :   }
     334             : 
     335           4 :   AliPMDDDLRawData rawWriter;
     336           4 :   rawWriter.WritePMDRawData(digits);
     337             : 
     338           4 :   fLoader->UnloadDigits();
     339           8 : }
     340             : 
     341             : Bool_t AliPMD::Raw2SDigits(AliRawReader *rawReader)
     342             : {
     343             :   // converts raw to sdigits
     344           0 :   AliRunLoader* runLoader = fLoader->GetRunLoader(); 
     345             :   //runLoader->GetEvent(ievt);
     346             : 
     347           0 :   AliPMDRawToSDigits pmdr2sd;
     348           0 :   pmdr2sd.Raw2SDigits(runLoader, rawReader);
     349           0 :   fLoader->UnloadSDigits();
     350             :   return kTRUE;
     351           0 : }
     352             : 

Generated by: LCOV version 1.11