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 "AliLoader.h"
28 #include "AliRunLoader.h"
29 #include "TObjArray.h"
32 /// The sdigitizer performs the transformation from hits (energy deposits by
33 /// the transport code) to sdigits (equivalent of charges on pad).
35 /// It does so by converting the energy deposit into a charge and then spreading
36 /// this charge over several pads, according to the response function (a
37 /// Mathieson distribution, basically).
39 /// See also AliMUONResponseV0, which is doing the real job (in DisIntegrate
40 /// method), while this sdigitizer is just "steering" the process.
42 /// Please note that we do *not* merge sdigits after creation, which means
43 /// that after sdigitization, a given pad can have several sdigits. This
44 /// merging is taken care of later on by the digitizer(V3).
47 ClassImp(AliMUONSDigitizerV2)
49 //_____________________________________________________________________________
50 AliMUONSDigitizerV2::AliMUONSDigitizerV2()
51 : TTask("AliMUONSDigitizerV2","From Hits to SDigits for MUON")
58 //_____________________________________________________________________________
59 AliMUONSDigitizerV2::~AliMUONSDigitizerV2()
66 //_____________________________________________________________________________
68 AliMUONSDigitizerV2::Exec(Option_t*)
71 // Go from hits to sdigits.
73 // In the code below, apart from the loop itself (which look complicated
74 // but is really only a loop on each hit in the input file) the main
75 // work is done in AliMUONResponse::DisIntegrate method, which converts
76 // a single hit in (possibly) several sdigits.
81 AliRunLoader* runLoader = AliRunLoader::GetRunLoader();
82 AliLoader* fLoader = runLoader->GetLoader("MUONLoader");
84 fLoader->LoadHits("READ");
86 AliMUONData muonData(fLoader,"MUON","MUON");
88 AliMUON* muon = static_cast<AliMUON*>(gAlice->GetModule("MUON"));
90 Int_t nofEvents(runLoader->GetNumberOfEvents());
91 for ( Int_t iEvent = 0; iEvent < nofEvents; ++iEvent )
95 tdlist.SetOwner(kTRUE);
97 AliDebug(1,Form("iEvent=%d",iEvent));
98 runLoader->GetEvent(iEvent);
99 TTree* treeS = fLoader->TreeS();
100 AliDebug(1,Form("TreeS=%p",treeS));
103 AliDebug(1,"MakeSDigitsContainer");
104 fLoader->MakeSDigitsContainer();
105 treeS = fLoader->TreeS();
107 AliDebug(1,Form("TreeS=%p",treeS));
108 muonData.MakeBranch("S");
109 muonData.SetTreeAddress("S");
111 muonData.SetTreeAddress("H");
112 TTree* treeH = fLoader->TreeH();
113 AliDebug(1,Form("TreeH=%p",treeH));
115 Long64_t nofTracks = treeH->GetEntries();
116 for ( Long64_t iTrack = 0; iTrack < nofTracks; ++iTrack )
118 // Loop over the tracks of this event.
119 treeH->GetEvent(iTrack);
120 TClonesArray* hits = muonData.Hits();
121 Int_t nofHits = hits->GetEntriesFast();
122 for ( Int_t ihit = 0; ihit < nofHits; ++ihit )
124 // Loop over the hits of this track.
125 AliMUONHit* hit = static_cast<AliMUONHit*>(hits->At(ihit));
126 Int_t chamberId = hit->Chamber()-1;
127 AliMUONChamber& chamber = muon->Chamber(chamberId);
128 AliMUONResponse* response = chamber.ResponseModel();
130 // This is the heart of this method : the dis-integration
132 response->DisIntegrate(*hit,digits);
136 while ( ( d = (AliMUONDigit*)next() ) )
138 // Update some sdigit information that could not be known
139 // by the DisIntegrate method
141 d->AddTrack(iTrack,d->Signal());
145 muonData.ResetHits();
146 } // end of loop on tracks within an event
148 for ( Int_t i = 0; i <= tdlist.GetLast(); ++i )
150 AliMUONDigit* d = (AliMUONDigit*)tdlist[i];
151 StdoutToAliDebug(1,d->Print(););
152 if ( d->Signal() > 0 ) // that check would be better in the disintegrate
153 // method, but to compare with old sdigitizer, it has to be there.
155 muonData.AddSDigit(d->DetElemId()/100-1,*d);
159 fLoader->WriteSDigits("OVERWRITE");
161 muonData.ResetSDigits();
162 fLoader->UnloadSDigits();
165 fLoader->UnloadHits();