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 "AliMUONSDigitizerV2.h"
22 #include "AliMUONChamber.h"
23 #include "AliMUONData.h"
24 #include "AliMUONDigit.h"
25 #include "AliMUONHit.h"
26 #include "AliMpDEManager.h"
27 #include "AliLoader.h"
29 #include "AliRunLoader.h"
30 #include "TObjArray.h"
34 /// The sdigitizer performs the transformation from hits (energy deposits by
35 /// the transport code) to sdigits (equivalent of charges on pad).
37 /// It does so by converting the energy deposit into a charge and then spreading
38 /// this charge over several pads, according to the response function (a
39 /// Mathieson distribution, basically).
41 /// See also AliMUONResponseV0, which is doing the real job (in DisIntegrate
42 /// method), while this sdigitizer is just "steering" the process.
44 /// Please note that we do *not* merge sdigits after creation, which means
45 /// that after sdigitization, a given pad can have several sdigits. This
46 /// merging is taken care of later on by the digitizer(V3).
49 ClassImp(AliMUONSDigitizerV2)
51 //_____________________________________________________________________________
52 AliMUONSDigitizerV2::AliMUONSDigitizerV2()
53 : TTask("AliMUONSDigitizerV2","From Hits to SDigits for MUON")
60 //_____________________________________________________________________________
61 AliMUONSDigitizerV2::~AliMUONSDigitizerV2()
68 //_____________________________________________________________________________
70 AliMUONSDigitizerV2::Exec(Option_t*)
73 // Go from hits to sdigits.
75 // In the code below, apart from the loop itself (which look complicated
76 // but is really only a loop on each hit in the input file) the main
77 // work is done in AliMUONResponse::DisIntegrate method, which converts
78 // a single hit in (possibly) several sdigits.
83 AliRunLoader* runLoader = AliRunLoader::GetRunLoader();
84 AliLoader* fLoader = runLoader->GetLoader("MUONLoader");
86 fLoader->LoadHits("READ");
88 AliMUONData muonData(fLoader,"MUON","MUON");
90 AliMUON* muon = static_cast<AliMUON*>(gAlice->GetModule("MUON"));
92 Int_t nofEvents(runLoader->GetNumberOfEvents());
93 for ( Int_t iEvent = 0; iEvent < nofEvents; ++iEvent )
97 tdlist.SetOwner(kTRUE);
99 AliDebug(1,Form("iEvent=%d",iEvent));
100 runLoader->GetEvent(iEvent);
101 TTree* treeS = fLoader->TreeS();
102 AliDebug(1,Form("TreeS=%p",treeS));
105 AliDebug(1,"MakeSDigitsContainer");
106 fLoader->MakeSDigitsContainer();
107 treeS = fLoader->TreeS();
109 AliDebug(1,Form("TreeS=%p",treeS));
110 muonData.MakeBranch("S");
111 muonData.SetTreeAddress("S");
113 muonData.SetTreeAddress("H");
114 TTree* treeH = fLoader->TreeH();
115 AliDebug(1,Form("TreeH=%p",treeH));
117 Long64_t nofTracks = treeH->GetEntries();
118 for ( Long64_t iTrack = 0; iTrack < nofTracks; ++iTrack )
120 // Loop over the tracks of this event.
121 treeH->GetEvent(iTrack);
122 TClonesArray* hits = muonData.Hits();
123 Int_t nofHits = hits->GetEntriesFast();
124 for ( Int_t ihit = 0; ihit < nofHits; ++ihit )
126 // Loop over the hits of this track.
127 AliMUONHit* hit = static_cast<AliMUONHit*>(hits->At(ihit));
128 Int_t chamberId = hit->Chamber()-1;
129 AliMUONChamber& chamber = muon->Chamber(chamberId);
130 AliMUONResponse* response = chamber.ResponseModel();
132 // This is the heart of this method : the dis-integration
134 response->DisIntegrate(*hit,digits);
138 while ( ( d = (AliMUONDigit*)next() ) )
140 // Update some sdigit information that could not be known
141 // by the DisIntegrate method
143 d->AddTrack(iTrack,d->Signal());
147 muonData.ResetHits();
148 } // end of loop on tracks within an event
150 for ( Int_t i = 0; i <= tdlist.GetLast(); ++i )
152 AliMUONDigit* d = (AliMUONDigit*)tdlist[i];
153 StdoutToAliDebug(1,d->Print(););
154 if ( d->Signal() > 0 ) // that check would be better in the disintegrate
155 // method, but to compare with old sdigitizer, it has to be there.
157 muonData.AddSDigit(AliMpDEManager::GetChamberId(d->DetElemId()),*d);
161 fLoader->WriteSDigits("OVERWRITE");
163 muonData.ResetSDigits();
164 fLoader->UnloadSDigits();
167 fLoader->UnloadHits();