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"
31 ClassImp(AliMUONSDigitizerV2)
33 //_____________________________________________________________________________
34 AliMUONSDigitizerV2::AliMUONSDigitizerV2()
35 : TTask("AliMUONSDigitizerV2","From Hits to SDigits for MUON")
39 //_____________________________________________________________________________
40 AliMUONSDigitizerV2::~AliMUONSDigitizerV2()
44 //_____________________________________________________________________________
46 AliMUONSDigitizerV2::Exec(Option_t*)
49 // Go from hits to sdigits.
54 AliRunLoader* runLoader = AliRunLoader::GetRunLoader();
55 AliLoader* fLoader = runLoader->GetLoader("MUONLoader");
57 fLoader->LoadHits("READ");
59 AliMUONData muonData(fLoader,"MUON","MUON");
61 AliMUON* muon = static_cast<AliMUON*>(gAlice->GetModule("MUON"));
63 const Int_t nofEvents(runLoader->GetNumberOfEvents());
64 for ( Int_t iEvent = 0; iEvent < nofEvents; ++iEvent )
67 tdlist.SetOwner(kTRUE);
69 AliDebug(1,Form("iEvent=%d",iEvent));
70 runLoader->GetEvent(iEvent);
71 TTree* treeS = fLoader->TreeS();
72 AliDebug(1,Form("TreeS=%p",treeS));
75 AliDebug(1,"MakeSDigitsContainer");
76 fLoader->MakeSDigitsContainer();
77 treeS = fLoader->TreeS();
79 AliDebug(1,Form("TreeS=%p",treeS));
80 muonData.MakeBranch("S");
81 muonData.SetTreeAddress("S");
83 muonData.SetTreeAddress("H");
84 TTree* treeH = fLoader->TreeH();
85 AliDebug(1,Form("TreeH=%p",treeH));
87 Long64_t nofTracks = treeH->GetEntries();
88 for ( Long64_t iTrack = 0; iTrack < nofTracks; ++iTrack )
90 treeH->GetEvent(iTrack);
91 TClonesArray* hits = muonData.Hits();
92 Int_t nofHits = hits->GetEntriesFast();
93 for ( Int_t ihit = 0; ihit < nofHits; ++ihit )
95 AliMUONHit* hit = static_cast<AliMUONHit*>(hits->At(ihit));
96 Int_t chamberId = hit->Chamber()-1;
97 AliMUONChamber& chamber = muon->Chamber(chamberId);
98 AliMUONResponse* response = chamber.ResponseModel();
100 response->DisIntegrate(*hit,digits);
103 while ( ( d = (AliMUONDigit*)next() ) )
109 muonData.ResetHits();
110 } // loop on tracks within an event
111 tdlist.Sort(); // not really needed, except for comparing with old sdigitizer
112 for ( Int_t i = 0; i <= tdlist.GetLast(); ++i )
114 AliMUONDigit* d = (AliMUONDigit*)tdlist[i];
115 StdoutToAliDebug(1,d->Print(););
116 if ( d->Signal() > 0 ) // that check would be better in the disintegrate
117 // method, but to compare with old sdigitizer, it has to be there.
119 muonData.AddSDigit(d->DetElemId()/100-1,*d);
123 fLoader->WriteSDigits("OVERWRITE");
124 muonData.ResetSDigits();
125 fLoader->UnloadSDigits();
128 fLoader->UnloadHits();