]> git.uio.no Git - u/mrichter/AliRoot.git/blob - test/vmctest/scripts/digitsPHOS.C
updates from Salvatore
[u/mrichter/AliRoot.git] / test / vmctest / scripts / digitsPHOS.C
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 // Macro to generate histograms from digits
19 // By E. Sicking, CERN
20
21
22 void digitsPHOS(Int_t nevents, Int_t nfiles)
23 {
24
25  TH1F * hadc = new TH1F ("hadc", "hadc", 100, -10, 200);
26  TH1F * hadcLog = new TH1F ("hadclog", "hadclog", 100, -2, 4);
27  AliRunLoader* runLoader = AliRunLoader::Open("galice.root","Event","READ");
28  AliPHOSLoader * phosLoader = dynamic_cast<AliPHOSLoader*>(runLoader->GetLoader("PHOSLoader"));
29  
30  for (Int_t ievent=0; ievent <nevents; ievent++) {
31   // for (Int_t ievent = 0; ievent < runLoader->GetNumberOfEvents(); ievent++) {
32    runLoader->GetEvent(ievent) ;
33    phosLoader->CleanDigits() ; 
34    phosLoader->LoadDigits("READ") ;
35    TClonesArray * digits    = phosLoader->Digits() ;
36    printf("Event %d contains %d digits\n",ievent,digits->GetEntriesFast());
37    
38    
39    for (Int_t j = 0; j < digits->GetEntries(); j++) {
40      
41      AliPHOSDigit* dig = dynamic_cast<AliPHOSDigit*> (digits->At(j));
42      //cout << dig->GetEnergy() << endl;
43      hadc->Fill(dig->GetEnergy());
44      if(dig->GetEnergy()>0)
45        hadcLog->Fill(TMath::Log10(dig->GetEnergy()));
46      
47    }
48    
49  }
50  
51  TFile fc("digits.PHOS.root","RECREATE");
52  fc.cd();
53  hadc->Write();
54  hadcLog->Write();
55  fc.Close();
56
57
58 }