Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GMT #680

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open

GMT #680

wants to merge 26 commits into from

Conversation

nigmatkulov
Copy link
Member

Commit GMT-related classes and macroses. Also update StarDb/geometry for GMT with the last alignemnt.

TH2F * dMin = new TH2F("DMin","vumin",100,-0.75,0.75,100,-0.75,0.75);
TH1F * vMin = new TH1F("VMin","vmin", plotDuv.nx, plotDuv.xmin, plotDuv.xmax);
TH1F * uMin = new TH1F("UMin","umin", plotDuv.nx, plotDuv.xmin, plotDuv.xmax);
TH1F * uMinC = new TH1F("UMinC","umC", plotDuv.nx, plotDuv.xmin, plotDuv.xmax);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this histogram used? The compiler complains about the variable not being used

Comment on lines 101 to 104
if (tree == 0) {
TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("/star/data09/calib/fisyak/Pass112/TpcSsd/065/Event_6065045_raw_1010001.root");
if (!f) {
f = new TFile("/star/data09/calib/fisyak/Pass112/TpcSsd/065/Event_6065045_raw_1010001.root");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not a good practice to have hard coded file names in the code. A better option would be to introduce a function argument with a default value.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Contributor

@klendathu2k klendathu2k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few suggestions indicated. Few changes should be made,... StGmtAligner should be a maker, and prefer c++ native types (e.g. int) over ROOT types (Int_t) when a class is not intended for IO.

@@ -1141,13 +1141,14 @@ void StAnalysisMaker::summarizeEvent(StEvent *event, Int_t mEventCounter) {
if (event->numberOfPsds()) {
LOG_QA << "# PSDs: " << event->numberOfPsds() << endm;
}
#ifdef _ST_GMT_HIT_H_
//#ifdef _ST_GMT_HIT_H_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest removing rather than commenting ifdefs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed most of those and left only a few that are needed for debug and analysis purpose

/// ADC error in Y
Float_t getErrorAdcY() const { return mdAdcY; }
/// Local X coordinate
Float_t getLocalX() const { return position().x(); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The optimizer probably avoids a copy here... but for consistency with the way you write the setters, I recommend using mPosition.x() rather than position().x(). (same for error and y...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, but that cannot be done here due to the inheritance

return;
}

mHitLocalX = mHitLocalY = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't lines 35 to 42 be uncommented? If not, what does this constructor do?

Short_t mMaxAdcTB;
/// Max over the time bins
Short_t mMaxPedSubtractedAdcTB;
// Short_t mClusterSeedType; // See types in StGmtConsts.h
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented out references to mClusterSeedType (or uncomment them if they are needed.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

// strip. New strip is created if it does not exist, but only
// using StGmtStrip() constructor. Ownership is retained by the
// collection.
// StGmtStrip* getStrip( int elecId );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleanup


// inline functions

// inline StGmtStripCollection::StGmtStripCollection( short module ) : StObject(), mModule( module ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... cleanup constructors / methods / variables which are commented out.

};

// sort by coordinate number
inline void StGmtStripCollection::sortByCoord(){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a comment. You can always sort vectors inside of consumer codes. So... I don't really see a need to sort the in-memory collection, unless there are multiple downstream codes that would prefer a given order.

#include "StTpcDb/StTpcDb.h"
#include "StDetectorDbMaker/StGmtSurveyC.h"
//________________________________________________________________________________
StGmtAligner::StGmtAligner(const Char_t *name) : StMaker(name),fFile(0), fTree(0), fEvent(0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StGmtAligner is a maker. The "maker" rules should apply here.

  1. The name of the code should by in the form StTLAMaker. e.g. StGmtAlignmentMaker
  2. The code should be organized under StRoot/StGmtAlignmentMaker/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -0,0 +1,23 @@
void runGmtTree(const Char_t *input, const Char_t *output=0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a "macros" directory to collect analysis macros.

#include "StMessMgr.h"
ClassImp(StGmtClusterMaker);

Int_t StGmtClusterMaker::gmtStat = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

STAR coding standards prefer using standard c++ types (int, float, char, etc...) over ROOT types (Int_t, Float_t, etc...) when you are implementing a non persistent class... i.e. anything you don't intend save in MuDst, PicoDst, StEvent... or any ttree.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected

Copy link
Member

@plexoos plexoos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before I do another round of comments on this massive PR, I would like to see the compiler errors addressed.

Float_t mChargeUncert;

private:
ClassDef(StGmtHit,2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StGmtHit is a new data type. Why start with version 2?

#include "StGmtHit.h"
#include "StGmtHitCollection.h"

ClassImp(StGmtHitCollection)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ClassImp macro is not needed anywhere. Please remove

if ( !hit1 || !hit2 ) {
LOG_ERROR << "Passed null pointer into StGmtPoint::StGmtPoint( StGmtHit* hit1, StGmtHit* hit2, int key )" << endm;
mKey = -999;
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't return from a constructor. It must create a valid object or throw an exception. Please reconsider the logic. You can make sure the input StGmtHits are valid to construct a StGmtPoint

// StGmtStrip header
#include "StGmtStrip.h"

ClassImp(StGmtStrip)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Suggested change
ClassImp(StGmtStrip)

Comment on lines 61 to 108
// if( (h1->isY() && h2->isY()) || ( !(h1->isY()) && !(h2->isY()) ) )
// {
// // LOG_ERROR << "StGmtStripCollection::hitCoordLessThan sort CASE 1: " <<
// // "\n\t h1 " << h1 <<
// // "\n\t h1->isY() " << h1->isY() <<
// // "\n\t h1->GetCoordNum() " << h1->getCoordNum() <<
// // "\n\t h2 " << h2 <<
// // "\n\t h2->isY() " << h2->isY() <<
// // "\n\t h2->GetCoordNum() " << h2->getCoordNum() <<
// // "\n\t will return: " << h1->getCoordNum() << " < " << h2->getCoordNum() << endm;
// return h1->getCoordNum() < h2->getCoordNum();
// }
// else if( h1->isY() && !(h2->isY()) )
// {
// // LOG_ERROR << "StGmtStripCollection::hitCoordLessThan sort CASE 2: " <<
// // "\n\t h1 " << h1 <<
// // "\n\t h1->isY() " << h1->isY() <<
// // "\n\t h1->GetCoordNum() " << h1->getCoordNum() <<
// // "\n\t h2 " << h2 <<
// // "\n\t h2->isY() " << h2->isY() <<
// // "\n\t h2->GetCoordNum() " << h2->getCoordNum() <<
// // "\n\t will return: " << h1->getCoordNum()+kGmtNumStrips << " < " << h2->getCoordNum() << endm;
// return (h1->getCoordNum()+kGmtNumStrips) < h2->getCoordNum(); // order X first
// }
// else if( !(h1->isY()) && h2->isY() )
// {
// // LOG_ERROR << "StGmtStripCollection::hitCoordLessThan sort CASE 3: " <<
// // "\n\t h1 " << h1 <<
// // "\n\t h1->isY() " << h1->isY() <<
// // "\n\t h1->GetCoordNum() " << h1->getCoordNum() <<
// // "\n\t h2 " << h2 <<
// // "\n\t h2->isY() " << h2->isY() <<
// // "\n\t h2->GetCoordNum() " << h2->getCoordNum() <<
// // "\n\t will return: " << h1->getCoordNum() << " < " << h2->getCoordNum()+kGmtNumStrips << endm;
// return h1->getCoordNum() < (h2->getCoordNum()+kGmtNumStrips); // order X first
// }
// else
// {
// // LOG_ERROR << "StGmtStripCollection::hitCoordLessThan sort FAILED: " <<
// // "\n\t h1 " << h1 <<
// // "\n\t h1->isY() " << h1->isY() <<
// // "\n\t h1->GetCoordNum() " << h1->getCoordNum() <<
// // "\n\t h2 " << h2 <<
// // "\n\t h2->isY() " << h2->isY() <<
// // "\n\t h2->GetCoordNum() " << h2->getCoordNum() <<
// // "\n\t will return: " << -1 << endm;
// return -1;
// }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this "dead" code

Init(tree);
}

virtual ~TBase() {if (!fChain) return; delete fChain->GetCurrentFile();}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can you be sure that the current file is the one you opened in this maker? What if another maker makes a different file current?
Also, are you sure the file is written and closed when you call it destructor?

Comment on lines +93 to +96
#if 0
void SetValidDerivatives(Bool_t p=kTRUE) {fValidDerivatives = p;}
void SetDerivatives(Double32_t *der) {Double32_t *d = &duPdxV; for (Int_t i = 0; i < 12; i++) d[i] = der[i];}
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of disabling these lines with #if 0?

Comment on lines 2 to 26
#include <stdlib.h>
#include "Riostream.h"
#include "TROOT.h"
#include "TSystem.h"
#include "TFile.h"
#include "TKey.h"
#include "TRandom.h"
#include "TTree.h"
#include "TBranch.h"
#include "TStopwatch.h"
#include "StThreeVectorF.hh"
#include "StMatrixF.hh"
#include "TH1.h"
#include "TH2.h"
#include "TProfile.h"
#include "TMath.h"
#include "TVector3.h"
#include "TProcessID.h"
#include "StEvent.h"
#include "StPrimaryVertex.h"
#include "StBFChain.h"
#include "TGeoMatrix.h"
#include "EventT.h"
#include "StTpcDb/StTpcDb.h"
#include "StDetectorDbMaker/StGmtSurveyC.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include only the header files you really need.

@fgeurts
Copy link
Member

fgeurts commented Aug 21, 2024

Hi, what is the status of this PR? Have all comments been addressed? If so, can we wrap this one up and prepare this to be merged into the STAR library?

@plexoos
Copy link
Member

plexoos commented Nov 28, 2024

The error you are getting is valid:

#10 1262.0 g++ -m64 -fPIC -pipe -Wall -Woverloaded-virtual -std=c++0x -Wno-long-long -pthread -Wno-deprecated-declarations -Werror -O2 -g -falign-loops -falign-jumps -falign-functions -Dsl79_gcc485 -D__ROOT__ -DNEW_DAQ_READER -I. -IStRoot -I.sl79_gcc485/include -I/opt/software/linux-scientific7-x86_64/gcc-4.8.5/root-5.34.38-ffhsnriu5ktoo4tieuku5tbezanz6q5g/include -c .sl79_gcc485/OBJ/StRoot/StGmtUtil/geometry/StGmtGeom.cxx -o .sl79_gcc485/OBJ/StRoot/StGmtUtil/geometry/StGmtGeom.o
#10 1262.5 .sl79_gcc485/OBJ/StRoot/StGmtUtil/geometry/StGmtGeom.cxx: In static member function 'static Int_t StGmtGeom::translateGeoNameToGeoId(const string&)':
#10 1262.5 .sl79_gcc485/OBJ/StRoot/StGmtUtil/geometry/StGmtGeom.cxx:159:48: error: 'rdo' may be used uninitialized in this function [-Werror=maybe-uninitialized]
#10 1262.5      return encodeGeoId( rdo, arm, apv, channel );
#10 1262.5                                                 ^
#10 1262.5 .sl79_gcc485/OBJ/StRoot/StGmtUtil/geometry/StGmtGeom.cxx:159:48: error: 'arm' may be used uninitialized in this function [-Werror=maybe-uninitialized]
#10 1262.5 .sl79_gcc485/OBJ/StRoot/StGmtUtil/geometry/StGmtGeom.cxx:159:48: error: 'apv' may be used uninitialized in this function [-Werror=maybe-uninitialized]
#10 1262.5 .sl79_gcc485/OBJ/StRoot/StGmtUtil/geometry/StGmtGeom.cxx:159:48: error: 'channel' may be used uninitialized in this function [-Werror=maybe-uninitialized]

What do you expect to get from Int_t StGmtGeom::encodeGeoId(Int_t rdo, Int_t arm, Int_t apv, Int_t channel) if you don't provide values for its arguments?

Int_t StGmtGeom::translateGeoNameToGeoId(const std::string & geoName) {
Short_t module, strip;
Int_t layer;
Int_t rdo, arm, apv, channel;
// Error message already taken care of in decodeGeoName.
if ( decodeGeoName( geoName, module, layer, strip ) < 0 )
return kGmtError;
// return encodeGeoId( module, layer, strip );
return encodeGeoId( rdo, arm, apv, channel );
}

@nigmatkulov
Copy link
Member Author

The error you are getting is valid:

#10 1262.0 g++ -m64 -fPIC -pipe -Wall -Woverloaded-virtual -std=c++0x -Wno-long-long -pthread -Wno-deprecated-declarations -Werror -O2 -g -falign-loops -falign-jumps -falign-functions -Dsl79_gcc485 -D__ROOT__ -DNEW_DAQ_READER -I. -IStRoot -I.sl79_gcc485/include -I/opt/software/linux-scientific7-x86_64/gcc-4.8.5/root-5.34.38-ffhsnriu5ktoo4tieuku5tbezanz6q5g/include -c .sl79_gcc485/OBJ/StRoot/StGmtUtil/geometry/StGmtGeom.cxx -o .sl79_gcc485/OBJ/StRoot/StGmtUtil/geometry/StGmtGeom.o
#10 1262.5 .sl79_gcc485/OBJ/StRoot/StGmtUtil/geometry/StGmtGeom.cxx: In static member function 'static Int_t StGmtGeom::translateGeoNameToGeoId(const string&)':
#10 1262.5 .sl79_gcc485/OBJ/StRoot/StGmtUtil/geometry/StGmtGeom.cxx:159:48: error: 'rdo' may be used uninitialized in this function [-Werror=maybe-uninitialized]
#10 1262.5      return encodeGeoId( rdo, arm, apv, channel );
#10 1262.5                                                 ^
#10 1262.5 .sl79_gcc485/OBJ/StRoot/StGmtUtil/geometry/StGmtGeom.cxx:159:48: error: 'arm' may be used uninitialized in this function [-Werror=maybe-uninitialized]
#10 1262.5 .sl79_gcc485/OBJ/StRoot/StGmtUtil/geometry/StGmtGeom.cxx:159:48: error: 'apv' may be used uninitialized in this function [-Werror=maybe-uninitialized]
#10 1262.5 .sl79_gcc485/OBJ/StRoot/StGmtUtil/geometry/StGmtGeom.cxx:159:48: error: 'channel' may be used uninitialized in this function [-Werror=maybe-uninitialized]

What do you expect to get from Int_t StGmtGeom::encodeGeoId(Int_t rdo, Int_t arm, Int_t apv, Int_t channel) if you don't provide values for its arguments?

Int_t StGmtGeom::translateGeoNameToGeoId(const std::string & geoName) {
Short_t module, strip;
Int_t layer;
Int_t rdo, arm, apv, channel;
// Error message already taken care of in decodeGeoName.
if ( decodeGeoName( geoName, module, layer, strip ) < 0 )
return kGmtError;
// return encodeGeoId( module, layer, strip );
return encodeGeoId( rdo, arm, apv, channel );
}

Good catch. I'll update this part

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants