1 //*********************************************************************
2 // - AliEVE implementation -
3 // Fill containers for visualisation of EMCAL data structures
4 // - read and store MC Hits
5 // - read and store digits from esds or runloader
6 // - read and store clusters from esds or runloader
8 // Author: Magali Estienne (magali.estienne@cern.ch)
10 //*********************************************************************
16 #include <TObjArray.h>
17 #include <TRefArray.h>
18 #include <TClonesArray.h>
19 #include <TEvePointSet.h>
22 #include "AliRunLoader.h"
23 #include "AliEMCALLoader.h"
24 #include "AliESDEvent.h"
25 #include "AliESDVertex.h"
27 #include "AliEMCALGeometry.h"
28 #include "AliEMCALHit.h"
29 #include "AliEMCALDigit.h"
30 #include "AliEMCALRecPoint.h"
31 #include "AliESDCaloCells.h"
32 #include "AliESDCaloCluster.h"
34 #include "AliEveEMCALData.h"
35 #include "AliEveEMCALSModule.h"
36 #include "AliEveEMCALSModuleData.h"
38 ClassImp(AliEveEMCALData)
40 //______________________________________________________________________________
41 AliEveEMCALData::AliEveEMCALData():
64 // for(Int_t i=0; i<12; i++)
66 // for(Int_t i=0; i<10; i++)
68 // fSMhalf[0] = fSMhalf[1] = 0x0;
75 //______________________________________________________________________________
76 AliEveEMCALData::AliEveEMCALData(AliRunLoader* rl, TGeoNode* node, TGeoHMatrix* m):
99 // for(Int_t i=0; i<12; i++)
101 // for(Int_t i=0; i<10; i++)
103 // fSMhalf[0] = fSMhalf[1] = 0x0;
110 //______________________________________________________________________________
111 AliEveEMCALData::~AliEveEMCALData()
117 DeleteSuperModules();
126 //______________________________________________________________________________
127 void AliEveEMCALData::Reset()
132 //______________________________________________________________________________
133 AliEveEMCALData::AliEveEMCALData(const AliEveEMCALData &edata) :
136 fEmcal(edata.fEmcal),
139 fHMatrix(edata.fHMatrix),
143 fNsmfull(edata.fNsmfull),
144 fNsmhalf(edata.fNsmhalf),
146 fSMfull(edata.fSMfull),
147 fSMhalf(edata.fSMhalf),
148 fRunLoader(edata.fRunLoader),
149 fDebug(edata.fDebug),
155 InitEMCALGeom(edata.fRunLoader);
159 //______________________________________________________________________________
160 AliEveEMCALData& AliEveEMCALData::operator=(const AliEveEMCALData &edata)
163 // Assignment operator
166 if (this != &edata) {
174 //______________________________________________________________________________
175 void AliEveEMCALData::SetTree(TTree* tree)
178 // Set digit-tree to be used for digit retrieval. Data is loaded on
185 //______________________________________________________________________________
186 void AliEveEMCALData::SetESD(AliESDEvent* esd)
191 //______________________________________________________________________________
192 void AliEveEMCALData::SetNode(TGeoNode* node)
197 //______________________________________________________________________________
198 void AliEveEMCALData::InitEMCALGeom(AliRunLoader* rl)
200 // // Handle an individual point selection from GL.
202 // fParent->SpawnEditor();
203 fEmcal = (AliEMCAL*) rl->GetAliRun()->GetDetector("EMCAL");
204 fGeom = (AliEMCALGeometry*) fEmcal->GetGeometry();
208 //______________________________________________________________________________
209 void AliEveEMCALData::GetGeomInfo(Int_t id, Int_t &iSupMod, Double_t& x, Double_t& y, Double_t& z)
211 // Get geometrical information from hit/digit/cluster absolute id
220 fGeom->GetCellIndex(id,iSupMod,iTower,iIphi,iIeta);
221 //Gives SuperModule and Tower numbers
222 fGeom->RelPosCellInSModule(id, x, y, z);
226 //______________________________________________________________________________
227 void AliEveEMCALData::CreateAllSModules()
230 // Create all fNsm super modules
231 for(Int_t sm = 0; sm < fNsm; sm++)
236 //______________________________________________________________________________
237 void AliEveEMCALData::CreateSModule(Int_t sm)
239 // Create super-module-data for sm if it does not exist already.
240 if(fSM[sm] == 0) fSM[sm] = new AliEveEMCALSModuleData(sm,fGeom,fNode,fHMatrix);
241 if(fSMfull[sm] == 0 && sm < 10) fSMfull[sm] = new AliEveEMCALSModuleData(sm,fGeom,fNode,fHMatrix);
242 if(fSMhalf[sm-10] == 0 && sm > 10) fSMhalf[sm-10] = new AliEveEMCALSModuleData(sm,fGeom,fNode,fHMatrix);
245 //______________________________________________________________________________
246 void AliEveEMCALData::DropAllSModules()
248 // Drop data of all existing sectors.
250 for (Int_t sm = 0; sm < fNsm; sm++) {
256 //______________________________________________________________________________
257 void AliEveEMCALData::DeleteSuperModules()
260 // delete all super module data
263 for (Int_t sm = 0; sm < fNsm; sm++)
269 for(Int_t smf = 0; smf < fNsmfull; smf++)
275 for(Int_t smh = 0; smh < fNsmhalf; smh++)
283 //______________________________________________________________________________
284 void AliEveEMCALData::LoadHits(TTree* t)
289 // These are global coordinates !
291 const char *selection = "";
292 const char *varexp = "fX:fY:fZ";
293 sprintf(form,"EMCAL Hits '%s'", selection);
294 fPoint = new TEvePointSet(form);
296 TEvePointSelector ps(t, fPoint, varexp, selection);
299 if (fPoint->Size() == 0) {
300 Warning("emcal_hits", Form("No hits match '%s'", selection));
306 // TObjArray *harr=NULL;
307 // TBranch *hbranch=t->GetBranch("EMCAL");
308 // hbranch->SetAddress(&harr);
310 // if(hbranch->GetEvent(0)) {
311 // for(Int_t ih = 0; ih < harr->GetEntriesFast(); ih++) {
312 // AliEMCALHit* hit =(AliEMCALHit*)harr->UncheckedAt(ih);
314 // cout << "Hit info " << hit->GetId() << " " << hit->GetEnergy() << endl;
315 // fSM[iSupMod]->RegisterDigit(id,iSupMod,amp,x,y,z);
319 // //********************************
320 // // To be completed !!!
321 // //********************************
325 //______________________________________________________________________________
326 void AliEveEMCALData::LoadHitsFromEMCALLoader(AliEMCALLoader* emcl)
329 // Need to know the local position in each sm
335 TClonesArray *hits = (TClonesArray*)emcl->Hits();
337 //Get hits from the list
338 for(Int_t ihit = 0; ihit< hits->GetEntries();ihit++){
339 //cout<<">> idig "<<idig<<endl;
340 hit = static_cast<AliEMCALHit *>(hits->At(ihit)) ;
343 cout << "Hit info " << hit->GetId() << " " << hit->GetEnergy() << endl;
347 //********************************
348 // To be completed !!!
349 //********************************
355 //______________________________________________________________________________
356 void AliEveEMCALData::LoadDigits(TTree *t)
359 // load digits from the TreeD
362 TClonesArray *digits = 0;
363 t->SetBranchAddress("EMCAL", &digits);
366 Int_t nEnt = digits->GetEntriesFast();
367 cout << "nEnt: " << nEnt << endl;
375 for (Int_t idig = 0; idig < nEnt; idig++)
377 dig = static_cast<AliEMCALDigit *>(digits->At(idig));
380 id = dig->GetId() ; //cell (digit) label
381 amp = dig->GetAmp(); //amplitude in cell (digit)
383 GetGeomInfo(id,iSupMod,x,y,z);
385 fSM[iSupMod]->RegisterDigit(id,iSupMod,amp,x,y,z);
386 // fSM[iSupMod]->SaveDigit(dig);
387 // if(iSupMod<fNsmfull) fSMfull[iSupMod]->RegisterDigit(id,iSupMod,amp,x,y,z);
388 // if(iSupMod>fNsmfull) fSMhalf[iSupMod-10]->RegisterDigit(id,iSupMod,amp,x,y,z);
391 cout << "Digit object empty" << endl;
395 cout << "after loop on digits !" << endl;
398 //______________________________________________________________________________
399 void AliEveEMCALData::LoadDigitsFromEMCALLoader(AliEMCALLoader* emcl)
403 // load digits from EMCAL Loader
408 //Fill array of digits
409 TClonesArray *digits = (TClonesArray*)emcl->Digits();
411 //Get digits from the list
418 for(Int_t idig = 0; idig< digits->GetEntries();idig++){
420 dig = static_cast<AliEMCALDigit *>(digits->At(idig)) ;
423 if(fDebug>1) cout << "Digit info " << dig->GetId() << " " << dig->GetAmp() << endl;
424 id = dig->GetId() ; //cell (digit) label
425 amp = dig->GetAmp(); //amplitude in cell (digit)
427 GetGeomInfo(id,iSupMod,x,y,z);
429 fSM[iSupMod]->RegisterDigit(id,iSupMod,amp,x,y,z);
432 cout << "Digit object empty" << endl;
435 } // end loop on digits
439 //______________________________________________________________________________
440 void AliEveEMCALData::LoadDigitsFromESD()
443 // Get digit information from esd
446 AliESDCaloCells &cells= *(fESD->GetEMCALCells());
447 Int_t ncell = cells.GetNumberOfCells() ;
448 Int_t type = cells.GetType();
453 // Extract digit information from the ESDs
454 for (Int_t icell= 0; icell < ncell; icell++)
456 Int_t id = cells.GetCellNumber(icell);
457 Float_t amp = cells.GetAmplitude(icell);
459 GetGeomInfo(id,iSupMod,x,y,z);
461 fSM[iSupMod]->RegisterDigit(id,iSupMod,amp,x,y,z);
462 if(iSupMod<fNsmfull) fSMfull[iSupMod]->RegisterDigit(id,iSupMod,amp,x,y,z);
463 if(iSupMod>fNsmfull) fSMhalf[iSupMod-10]->RegisterDigit(id,iSupMod,amp,x,y,z);
468 //______________________________________________________________________________
469 void AliEveEMCALData::LoadRecPoints(TTree* t)
471 //*************************************************
472 // To be improved !!!!!
473 // Size and shape of cluster to be implemented
475 //*************************************************
478 TObjArray *carr=NULL;
479 TBranch *cbranch=t->GetBranch("EMCALECARP");
480 cbranch->SetAddress(&carr);
482 if(cbranch->GetEvent(0)) {
483 for(Int_t ic = 0; ic < carr->GetEntriesFast(); ic++) {
484 AliEMCALRecPoint* rp =(AliEMCALRecPoint*)carr->UncheckedAt(ic);
486 cout << "RecPoint info " << rp->GetAbsId() << " " << rp->GetEnergy() << endl;
487 Int_t iSupMod = rp->GetSuperModuleNumber();
488 Float_t amp = rp->GetEnergy();
490 rp->GetLocalPosition(lpos);
492 fSM[iSupMod]->RegisterCluster(iSupMod,amp,lpos[0],lpos[1],lpos[2]);
499 //______________________________________________________________________________
500 void AliEveEMCALData::LoadRecPointsFromEMCALLoader(AliEMCALLoader* emcl)
502 //*************************************************
503 // To be improved !!!!!
504 // Size and shape of cluster to be implemented
506 //*************************************************
509 AliEMCALRecPoint* rp;
511 //Fill array of clusters
512 TClonesArray *clusters = (TClonesArray*)emcl->RecPoints();
514 //Get clusters from the list
515 for(Int_t iclu = 0; iclu< clusters->GetEntries();iclu++){
517 rp = static_cast<AliEMCALRecPoint *>(clusters->At(iclu)) ;
520 cout << "RecPoint info " << rp->GetAbsId() << " " << rp->GetEnergy() << endl;
521 Int_t iSupMod = rp->GetSuperModuleNumber();
522 Float_t amp = rp->GetEnergy();
524 rp->GetLocalPosition(lpos);
526 fSM[iSupMod]->RegisterCluster(iSupMod,amp,lpos[0],lpos[1],lpos[2]);
532 //______________________________________________________________________________
533 void AliEveEMCALData::LoadRecPointsFromESD()
546 // Get reconstructed vertex position
547 AliESDVertex* primVertex =(AliESDVertex*) fESD->GetVertex();
548 Double_t vertex_position[3] ;
549 primVertex->GetXYZ(vertex_position) ;
551 //Get the CaloClusters
552 //select EMCAL clusters only
553 TRefArray * caloClusters = new TRefArray();
554 fESD->GetEMCALClusters(caloClusters);
555 Int_t nclus = caloClusters->GetEntries();
556 cout << "nclus: " << nclus << endl;
558 if(!caloClusters) return;
560 for (Int_t iclus = 0; iclus < nclus; iclus++)
562 AliESDCaloCluster *clus = (AliESDCaloCluster *) caloClusters->At(iclus) ;
563 //Get the cluster info
565 Float_t energy = clus->E() ;
566 Int_t eneInt = (Int_t) energy*500+0.5;
567 Float_t disp = clus->GetClusterDisp() ;
568 Int_t iprim = clus->GetLabel();
570 clus->GetPosition(pos) ; // Global position
571 TVector3 vpos(pos[0],pos[1],pos[2]) ;
574 clus->GetMomentum(p4,vertex_position);
575 p3.SetXYZ(p4[0],p4[1],p4[2]);
576 Float_t eta = p3.Eta();
577 Float_t phi = ( (p3.Phi()) < 0) ? (p3.Phi()) + 2. * TMath::Pi() : (p3.Phi());
579 Int_t mult = clus->GetNCells() ;
581 cout << "In cluster: " << iclus << ", ncells: " << mult << ", energy: " <<
582 eneInt << ", disp: " << disp << endl;
583 cout << "Cluster " << iclus << ", eta: " << eta << ", phi: " << phi << endl;
587 fGeom->GetAbsCellIdFromEtaPhi(eta,phi,clusId);
589 cout << "Abs Cluster Id: " << clusId << ", xc: " << pos[0] <<
590 ", yc: " << pos[1] << ", zc: " << pos[2] << endl;
593 GetGeomInfo(clusId,iSupMod,x,y,z);
595 //******** Not used yet but will come ********
596 Int_t digMult = clus->GetNCells() ;
597 UShort_t *digID = clus->GetCellsAbsId() ;
598 for(Int_t i=0; i<digMult; i++){
599 fGeom->RelPosCellInSModule(digID[i], xd, yd, zd);
601 fGeom->GetCellIndex(digID[i],iSM,iT,iIp,iIe);
602 //Gives SuperModule and Tower numbers
605 //*********************************************
607 fSM[iSupMod]->RegisterCluster(iSM,energy,x,y,z);
609 } // end cluster loop
612 //______________________________________________________________________________
613 AliEveEMCALSModuleData* AliEveEMCALData::GetSModuleData(Int_t sm)
616 // return super module data
619 if (sm < 0 || sm > fNsm)
621 printf("The number of super modules must be lower or equal to %d",fNsm);
628 //______________________________________________________________________________
629 void AliEveEMCALData::LoadRaw()