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")
42 //_____________________________________________________________________________
43 AliMUONSDigitizerV2::~AliMUONSDigitizerV2()
50 //_____________________________________________________________________________
52 AliMUONSDigitizerV2::Exec(Option_t*)
55 // Go from hits to sdigits.
57 // In the code below, apart from the loop itself (which look complicated
58 // but is really only a loop on each hit in the input file) the main
59 // work is done in AliMUONResponse::DisIntegrate method, which converts
60 // a single hit in (possibly) several sdigits.
65 AliRunLoader* runLoader = AliRunLoader::GetRunLoader();
66 AliLoader* fLoader = runLoader->GetLoader("MUONLoader");
68 fLoader->LoadHits("READ");
70 AliMUONData muonData(fLoader,"MUON","MUON");
72 AliMUON* muon = static_cast<AliMUON*>(gAlice->GetModule("MUON"));
74 const Int_t nofEvents(runLoader->GetNumberOfEvents());
75 for ( Int_t iEvent = 0; iEvent < nofEvents; ++iEvent )
79 tdlist.SetOwner(kTRUE);
81 AliDebug(1,Form("iEvent=%d",iEvent));
82 runLoader->GetEvent(iEvent);
83 TTree* treeS = fLoader->TreeS();
84 AliDebug(1,Form("TreeS=%p",treeS));
87 AliDebug(1,"MakeSDigitsContainer");
88 fLoader->MakeSDigitsContainer();
89 treeS = fLoader->TreeS();
91 AliDebug(1,Form("TreeS=%p",treeS));
92 muonData.MakeBranch("S");
93 muonData.SetTreeAddress("S");
95 muonData.SetTreeAddress("H");
96 TTree* treeH = fLoader->TreeH();
97 AliDebug(1,Form("TreeH=%p",treeH));
99 Long64_t nofTracks = treeH->GetEntries();
100 for ( Long64_t iTrack = 0; iTrack < nofTracks; ++iTrack )
102 // Loop over the tracks of this event.
103 treeH->GetEvent(iTrack);
104 TClonesArray* hits = muonData.Hits();
105 Int_t nofHits = hits->GetEntriesFast();
106 for ( Int_t ihit = 0; ihit < nofHits; ++ihit )
108 // Loop over the hits of this track.
109 AliMUONHit* hit = static_cast<AliMUONHit*>(hits->At(ihit));
110 Int_t chamberId = hit->Chamber()-1;
111 AliMUONChamber& chamber = muon->Chamber(chamberId);
112 AliMUONResponse* response = chamber.ResponseModel();
114 // This is the heart of this method : the dis-integration
116 response->DisIntegrate(*hit,digits);
120 while ( ( d = (AliMUONDigit*)next() ) )
122 // Update some sdigit information that could not be known
123 // by the DisIntegrate method
125 d->AddTrack(iTrack,d->Signal());
129 muonData.ResetHits();
130 } // end of loop on tracks within an event
132 for ( Int_t i = 0; i <= tdlist.GetLast(); ++i )
134 AliMUONDigit* d = (AliMUONDigit*)tdlist[i];
135 StdoutToAliDebug(1,d->Print(););
136 if ( d->Signal() > 0 ) // that check would be better in the disintegrate
137 // method, but to compare with old sdigitizer, it has to be there.
139 muonData.AddSDigit(d->DetElemId()/100-1,*d);
143 fLoader->WriteSDigits("OVERWRITE");
145 muonData.ResetSDigits();
146 fLoader->UnloadSDigits();
149 fLoader->UnloadHits();