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"
28 #include "AliLoader.h"
30 #include "AliRunLoader.h"
31 #include "AliMUONVDigitStore.h"
32 #include "AliMUONVHitStore.h"
35 /// The sdigitizer performs the transformation from hits (energy deposits by
36 /// the transport code) to sdigits (equivalent of charges on pad).
38 /// It does so by converting the energy deposit into a charge and then spreading
39 /// this charge over several pads, according to the response function (a
40 /// Mathieson distribution, basically).
42 /// See also AliMUONResponseV0, which is doing the real job (in DisIntegrate
43 /// method), while this sdigitizer is just "steering" the process.
45 /// Please note that we do *not* merge sdigits after creation, which means
46 /// that after sdigitization, a given pad can have several sdigits. This
47 /// merging is taken care of later on by the digitizer(V3).
50 ClassImp(AliMUONSDigitizerV2)
52 //_____________________________________________________________________________
53 AliMUONSDigitizerV2::AliMUONSDigitizerV2()
54 : TTask("AliMUONSDigitizerV2","From Hits to SDigits for MUON")
61 //_____________________________________________________________________________
62 AliMUONSDigitizerV2::~AliMUONSDigitizerV2()
69 //_____________________________________________________________________________
71 AliMUONSDigitizerV2::Exec(Option_t*)
74 /// Go from hits to sdigits.
76 /// In the code below, apart from the loop itself (which look complicated
77 /// but is really only a loop on each hit in the input file) the main
78 /// work is done in AliMUONResponse::DisIntegrate method, which converts
79 /// a single hit in (possibly) several sdigits.
84 AliRunLoader* runLoader = AliRunLoader::GetRunLoader();
85 AliLoader* loader = runLoader->GetDetectorLoader("MUON");
87 loader->LoadHits("READ");
89 AliMUON* muon = static_cast<AliMUON*>(gAlice->GetModule("MUON"));
91 Int_t nofEvents(runLoader->GetNumberOfEvents());
93 TString classname = muon->DigitStoreClassName();
95 AliMUONVDigitStore* sDigitStore = AliMUONVDigitStore::Create(classname.Data());
99 AliFatal(Form("Could not create digitstore of class %s",classname.Data()));
102 AliInfo(Form("Will use digitStore of type %s",sDigitStore->ClassName()));
104 for ( Int_t iEvent = 0; iEvent < nofEvents; ++iEvent )
108 tdlist.SetOwner(kTRUE);
110 AliDebug(1,Form("iEvent=%d",iEvent));
111 runLoader->GetEvent(iEvent);
113 loader->MakeSDigitsContainer();
115 TTree* treeS = loader->TreeS();
122 sDigitStore->Connect(*treeS);
124 TTree* treeH = loader->TreeH();
126 AliMUONVHitStore* hitStore = AliMUONVHitStore::Create(*treeH);
127 hitStore->Connect(*treeH);
129 Long64_t nofTracks = treeH->GetEntries();
131 for ( Long64_t iTrack = 0; iTrack < nofTracks; ++iTrack )
133 // Loop over the tracks of this event.
134 treeH->GetEvent(iTrack);
137 TIter next(hitStore->CreateIterator());
140 while ( ( hit = static_cast<AliMUONHit*>(next()) ) )
142 Int_t chamberId = hit->Chamber()-1;
143 AliMUONChamber& chamber = muon->Chamber(chamberId);
144 AliMUONResponse* response = chamber.ResponseModel();
146 // This is the heart of this method : the dis-integration
148 response->DisIntegrate(*hit,digits);
152 while ( ( d = (AliMUONVDigit*)next() ) )
154 // Update some sdigit information that could not be known
155 // by the DisIntegrate method
157 d->AddTrack(iTrack,d->Charge());
163 } // end of loop on tracks within an event
168 while ( ( d = static_cast<AliMUONVDigit*>(next()) ) )
170 if ( d->Charge() > 0 ) // that check would be better in the disintegrate
171 // method, but to compare with old sdigitizer, it has to be there.
173 AliMUONVDigit* added = sDigitStore->Add(*d,AliMUONVDigitStore::kMerge);
176 AliError("Could not add digit to digitStore");
183 loader->WriteSDigits("OVERWRITE");
185 sDigitStore->Clear();
187 loader->UnloadSDigits();
193 loader->UnloadHits();