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