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 "AliMUONSimData.h"
26 #include "AliMUONDigit.h"
27 #include "AliMUONHit.h"
28 #include "AliMpDEManager.h"
29 #include "AliLoader.h"
31 #include "AliRunLoader.h"
32 #include "TObjArray.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")
62 //_____________________________________________________________________________
63 AliMUONSDigitizerV2::~AliMUONSDigitizerV2()
70 //_____________________________________________________________________________
72 AliMUONSDigitizerV2::Exec(Option_t*)
75 /// Go from hits to sdigits.
77 /// In the code below, apart from the loop itself (which look complicated
78 /// but is really only a loop on each hit in the input file) the main
79 /// work is done in AliMUONResponse::DisIntegrate method, which converts
80 /// a single hit in (possibly) several sdigits.
85 AliRunLoader* runLoader = AliRunLoader::GetRunLoader();
86 AliLoader* fLoader = runLoader->GetLoader("MUONLoader");
88 fLoader->LoadHits("READ");
90 AliMUONSimData muonData(fLoader,"MUON","MUON");
92 AliMUON* muon = static_cast<AliMUON*>(gAlice->GetModule("MUON"));
94 Int_t nofEvents(runLoader->GetNumberOfEvents());
95 for ( Int_t iEvent = 0; iEvent < nofEvents; ++iEvent )
99 tdlist.SetOwner(kTRUE);
101 AliDebug(1,Form("iEvent=%d",iEvent));
102 runLoader->GetEvent(iEvent);
103 TTree* treeS = fLoader->TreeS();
104 AliDebug(1,Form("TreeS=%p",treeS));
107 AliDebug(1,"MakeSDigitsContainer");
108 fLoader->MakeSDigitsContainer();
109 treeS = fLoader->TreeS();
111 AliDebug(1,Form("TreeS=%p",treeS));
112 muonData.MakeBranch("S");
113 muonData.SetTreeAddress("S");
115 muonData.SetTreeAddress("H");
116 TTree* treeH = fLoader->TreeH();
117 AliDebug(1,Form("TreeH=%p",treeH));
119 Long64_t nofTracks = treeH->GetEntries();
120 for ( Long64_t iTrack = 0; iTrack < nofTracks; ++iTrack )
122 // Loop over the tracks of this event.
123 treeH->GetEvent(iTrack);
124 TClonesArray* hits = muonData.Hits();
125 Int_t nofHits = hits->GetEntriesFast();
126 for ( Int_t ihit = 0; ihit < nofHits; ++ihit )
128 // Loop over the hits of this track.
129 AliMUONHit* hit = static_cast<AliMUONHit*>(hits->At(ihit));
130 Int_t chamberId = hit->Chamber()-1;
131 AliMUONChamber& chamber = muon->Chamber(chamberId);
132 AliMUONResponse* response = chamber.ResponseModel();
134 // This is the heart of this method : the dis-integration
136 response->DisIntegrate(*hit,digits);
140 while ( ( d = (AliMUONDigit*)next() ) )
142 // Update some sdigit information that could not be known
143 // by the DisIntegrate method
145 d->AddTrack(iTrack,d->Signal());
149 muonData.ResetHits();
150 } // end of loop on tracks within an event
152 for ( Int_t i = 0; i <= tdlist.GetLast(); ++i )
154 AliMUONDigit* d = (AliMUONDigit*)tdlist[i];
155 StdoutToAliDebug(1,d->Print(););
156 if ( d->Signal() > 0 ) // that check would be better in the disintegrate
157 // method, but to compare with old sdigitizer, it has to be there.
159 muonData.AddSDigit(AliMpDEManager::GetChamberId(d->DetElemId()),*d);
163 fLoader->WriteSDigits("OVERWRITE");
165 muonData.ResetSDigits();
166 fLoader->UnloadSDigits();
169 fLoader->UnloadHits();