]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONSDigitizerV2.cxx
Updated for modifs in AliMpFiles
[u/mrichter/AliRoot.git] / MUON / AliMUONSDigitizerV2.cxx
CommitLineData
60d3a1d3 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 "AliMUONSDigitizerV2.h"
19
20#include "AliLog.h"
21#include "AliMUON.h"
22#include "AliMUONChamber.h"
23#include "AliMUONData.h"
24#include "AliMUONDigit.h"
25#include "AliMUONHit.h"
26#include "AliLoader.h"
27#include "AliRun.h"
28#include "AliRunLoader.h"
29#include "TObjArray.h"
30
31ClassImp(AliMUONSDigitizerV2)
32
33//_____________________________________________________________________________
34AliMUONSDigitizerV2::AliMUONSDigitizerV2()
35: TTask("AliMUONSDigitizerV2","From Hits to SDigits for MUON")
36{
37}
38
39//_____________________________________________________________________________
40AliMUONSDigitizerV2::~AliMUONSDigitizerV2()
41{
42}
43
44//_____________________________________________________________________________
45void
46AliMUONSDigitizerV2::Exec(Option_t*)
47{
48 //
49 // Go from hits to sdigits.
50 //
51
52 AliDebug(1,"");
53
54 AliRunLoader* runLoader = AliRunLoader::GetRunLoader();
55 AliLoader* fLoader = runLoader->GetLoader("MUONLoader");
56
57 fLoader->LoadHits("READ");
58
59 AliMUONData muonData(fLoader,"MUON","MUON");
60
61 AliMUON* muon = static_cast<AliMUON*>(gAlice->GetModule("MUON"));
62
63 const Int_t nofEvents(runLoader->GetNumberOfEvents());
64 for ( Int_t iEvent = 0; iEvent < nofEvents; ++iEvent )
65 {
66 TObjArray tdlist;
67 tdlist.SetOwner(kTRUE);
68
69 AliDebug(1,Form("iEvent=%d",iEvent));
70 runLoader->GetEvent(iEvent);
71 TTree* treeS = fLoader->TreeS();
72 AliDebug(1,Form("TreeS=%p",treeS));
73 if ( !treeS )
74 {
75 AliDebug(1,"MakeSDigitsContainer");
76 fLoader->MakeSDigitsContainer();
77 treeS = fLoader->TreeS();
78 }
79 AliDebug(1,Form("TreeS=%p",treeS));
80 muonData.MakeBranch("S");
81 muonData.SetTreeAddress("S");
82
83 muonData.SetTreeAddress("H");
84 TTree* treeH = fLoader->TreeH();
85 AliDebug(1,Form("TreeH=%p",treeH));
86
87 Long64_t nofTracks = treeH->GetEntries();
88 for ( Long64_t iTrack = 0; iTrack < nofTracks; ++iTrack )
89 {
90 treeH->GetEvent(iTrack);
91 TClonesArray* hits = muonData.Hits();
92 Int_t nofHits = hits->GetEntriesFast();
93 for ( Int_t ihit = 0; ihit < nofHits; ++ihit )
94 {
95 AliMUONHit* hit = static_cast<AliMUONHit*>(hits->At(ihit));
96 Int_t chamberId = hit->Chamber()-1;
97 AliMUONChamber& chamber = muon->Chamber(chamberId);
98 AliMUONResponse* response = chamber.ResponseModel();
99 TList digits;
100 response->DisIntegrate(*hit,digits);
101 TIter next(&digits);
102 AliMUONDigit* d;
103 while ( ( d = (AliMUONDigit*)next() ) )
104 {
105 d->SetHit(ihit);
106 tdlist.Add(d);
107 }
108 }
109 muonData.ResetHits();
110 } // loop on tracks within an event
111 tdlist.Sort(); // not really needed, except for comparing with old sdigitizer
112 for ( Int_t i = 0; i <= tdlist.GetLast(); ++i )
113 {
114 AliMUONDigit* d = (AliMUONDigit*)tdlist[i];
115 StdoutToAliDebug(1,d->Print(););
116 if ( d->Signal() > 0 ) // that check would be better in the disintegrate
117 // method, but to compare with old sdigitizer, it has to be there.
118 {
119 muonData.AddSDigit(d->DetElemId()/100-1,*d);
120 }
121 }
122 muonData.Fill("S");
123 fLoader->WriteSDigits("OVERWRITE");
124 muonData.ResetSDigits();
125 fLoader->UnloadSDigits();
126 } // loop on events
127
128 fLoader->UnloadHits();
129}