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