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>
20 #include "AliMUONSDigitizerV2.h"
23 #include "AliMUONChamber.h"
24 #include "AliMUONVDigit.h"
25 #include "AliMUONHit.h"
26 #include "AliMUONVDigitStore.h"
27 #include "AliMUONVHitStore.h"
28 #include "AliMUONCalibrationData.h"
29 #include "AliMUONResponseTrigger.h"
32 #include "AliMpDEManager.h"
35 #include "AliCDBManager.h"
36 #include "AliLoader.h"
38 #include "AliRunLoader.h"
40 //-----------------------------------------------------------------------------
41 /// The sdigitizer performs the transformation from hits (energy deposits by
42 /// the transport code) to sdigits (equivalent of charges on pad).
44 /// It does so by converting the energy deposit into a charge and then spreading
45 /// this charge over several pads, according to the response function (a
46 /// Mathieson distribution, basically).
48 /// See also AliMUONResponseV0, which is doing the real job (in DisIntegrate
49 /// method), while this sdigitizer is just "steering" the process.
51 /// Please note that we do *not* merge sdigits after creation, which means
52 /// that after sdigitization, a given pad can have several sdigits. This
53 /// merging is taken care of later on by the digitizer(V3).
54 //-----------------------------------------------------------------------------
56 ClassImp(AliMUONSDigitizerV2)
58 //_____________________________________________________________________________
59 AliMUONSDigitizerV2::AliMUONSDigitizerV2()
60 : TTask("AliMUONSDigitizerV2","From Hits to SDigits for MUON")
67 if ( ! AliMpCDB::LoadMpSegmentation() ) {
68 AliFatal("Could not access mapping from OCDB !");
72 //_____________________________________________________________________________
73 AliMUONSDigitizerV2::~AliMUONSDigitizerV2()
80 //_____________________________________________________________________________
82 AliMUONSDigitizerV2::Exec(Option_t*)
85 /// Go from hits to sdigits.
87 /// In the code below, apart from the loop itself (which look complicated
88 /// but is really only a loop on each hit in the input file) the main
89 /// work is done in AliMUONResponse::DisIntegrate method, which converts
90 /// a single hit in (possibly) several sdigits.
95 AliRunLoader* runLoader = AliRunLoader::GetRunLoader();
96 AliLoader* loader = runLoader->GetDetectorLoader("MUON");
98 loader->LoadHits("READ");
100 AliMUON* muon = static_cast<AliMUON*>(gAlice->GetModule("MUON"));
102 AliMUONCalibrationData *calibrationData = 0x0;
104 if(muon->GetTriggerEffCells()){
105 Int_t runnumber = AliCDBManager::Instance()->GetRun();
106 calibrationData = new AliMUONCalibrationData(runnumber);
107 for (Int_t chamber = 10; chamber < 14; chamber++) {
108 ((AliMUONResponseTrigger *) (muon->Chamber(chamber).ResponseModel()))->InitTriggerEfficiency(calibrationData->TriggerEfficiency()); // Init trigger efficiency
112 Int_t nofEvents(runLoader->GetNumberOfEvents());
114 TString classname = muon->DigitStoreClassName();
116 AliMUONVDigitStore* sDigitStore = AliMUONVDigitStore::Create(classname.Data());
120 AliFatal(Form("Could not create digitstore of class %s",classname.Data()));
123 AliInfo(Form("Will use digitStore of type %s",sDigitStore->ClassName()));
125 for ( Int_t iEvent = 0; iEvent < nofEvents; ++iEvent )
129 tdlist.SetOwner(kTRUE);
131 AliDebug(1,Form("iEvent=%d",iEvent));
132 runLoader->GetEvent(iEvent);
134 loader->MakeSDigitsContainer();
136 TTree* treeS = loader->TreeS();
143 sDigitStore->Connect(*treeS);
145 TTree* treeH = loader->TreeH();
147 AliMUONVHitStore* hitStore = AliMUONVHitStore::Create(*treeH);
148 hitStore->Connect(*treeH);
150 Long64_t nofTracks = treeH->GetEntries();
152 for ( Long64_t iTrack = 0; iTrack < nofTracks; ++iTrack )
154 // Loop over the tracks of this event.
155 treeH->GetEvent(iTrack);
158 TIter next(hitStore->CreateIterator());
161 while ( ( hit = static_cast<AliMUONHit*>(next()) ) )
163 Int_t chamberId = hit->Chamber()-1;
164 AliMUONChamber& chamber = muon->Chamber(chamberId);
165 AliMUONResponse* response = chamber.ResponseModel();
167 // This is the heart of this method : the dis-integration
169 response->DisIntegrate(*hit,digits);
173 while ( ( d = (AliMUONVDigit*)next() ) )
175 // Update some sdigit information that could not be known
176 // by the DisIntegrate method
178 d->AddTrack(iTrack,d->Charge());
184 } // end of loop on tracks within an event
189 while ( ( d = static_cast<AliMUONVDigit*>(next()) ) )
191 if ( d->Charge() > 0 ) // that check would be better in the disintegrate
192 // method, but to compare with old sdigitizer, it has to be there.
194 AliMUONVDigit* added = sDigitStore->Add(*d,AliMUONVDigitStore::kMerge);
197 AliError("Could not add digit to digitStore");
204 loader->WriteSDigits("OVERWRITE");
206 sDigitStore->Clear();
208 loader->UnloadSDigits();
214 loader->UnloadHits();
218 if(calibrationData) delete calibrationData;