28 #include "FairRootManager.h"
29 #include "FairRunAna.h"
30 #include "FairRuntimeDb.h"
32 #include "TClonesArray.h"
46 using std::setprecision;
52 : FairTask(
"GEMFindClusters", 0),
67 fInBranchName(
"GEMDigi")
76 : FairTask(
"GEMFindClusters", iVerbose),
91 fInBranchName(
"GEMDigi")
100 : FairTask(name, iVerbose),
115 fInBranchName(
"GEMDigi") {
142 std::cout <<
"-I- PndGemFindClustersTB::Exec Digis: " <<
fDigis->GetEntries() << std::endl;
147 fClusters = FairRootManager::Instance()->GetTClonesArray(
"GEMCluster");
148 if ( !
fClusters ) Fatal(
"Exec",
"No GEM Cluster Array");
154 Int_t nDigis =
fDigis->GetEntries();
226 for ( Int_t idigi = 0 ; idigi <
fDigis->GetEntries() ; idigi++ ) {
235 tempDC.
digiNr.push_back(idigi);
238 tempDC.
sigTDC.push_back(digi->GetTimeStamp());
239 tempDC.
cluTDC = digi->GetTimeStamp();
265 Bool_t printInfo = kFALSE;
273 cout <<
"digi [" << digiNumber <<
"] in detector " << digi->
GetDetectorId() <<
" channel " << digi->
GetChannelNr() <<
" @ " << digi->GetTimeStamp() << endl;
276 for (
size_t idc = 0 ; idc <
fDigiClusters.size() ; idc++ ) {
283 cout <<
"Trying to match digi "
284 << digiNumber <<
" @ "
306 cout <<
"GOT DISTANCE: " << digiClustDist <<
" WHILE THE CLUSTER LENGTH = " << clusterLength <<
" CHECK AT " << 19/clusterLength+1 << endl;
307 if ( digiClustDist < 0 )
continue;
308 if ( digiClustDist > 20 )
continue;
311 if (
TMath::Abs(digiTimeDist) > 11. )
continue;
314 cout <<
"digi " << digiNumber <<
" ( " << digi->
GetDetectorId() <<
" / " << digi->
GetChannelNr() <<
" ) could attach to cluster "
315 << idc <<
" ( " <<
fDigiClusters[idc].cluPos <<
" ) with distance " << digiClustDist <<
" . " <<
fDigiClusters[idc].digiNr.size() <<
" digis in cluster" << flush;
322 cout <<
" >>> new pos = " <<
fDigiClusters[idc].cluPos << endl;
326 cout <<
"DIGI " << digiNumber <<
" AT " << digi->
GetChannelNr() <<
" MATCHES TO CLUSTER " << endl;
329 if ( digiUsed >= 0 ) {
335 return (digiUsed==-1?kFALSE:kTRUE);
342 Bool_t printInfo = kFALSE;
346 cout <<
"JoinTwoClusters-------------------------------------" << endl;
354 for (
size_t id2 = 0 ; id2 <
fDigiClusters[clus2].digiNr.size() ; id2++ ) {
357 Int_t addDigi = kTRUE;
358 for (
size_t id1 = 0 ; id1 <
fDigiClusters[clus1].digiNr.size() ; id1++ )
403 fDigiClusters[clusNr].sigTDC.push_back(digi->GetTimeStamp());
414 Bool_t printInfo = kFALSE;
418 if ( printInfo ) cout <<
"AnalyzeClusters" << endl;
420 for (
size_t idc = 0 ; idc <
fDigiClusters.size() ; idc++ ) {
427 <<
" FROM " <<
fDigiClusters[idc].digiNr.size() <<
" DIGIS ("
439 cout <<
"DIGI [" <<
fDigiClusters[idc].digiNr[0] <<
"] in station " << stationNr <<
" sensor " << sensorNr <<
" side " << iSide <<
" channel " << digi->
GetChannelNr() << endl;
444 cout <<
"CLUSTERS IN " <<
fDigiClusters[idc].detId <<
" COVERS "
449 <<
fDigiClusters[idc].digiNr.size() <<
" STRIPS FIRED." << endl;
453 cout <<
"The cluster has as many digis as possible strips (" <<
fDigiClusters[idc].digiNr.size() <<
")." << endl;
462 for (
size_t idigi = 0 ; idigi <
fDigiClusters[idc].digiNr.size() ; idigi++ ) {
466 if ( lastChan != -1 )
467 chanDist = sensor->
GetDistance(iSide,thisChan,lastChan);
469 if ( lastChan == -1 || chanDist > 1 ) {
475 tempDC.
sigTDC.push_back(digi->GetTimeStamp());
476 tempDC.
cluTDC = digi->GetTimeStamp();
490 cout <<
" ADDED CHANNEL " <<
fDigiClusters[idc].chanNr[idigi]
517 std::vector<Int_t> clusterRefs;
520 for (
size_t idc = 0 ; idc <
fDigiClusters.size() ; idc++ ) {
527 for (
size_t id = 0 ;
id <
fDigiClusters[idc].digiNr.size() ;
id++ ) {
530 if ( !digi ) cout <<
"there is no digi number " <<
fDigiClusters[idc].digiNr[id] <<
", cause there are only " <<
fDigis->GetEntries() <<
" of them" << endl;
531 for ( Int_t irf = digi->
GetNIndices()-1 ; irf >= 0 ; irf-- ) {
534 Bool_t alreadyKnown = kFALSE;
535 for ( Int_t icr = clusterRefs.size()-1 ; icr >= 0 ; icr-- ) {
536 if ( refIndex == clusterRefs[icr] ) {
537 alreadyKnown = kTRUE;
541 if ( !alreadyKnown ) clusterRefs.push_back(refIndex);
568 for (
size_t idc = 0 ; idc <
fDigiClusters.size() ; idc++ ) {
587 if ( minPart == -1 )
return;
590 if ( minPart == maxPart )
return;
593 for (
size_t ichan = 1 ; ichan <
fDigiClusters[clus].digiNr.size()-1 ; ichan++ ) {
595 if ( tempPart != minPart && tempPart != maxPart ) {
606 if ( tempPart < 600 )
return;
617 for (
size_t ichan = 0 ; ichan <
fDigiClusters[clus].digiNr.size() ; ichan++ ) {
620 if ( tempPart == 0 || tempPart == 1 ) {
626 if ( tempPart == 0 || tempPart == 2 ) {
640 for (
size_t idc = 0 ; idc <
fDigiClusters.size() ; idc++ ) {
648 Int_t channelPosition = 0;
651 for (
size_t idigi = channelPosition ; idigi <
fDigiClusters[clus].digiNr.size() ; idigi++ ) {
675 for (
size_t idc = 0 ; idc <
fDigiClusters.size() ; idc++ ) {
687 <<
" CREATED FROM " <<
fDigiClusters[clus].digiNr.size() <<
" DIGIS, FROM "
699 for ( Int_t icol = 0 ; icol <
fDigiClusters[clus].cluPMx-
fDigiClusters[clus].cluPMn+3 ; icol++ ) cout <<
"-" << flush; cout<<endl;
700 for (
Double_t fh = 0.99 ; fh >= 0. ; fh-=0.247475 ) {
701 cout <<
"|" << flush;
710 if ( thisADC > fh*
fDigiClusters[clus].cluMVl ) cout <<
"*" << flush;
711 else cout <<
" " << flush;
715 for ( Int_t icol = 0 ; icol <
fDigiClusters[clus].cluPMx-
fDigiClusters[clus].cluPMn+3 ; icol++ ) cout <<
"-" << flush; cout<<endl;
723 FairRunAna*
run = FairRunAna::Instance();
724 if ( ! run ) Fatal(
"SetParContainers",
"No analysis run");
726 FairRuntimeDb* db = run->GetRuntimeDb();
727 if ( ! db ) Fatal(
"SetParContainers",
"No runtime database");
741 FairRootManager* ioman = FairRootManager::Instance();
742 if ( ! ioman ) Fatal(
"Init",
"No FairRootManager");
750 fClusters = ioman->Register(
"GEMCluster",
"PndGemCluster",
"PndGEM", kTRUE);
752 cout <<
"-I- " << fName.Data() <<
"::Init(). There are " <<
fDigiPar->
GetNStations() <<
" GEM stations." << endl;
753 cout <<
"-I- " << fName.Data() <<
"::Init(). Initialization succesfull." << endl;
783 cout <<
"-------------------- " << fName.Data() <<
" : Summary -----------------------" << endl;
784 cout <<
" Events: " << setw(10) <<
fTNofEvents << endl;
788 cout <<
"---------------------------------------------------------------------" << endl;
789 cout <<
" >>> CF >>> prep time = " <<
fPrepTime <<
"s (get data from input array)" << endl;
796 cout <<
"---------------------------------------------------------------------" << endl;
Int_t GetStationNr() const
std::vector< Double_t > sigTDC
virtual InitStatus Init()
virtual ~PndGemFindClustersTB()
Digitization Parameter Class for GEM part.
Int_t GetDetectorId() const
void JoinTwoClusters(Int_t clus1, Int_t clus2)
PndGemSensor * GetSensor(Int_t iSensor)
virtual void Exec(Option_t *opt)
void AddDigiToCluster(Int_t digiNr, Int_t clusNr)
void CheckCluster(Int_t clus)
Int_t GetSensorNr() const
PndGemSensor * GetSensor(Int_t stationNr, Int_t sensorNr)
std::vector< Int_t > digiNr
Double_t GetDistance(Int_t iSide, Double_t chan1, Double_t chan2)
Bool_t CompareDigiToClusters(Int_t digiNumber)
Double_t GetChannelNr() const
void PrintCluster(Int_t clus)
std::vector< Double_t > sigADC
Int_t GetSensorPart(Int_t iSide, Int_t chan)
std::vector< Int_t > chanNr
std::vector< DigiClusterTB > fDigiClusters
Int_t GetIndex(int i=0) const
Double_t GetCharge() const
Double_t GetOuterRadius() const
Double_t GetMeanChannel(Int_t iSide, Double_t chan1, Double_t weight1, Double_t chan2, Double_t weight2)
virtual InitStatus ReInit()
void SortCluster(Int_t clus)
virtual void SetParContainers()
PndGemStation * GetStation(Int_t iStation)