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