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