]>
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 | ||
7ca4655f | 18 | #include <TClonesArray.h> |
19 | ||
60d3a1d3 | 20 | #include "AliMUONSDigitizerV2.h" |
21 | ||
22 | #include "AliLog.h" | |
23 | #include "AliMUON.h" | |
24 | #include "AliMUONChamber.h" | |
445096c0 | 25 | #include "AliMUONVDigit.h" |
60d3a1d3 | 26 | #include "AliMUONHit.h" |
66f4c572 | 27 | #include "AliMpDEManager.h" |
60d3a1d3 | 28 | #include "AliLoader.h" |
29 | #include "AliRun.h" | |
30 | #include "AliRunLoader.h" | |
5ee595ac | 31 | #include "AliMUONVDigitStore.h" |
445096c0 | 32 | #include "AliMUONVHitStore.h" |
66f4c572 | 33 | |
ae6eeca4 | 34 | /// |
35 | /// The sdigitizer performs the transformation from hits (energy deposits by | |
36 | /// the transport code) to sdigits (equivalent of charges on pad). | |
37 | /// | |
38 | /// It does so by converting the energy deposit into a charge and then spreading | |
39 | /// this charge over several pads, according to the response function (a | |
40 | /// Mathieson distribution, basically). | |
41 | /// | |
42 | /// See also AliMUONResponseV0, which is doing the real job (in DisIntegrate | |
43 | /// method), while this sdigitizer is just "steering" the process. | |
44 | /// | |
45 | /// Please note that we do *not* merge sdigits after creation, which means | |
46 | /// that after sdigitization, a given pad can have several sdigits. This | |
47 | /// merging is taken care of later on by the digitizer(V3). | |
48 | /// | |
49 | ||
60d3a1d3 | 50 | ClassImp(AliMUONSDigitizerV2) |
51 | ||
52 | //_____________________________________________________________________________ | |
53 | AliMUONSDigitizerV2::AliMUONSDigitizerV2() | |
54 | : TTask("AliMUONSDigitizerV2","From Hits to SDigits for MUON") | |
55 | { | |
71a2d3aa | 56 | /// |
57 | /// ctor. | |
58 | /// | |
60d3a1d3 | 59 | } |
60 | ||
61 | //_____________________________________________________________________________ | |
62 | AliMUONSDigitizerV2::~AliMUONSDigitizerV2() | |
63 | { | |
71a2d3aa | 64 | /// |
65 | /// dtor. | |
66 | /// | |
60d3a1d3 | 67 | } |
68 | ||
69 | //_____________________________________________________________________________ | |
70 | void | |
71 | AliMUONSDigitizerV2::Exec(Option_t*) | |
72 | { | |
71a2d3aa | 73 | /// |
74 | /// Go from hits to sdigits. | |
75 | /// | |
76 | /// In the code below, apart from the loop itself (which look complicated | |
77 | /// but is really only a loop on each hit in the input file) the main | |
78 | /// work is done in AliMUONResponse::DisIntegrate method, which converts | |
79 | /// a single hit in (possibly) several sdigits. | |
80 | /// | |
60d3a1d3 | 81 | |
82 | AliDebug(1,""); | |
83 | ||
84 | AliRunLoader* runLoader = AliRunLoader::GetRunLoader(); | |
445096c0 | 85 | AliLoader* loader = runLoader->GetDetectorLoader("MUON"); |
60d3a1d3 | 86 | |
445096c0 | 87 | loader->LoadHits("READ"); |
60d3a1d3 | 88 | |
60d3a1d3 | 89 | AliMUON* muon = static_cast<AliMUON*>(gAlice->GetModule("MUON")); |
90 | ||
ae6eeca4 | 91 | Int_t nofEvents(runLoader->GetNumberOfEvents()); |
445096c0 | 92 | |
5ee595ac | 93 | TString classname = muon->DigitStoreClassName(); |
445096c0 | 94 | |
5ee595ac | 95 | AliMUONVDigitStore* sDigitStore = AliMUONVDigitStore::Create(classname.Data()); |
96 | ||
97 | if (!sDigitStore) | |
98 | { | |
99 | AliFatal(Form("Could not create digitstore of class %s",classname.Data())); | |
100 | } | |
101 | ||
102 | AliInfo(Form("Will use digitStore of type %s",sDigitStore->ClassName())); | |
103 | ||
60d3a1d3 | 104 | for ( Int_t iEvent = 0; iEvent < nofEvents; ++iEvent ) |
105 | { | |
2c6e3e30 | 106 | // Loop over events. |
60d3a1d3 | 107 | TObjArray tdlist; |
108 | tdlist.SetOwner(kTRUE); | |
109 | ||
110 | AliDebug(1,Form("iEvent=%d",iEvent)); | |
111 | runLoader->GetEvent(iEvent); | |
445096c0 | 112 | |
113 | loader->MakeSDigitsContainer(); | |
114 | ||
115 | TTree* treeS = loader->TreeS(); | |
116 | ||
60d3a1d3 | 117 | if ( !treeS ) |
118 | { | |
445096c0 | 119 | AliFatal(""); |
60d3a1d3 | 120 | } |
445096c0 | 121 | |
122 | sDigitStore->Connect(*treeS); | |
123 | ||
124 | TTree* treeH = loader->TreeH(); | |
125 | ||
126 | AliMUONVHitStore* hitStore = AliMUONVHitStore::Create(*treeH); | |
127 | hitStore->Connect(*treeH); | |
60d3a1d3 | 128 | |
60d3a1d3 | 129 | Long64_t nofTracks = treeH->GetEntries(); |
445096c0 | 130 | |
60d3a1d3 | 131 | for ( Long64_t iTrack = 0; iTrack < nofTracks; ++iTrack ) |
132 | { | |
2c6e3e30 | 133 | // Loop over the tracks of this event. |
60d3a1d3 | 134 | treeH->GetEvent(iTrack); |
445096c0 | 135 | |
136 | AliMUONHit* hit; | |
137 | TIter next(hitStore->CreateIterator()); | |
138 | Int_t ihit(0); | |
139 | ||
140 | while ( ( hit = static_cast<AliMUONHit*>(next()) ) ) | |
60d3a1d3 | 141 | { |
60d3a1d3 | 142 | Int_t chamberId = hit->Chamber()-1; |
143 | AliMUONChamber& chamber = muon->Chamber(chamberId); | |
144 | AliMUONResponse* response = chamber.ResponseModel(); | |
2c6e3e30 | 145 | |
146 | // This is the heart of this method : the dis-integration | |
147 | TList digits; | |
60d3a1d3 | 148 | response->DisIntegrate(*hit,digits); |
2c6e3e30 | 149 | |
60d3a1d3 | 150 | TIter next(&digits); |
445096c0 | 151 | AliMUONVDigit* d; |
152 | while ( ( d = (AliMUONVDigit*)next() ) ) | |
60d3a1d3 | 153 | { |
2c6e3e30 | 154 | // Update some sdigit information that could not be known |
155 | // by the DisIntegrate method | |
60d3a1d3 | 156 | d->SetHit(ihit); |
445096c0 | 157 | d->AddTrack(iTrack,d->Charge()); |
60d3a1d3 | 158 | tdlist.Add(d); |
159 | } | |
445096c0 | 160 | ++ihit; |
60d3a1d3 | 161 | } |
445096c0 | 162 | hitStore->Clear(); |
2c6e3e30 | 163 | } // end of loop on tracks within an event |
164 | ||
445096c0 | 165 | TIter next(&tdlist); |
166 | AliMUONVDigit* d; | |
167 | ||
168 | while ( ( d = static_cast<AliMUONVDigit*>(next()) ) ) | |
60d3a1d3 | 169 | { |
445096c0 | 170 | if ( d->Charge() > 0 ) // that check would be better in the disintegrate |
60d3a1d3 | 171 | // method, but to compare with old sdigitizer, it has to be there. |
172 | { | |
445096c0 | 173 | AliMUONVDigit* added = sDigitStore->Add(*d,AliMUONVDigitStore::kMerge); |
174 | if (!added) | |
175 | { | |
176 | AliError("Could not add digit to digitStore"); | |
177 | } | |
60d3a1d3 | 178 | } |
179 | } | |
445096c0 | 180 | |
181 | treeS->Fill(); | |
182 | ||
183 | loader->WriteSDigits("OVERWRITE"); | |
184 | ||
185 | sDigitStore->Clear(); | |
186 | ||
187 | loader->UnloadSDigits(); | |
188 | ||
189 | delete hitStore; | |
2c6e3e30 | 190 | |
60d3a1d3 | 191 | } // loop on events |
192 | ||
445096c0 | 193 | loader->UnloadHits(); |
194 | ||
195 | delete sDigitStore; | |
60d3a1d3 | 196 | } |