]>
Commit | Line | Data |
---|---|---|
66f93042 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2000, 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 | ||
88cb7938 | 16 | /* $Id$ */ |
ba030c0e | 17 | |
116cbefd | 18 | #include <TObjArray.h> |
88cb7938 | 19 | #include <TFile.h> |
30178c30 | 20 | #include <TError.h> |
21 | //#include <TTree.h> | |
22 | //#include <TDirectory.h> | |
66f93042 | 23 | |
116cbefd | 24 | #include "AliMUONMerger.h" |
30178c30 | 25 | #include "AliMUON.h" |
66f93042 | 26 | #include "AliMUONPadHit.h" |
66f93042 | 27 | #include "AliMUONTransientDigit.h" |
30178c30 | 28 | #include "AliHitMap.h" |
29 | //#include "AliMUONChamber.h" | |
30 | //#include "AliMUONConstants.h" | |
31 | //#include "AliMUONHit.h" | |
32 | //#include "AliMUONHitMapA1.h" | |
33 | //#include "AliRun.h" | |
c4a97bcd | 34 | #include "AliLog.h" |
66f93042 | 35 | |
36 | ClassImp(AliMUONMerger) | |
37 | ||
11ca64ac | 38 | //---------------------------------------------------------------------- |
c4a97bcd | 39 | AliMUONMerger::AliMUONMerger(): TObject() |
66f93042 | 40 | { |
41 | // Default constructor | |
42 | fEvNrSig = 0; | |
43 | fEvNrBgr = 0; | |
44 | fMerge = kDigitize; | |
45 | fFnBgr = 0; | |
46 | fHitMap = 0; | |
47 | fList = 0; | |
48 | fTrH1 = 0; | |
49 | fHitsBgr = 0; | |
50 | fPadHitsBgr = 0; | |
51 | fHitMap = 0; | |
52 | fList = 0; | |
77ccf5b0 | 53 | fBgrFile = 0; |
ba030c0e | 54 | fDebug = 0; |
66f93042 | 55 | } |
56 | ||
11ca64ac | 57 | //---------------------------------------------------------------------- |
c4a97bcd | 58 | AliMUONMerger::AliMUONMerger(const AliMUONMerger&): TObject() |
11ca64ac | 59 | { |
60 | // Protected copy constructor | |
61 | ||
c4a97bcd | 62 | AliFatal("Not implemented."); |
11ca64ac | 63 | } |
64 | ||
66f93042 | 65 | //------------------------------------------------------------------------ |
66 | AliMUONMerger::~AliMUONMerger() | |
67 | { | |
68 | // Destructor | |
69 | if (fTrH1) delete fTrH1; | |
70 | if (fHitsBgr) delete fHitsBgr; | |
71 | if (fPadHitsBgr) delete fPadHitsBgr; | |
3ec837bb | 72 | if (fHitMap) delete [] fHitMap; |
66f93042 | 73 | if (fList) delete fList; |
77ccf5b0 | 74 | if (fBgrFile) delete fBgrFile; |
66f93042 | 75 | } |
76 | ||
11ca64ac | 77 | //---------------------------------------------------------------------- |
78 | AliMUONMerger& AliMUONMerger::operator=(const AliMUONMerger& rhs) | |
79 | { | |
80 | // Protected assignement operator | |
81 | ||
82 | if (this == &rhs) return *this; | |
83 | ||
c4a97bcd | 84 | AliFatal("Not implemented."); |
11ca64ac | 85 | |
86 | return *this; | |
87 | } | |
88 | ||
66f93042 | 89 | //------------------------------------------------------------------------ |
c7955c78 | 90 | Bool_t AliMUONMerger::Exists(const AliMUONPadHit *padhit) const |
66f93042 | 91 | { |
3ec837bb | 92 | // test if the given padhit was already fired |
66f93042 | 93 | return (fHitMap[fNch]->TestHit(padhit->PadX(),padhit->PadY())); |
94 | } | |
95 | ||
96 | //------------------------------------------------------------------------ | |
8f36c696 | 97 | void AliMUONMerger::Update(AliMUONPadHit *padhit) |
66f93042 | 98 | { |
3ec837bb | 99 | // add new contribution to the fired padhit |
8f36c696 | 100 | AliMUONTransientDigit *pdigit = |
101 | static_cast<AliMUONTransientDigit*>( | |
102 | fHitMap[fNch]->GetHit(padhit->PadX(),padhit->PadY())); | |
66f93042 | 103 | |
66f93042 | 104 | // update charge |
105 | // | |
8f36c696 | 106 | Int_t iqpad = padhit->QPad(); // charge per pad |
107 | pdigit->AddSignal(iqpad); | |
108 | pdigit->AddPhysicsSignal(iqpad); | |
109 | ||
66f93042 | 110 | // update list of tracks |
111 | // | |
3351e14b | 112 | Int_t track, charge; |
8f36c696 | 113 | if (fSignal) { |
114 | track = fTrack; | |
115 | charge = iqpad; | |
66f93042 | 116 | } else { |
8f36c696 | 117 | track = kBgTag; |
118 | charge = kBgTag; | |
66f93042 | 119 | } |
8f36c696 | 120 | pdigit->UpdateTrackList(track,charge); |
66f93042 | 121 | } |
122 | ||
123 | //------------------------------------------------------------------------ | |
8f36c696 | 124 | void AliMUONMerger::CreateNew(AliMUONPadHit *padhit) |
66f93042 | 125 | { |
3ec837bb | 126 | // add new transient digit to the list, update hit map |
66f93042 | 127 | fList->AddAtAndExpand( |
128 | new AliMUONTransientDigit(fNch,fDigits),fCounter); | |
8f36c696 | 129 | fHitMap[fNch]->SetHit(padhit->PadX(),padhit->PadY(),fCounter); |
130 | AliMUONTransientDigit* pdigit = | |
c7955c78 | 131 | static_cast<AliMUONTransientDigit*>(fList->Last()); |
66f93042 | 132 | // list of tracks |
8f36c696 | 133 | Int_t track, charge; |
134 | if (fSignal) { | |
135 | track = fTrack; | |
136 | charge = padhit->QPad(); | |
137 | } else { | |
138 | track = kBgTag; | |
139 | charge = kBgTag; | |
140 | } | |
141 | pdigit->AddToTrackList(track,charge); | |
142 | fCounter++; | |
66f93042 | 143 | } |
144 | ||
145 | ||
146 | //------------------------------------------------------------------------ | |
147 | void AliMUONMerger::Init() | |
148 | { | |
149 | // Initialisation | |
77ccf5b0 | 150 | // open only once the background file !! |
151 | if (fMerge && !fBgrFile) fBgrFile = InitBgr(); | |
66f93042 | 152 | } |
153 | ||
154 | ||
155 | ||
156 | //------------------------------------------------------------------------ | |
157 | TFile* AliMUONMerger::InitBgr() | |
158 | { | |
159 | // Initialise background event | |
160 | TFile *file = new TFile(fFnBgr); | |
161 | // add error checking later | |
c4a97bcd | 162 | AliInfo(Form("\n AliMUONMerger has opened %s file with background event \n", fFnBgr)); |
66f93042 | 163 | fHitsBgr = new TClonesArray("AliMUONHit",1000); |
164 | fPadHitsBgr = new TClonesArray("AliMUONPadHit",1000); | |
165 | return file; | |
166 | } | |
167 | ||
168 | //------------------------------------------------------------------------ | |
169 | void AliMUONMerger::Digitise() | |
170 | { | |
171 | ||
172 | // keep galice.root for signal and name differently the file for | |
173 | // background when add! otherwise the track info for signal will be lost ! | |
ce3f5e87 | 174 | // Obsolete sep 2003 Gines MARTINEZ |
175 | // AliMUONChamber* iChamber; | |
176 | // AliSegmentation* segmentation; | |
177 | ||
178 | // fList = new TObjArray; | |
179 | ||
180 | // AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON"); | |
181 | // fHitMap= new AliHitMap* [AliMUONConstants::NCh()]; | |
182 | // if (fMerge ) { | |
183 | // fBgrFile->cd(); | |
184 | // // | |
185 | // // Get Hits Tree header from file | |
186 | // //if(fHitsBgr) fHitsBgr->Clear(); // Useless because line 327 | |
187 | // //if(fPadHitsBgr) fPadHitsBgr->Clear(); // Useless because line 328 | |
188 | // if(fTrH1) delete fTrH1; | |
189 | // fTrH1 = 0; | |
66f93042 | 190 | |
ce3f5e87 | 191 | // char treeName[20]; |
192 | // sprintf(treeName,"TreeH%d",fEvNrBgr); | |
193 | // fTrH1 = (TTree*)gDirectory->Get(treeName); | |
194 | // if (!fTrH1) { | |
195 | // printf("ERROR: cannot find Hits Tree for event:%d\n",fEvNrBgr); | |
196 | // } | |
197 | // // | |
198 | // // Set branch addresses | |
199 | // TBranch *branch; | |
200 | // char branchname[20]; | |
201 | // sprintf(branchname,"%s",pMUON->GetName()); | |
202 | // if (fTrH1 && fHitsBgr) { | |
203 | // branch = fTrH1->GetBranch(branchname); | |
204 | // if (branch) branch->SetAddress(&fHitsBgr); | |
205 | // } | |
206 | // if (fTrH1 && fPadHitsBgr) { | |
207 | // branch = fTrH1->GetBranch("MUONCluster"); | |
208 | // if (branch) branch->SetAddress(&fPadHitsBgr); | |
209 | // } | |
210 | // } | |
211 | // // | |
212 | // // loop over cathodes | |
213 | // // | |
214 | // fSignal = kTRUE; | |
215 | // for (int icat = 0; icat < 2; icat++) { | |
216 | // fCounter = 0; | |
217 | // for (Int_t i = 0; i < AliMUONConstants::NCh(); i++) { | |
218 | // iChamber = &(pMUON->Chamber(i)); | |
219 | // if (iChamber->Nsec() == 1 && icat == 1) { | |
220 | // continue; | |
221 | // } else { | |
222 | // segmentation = iChamber->SegmentationModel(icat+1); | |
223 | // } | |
224 | // fHitMap[i] = new AliMUONHitMapA1(segmentation, fList); | |
225 | // } | |
226 | ||
227 | // // | |
228 | // // Loop over tracks | |
229 | // // | |
230 | ||
231 | // /******************************************************************/ | |
232 | // TTree* treeH = pMUON->TreeH(); | |
233 | // if (treeH == 0x0) | |
234 | // { | |
235 | // cerr<<"AliMUONMerger::Exec: Can not get TreeH"<<endl; | |
236 | // return; | |
237 | // } | |
238 | // /******************************************************************/ | |
88cb7938 | 239 | |
240 | ||
241 | ||
ce3f5e87 | 242 | // Int_t ntracks = (Int_t) treeH->GetEntries(); |
243 | // treeH->SetBranchStatus("*",0); // switch off all branches | |
244 | // treeH->SetBranchStatus("MUON*",1); // switch on only MUON | |
245 | ||
246 | // for (fTrack = 0; fTrack < ntracks; fTrack++) { | |
247 | // gAlice->ResetHits(); | |
248 | // treeH->GetEntry(fTrack,0); | |
249 | // // | |
250 | // // Loop over hits | |
251 | // for(AliMUONHit* mHit = (AliMUONHit*)pMUON->FirstHit(-1); | |
252 | // mHit; | |
253 | // mHit = (AliMUONHit*)pMUON->NextHit()) | |
254 | // { | |
255 | // fNch = mHit->Chamber()-1; // chamber number | |
256 | // if (fNch > AliMUONConstants::NCh()-1) continue; | |
257 | // iChamber = &(pMUON->Chamber(fNch)); | |
66f93042 | 258 | |
ce3f5e87 | 259 | // // |
260 | // // Loop over pad hits | |
261 | // for (AliMUONPadHit* mPad = | |
262 | // (AliMUONPadHit*)pMUON->FirstPad(mHit,pMUON->PadHits()); | |
263 | // mPad; | |
264 | // mPad = (AliMUONPadHit*)pMUON->NextPad(pMUON->PadHits())) | |
265 | // { | |
266 | // Int_t cathode = mPad->Cathode(); // cathode number | |
267 | // if (cathode != (icat+1)) continue; | |
268 | // Int_t iqpad = Int_t(mPad->QPad()); // charge per pad | |
269 | // // segmentation = iChamber->SegmentationModel(cathode); | |
270 | // fDigits[0] = mPad->PadX(); | |
271 | // fDigits[1] = mPad->PadY(); | |
272 | // if (!(fHitMap[fNch]->ValidateHit(fDigits[0], fDigits[1]))) continue; | |
273 | // fDigits[2] = icat; | |
274 | // fDigits[3] = iqpad; | |
275 | // fDigits[4] = iqpad; | |
276 | // if (mHit->Particle() == kMuonPlus || | |
277 | // mHit->Particle() == kMuonMinus) { | |
278 | // fDigits[5] = mPad->HitNumber(); | |
279 | // } else fDigits[5] = -1; | |
280 | ||
281 | // // build the list of fired pads and update the info | |
282 | ||
283 | // if (!Exists(mPad)) { | |
284 | // CreateNew(mPad); | |
285 | // } else { | |
286 | // Update(mPad); | |
287 | // } // end if pdigit | |
288 | // } //end loop over clusters | |
289 | // } // hit loop | |
290 | // } // track loop | |
291 | ||
292 | // // open the file with background | |
66f93042 | 293 | |
ce3f5e87 | 294 | // if (fMerge) { |
295 | // fSignal = kFALSE; | |
296 | // ntracks = (Int_t)fTrH1->GetEntries(); | |
297 | // // | |
298 | // // Loop over tracks | |
299 | // // | |
300 | // for (fTrack = 0; fTrack < ntracks; fTrack++) { | |
301 | ||
302 | // if (fHitsBgr) fHitsBgr->Clear(); | |
303 | // if (fPadHitsBgr) fPadHitsBgr->Clear(); | |
304 | ||
305 | // fTrH1->GetEvent(fTrack); | |
306 | // // | |
307 | // // Loop over hits | |
308 | // AliMUONHit* mHit; | |
309 | // for(Int_t i = 0; i < fHitsBgr->GetEntriesFast(); ++i) | |
310 | // { | |
311 | // mHit = (AliMUONHit*) (*fHitsBgr)[i]; | |
312 | // fNch = mHit->Chamber()-1; // chamber number | |
313 | // iChamber = &(pMUON->Chamber(fNch)); | |
314 | // // | |
315 | // // Loop over pad hits | |
316 | // for (AliMUONPadHit* mPad = | |
317 | // (AliMUONPadHit*)pMUON->FirstPad(mHit,fPadHitsBgr); | |
318 | // mPad; | |
319 | // mPad = (AliMUONPadHit*)pMUON->NextPad(fPadHitsBgr)) | |
320 | // { | |
321 | // Int_t cathode = mPad->Cathode(); // cathode number | |
322 | // Int_t ipx = mPad->PadX(); // pad number on X | |
323 | // Int_t ipy = mPad->PadY(); // pad number on Y | |
324 | // Int_t iqpad = Int_t(mPad->QPad()); // charge per pad | |
325 | // if (!(fHitMap[fNch]->ValidateHit(ipx, ipy))) continue; | |
326 | ||
327 | // if (cathode != (icat+1)) continue; | |
328 | // fDigits[0] = ipx; | |
329 | // fDigits[1] = ipy; | |
330 | // fDigits[2] = icat; | |
331 | // fDigits[3] = iqpad; | |
332 | // fDigits[4] = 0; | |
333 | // fDigits[5] = -1; | |
66f93042 | 334 | |
ce3f5e87 | 335 | // // build the list of fired pads and update the info |
336 | // if (!Exists(mPad)) { | |
337 | // CreateNew(mPad); | |
338 | // } else { | |
339 | // Update(mPad); | |
340 | // } // end if !Exists | |
341 | // } //end loop over clusters | |
342 | // } // hit loop | |
343 | // } // track loop | |
344 | ||
345 | // TTree *treeK = gAlice->TreeK(); | |
346 | // TFile *file = NULL; | |
66f93042 | 347 | |
ce3f5e87 | 348 | // if (treeK) file = treeK->GetCurrentFile(); |
349 | // file->cd(); | |
350 | // } // if fMerge | |
66f93042 | 351 | |
ce3f5e87 | 352 | // Int_t tracks[kMAXTRACKS]; |
353 | // Int_t charges[kMAXTRACKS]; | |
354 | // Int_t nentries = fList->GetEntriesFast(); | |
66f93042 | 355 | |
ce3f5e87 | 356 | // for (Int_t nent = 0; nent < nentries; nent++) { |
357 | // AliMUONTransientDigit *address = (AliMUONTransientDigit*)fList->At(nent); | |
358 | // if (address == 0) continue; | |
359 | // Int_t ich = address->Chamber(); | |
360 | // Int_t q = address->Signal(); | |
361 | // iChamber = &(pMUON->Chamber(ich)); | |
362 | // // | |
363 | // // Digit Response (noise, threshold, saturation, ...) | |
364 | // AliMUONResponse * response = iChamber->ResponseModel(); | |
365 | // q = response->DigitResponse(q,address); | |
66f93042 | 366 | |
ce3f5e87 | 367 | // if (!q) continue; |
66f93042 | 368 | |
ce3f5e87 | 369 | // fDigits[0] = address->PadX(); |
370 | // fDigits[1] = address->PadY(); | |
371 | // fDigits[2] = address->Cathode(); | |
372 | // fDigits[3] = q; | |
373 | // fDigits[4] = address->Physics(); | |
374 | // fDigits[5] = address->Hit(); | |
66f93042 | 375 | |
ce3f5e87 | 376 | // Int_t nptracks = address->GetNTracks(); |
377 | ||
378 | // if (nptracks > kMAXTRACKS) { | |
379 | // if (fDebug>0) | |
380 | // printf("\n Attention - nptracks > kMAXTRACKS %d \n", nptracks); | |
381 | // nptracks = kMAXTRACKS; | |
382 | // } | |
383 | // if (nptracks > 2) { | |
384 | // if (fDebug>0) { | |
385 | // printf("Attention - nptracks > 2 %d \n",nptracks); | |
386 | // printf("cat,ich,ix,iy,q %d %d %d %d %d \n",icat,ich,fDigits[0],fDigits[1],q); | |
387 | // } | |
388 | // } | |
389 | // for (Int_t tr = 0; tr < nptracks; tr++) { | |
390 | // tracks[tr] = address->GetTrack(tr); | |
391 | // charges[tr] = address->GetCharge(tr); | |
392 | // } //end loop over list of tracks for one pad | |
393 | // // Sort list of tracks according to charge | |
394 | // if (nptracks > 1) { | |
395 | // SortTracks(tracks,charges,nptracks); | |
396 | // } | |
397 | // if (nptracks < kMAXTRACKS ) { | |
398 | // for (Int_t i = nptracks; i < kMAXTRACKS; i++) { | |
399 | // tracks[i] = 0; | |
400 | // charges[i] = 0; | |
401 | // } | |
402 | // } | |
66f93042 | 403 | |
ce3f5e87 | 404 | // // fill digits |
405 | // pMUON->AddDigits(ich,tracks,charges,fDigits); | |
406 | // } | |
407 | // gAlice->TreeD()->Fill(); | |
408 | // pMUON->ResetDigits(); | |
409 | // fList->Delete(); | |
66f93042 | 410 | |
411 | ||
ce3f5e87 | 412 | // for(Int_t ii = 0; ii < AliMUONConstants::NCh(); ++ii) { |
413 | // if (fHitMap[ii]) { | |
414 | // delete fHitMap[ii]; | |
415 | // fHitMap[ii] = 0; | |
416 | // } | |
417 | // } | |
418 | // } //end loop over cathodes | |
419 | // delete [] fHitMap; | |
420 | // delete fList; | |
66f93042 | 421 | |
77ccf5b0 | 422 | // no need to delete ... and it makes a crash also |
423 | // if (fHitsBgr) fHitsBgr->Delete(); | |
424 | // if (fPadHitsBgr) fPadHitsBgr->Delete(); | |
66f93042 | 425 | // gObjectTable->Print(); |
426 | } | |
427 | ||
428 | ||
429 | ||
30178c30 | 430 | void AliMUONMerger::SortTracks(Int_t *tracks,Int_t *charges,Int_t ntr) const |
a3f472a9 | 431 | { |
432 | // | |
433 | // Sort the list of tracks contributing to a given digit | |
434 | // Only the 3 most significant tracks are acctually sorted | |
435 | // | |
436 | ||
437 | // | |
438 | // Loop over signals, only 3 times | |
439 | // | |
440 | ||
441 | Int_t qmax; | |
442 | Int_t jmax; | |
443 | Int_t idx[3] = {-2,-2,-2}; | |
444 | Int_t jch[3] = {-2,-2,-2}; | |
445 | Int_t jtr[3] = {-2,-2,-2}; | |
446 | Int_t i,j,imax; | |
447 | ||
448 | if (ntr<3) imax=ntr; | |
449 | else imax=3; | |
450 | for(i=0;i<imax;i++){ | |
451 | qmax=0; | |
452 | jmax=0; | |
453 | ||
454 | for(j=0;j<ntr;j++){ | |
455 | ||
456 | if((i == 1 && j == idx[i-1]) | |
457 | ||(i == 2 && (j == idx[i-1] || j == idx[i-2]))) continue; | |
458 | ||
459 | if(charges[j] > qmax) { | |
460 | qmax = charges[j]; | |
461 | jmax=j; | |
462 | } | |
463 | } | |
464 | ||
465 | if(qmax > 0) { | |
466 | idx[i]=jmax; | |
467 | jch[i]=charges[jmax]; | |
468 | jtr[i]=tracks[jmax]; | |
469 | } | |
470 | ||
471 | } | |
472 | ||
473 | for(i=0;i<3;i++){ | |
474 | if (jtr[i] == -2) { | |
475 | charges[i]=0; | |
476 | tracks[i]=0; | |
477 | } else { | |
478 | charges[i]=jch[i]; | |
479 | tracks[i]=jtr[i]; | |
480 | } | |
481 | } | |
482 | } | |
483 | ||
66f93042 | 484 | |
485 |