TProfile for TH2Poly

Dear ROOT experts,

I’m involved in the code development of the CMS Tracker DQM and I am reimplementing some plots using TH2Poly instead of TH2D, which is being used currently. This makes it easy to represent the geometry of the detector in the plots. However, currently we are using the TProfile2D in order to easily do the avaraging of variables (so that they would not depend on the length of a run). We would therefore need some kind of TProfile for the TH2Poly plots, in order to integrate our new plots in the DQM framework. Would it be possible to implement this? I have no idea how much effort/time this would take, but I can help with the testing of the new code. Thanks!

Cheers,
Isa

Thanks for the suggesttion. Can you post a couple of lines showing what you are currently doing with TH2D and TProfile ? that will help to understand what you need in the TH2Poly case. Also keep in mind that TH2Poly can have bins with completely random shapes. Including bins made with TMultigraphs. That might be difficult to achieve what you request in a such general case…

Dear Olivier,

Thanks for your reply!

What we are doing with TProfile2D is quite simple:

We simply fill the TProfile2D for each event, which means the value is an average and doesn’t depend on the number of events.

For the moment we achieve the same result for the TH2Poly version of the plots by implementing an averaging in the filling of the plot (see github.com/idebruyn/cmssw/blob/ … #L225-L239):

void TkHistoMap::fillPoly(uint32_t detid, float value, PolyUtil* pu){ int16_t layerNum=tkdetmap_->FindLayer(detid , cached_detid , cached_layer , cached_XYbin); ValueClass v ; v = valueMap[detid]; v.setNumber(v.getNumber()+1); v.setValue(v.getValue()+value); if (v.getBinNumber()==0){ Int_t binNumber= tkHistoMapPoly_[layerNum]->getTH2Poly()->Fill(TString::Format("%u",detid),v.getValue()/v.getNumber()); v.setBinNumber(binNumber); } else{ tkHistoMapPoly_[layerNum]->getTH2Poly()->SetBinContent(v.getBinNumber(),v.getValue()/v.getNumber()); } valueMap[detid]=v; }

The TH2Poly bins are constructed from an xml file and represent the Tracker modules. Each bin has a name, which is the DetId of the module, and a value.

Would it be possible to implement the TProfile for this? Let me know if you need more information, or if things are not clear.

Cheers,
Isa

Hi all,
Is there any improvement in this issue? I have exactly the same probelm: a TH2Poly that reproduces the geometry of my detectors on which I would like to plot a TProfile to create a visual map of e.g. energy deposition. As Isa says, you can find a work-around by filling with weights and then normalizing, but a TProfile but definitely be more useful, e.g. to calculate standard deviation or higher momentum statistics.
Cheers,
Carlos

We have this now:

https://root.cern/doc/master/classTProfile2Poly.html

Awesome! Thanks couet, that’s precisely what I meant!