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"
42 //-----------------------------------------------------------------------------
43 /// The sdigitizer performs the transformation from hits (energy deposits by
44 /// the transport code) to sdigits (equivalent of charges on pad).
46 /// It does so by converting the energy deposit into a charge and then spreading
47 /// this charge over several pads, according to the response function (a
48 /// Mathieson distribution, basically).
50 /// See also AliMUONResponseV0, which is doing the real job (in DisIntegrate
51 /// method), while this sdigitizer is just "steering" the process.
53 /// Please note that we do *not* merge sdigits after creation, which means
54 /// that after sdigitization, a given pad can have several sdigits. This
55 /// merging is taken care of later on by the digitizer(V3).
56 //-----------------------------------------------------------------------------
58 ClassImp(AliMUONSDigitizerV2)
60 //_____________________________________________________________________________
61 AliMUONSDigitizerV2::AliMUONSDigitizerV2()
62 : TTask("AliMUONSDigitizerV2","From Hits to SDigits for MUON")
69 if ( ! AliMpCDB::LoadMpSegmentation() ) {
70 AliFatal("Could not access mapping from OCDB !");
74 //_____________________________________________________________________________
75 AliMUONSDigitizerV2::~AliMUONSDigitizerV2()
82 //_____________________________________________________________________________
84 AliMUONSDigitizerV2::Exec(Option_t*)
87 /// Go from hits to sdigits.
89 /// In the code below, apart from the loop itself (which look complicated
90 /// but is really only a loop on each hit in the input file) the main
91 /// work is done in AliMUONResponse::DisIntegrate method, which converts
92 /// a single hit in (possibly) several sdigits.
97 AliRunLoader* runLoader = AliRunLoader::Instance();
98 AliLoader* loader = runLoader->GetDetectorLoader("MUON");
100 loader->LoadHits("READ");
102 AliMUON* muon = static_cast<AliMUON*>(gAlice->GetModule("MUON"));
104 AliMUONCalibrationData *calibrationData = 0x0;
106 if(muon->GetTriggerEffCells()){
107 Int_t runnumber = AliCDBManager::Instance()->GetRun();
108 calibrationData = new AliMUONCalibrationData(runnumber);
109 for (Int_t chamber = 10; chamber < 14; chamber++) {
110 ((AliMUONResponseTrigger *) (muon->Chamber(chamber).ResponseModel()))->InitTriggerEfficiency(calibrationData->TriggerEfficiency()); // Init trigger efficiency
114 Int_t nofEvents(runLoader->GetNumberOfEvents());
116 TString classname = muon->DigitStoreClassName();
118 AliMUONVDigitStore* sDigitStore = AliMUONVDigitStore::Create(classname.Data());
122 AliFatal(Form("Could not create digitstore of class %s",classname.Data()));
125 AliDebug(1,Form("Will use digitStore of type %s",sDigitStore->ClassName()));
127 for ( Int_t iEvent = 0; iEvent < nofEvents; ++iEvent )
131 tdlist.SetOwner(kTRUE);
133 AliDebug(1,Form("iEvent=%d",iEvent));
134 runLoader->GetEvent(iEvent);
136 // for pile up studies
137 runLoader->LoadKinematics();
138 AliStack* stack = runLoader->Stack();
139 Int_t nparticles = (Int_t) stack->GetNtrack();
140 float T0=10; // time of the triggered event
141 // loop to find the time of the triggered event (this may change)
142 for (Int_t iparticle=0; iparticle<nparticles; ++iparticle) {
143 float t = stack->Particle(iparticle)->T();
144 if (TMath::Abs(t)<TMath::Abs(T0)) T0 = t;
147 loader->MakeSDigitsContainer();
149 TTree* treeS = loader->TreeS();
156 sDigitStore->Connect(*treeS);
158 TTree* treeH = loader->TreeH();
160 AliMUONVHitStore* hitStore = AliMUONVHitStore::Create(*treeH);
161 hitStore->Connect(*treeH);
163 Long64_t nofTracks = treeH->GetEntries();
165 for ( Long64_t iTrack = 0; iTrack < nofTracks; ++iTrack )
167 // Loop over the tracks of this event.
168 treeH->GetEvent(iTrack);
171 TIter next(hitStore->CreateIterator());
174 while ( ( hit = static_cast<AliMUONHit*>(next()) ) )
176 Int_t chamberId = hit->Chamber()-1;
177 Float_t age = hit->Age()-T0;
179 AliMUONChamber& chamber = muon->Chamber(chamberId);
180 AliMUONResponse* response = chamber.ResponseModel();
182 // This is the heart of this method : the dis-integration
184 response->DisIntegrate(*hit,digits);
186 TIter nextd(&digits);
188 while ( ( d = (AliMUONVDigit*)nextd() ) )
190 // Update some sdigit information that could not be known
191 // by the DisIntegrate method
194 d->AddTrack(hit->GetTrack(),d->Charge());
200 } // end of loop on tracks within an event
205 while ( ( d = static_cast<AliMUONVDigit*>(next()) ) )
207 if ( d->Charge() > 0 ) // that check would be better in the disintegrate
208 // method, but to compare with old sdigitizer, it has to be there.
210 AliMUONVDigit* added = sDigitStore->Add(*d,AliMUONVDigitStore::kMerge);
213 AliError("Could not add digit to digitStore");
220 loader->WriteSDigits("OVERWRITE");
222 sDigitStore->Clear();
224 loader->UnloadSDigits();
230 loader->UnloadHits();
234 if(calibrationData) delete calibrationData;