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