]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONSDigitizerV2.cxx
Remove obsolete class AliTPCclusterLMI (Marian)
[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
ae6eeca4 31///
32/// The sdigitizer performs the transformation from hits (energy deposits by
33/// the transport code) to sdigits (equivalent of charges on pad).
34///
35/// It does so by converting the energy deposit into a charge and then spreading
36/// this charge over several pads, according to the response function (a
37/// Mathieson distribution, basically).
38///
39/// See also AliMUONResponseV0, which is doing the real job (in DisIntegrate
40/// method), while this sdigitizer is just "steering" the process.
41///
42/// Please note that we do *not* merge sdigits after creation, which means
43/// that after sdigitization, a given pad can have several sdigits. This
44/// merging is taken care of later on by the digitizer(V3).
45///
46
60d3a1d3 47ClassImp(AliMUONSDigitizerV2)
48
49//_____________________________________________________________________________
50AliMUONSDigitizerV2::AliMUONSDigitizerV2()
51: TTask("AliMUONSDigitizerV2","From Hits to SDigits for MUON")
52{
2c6e3e30 53 //
54 // ctor.
55 //
60d3a1d3 56}
57
58//_____________________________________________________________________________
59AliMUONSDigitizerV2::~AliMUONSDigitizerV2()
60{
2c6e3e30 61 //
62 // dtor.
63 //
60d3a1d3 64}
65
66//_____________________________________________________________________________
67void
68AliMUONSDigitizerV2::Exec(Option_t*)
69{
70 //
71 // Go from hits to sdigits.
72 //
2c6e3e30 73 // In the code below, apart from the loop itself (which look complicated
74 // but is really only a loop on each hit in the input file) the main
75 // work is done in AliMUONResponse::DisIntegrate method, which converts
76 // a single hit in (possibly) several sdigits.
77 //
60d3a1d3 78
79 AliDebug(1,"");
80
81 AliRunLoader* runLoader = AliRunLoader::GetRunLoader();
82 AliLoader* fLoader = runLoader->GetLoader("MUONLoader");
83
84 fLoader->LoadHits("READ");
85
86 AliMUONData muonData(fLoader,"MUON","MUON");
87
88 AliMUON* muon = static_cast<AliMUON*>(gAlice->GetModule("MUON"));
89
ae6eeca4 90 Int_t nofEvents(runLoader->GetNumberOfEvents());
60d3a1d3 91 for ( Int_t iEvent = 0; iEvent < nofEvents; ++iEvent )
92 {
2c6e3e30 93 // Loop over events.
60d3a1d3 94 TObjArray tdlist;
95 tdlist.SetOwner(kTRUE);
96
97 AliDebug(1,Form("iEvent=%d",iEvent));
98 runLoader->GetEvent(iEvent);
99 TTree* treeS = fLoader->TreeS();
100 AliDebug(1,Form("TreeS=%p",treeS));
101 if ( !treeS )
102 {
103 AliDebug(1,"MakeSDigitsContainer");
104 fLoader->MakeSDigitsContainer();
105 treeS = fLoader->TreeS();
106 }
107 AliDebug(1,Form("TreeS=%p",treeS));
108 muonData.MakeBranch("S");
109 muonData.SetTreeAddress("S");
110
111 muonData.SetTreeAddress("H");
112 TTree* treeH = fLoader->TreeH();
113 AliDebug(1,Form("TreeH=%p",treeH));
114
115 Long64_t nofTracks = treeH->GetEntries();
116 for ( Long64_t iTrack = 0; iTrack < nofTracks; ++iTrack )
117 {
2c6e3e30 118 // Loop over the tracks of this event.
60d3a1d3 119 treeH->GetEvent(iTrack);
120 TClonesArray* hits = muonData.Hits();
121 Int_t nofHits = hits->GetEntriesFast();
122 for ( Int_t ihit = 0; ihit < nofHits; ++ihit )
123 {
2c6e3e30 124 // Loop over the hits of this track.
60d3a1d3 125 AliMUONHit* hit = static_cast<AliMUONHit*>(hits->At(ihit));
126 Int_t chamberId = hit->Chamber()-1;
127 AliMUONChamber& chamber = muon->Chamber(chamberId);
128 AliMUONResponse* response = chamber.ResponseModel();
2c6e3e30 129
130 // This is the heart of this method : the dis-integration
131 TList digits;
60d3a1d3 132 response->DisIntegrate(*hit,digits);
2c6e3e30 133
60d3a1d3 134 TIter next(&digits);
135 AliMUONDigit* d;
136 while ( ( d = (AliMUONDigit*)next() ) )
137 {
2c6e3e30 138 // Update some sdigit information that could not be known
139 // by the DisIntegrate method
60d3a1d3 140 d->SetHit(ihit);
2c6e3e30 141 d->AddTrack(iTrack,d->Signal());
60d3a1d3 142 tdlist.Add(d);
143 }
144 }
145 muonData.ResetHits();
2c6e3e30 146 } // end of loop on tracks within an event
147
60d3a1d3 148 for ( Int_t i = 0; i <= tdlist.GetLast(); ++i )
149 {
150 AliMUONDigit* d = (AliMUONDigit*)tdlist[i];
151 StdoutToAliDebug(1,d->Print(););
152 if ( d->Signal() > 0 ) // that check would be better in the disintegrate
153 // method, but to compare with old sdigitizer, it has to be there.
154 {
155 muonData.AddSDigit(d->DetElemId()/100-1,*d);
156 }
157 }
158 muonData.Fill("S");
159 fLoader->WriteSDigits("OVERWRITE");
2c6e3e30 160
60d3a1d3 161 muonData.ResetSDigits();
162 fLoader->UnloadSDigits();
163 } // loop on events
164
165 fLoader->UnloadHits();
166}