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>
19 #include <TParticle.h>
21 #include "AliMUONSDigitizerV2.h"
24 #include "AliMUONChamber.h"
25 #include "AliMUONVDigit.h"
26 #include "AliMUONHit.h"
27 #include "AliMUONVDigitStore.h"
28 #include "AliMUONVHitStore.h"
29 #include "AliMUONCalibrationData.h"
30 #include "AliMUONResponseTrigger.h"
33 #include "AliMpDEManager.h"
36 #include "AliCDBManager.h"
37 #include "AliLoader.h"
39 #include "AliRunLoader.h"
41 #include "AliHeader.h"
42 #include "AliGenCocktailEventHeader.h"
44 //-----------------------------------------------------------------------------
45 /// The sdigitizer performs the transformation from hits (energy deposits by
46 /// the transport code) to sdigits (equivalent of charges on pad).
48 /// It does so by converting the energy deposit into a charge and then spreading
49 /// this charge over several pads, according to the response function (a
50 /// Mathieson distribution, basically).
52 /// See also AliMUONResponseV0, which is doing the real job (in DisIntegrate
53 /// method), while this sdigitizer is just "steering" the process.
55 /// Please note that we do *not* merge sdigits after creation, which means
56 /// that after sdigitization, a given pad can have several sdigits. This
57 /// merging is taken care of later on by the digitizer(V3).
58 //-----------------------------------------------------------------------------
60 ClassImp(AliMUONSDigitizerV2)
62 //_____________________________________________________________________________
63 AliMUONSDigitizerV2::AliMUONSDigitizerV2()
64 : TTask("AliMUONSDigitizerV2","From Hits to SDigits for MUON")
71 if ( ! AliMpCDB::LoadMpSegmentation() ) {
72 AliFatal("Could not access mapping from OCDB !");
76 //_____________________________________________________________________________
77 AliMUONSDigitizerV2::~AliMUONSDigitizerV2()
84 //_____________________________________________________________________________
86 AliMUONSDigitizerV2::Exec(Option_t*)
89 /// Go from hits to sdigits.
91 /// In the code below, apart from the loop itself (which look complicated
92 /// but is really only a loop on each hit in the input file) the main
93 /// work is done in AliMUONResponse::DisIntegrate method, which converts
94 /// a single hit in (possibly) several sdigits.
99 AliRunLoader* runLoader = AliRunLoader::Instance();
100 AliLoader* loader = runLoader->GetDetectorLoader("MUON");
102 loader->LoadHits("READ");
104 AliMUON* muon = static_cast<AliMUON*>(gAlice->GetModule("MUON"));
106 AliMUONCalibrationData *calibrationData = 0x0;
108 if(muon->GetTriggerEffCells()){
109 Int_t runnumber = AliCDBManager::Instance()->GetRun();
110 calibrationData = new AliMUONCalibrationData(runnumber);
111 for (Int_t chamber = 10; chamber < 14; chamber++) {
112 ((AliMUONResponseTrigger *) (muon->Chamber(chamber).ResponseModel()))->InitTriggerEfficiency(calibrationData->TriggerEfficiency()); // Init trigger efficiency
116 Int_t nofEvents(runLoader->GetNumberOfEvents());
118 TString classname = muon->DigitStoreClassName();
120 AliMUONVDigitStore* sDigitStore = AliMUONVDigitStore::Create(classname.Data());
124 AliFatal(Form("Could not create digitstore of class %s",classname.Data()));
127 AliDebug(1,Form("Will use digitStore of type %s",sDigitStore->ClassName()));
129 for ( Int_t iEvent = 0; iEvent < nofEvents; ++iEvent )
133 tdlist.SetOwner(kTRUE);
135 AliDebug(1,Form("iEvent=%d",iEvent));
136 runLoader->GetEvent(iEvent);
138 // for pile up studies
140 AliHeader* header = runLoader->GetHeader();
141 AliGenCocktailEventHeader* cocktailHeader =
142 dynamic_cast<AliGenCocktailEventHeader*>(header->GenEventHeader());
143 if (cocktailHeader) {
144 AliGenCocktailEventHeader* genEventHeader = (AliGenCocktailEventHeader*) (header->GenEventHeader());
145 TList* headers = genEventHeader->GetHeaders();
146 TIter nextH(headers);
147 AliGenEventHeader *entry;
148 while((entry = (AliGenEventHeader*)nextH())) {
149 float t = entry->InteractionTime();
150 if (TMath::Abs(t)<TMath::Abs(T0)) T0 = t;
153 AliGenEventHeader* evtHeader =
154 (AliGenEventHeader*)(header->GenEventHeader());
155 float t = evtHeader->InteractionTime();
156 if (TMath::Abs(t)<TMath::Abs(T0)) T0 = t;
159 loader->MakeSDigitsContainer();
161 TTree* treeS = loader->TreeS();
168 sDigitStore->Connect(*treeS);
170 TTree* treeH = loader->TreeH();
172 AliMUONVHitStore* hitStore = AliMUONVHitStore::Create(*treeH);
173 hitStore->Connect(*treeH);
175 Long64_t nofTracks = treeH->GetEntries();
177 for ( Long64_t iTrack = 0; iTrack < nofTracks; ++iTrack )
179 // Loop over the tracks of this event.
180 treeH->GetEvent(iTrack);
183 TIter next(hitStore->CreateIterator());
186 while ( ( hit = static_cast<AliMUONHit*>(next()) ) )
188 Int_t chamberId = hit->Chamber()-1;
189 Float_t age = hit->Age()-T0;
191 AliMUONChamber& chamber = muon->Chamber(chamberId);
192 AliMUONResponse* response = chamber.ResponseModel();
194 // This is the heart of this method : the dis-integration
196 response->DisIntegrate(*hit,digits);
198 TIter nextd(&digits);
200 while ( ( d = (AliMUONVDigit*)nextd() ) )
202 // Update some sdigit information that could not be known
203 // by the DisIntegrate method
206 d->AddTrack(hit->GetTrack(),d->Charge());
212 } // end of loop on tracks within an event
217 while ( ( d = static_cast<AliMUONVDigit*>(next()) ) )
219 if ( d->Charge() > 0 ) // that check would be better in the disintegrate
220 // method, but to compare with old sdigitizer, it has to be there.
222 AliMUONVDigit* added = sDigitStore->Add(*d,AliMUONVDigitStore::kMerge);
225 AliError("Could not add digit to digitStore");
232 loader->WriteSDigits("OVERWRITE");
234 sDigitStore->Clear();
236 loader->UnloadSDigits();
242 loader->UnloadHits();
246 if(calibrationData) delete calibrationData;