FairRoot/PandaRoot
PndEmcClusterRemoveDuplCrys.cxx
Go to the documentation of this file.
2 #include "PndEmcDigi.h"
3 #include "PndEmcCluster.h"
4 
5 #include "FairRootManager.h"
6 #include "FairRunAna.h"
7 
8 #include "TClonesArray.h"
9 
10 using std::cout;
11 using std::cerr;
12 using std::endl;
13 
15  FairTask("PndEmcClusterRemoveDuplCrys", verbose) {
16 }
17 
18 
20 
21  FairRootManager* ioman = FairRootManager::Instance();
22  if (!ioman) {
23  cout << "-E- PndEmcClusterRemoveDuplCrys::Init: "
24  << "RootManager not instantiated!" << endl;
25  return kFATAL;
26  }
27 
28  // Get inputarray
29  fClusterArray = (TClonesArray*) ioman->GetObject("EmcCluster");
30  if (!fClusterArray) {
31  cout << "-W- PndEmcClusterRemoveDuplCrys::Init: "
32  << "No PndEmcHit array! Needed for MC Truth" << endl;
33  }
34 
35  // Get input/output array
36  fDigiArray = FairRunAna::Instance()->IsTimeStamp() ? (TClonesArray*) ioman->GetObject("EmcDigiClusterBase") : (TClonesArray*) ioman->GetObject("EmcDigi");
37  if (!fDigiArray) {
38  cout << "-W- PndEmcClusterRemoveDuplCrys::Init: "
39  << "No PndEmcDigi array!" << endl;
40  return kERROR;
41  }
42 
43  cout <<"-I- PndEmcClusterRemoveDuplCrys: "
44  << "Got both arrays" << endl;
45 
46  return kSUCCESS;
47 }
48 
50 
51  for(Int_t iClu=0; iClu<fClusterArray->GetEntriesFast(); ++iClu) {
52  PndEmcCluster* theCluster = static_cast<PndEmcCluster*>(fClusterArray->UncheckedAt(iClu));
53 
54  for(std::vector<Int_t>::reverse_iterator rit = theCluster->DigiList().rbegin(); rit!=theCluster->DigiList().rend(); ) {
55 
56  PndEmcDigi* theDigi = static_cast<PndEmcDigi*>(fDigiArray->UncheckedAt(*rit));
57  Int_t detId = theDigi->GetDetectorId();
58 
59  //check wether other digi with same detector Id was already included in cluster
60  //..we do a reverse iteration here, because only the first (i.e. with the smallest idx) digi out of all digis with same detId in fDigiArry will be seen in the MemberDigiMap
61  //(cf PndEmcMakeCluster::addDigi...)
62 
63  Int_t tmp_pos = theCluster->MemberDigiMap().find(detId)->second;
64  if(tmp_pos != *rit) { //in Member Map ..other digi is related to this detId...add digis up
65  PndEmcDigi* oldDigi = static_cast<PndEmcDigi*>(fDigiArray->UncheckedAt(tmp_pos));
66  oldDigi->AbsorbEnergy(*theDigi);
67 
68  //std::cerr << "Absorbing energy (ptr|detId): (" << oldDigi << " | "<< oldDigi->GetDetectorId() << ")" << std::flush;
69  theCluster->removeDigi(fDigiArray, (++rit).base()); //remove theDigi from cluster
70  } else {
71  ++rit;
72  }
73  }
74  }
75 }
represents the reconstructed hit of one emc crystal
Definition: PndEmcDigi.h:40
Int_t GetDetectorId() const
Definition: PndEmcDigi.h:97
#define verbose
const std::vector< Int_t > & DigiList() const
Definition: PndEmcCluster.h:40
virtual void removeDigi(const TClonesArray *digiArray, Int_t iDigi)
a cluster (group of neighboring crystals) of hit emc crystals
Definition: PndEmcCluster.h:29
const std::map< Int_t, Int_t > & MemberDigiMap() const
Definition: PndEmcCluster.h:43
virtual void AbsorbEnergy(PndEmcDigi &otherDigi)
Definition: PndEmcDigi.cxx:118