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>
22 #include "AliMUONSDigitizerV2.h"
25 #include "AliMUONChamber.h"
26 #include "AliMUONVDigit.h"
27 #include "AliMUONHit.h"
28 #include "AliMUONVDigitStore.h"
29 #include "AliMUONVHitStore.h"
30 #include "AliMUONCalibrationData.h"
31 #include "AliMUONResponseTrigger.h"
32 #include "AliMUONConstants.h"
35 #include "AliMpDEManager.h"
38 #include "AliCDBManager.h"
39 #include "AliLoader.h"
41 #include "AliRunLoader.h"
43 #include "AliHeader.h"
44 #include "AliGenCocktailEventHeader.h"
46 //-----------------------------------------------------------------------------
47 /// The sdigitizer performs the transformation from hits (energy deposits by
48 /// the transport code) to sdigits (equivalent of charges on pad).
50 /// It does so by converting the energy deposit into a charge and then spreading
51 /// this charge over several pads, according to the response function (a
52 /// Mathieson distribution, basically).
54 /// See also AliMUONResponseV0, which is doing the real job (in DisIntegrate
55 /// method), while this sdigitizer is just "steering" the process.
57 /// Please note that we do *not* merge sdigits after creation, which means
58 /// that after sdigitization, a given pad can have several sdigits. This
59 /// merging is taken care of later on by the digitizer(V3).
60 //-----------------------------------------------------------------------------
62 ClassImp(AliMUONSDigitizerV2)
64 Float_t AliMUONSDigitizerV2::fgkMaxIntTime = 10.0;
65 Float_t AliMUONSDigitizerV2::fgkMaxPosTimeDif = 1.22E-6;
66 Float_t AliMUONSDigitizerV2::fgkMaxNegTimeDif = -3.5E-6;
67 Float_t AliMUONSDigitizerV2::fgkMinTimeDif = 25E-9;
69 //_____________________________________________________________________________
70 AliMUONSDigitizerV2::AliMUONSDigitizerV2()
71 : TTask("AliMUONSDigitizerV2","From Hits to SDigits for MUON")
78 if ( ! AliMpCDB::LoadMpSegmentation() ) {
79 AliFatal("Could not access mapping from OCDB !");
83 //_____________________________________________________________________________
84 AliMUONSDigitizerV2::~AliMUONSDigitizerV2()
91 //_____________________________________________________________________________
93 AliMUONSDigitizerV2::Exec(Option_t*)
96 /// Go from hits to sdigits.
98 /// In the code below, apart from the loop itself (which look complicated
99 /// but is really only a loop on each hit in the input file) the main
100 /// work is done in AliMUONResponse::DisIntegrate method, which converts
101 /// a single hit in (possibly) several sdigits.
106 AliRunLoader* runLoader = AliRunLoader::Instance();
107 AliLoader* loader = runLoader->GetDetectorLoader("MUON");
109 loader->LoadHits("READ");
111 AliMUON* muon = static_cast<AliMUON*>(gAlice->GetModule("MUON"));
113 AliMUONCalibrationData *calibrationData = 0x0;
115 if(muon->GetTriggerEffCells()){
116 Int_t runnumber = AliCDBManager::Instance()->GetRun();
117 calibrationData = new AliMUONCalibrationData(runnumber);
118 for (Int_t chamber = 10; chamber < 14; chamber++) {
119 ((AliMUONResponseTrigger *) (muon->Chamber(chamber).ResponseModel()))->InitTriggerEfficiency(calibrationData->TriggerEfficiency()); // Init trigger efficiency
123 Int_t nofEvents(runLoader->GetNumberOfEvents());
125 TString classname = muon->DigitStoreClassName();
127 AliMUONVDigitStore* sDigitStore = AliMUONVDigitStore::Create(classname.Data());
131 AliFatal(Form("Could not create digitstore of class %s",classname.Data()));
134 AliDebug(1,Form("Will use digitStore of type %s",sDigitStore->ClassName()));
136 // average arrival time to chambers, for pileup studies
138 for ( Int_t iEvent = 0; iEvent < nofEvents; ++iEvent )
142 tdlist.SetOwner(kTRUE);
144 AliDebug(1,Form("iEvent=%d",iEvent));
145 runLoader->GetEvent(iEvent);
147 // for pile up studies
148 float t0=fgkMaxIntTime; int aa=0;
149 AliHeader* header = runLoader->GetHeader();
150 AliGenCocktailEventHeader* cocktailHeader =
151 dynamic_cast<AliGenCocktailEventHeader*>(header->GenEventHeader());
152 if (cocktailHeader) {
153 AliGenCocktailEventHeader* genEventHeader = (AliGenCocktailEventHeader*) (header->GenEventHeader());
154 TList* headers = genEventHeader->GetHeaders();
155 TIter nextH(headers);
156 AliGenEventHeader *entry;
157 while((entry = (AliGenEventHeader*)nextH())) {
158 float t = entry->InteractionTime();
159 if (TMath::Abs(t)<TMath::Abs(t0)) t0 = t;
163 AliGenEventHeader* evtHeader =
164 (AliGenEventHeader*)(header->GenEventHeader());
165 float t = evtHeader->InteractionTime();
166 if (TMath::Abs(t)<TMath::Abs(t0)) t0 = t;
170 loader->MakeSDigitsContainer();
172 TTree* treeS = loader->TreeS();
179 sDigitStore->Connect(*treeS);
181 TTree* treeH = loader->TreeH();
183 AliMUONVHitStore* hitStore = AliMUONVHitStore::Create(*treeH);
184 hitStore->Connect(*treeH);
186 Long64_t nofTracks = treeH->GetEntries();
188 for ( Long64_t iTrack = 0; iTrack < nofTracks; ++iTrack )
190 // Loop over the tracks of this event.
191 treeH->GetEvent(iTrack);
194 TIter next(hitStore->CreateIterator());
197 while ( ( hit = static_cast<AliMUONHit*>(next()) ) )
199 Int_t chamberId = hit->Chamber()-1;
200 Float_t age = hit->Age()-t0;
202 AliMUONChamber& chamber = muon->Chamber(chamberId);
203 AliMUONResponse* response = chamber.ResponseModel();
205 // This is the heart of this method : the dis-integration
207 if (aa>1){ // if there are pileup events
208 Float_t chamberTime = AliMUONConstants::AverageChamberT(chamberId);
209 Float_t timeDif=age-chamberTime;
210 if (timeDif>fgkMaxPosTimeDif || timeDif<fgkMaxNegTimeDif) {
213 if(TMath::Abs(timeDif)>fgkMinTimeDif){
214 response->DisIntegrate(*hit,digits,timeDif);
217 response->DisIntegrate(*hit,digits,0.);
221 response->DisIntegrate(*hit,digits,0.);
224 TIter nextd(&digits);
226 while ( ( d = (AliMUONVDigit*)nextd() ) )
228 // Update some sdigit information that could not be known
229 // by the DisIntegrate method
232 d->AddTrack(hit->GetTrack(),d->Charge());
238 } // end of loop on tracks within an event
243 while ( ( d = static_cast<AliMUONVDigit*>(next()) ) )
245 if ( d->Charge() > 0 ) // that check would be better in the disintegrate
246 // method, but to compare with old sdigitizer, it has to be there.
248 AliMUONVDigit* added = sDigitStore->Add(*d,AliMUONVDigitStore::kMerge);
251 AliError("Could not add digit to digitStore");
258 loader->WriteSDigits("OVERWRITE");
260 sDigitStore->Clear();
262 loader->UnloadSDigits();
268 loader->UnloadHits();
272 if(calibrationData) delete calibrationData;