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