43 #include "FairRootManager.h" 
   44 #include "FairRunAna.h" 
   45 #include "FairRuntimeDb.h" 
   46 #include "TClonesArray.h" 
   72 fDigiArray(0), fClusterArray(0), fBumpArray(0), fSharedDigiArray(0), fGeoPar(new 
PndEmcGeoPar()), fDigiPar(new 
PndEmcDigiPar()), fRecoPar(new 
PndEmcRecoPar()), fClusterPosParam(), fMoliereRadius(0), fMoliereRadiusShashlyk(0), fExponentialConstant(0), fMaxIterations(0), fCentroidShift(0), fMaxBumps(0), fMinDigiEnergy(0)
 
   98   FairRootManager* ioman = FairRootManager::Instance();
 
  100     cout << 
"-E- PndEmcExpClusterSplitter::Init: " 
  101          << 
"RootManager not instantiated!" << endl;
 
  110         if(FairRunAna::Instance()->IsTimeStamp()) {
 
  111                 fDigiArray = (TClonesArray*) ioman->GetObject(
"EmcDigiClusterBase");
 
  113                 fDigiArray = (TClonesArray*) ioman->GetObject(
"EmcDigi");
 
  116                 cout << 
"-W- PndEmcExpClusterSplitter::Init: " 
  117                 << 
"No PndEmcDigi array!" << endl;
 
  121   fClusterArray = 
dynamic_cast<TClonesArray *
> (ioman->GetObject(
"EmcCluster"));
 
  123     cout << 
"-W- PndEmcExpClusterSplitter::Init: " 
  124          << 
"No PndEmcCluster array!" << endl;
 
  154                 cout<<
"Lilo cluster position method"<<endl;
 
  169   cout << 
"-I- PndEmcExpClusterSplitter: Intialization successfull" << endl;
 
  194         if ( ! 
fBumpArray ) Fatal(
"Exec", 
"No Bump Array");
 
  201         for (Int_t iCluster = 0; iCluster < nClusters; iCluster++){
 
  204                 int numberOfBumps = -1;
 
  205                 numberOfBumps = (theCluster->
LocalMaxMap()).size();
 
  207                 if (numberOfBumps<=1 || numberOfBumps >= 
fMaxBumps){
 
  212                         std::map<Int_t, Int_t>::const_iterator theDigiIterator;
 
  216                         theNewBump->SetLink(FairLink(
"EmcCluster", iCluster));
 
  219                         theDigiIterator != theCluster->
MemberDigiMap().end(); ++theDigiIterator){
 
  227                         std::map<Int_t,Int_t> theMaximaDigis=theCluster->
LocalMaxMap();
 
  228                         std::map<Int_t,Int_t>::iterator theMaximaDigisIterator;
 
  229                         std::map<PndEmcTwoCoordIndex*, TVector3*> theCentroidPoints;
 
  230                         std::map<PndEmcTwoCoordIndex*, TVector3*> theMaximaPoints;
 
  231                         std::map<PndEmcTwoCoordIndex*, PndEmcBump*> theIndexedBumps;
 
  232                         std::map<PndEmcTwoCoordIndex*, TVector3*> theAllDigiPoints;
 
  234                         std::map<Int_t, Int_t> theDigiDict = theCluster->
MemberDigiMap();
 
  236                         double totalEnergy=0;
 
  238                         for(theMaximaDigisIterator = theMaximaDigis.begin(); 
 
  239                         theMaximaDigisIterator != theMaximaDigis.end();
 
  240                         ++theMaximaDigisIterator){
 
  243                                 Int_t detId = theMaximaDigisIterator->first;
 
  248                                 TVector3 *digiLocation = 
new TVector3(theMaxDigi->
where());
 
  249                                 TVector3 *sameLocation = 
new TVector3(theMaxDigi->
where());
 
  251                                 theMaximaPoints.insert(std::map<PndEmcTwoCoordIndex*, TVector3*>::value_type(theTCI, digiLocation));
 
  252                                 theCentroidPoints.insert(std::map<PndEmcTwoCoordIndex*, TVector3*>::value_type(theTCI, sameLocation));
 
  255                         std::map<Int_t,Int_t>::iterator theAllDigisIterator;            
 
  258                         for( theAllDigisIterator = theDigiDict.begin(); theAllDigisIterator != theDigiDict.end();
 
  259                                         ++theAllDigisIterator){
 
  260                                 Int_t detId = theAllDigisIterator->first;
 
  263                                 TVector3 *digiLocation = 
new TVector3(theDigi->
where());
 
  264                                 theAllDigiPoints.insert(std::map<PndEmcTwoCoordIndex*, TVector3*>::value_type( theTCI, digiLocation ));
 
  267                         theMaximaDigisIterator = theMaximaDigis.begin();
 
  281                         Int_t iterations = 0;
 
  287                                         std::cout<<
"iteration No "<<iterations<<std::endl;
 
  289                                 averageCentroidShift=0.0;
 
  292                                 std::map<PndEmcTwoCoordIndex*, PndEmcBump*>::iterator theBumpKiller = theIndexedBumps.begin();
 
  293                                 while(theBumpKiller != theIndexedBumps.end()){
 
  298                                 theIndexedBumps.clear();
 
  301                                 for (theMaximaDigisIterator = theMaximaDigis.begin();
 
  302                                                 theMaximaDigisIterator != theMaximaDigis.end();
 
  303                                                 ++theMaximaDigisIterator) {
 
  304                                         Int_t detId = theMaximaDigisIterator->first;
 
  308                                                 std::cout<<
"***************** current maximum: theta = "<<theCurrentMaximaTCI->
XCoord()
 
  309                                                         <<
", phi = "<<theCurrentMaximaTCI->
YCoord()<<
"*********"<<std::endl;
 
  316                                                         PndEmcBump*>::value_type(theCurrentMaximaTCI, theNewBump));
 
  322                                         for (theAllDigisIterator = theDigiDict.begin();
 
  323                                                         theAllDigisIterator != theDigiDict.end();++theAllDigisIterator) {
 
  347                                                 std::map<PndEmcTwoCoordIndex*,TVector3*>::iterator theMaxPointsIterator;
 
  349                                                 for(theMaxPointsIterator = theCentroidPoints.begin(); theMaxPointsIterator != theCentroidPoints.end();++theMaxPointsIterator){
 
  352                                                         TVector3 *theMaxPoint = theMaxPointsIterator->second;
 
  353                                                         TVector3 *theCurrentDigiPoint = theAllDigiPoints.find(theCurrentTCI)->second;
 
  361                                                         if ((*theCurrentTCI)==(*theMaxPointsTCI)){
 
  364                                                                 TVector3 distance( *theMaxPoint - *theCurrentDigiPoint);
 
  366                                                                 theDistance = distance.Mag();
 
  369                                                         if (*theCurrentMaximaTCI == *(theMaxPointsTCI)){
 
  372                                                                 myDistance = theDistance;
 
  373                                                                 Int_t iCurentMaxDigi = (theDigiDict.find(theMaxPointsTCI->
Index()))->second;
 
  377                                                         Int_t iMaxPoint = (theDigiDict.find(theMaxPointsTCI->
Index()))->second;
 
  382                                                 if(totalDistanceEnergy > 0.0)
 
  384                                                                         myDistance/MoliereRadius) / ( totalDistanceEnergy);
 
  389                                                         std::cout<<
"\t digi theta = "<<theCurrentDigi->
GetTCI()->
XCoord()
 
  390                                                                 <<
", phi = "<<theCurrentDigi->
GetTCI()->
YCoord()<<std::endl;
 
  391                                                         std::cout<<
"energy = "<<theCurrentDigi->
GetEnergy()<<
", weight = "<< weight<<std::endl;
 
  396                                                         std::cout<<
"shared digi energy = "<<sharedDigi->
GetEnergy()<<std::endl;
 
  409                                         TVector3 *theOldCentroid = theCentroidPoints.find(theCurrentMaximaTCI)->second;
 
  415                                         TVector3 centroidShift(*theOldCentroid - newbumppos);
 
  416                                         averageCentroidShift+=centroidShift.Mag();
 
  419                                 averageCentroidShift/=(
Double_t)numberOfBumps;
 
  423                                 std::map<PndEmcTwoCoordIndex*, TVector3*>::iterator 
 
  424                                         theCentroidPointsIterator = theCentroidPoints.begin();
 
  425                                 for(theCentroidPointsIterator = theCentroidPoints.begin();
 
  426                                                 theCentroidPointsIterator != theCentroidPoints.end(); 
 
  427                                                 ++theCentroidPointsIterator) {
 
  428                                         delete theCentroidPointsIterator->second;
 
  430                                 theCentroidPoints.clear();
 
  432                                 std::map<PndEmcTwoCoordIndex*, PndEmcBump*>::iterator theIndexedBumpsIterator;
 
  433                                 for(theIndexedBumpsIterator = theIndexedBumps.begin();
 
  434                                                 theIndexedBumpsIterator != theIndexedBumps.end(); ++theIndexedBumpsIterator){
 
  435                                         TVector3 *theNewCentroid = 
new TVector3((theIndexedBumpsIterator->second)->where());
 
  436                                         theCentroidPoints.insert(std::map<PndEmcTwoCoordIndex*, TVector3*>::value_type(theIndexedBumpsIterator->first,theNewCentroid));
 
  441                         } 
while (iterations < fMaxIterations && averageCentroidShift > 
fCentroidShift);
 
  445                         std::map<PndEmcTwoCoordIndex*, PndEmcBump*>::iterator theBumpsIterator;
 
  448                         for(theBumpsIterator = theIndexedBumps.begin(); theBumpsIterator != theIndexedBumps.end();++theBumpsIterator){
 
  449                                 theBump = theBumpsIterator->second;
 
  453                                         std::cout << 
"Bump Created!" << std::endl;
 
  454                                 theNextBump->SetInsertHistory(kFALSE);
 
  455                                 theNextBump->SetLink(FairLink(
"EmcCluster", iCluster));
 
  458                                 theNextBump->SetTimeStamp(myCluster->GetTimeStamp());
 
  459                                 theNextBump->SetTimeStampError(myCluster->GetTimeStampError());
 
  462                         std::map<PndEmcTwoCoordIndex*,TVector3*>::iterator theGrimReaper = theMaximaPoints.begin();
 
  463                         for(theGrimReaper = theMaximaPoints.begin();
 
  464                                         theGrimReaper != theMaximaPoints.end();
 
  466                                 delete theGrimReaper->second;
 
  468                         theMaximaPoints.clear();
 
  470                         for(theGrimReaper  = theAllDigiPoints.begin();
 
  471                                         theGrimReaper != theAllDigiPoints.end();
 
  473                                 delete theGrimReaper->second;
 
  475                         theAllDigiPoints.clear();
 
  477                         for(theGrimReaper = theCentroidPoints.begin(); 
 
  478                                         theGrimReaper != theCentroidPoints.end();
 
  480                                 delete theGrimReaper->second;
 
  482                         theCentroidPoints.clear();
 
  495         Double_t WeightedFactor1(0.), NormWeightedFactor1(0.), AverageTime1(0.);
 
  498         for (Int_t 
i=0; 
i<nBump; 
i++){
 
  512                 WeightedFactor1 = 0.;
 
  515                 const std::vector<Int_t>& listOfDigi = tmpbump->
DigiList();
 
  516                 for(
size_t id=0;
id <listOfDigi.size();++id){
 
  520                         WeightedFactor1 += 1./fTimeError/fTimeError;
 
  523                         if(theDigi->
GetEnergy() > fMaxDigiEnergy){
 
  530                 for(
size_t id=0;
id <listOfDigi.size();++id){
 
  534                         NormWeightedFactor1 = 1./fTimeError/fTimeError;
 
  535                         NormWeightedFactor1 /= WeightedFactor1;
 
  536                         AverageTime1 += NormWeightedFactor1*theDigi->GetTimeStamp();
 
  546                 tmpbump->SetTimeStamp(AverageTime1);
 
  555                 std::cout<<
"PndEmcExpClusterSplitter:: Number of clusters = "<<nClusters<<std::endl;
 
  556                 std::cout<<
"PndEmcExpClusterSplitter:: Number of bumps = "<<nBump<<std::endl;
 
  569         Int_t size = clref.GetEntriesFast();
 
  582         Int_t size = clref.GetEntriesFast();
 
  595         cout<<
"================================================="<<endl;
 
  596         cout<<
"PndEmcExpClusterSplitter::FinishTask"<<endl;
 
  597         cout<<
"================================================="<<endl;
 
  604         FairRun* 
run = FairRun::Instance();
 
  605         if ( ! run ) Fatal(
"SetParContainers", 
"No analysis run");
 
  607         FairRuntimeDb* db = run->GetRuntimeDb();
 
  608         if ( ! db ) Fatal(
"SetParContainers", 
"No runtime database");
 
void SetEnergy(Double_t en)
virtual void MadeFrom(Int_t clusterIndex)
std::vector< Double_t > fClusterPosParam
virtual Double_t GetEnergy() const 
represents the reconstructed hit of one emc crystal 
friend F32vec4 exp(const F32vec4 &a)
virtual void Exec(Option_t *opt)
Runs the task. 
Double_t CalibrationEvtTimeByDigi(PndEmcDigi *theDigi, bool PrintOut=kFALSE) const 
Double_t GetMoliereRadius()
virtual Double_t Lat() const 
void SetEventNo(Int_t evtNo)
PndEmcExpClusterSplitter(Int_t verbose=0)
Double_t GetCentroidShift()
bool IsEnergyValid() const 
virtual void SetNBumps(unsigned nbumps)
TVector3 Where(TString method, std::vector< Double_t > params)
void SetPersistency(Bool_t val=kTRUE)
const std::vector< Int_t > & DigiList() const 
stores crystal index coordinates (x,y) or (theta,phi) 
PndEmcTwoCoordIndex * GetTCI(Int_t DetectorId)
virtual Double_t AbsZernikeMoment(int n, int m, Double_t R0=15) const 
Double_t GetMinDigiEnergy()
Double_t GetOffsetParmB()
Double_t GetOffsetParmC()
PndEmcRecoPar * fRecoPar
Reconstruction parameter container. 
Short_t GetModule() const 
Double_t GetExponentialConstant()
TClonesArray * fDigiArray
PndEmcDigiCalibrator digiCalibrator
Double_t fMoliereRadiusShashlyk
const std::map< Int_t, Int_t > & LocalMaxMap() const 
Double_t GetMoliereRadiusShashlyk()
used to share PndEmcDigis between bumps 
splits clusters on the basis of exponential distance from the bump centroid 
Double_t fExponentialConstant
parameter set of Emc digitisation 
PndEmcGeoPar * fGeoPar
Geometry parameter container. 
PndEmcDigiPar * fDigiPar
Digitisation parameter container. 
Double_t GetOffsetParmA()
a cluster (group of neighboring crystals) of hit emc crystals 
const std::map< Int_t, Int_t > & MemberDigiMap() const 
TClonesArray * fClusterArray
void SetZ20(Double_t z20)
Int_t NumberOfDigis() const 
virtual Double_t Energy() const 
void SetZ53(Double_t z53)
virtual Double_t GetEnergy() const 
bool IsPositionValid() const 
virtual ~PndEmcExpClusterSplitter()
virtual InitStatus Init()
Init Task. 
virtual void FinishTask()
Called at end of task. 
PndEmcSharedDigi * AddSharedDigi(PndEmcDigi *, Double_t weight)
Adds a new PndEmcSharedDigi to fSharedDigiArray and returns it. 
const TVector3 & where() const 
void SetPosition(TVector3 pos)
TClonesArray * fSharedDigiArray
PndEmcBump * AddBump()
Adds a new PndEmcBump to fBumpArray and returns it. 
Double_t GetTimeResolutionOfDigi(PndEmcDigi *theDigi) const 
Text_t * GetEmcClusterPosMethod()
static PndEmcStructure * Instance()
virtual void SetParContainers()
static PndEmcMapper * Instance()
void SetLatMom(Double_t latMom)
represents a reconstructed (splitted) emc cluster 
FairMultiLinkedData GetTrackEntering() const 
Parameter set for Emc Reco. 
PndEmcTwoCoordIndex * GetTCI() const 
virtual void addDigi(const TClonesArray *digiArray, Int_t iDigi)
TClonesArray * fBumpArray