1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include <TClonesArray.h>
20 #include "AliMUONSDigitizerV2.h"
24 #include "AliMUONChamber.h"
25 #include "AliMUONVDigit.h"
26 #include "AliMUONHit.h"
27 #include "AliMpDEManager.h"
29 #include "AliLoader.h"
31 #include "AliRunLoader.h"
32 #include "AliMUONVDigitStore.h"
33 #include "AliMUONVHitStore.h"
36 /// The sdigitizer performs the transformation from hits (energy deposits by
37 /// the transport code) to sdigits (equivalent of charges on pad).
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).
43 /// See also AliMUONResponseV0, which is doing the real job (in DisIntegrate
44 /// method), while this sdigitizer is just "steering" the process.
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).
51 ClassImp(AliMUONSDigitizerV2)
53 //_____________________________________________________________________________
54 AliMUONSDigitizerV2::AliMUONSDigitizerV2()
55 : TTask("AliMUONSDigitizerV2","From Hits to SDigits for MUON")
60 if ( ! AliMpCDB::LoadMpSegmentation() )
62 AliFatal("Could not access mapping from OCDB !");
66 //_____________________________________________________________________________
67 AliMUONSDigitizerV2::~AliMUONSDigitizerV2()
74 //_____________________________________________________________________________
76 AliMUONSDigitizerV2::Exec(Option_t*)
79 /// Go from hits to sdigits.
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.
89 AliRunLoader* runLoader = AliRunLoader::GetRunLoader();
90 AliLoader* loader = runLoader->GetDetectorLoader("MUON");
92 loader->LoadHits("READ");
94 AliMUON* muon = static_cast<AliMUON*>(gAlice->GetModule("MUON"));
96 Int_t nofEvents(runLoader->GetNumberOfEvents());
98 TString classname = muon->DigitStoreClassName();
100 AliMUONVDigitStore* sDigitStore = AliMUONVDigitStore::Create(classname.Data());
104 AliFatal(Form("Could not create digitstore of class %s",classname.Data()));
107 AliInfo(Form("Will use digitStore of type %s",sDigitStore->ClassName()));
109 for ( Int_t iEvent = 0; iEvent < nofEvents; ++iEvent )
113 tdlist.SetOwner(kTRUE);
115 AliDebug(1,Form("iEvent=%d",iEvent));
116 runLoader->GetEvent(iEvent);
118 loader->MakeSDigitsContainer();
120 TTree* treeS = loader->TreeS();
127 sDigitStore->Connect(*treeS);
129 TTree* treeH = loader->TreeH();
131 AliMUONVHitStore* hitStore = AliMUONVHitStore::Create(*treeH);
132 hitStore->Connect(*treeH);
134 Long64_t nofTracks = treeH->GetEntries();
136 for ( Long64_t iTrack = 0; iTrack < nofTracks; ++iTrack )
138 // Loop over the tracks of this event.
139 treeH->GetEvent(iTrack);
142 TIter next(hitStore->CreateIterator());
145 while ( ( hit = static_cast<AliMUONHit*>(next()) ) )
147 Int_t chamberId = hit->Chamber()-1;
148 AliMUONChamber& chamber = muon->Chamber(chamberId);
149 AliMUONResponse* response = chamber.ResponseModel();
151 // This is the heart of this method : the dis-integration
153 response->DisIntegrate(*hit,digits);
157 while ( ( d = (AliMUONVDigit*)next() ) )
159 // Update some sdigit information that could not be known
160 // by the DisIntegrate method
162 d->AddTrack(iTrack,d->Charge());
168 } // end of loop on tracks within an event
173 while ( ( d = static_cast<AliMUONVDigit*>(next()) ) )
175 if ( d->Charge() > 0 ) // that check would be better in the disintegrate
176 // method, but to compare with old sdigitizer, it has to be there.
178 AliMUONVDigit* added = sDigitStore->Add(*d,AliMUONVDigitStore::kMerge);
181 AliError("Could not add digit to digitStore");
188 loader->WriteSDigits("OVERWRITE");
190 sDigitStore->Clear();
192 loader->UnloadSDigits();
198 loader->UnloadHits();