18 #include <FairRootManager.h>
20 #include <FairRuntimeDb.h>
21 #include <TClonesArray.h>
59 if (!strcmp(name,
""))
SetName(name);
67 std::cout <<
"PairFinderTask destructor called." <<
"\n";
92 FairRootManager* ioman = FairRootManager::Instance();
95 std::cout <<
"-E- LmdPairFinder::Init: " <<
"RootManager not instantiated!" <<
"\n";
104 std::cout <<
"-W- LmdPairFinder::Init: " <<
"ERROR, branch name " <<
fInBranchName
105 <<
" could not found!" <<
"\n";
110 std::cout <<
"-W- LmdPairFinder::Init: " <<
"ERROR, branch name " <<
fInRecoBranchName
111 <<
" not found!" <<
"\n";
117 <<
" not found!" <<
"\n";
125 cout <<
"PndLmdSensorAligner: reading dynamic cut Parameters from file... ";
127 cout <<
"cut parameter file does not exist! using static cut instead.\n";
133 for (
unsigned int i = 0;
i < overlapIDs.size();
i++) {
134 int overlapID = overlapIDs[
i];
138 std::stringstream configput(
"");
139 configput <<
"dynamicCut.aligners." << handler.
_overlapID <<
".";
142 handler.
_minDist =
config.get<
double>(configput.str() +
"minDist");
143 handler.
_maxDist =
config.get<
double>(configput.str() +
"maxDist");
145 catch (std::exception &e) {
146 cerr <<
"PndLmdSensorAligner: ERROR! Parameter not found in config file!\n";
155 cout <<
"PndLmdSensorAligner: trying to find dynamic cut Parameters.\n";
159 ioman->Register(
"PndLmdHitPair",
"PndLmd",
hitPairArray, kTRUE);
163 std::cout <<
"LmdPairFinder::Init(): Initialization successful." <<
"\n";
168 std::cout <<
"branch names set to " <<
fInBranchName <<
"\n";
180 std::cout <<
"PndLmdPixelClusterTask::SetParContainers() " <<
"\n";
182 ana = FairRun::Instance();
183 rtdb = ana->GetRuntimeDb();
188 Info(
"SetParContainers()",
"AlignLMD The container names list contains %i entries",
189 theAlignLMDContNames->GetEntries());
190 TIter cfAlIter(theAlignLMDContNames);
191 while (TObjString* contname = (TObjString*) cfAlIter()) {
192 TString parsetname = contname->String();
193 Info(
"SetParContainers()",
"%s", parsetname.Data());
219 Int_t nRecos =
recoArray->GetEntriesFast();
221 Int_t storedPairsPerEvent = 0;
224 for (
auto iReco = 0; iReco < nRecos; iReco++) {
225 for (
auto jReco = iReco + 1; jReco < nRecos; jReco++) {
237 if (infoOne.module_side > infoTwo.module_side) {
238 std::swap(hitOne, hitTwo);
245 const TVector3 vecOneGlobal = hitOne->
GetPosition();
246 const TVector3 vecTwoGlobal = hitTwo->
GetPosition();
252 PndLmdHitPair pairCanditate(vecOneGlobal, vecTwoGlobal, id1, id2);
269 pairCanditate.
check();
271 if (!pairCanditate.
isSane()) {
273 cerr <<
"==== WARNING: ====" <<
"\n";
274 cerr <<
"pair seems valid but did not pass sanity check!" <<
"\n";
275 cerr <<
"===============================================" <<
"\n";
301 if (!handler.
ready()) {
314 new ((*hitPairArray)[storedPairsPerEvent])
PndLmdHitPair(pairCanditate);
315 storedPairsPerEvent++;
331 cout <<
"PndLmdSensorAligner: writing cut parameters to disk...\n";
333 cout <<
"There are " <<
cutHandlers.size() <<
" handlers.\n";
339 cout <<
"Warning! handler " << handler.
_overlapID <<
" only has " << handler.
samples.size()
345 std::stringstream configput(
"");
346 configput <<
"dynamicCut.aligners." << handler.
_overlapID <<
".";
349 config.put(configput.str() +
"mean", handler.
_mean);
350 config.put(configput.str() +
"RMS", handler.
_RMS);
354 cout <<
"PndLmdSensorAligner: Attention! " << notReady <<
" handlers don't have enough pairs.\n";
358 cout <<
"PndLmdSensorAligner: Successfully written cutParameters to " <<
_cutParameterFile <<
"\n";
361 cout <<
"PndLmdSensorAligner: could not write cut parameters to disk!\n";
370 double plane3Percent = ((double) plane3 /
noOfGoodPairs) * 100;
371 double allPlanesPercent = ((double) sumOfAllPlanes /
noOfGoodPairs) * 100;
377 cout <<
"*************************************************************" <<
"\n";
378 cout <<
" pair finder done " <<
"\n";
379 cout <<
"*************************************************************" <<
"\n";
381 cout <<
" counting statistics:" <<
"\n";
386 printf(
"cluster ratio: %.2f %% \n", clusterRatio);
387 printf(
"pixel hits per event: %.2f \n", pixelsPerEvent);
388 printf(
"----------------------------\n");
392 printf(
"----------------------------\n");
394 printf(
"good pairs per event: %.2f \n", goodPairsPerEvent);
395 printf(
"----------------------------\n");
396 printf(
"hits on plane 0: %.2f %% \n", plane0Percent);
397 printf(
"hits on plane 1: %.2f %%\n", plane1Percent);
398 printf(
"hits on plane 2: %.2f %%\n", plane2Percent);
399 printf(
"hits on plane 3: %.2f %%\n", plane3Percent);
400 printf(
"hits on all planes: %.2f %% (should be 100%%!) \n", allPlanesPercent);
402 cout <<
"*************************************************************" <<
"\n";
440 fplane = infoOne.
plane;
458 cerr <<
"WARNING: hit was deemed suitable but plane number is " << fplane <<
"\n";
459 cerr <<
"This should not happen!" <<
"\n";
472 std::vector<pixelCluster> clusters;
477 for (
int iCluster = 0; iCluster < noOfClusters; iCluster++) {
492 if (col < 0 || row < 0) {
515 for (
size_t i = 0;
i < clusters.size();
i++) {
517 for (
size_t j =
i + 1; j < clusters.size(); j++) {
520 if (clusters[
i]._sensorId != clusters[j]._sensorId) {
524 if (clusters[
i].isNeighbour(clusters[j])) {
525 clusters[
i].merge(clusters[j]);
526 clusters.erase(clusters.begin() + j);
534 for (
size_t i = 0;
i < clusters.size();
i++) {
535 clusters[
i].calculateCenter();
538 if (clusters[
i].clusterSize > 1) {
544 clusters.erase(clusters.begin() +
i);
557 return pixelHit(hitSensorId, clusters[0].centerCol, clusters[0].centerRow);
562 int firstSensorId, secondSensorId;
563 firstSensorId = candidate.
getId1();
564 secondSensorId = candidate.
getId2();
567 if (firstSensorId == secondSensorId) {
Int_t GetPixelRow() const
std::map< int, dynamicCutHandler > cutHandlers
Bool_t _findDynamicCutParameters
virtual InitStatus ReInit()
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
Int_t GetClusterSize() const
Int_t GetSensorID() const
cout<< "-----------------------------------------------> Quarter VOLUME<<endl;name="QuarterShape";QuarterShape=newTGeoArb8(name,dz,vertQuar);name="Quarter4Vol";TStringmedium="air";QuarterVol=newTGeoVolumeAssembly(name);name="SubunitShape";SubunitShape=newTGeoArb8(name,dz,vertSub);TStringmedium="air";name="SubunitVol";name1="SubunitVol1";name2="SubunitVol2";name3="SubunitVol3";name4="SubunitVol4";name5="SubunitVol5";name6="SubunitVol6";name7="SubunitVol7";name8="SubunitVol8";name9="SubunitVol9";SubunitVol=newTGeoVolumeAssembly(name);SubunitVol1=newTGeoVolumeAssembly(name1);SubunitVol2=newTGeoVolumeAssembly(name2);SubunitVol3=newTGeoVolumeAssembly(name3);SubunitVol4=newTGeoVolumeAssembly(name4);SubunitVol5=newTGeoVolumeAssembly(name5);SubunitVol6=newTGeoVolumeAssembly(name6);SubunitVol7=newTGeoVolumeAssembly(name7);SubunitVol8=newTGeoVolumeAssembly(name8);SubunitVol9=newTGeoVolumeAssembly(name9);name="BoxShape";BoxShape=newTGeoArb8(name,dz,vertBox);TStringmedium="air";name="BoxVol";BoxVol=newTGeoVolumeAssembly(name);name1="BoxVol1";name2="BoxVol2";name3="BoxVol3";name4="BoxVol4";BoxVol1=newTGeoVolumeAssembly(name1);BoxVol2=newTGeoVolumeAssembly(name2);BoxVol3=newTGeoVolumeAssembly(name3);BoxVol4=newTGeoVolumeAssembly(name4);for(Int_tb=0;b<kNumOfBoxes;b++){cout<<""<<endl;cout<<"---------------->BOXnumber:"<<b<<endl;if(b==0){trBox=newTGeoTranslation(tr+kSpaceInSub+kAlveoleThickness+0.5*kSpaceInBox,tr+kSpaceInSub+kAlveoleThickness+0.5*kSpaceInBox,0.);rotBox=newTGeoRotation();rotBox.RotateX(0.465518);rotBox.RotateY(-0.465518);}if(b==1){trBox=newTGeoTranslation(-tr-kSpaceInSub-kAlveoleThickness-0.5*kSpaceInBox,-tr-kSpaceInSub-kAlveoleThickness-0.5*kSpaceInBox,0.);rotBox=newTGeoRotation();rotBox.RotateX(-0.465518);rotBox.RotateY(0.465518);}if(b==2){trBox=newTGeoTranslation(tr+kSpaceInSub+kAlveoleThickness+0.5*kSpaceInBox,-tr-kSpaceInSub-kAlveoleThickness-0.5*kSpaceInBox,0.);rotBox=newTGeoRotation();rotBox.RotateX(-0.465518);rotBox.RotateY(-0.465518);}if(b==3){trBox=newTGeoTranslation(-tr-kSpaceInSub-kAlveoleThickness-0.5*kSpaceInBox,tr+kSpaceInSub+kAlveoleThickness+0.5*kSpaceInBox,0.);rotBox=newTGeoRotation();rotBox.RotateX(0.465518);rotBox.RotateY(0.465518);}TGeoCombiTrans*trrotBox=newTGeoCombiTrans(trBox,rotBox);name="BoxVol";name+=b;trrotBox->SetName(name);trrotBox->RegisterYourself();SubunitVol->AddNode(BoxVol,b,trrotBox);if(b==1){name+=b;trrotBox->SetName(name);trrotBox->RegisterYourself();SubunitVol1->AddNode(BoxVol,b,trrotBox);}if(b==2){name+=b;trrotBox->SetName(name);trrotBox->RegisterYourself();SubunitVol2->AddNode(BoxVol1,b,trrotBox);}if(b==0){name+=b;trrotBox-> SetName(name)
static std::vector< int > getAvailableOverlapIDs()
TList * GetAlignParNames()
bool applyStaticDistanceCut(PndLmdHitPair &candidate)
TVector3 GetPosition() const
bool applyDynamicDistanceCut(PndLmdHitPair &candidate)
Int_t GetPixelColumn() const
virtual void SetParContainers()
virtual InitStatus Init()
static PndLmdGeometryHelper & getInstance()
void getStatistics(PndLmdHitPair &candidate)
pixelHit getPixelHitFromSdsHit(PndSdsHit *sdsHit)
TClonesArray * clusterCandidateArray
PndLmdGeometryHelper * helper
TString fInRecoBranchName
Int_t GetDigiIndex(Int_t i) const
Int_t getOverlapId() const
Double_t getDistance() const
boost::property_tree::ptree config
virtual void FinishTask()
Int_t eventMissedAllPlanes
virtual void FinishEvent()
const PndLmdHitLocationInfo & getHitLocationInfo(const std::string &volume_path)
virtual void SetBranchNames()
void addToSamples(PndLmdHitPair pair)
static boost::property_tree::ptree readConfigFile(std::string filename)
static PndGeoHandling * Instance()
static bool exists(std::string file)
std::string _cutParameterFile
std::vector< double > samples
virtual ~PndLmdPairFinderTask()
static bool writeConfigFile(boost::property_tree::ptree configTree, std::string filename, bool replaceExisting=true)
void setPixelHits(double col1, double row1, double col2, double row2)
void setOverlapId(Int_t overlapId)
Data class to store the digi output of a pixel module.
TVector3 transformPndGlobalToLmdLocal(const TVector3 &vec)
Int_t GetClusterIndex() const
TString fInClusterCandidates
Int_t GetSensorID() const
int getOverlapIdFromSensorIDs(int id1, int id2)
TClonesArray * hitPairArray
bool candHitsOverlappingArea(const PndLmdHitPair &candidate)
bool isOverlappingArea(const int id1, const int id2)
virtual void Exec(Option_t *opt)