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